babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087
  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. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1058. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1059. */
  1060. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1061. /**
  1062. * Constant used to retrieve the position texture index in the textures array in the prepass
  1063. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1064. */
  1065. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1066. /**
  1067. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1068. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1069. */
  1070. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1071. /**
  1072. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1073. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1074. */
  1075. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1076. /**
  1077. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1078. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1079. */
  1080. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1081. /**
  1082. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1083. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1084. */
  1085. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1086. /**
  1087. * Constant used to retrieve albedo index in the textures array in the prepass
  1088. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1089. */
  1090. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1091. }
  1092. }
  1093. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1094. import { Nullable } from "babylonjs/types";
  1095. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1096. /**
  1097. * This represents the required contract to create a new type of texture loader.
  1098. */
  1099. export interface IInternalTextureLoader {
  1100. /**
  1101. * Defines wether the loader supports cascade loading the different faces.
  1102. */
  1103. supportCascades: boolean;
  1104. /**
  1105. * This returns if the loader support the current file information.
  1106. * @param extension defines the file extension of the file being loaded
  1107. * @param mimeType defines the optional mime type of the file being loaded
  1108. * @returns true if the loader can load the specified file
  1109. */
  1110. canLoad(extension: string, mimeType?: string): boolean;
  1111. /**
  1112. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1113. * @param data contains the texture data
  1114. * @param texture defines the BabylonJS internal texture
  1115. * @param createPolynomials will be true if polynomials have been requested
  1116. * @param onLoad defines the callback to trigger once the texture is ready
  1117. * @param onError defines the callback to trigger in case of error
  1118. */
  1119. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1120. /**
  1121. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1122. * @param data contains the texture data
  1123. * @param texture defines the BabylonJS internal texture
  1124. * @param callback defines the method to call once ready to upload
  1125. */
  1126. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1127. }
  1128. }
  1129. declare module "babylonjs/Engines/IPipelineContext" {
  1130. /**
  1131. * Class used to store and describe the pipeline context associated with an effect
  1132. */
  1133. export interface IPipelineContext {
  1134. /**
  1135. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1136. */
  1137. isAsync: boolean;
  1138. /**
  1139. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1140. */
  1141. isReady: boolean;
  1142. /** @hidden */
  1143. _getVertexShaderCode(): string | null;
  1144. /** @hidden */
  1145. _getFragmentShaderCode(): string | null;
  1146. /** @hidden */
  1147. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1148. }
  1149. }
  1150. declare module "babylonjs/Meshes/dataBuffer" {
  1151. /**
  1152. * Class used to store gfx data (like WebGLBuffer)
  1153. */
  1154. export class DataBuffer {
  1155. /**
  1156. * Gets or sets the number of objects referencing this buffer
  1157. */
  1158. references: number;
  1159. /** Gets or sets the size of the underlying buffer */
  1160. capacity: number;
  1161. /**
  1162. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1163. */
  1164. is32Bits: boolean;
  1165. /**
  1166. * Gets the underlying buffer
  1167. */
  1168. get underlyingResource(): any;
  1169. }
  1170. }
  1171. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1172. /** @hidden */
  1173. export interface IShaderProcessor {
  1174. attributeProcessor?: (attribute: string) => string;
  1175. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1176. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1177. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1178. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1179. lineProcessor?: (line: string, isFragment: boolean) => string;
  1180. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1181. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1185. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1186. /** @hidden */
  1187. export interface ProcessingOptions {
  1188. defines: string[];
  1189. indexParameters: any;
  1190. isFragment: boolean;
  1191. shouldUseHighPrecisionShader: boolean;
  1192. supportsUniformBuffers: boolean;
  1193. shadersRepository: string;
  1194. includesShadersStore: {
  1195. [key: string]: string;
  1196. };
  1197. processor?: IShaderProcessor;
  1198. version: string;
  1199. platformName: string;
  1200. lookForClosingBracketForUniformBuffer?: boolean;
  1201. }
  1202. }
  1203. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1204. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1205. /** @hidden */
  1206. export class ShaderCodeNode {
  1207. line: string;
  1208. children: ShaderCodeNode[];
  1209. additionalDefineKey?: string;
  1210. additionalDefineValue?: string;
  1211. isValid(preprocessors: {
  1212. [key: string]: string;
  1213. }): boolean;
  1214. process(preprocessors: {
  1215. [key: string]: string;
  1216. }, options: ProcessingOptions): string;
  1217. }
  1218. }
  1219. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1220. /** @hidden */
  1221. export class ShaderCodeCursor {
  1222. private _lines;
  1223. lineIndex: number;
  1224. get currentLine(): string;
  1225. get canRead(): boolean;
  1226. set lines(value: string[]);
  1227. }
  1228. }
  1229. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1230. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1231. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1232. /** @hidden */
  1233. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1234. process(preprocessors: {
  1235. [key: string]: string;
  1236. }, options: ProcessingOptions): string;
  1237. }
  1238. }
  1239. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1240. /** @hidden */
  1241. export class ShaderDefineExpression {
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. private static _OperatorPriority;
  1246. private static _Stack;
  1247. static postfixToInfix(postfix: string[]): string;
  1248. static infixToPostfix(infix: string): string[];
  1249. }
  1250. }
  1251. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1252. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1253. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1254. /** @hidden */
  1255. export class ShaderCodeTestNode extends ShaderCodeNode {
  1256. testExpression: ShaderDefineExpression;
  1257. isValid(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1266. define: string;
  1267. not: boolean;
  1268. constructor(define: string, not?: boolean);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1275. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1276. /** @hidden */
  1277. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1278. leftOperand: ShaderDefineExpression;
  1279. rightOperand: ShaderDefineExpression;
  1280. isTrue(preprocessors: {
  1281. [key: string]: string;
  1282. }): boolean;
  1283. }
  1284. }
  1285. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1286. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1287. /** @hidden */
  1288. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1289. leftOperand: ShaderDefineExpression;
  1290. rightOperand: ShaderDefineExpression;
  1291. isTrue(preprocessors: {
  1292. [key: string]: string;
  1293. }): boolean;
  1294. }
  1295. }
  1296. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1297. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1298. /** @hidden */
  1299. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1300. define: string;
  1301. operand: string;
  1302. testValue: string;
  1303. constructor(define: string, operand: string, testValue: string);
  1304. isTrue(preprocessors: {
  1305. [key: string]: string;
  1306. }): boolean;
  1307. }
  1308. }
  1309. declare module "babylonjs/Offline/IOfflineProvider" {
  1310. /**
  1311. * Class used to enable access to offline support
  1312. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1313. */
  1314. export interface IOfflineProvider {
  1315. /**
  1316. * Gets a boolean indicating if scene must be saved in the database
  1317. */
  1318. enableSceneOffline: boolean;
  1319. /**
  1320. * Gets a boolean indicating if textures must be saved in the database
  1321. */
  1322. enableTexturesOffline: boolean;
  1323. /**
  1324. * Open the offline support and make it available
  1325. * @param successCallback defines the callback to call on success
  1326. * @param errorCallback defines the callback to call on error
  1327. */
  1328. open(successCallback: () => void, errorCallback: () => void): void;
  1329. /**
  1330. * Loads an image from the offline support
  1331. * @param url defines the url to load from
  1332. * @param image defines the target DOM image
  1333. */
  1334. loadImage(url: string, image: HTMLImageElement): void;
  1335. /**
  1336. * Loads a file from offline support
  1337. * @param url defines the URL to load from
  1338. * @param sceneLoaded defines a callback to call on success
  1339. * @param progressCallBack defines a callback to call when progress changed
  1340. * @param errorCallback defines a callback to call on error
  1341. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1342. */
  1343. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1344. }
  1345. }
  1346. declare module "babylonjs/Misc/filesInputStore" {
  1347. /**
  1348. * Class used to help managing file picking and drag'n'drop
  1349. * File Storage
  1350. */
  1351. export class FilesInputStore {
  1352. /**
  1353. * List of files ready to be loaded
  1354. */
  1355. static FilesToLoad: {
  1356. [key: string]: File;
  1357. };
  1358. }
  1359. }
  1360. declare module "babylonjs/Misc/retryStrategy" {
  1361. import { WebRequest } from "babylonjs/Misc/webRequest";
  1362. /**
  1363. * Class used to define a retry strategy when error happens while loading assets
  1364. */
  1365. export class RetryStrategy {
  1366. /**
  1367. * Function used to defines an exponential back off strategy
  1368. * @param maxRetries defines the maximum number of retries (3 by default)
  1369. * @param baseInterval defines the interval between retries
  1370. * @returns the strategy function to use
  1371. */
  1372. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1373. }
  1374. }
  1375. declare module "babylonjs/Misc/baseError" {
  1376. /**
  1377. * @ignore
  1378. * Application error to support additional information when loading a file
  1379. */
  1380. export abstract class BaseError extends Error {
  1381. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1382. }
  1383. }
  1384. declare module "babylonjs/Misc/fileTools" {
  1385. import { WebRequest } from "babylonjs/Misc/webRequest";
  1386. import { Nullable } from "babylonjs/types";
  1387. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1388. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1389. import { BaseError } from "babylonjs/Misc/baseError";
  1390. /** @ignore */
  1391. export class LoadFileError extends BaseError {
  1392. request?: WebRequest;
  1393. file?: File;
  1394. /**
  1395. * Creates a new LoadFileError
  1396. * @param message defines the message of the error
  1397. * @param request defines the optional web request
  1398. * @param file defines the optional file
  1399. */
  1400. constructor(message: string, object?: WebRequest | File);
  1401. }
  1402. /** @ignore */
  1403. export class RequestFileError extends BaseError {
  1404. request: WebRequest;
  1405. /**
  1406. * Creates a new LoadFileError
  1407. * @param message defines the message of the error
  1408. * @param request defines the optional web request
  1409. */
  1410. constructor(message: string, request: WebRequest);
  1411. }
  1412. /** @ignore */
  1413. export class ReadFileError extends BaseError {
  1414. file: File;
  1415. /**
  1416. * Creates a new ReadFileError
  1417. * @param message defines the message of the error
  1418. * @param file defines the optional file
  1419. */
  1420. constructor(message: string, file: File);
  1421. }
  1422. /**
  1423. * @hidden
  1424. */
  1425. export class FileTools {
  1426. /**
  1427. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1428. */
  1429. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1430. /**
  1431. * Gets or sets the base URL to use to load assets
  1432. */
  1433. static BaseUrl: string;
  1434. /**
  1435. * Default behaviour for cors in the application.
  1436. * It can be a string if the expected behavior is identical in the entire app.
  1437. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1438. */
  1439. static CorsBehavior: string | ((url: string | string[]) => string);
  1440. /**
  1441. * Gets or sets a function used to pre-process url before using them to load assets
  1442. */
  1443. static PreprocessUrl: (url: string) => string;
  1444. /**
  1445. * Removes unwanted characters from an url
  1446. * @param url defines the url to clean
  1447. * @returns the cleaned url
  1448. */
  1449. private static _CleanUrl;
  1450. /**
  1451. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1452. * @param url define the url we are trying
  1453. * @param element define the dom element where to configure the cors policy
  1454. */
  1455. static SetCorsBehavior(url: string | string[], element: {
  1456. crossOrigin: string | null;
  1457. }): void;
  1458. /**
  1459. * Loads an image as an HTMLImageElement.
  1460. * @param input url string, ArrayBuffer, or Blob to load
  1461. * @param onLoad callback called when the image successfully loads
  1462. * @param onError callback called when the image fails to load
  1463. * @param offlineProvider offline provider for caching
  1464. * @param mimeType optional mime type
  1465. * @returns the HTMLImageElement of the loaded image
  1466. */
  1467. 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>;
  1468. /**
  1469. * Reads a file from a File object
  1470. * @param file defines the file to load
  1471. * @param onSuccess defines the callback to call when data is loaded
  1472. * @param onProgress defines the callback to call during loading process
  1473. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1474. * @param onError defines the callback to call when an error occurs
  1475. * @returns a file request object
  1476. */
  1477. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1478. /**
  1479. * Loads a file from a url
  1480. * @param url url to load
  1481. * @param onSuccess callback called when the file successfully loads
  1482. * @param onProgress callback called while file is loading (if the server supports this mode)
  1483. * @param offlineProvider defines the offline provider for caching
  1484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1485. * @param onError callback called when the file fails to load
  1486. * @returns a file request object
  1487. */
  1488. 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;
  1489. /**
  1490. * Loads a file
  1491. * @param url url to load
  1492. * @param onSuccess callback called when the file successfully loads
  1493. * @param onProgress callback called while file is loading (if the server supports this mode)
  1494. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1495. * @param onError callback called when the file fails to load
  1496. * @param onOpened callback called when the web request is opened
  1497. * @returns a file request object
  1498. */
  1499. 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;
  1500. /**
  1501. * Checks if the loaded document was accessed via `file:`-Protocol.
  1502. * @returns boolean
  1503. */
  1504. static IsFileURL(): boolean;
  1505. }
  1506. }
  1507. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1508. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1509. import { WebRequest } from "babylonjs/Misc/webRequest";
  1510. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1511. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1512. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1513. /** @hidden */
  1514. export class ShaderProcessor {
  1515. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1516. private static _ProcessPrecision;
  1517. private static _ExtractOperation;
  1518. private static _BuildSubExpression;
  1519. private static _BuildExpression;
  1520. private static _MoveCursorWithinIf;
  1521. private static _MoveCursor;
  1522. private static _EvaluatePreProcessors;
  1523. private static _PreparePreProcessors;
  1524. private static _ProcessShaderConversion;
  1525. private static _ProcessIncludes;
  1526. /**
  1527. * Loads a file from a url
  1528. * @param url url to load
  1529. * @param onSuccess callback called when the file successfully loads
  1530. * @param onProgress callback called while file is loading (if the server supports this mode)
  1531. * @param offlineProvider defines the offline provider for caching
  1532. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1533. * @param onError callback called when the file fails to load
  1534. * @returns a file request object
  1535. * @hidden
  1536. */
  1537. 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;
  1538. }
  1539. }
  1540. declare module "babylonjs/Maths/math.like" {
  1541. import { float, int, DeepImmutable } from "babylonjs/types";
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IColor4Like {
  1546. r: float;
  1547. g: float;
  1548. b: float;
  1549. a: float;
  1550. }
  1551. /**
  1552. * @hidden
  1553. */
  1554. export interface IColor3Like {
  1555. r: float;
  1556. g: float;
  1557. b: float;
  1558. }
  1559. /**
  1560. * @hidden
  1561. */
  1562. export interface IVector4Like {
  1563. x: float;
  1564. y: float;
  1565. z: float;
  1566. w: float;
  1567. }
  1568. /**
  1569. * @hidden
  1570. */
  1571. export interface IVector3Like {
  1572. x: float;
  1573. y: float;
  1574. z: float;
  1575. }
  1576. /**
  1577. * @hidden
  1578. */
  1579. export interface IVector2Like {
  1580. x: float;
  1581. y: float;
  1582. }
  1583. /**
  1584. * @hidden
  1585. */
  1586. export interface IMatrixLike {
  1587. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1588. updateFlag: int;
  1589. }
  1590. /**
  1591. * @hidden
  1592. */
  1593. export interface IViewportLike {
  1594. x: float;
  1595. y: float;
  1596. width: float;
  1597. height: float;
  1598. }
  1599. /**
  1600. * @hidden
  1601. */
  1602. export interface IPlaneLike {
  1603. normal: IVector3Like;
  1604. d: float;
  1605. normalize(): void;
  1606. }
  1607. }
  1608. declare module "babylonjs/Materials/iEffectFallbacks" {
  1609. import { Effect } from "babylonjs/Materials/effect";
  1610. /**
  1611. * Interface used to define common properties for effect fallbacks
  1612. */
  1613. export interface IEffectFallbacks {
  1614. /**
  1615. * Removes the defines that should be removed when falling back.
  1616. * @param currentDefines defines the current define statements for the shader.
  1617. * @param effect defines the current effect we try to compile
  1618. * @returns The resulting defines with defines of the current rank removed.
  1619. */
  1620. reduce(currentDefines: string, effect: Effect): string;
  1621. /**
  1622. * Removes the fallback from the bound mesh.
  1623. */
  1624. unBindMesh(): void;
  1625. /**
  1626. * Checks to see if more fallbacks are still availible.
  1627. */
  1628. hasMoreFallbacks: boolean;
  1629. }
  1630. }
  1631. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1632. /**
  1633. * Class used to evalaute queries containing `and` and `or` operators
  1634. */
  1635. export class AndOrNotEvaluator {
  1636. /**
  1637. * Evaluate a query
  1638. * @param query defines the query to evaluate
  1639. * @param evaluateCallback defines the callback used to filter result
  1640. * @returns true if the query matches
  1641. */
  1642. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1643. private static _HandleParenthesisContent;
  1644. private static _SimplifyNegation;
  1645. }
  1646. }
  1647. declare module "babylonjs/Misc/tags" {
  1648. /**
  1649. * Class used to store custom tags
  1650. */
  1651. export class Tags {
  1652. /**
  1653. * Adds support for tags on the given object
  1654. * @param obj defines the object to use
  1655. */
  1656. static EnableFor(obj: any): void;
  1657. /**
  1658. * Removes tags support
  1659. * @param obj defines the object to use
  1660. */
  1661. static DisableFor(obj: any): void;
  1662. /**
  1663. * Gets a boolean indicating if the given object has tags
  1664. * @param obj defines the object to use
  1665. * @returns a boolean
  1666. */
  1667. static HasTags(obj: any): boolean;
  1668. /**
  1669. * Gets the tags available on a given object
  1670. * @param obj defines the object to use
  1671. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1672. * @returns the tags
  1673. */
  1674. static GetTags(obj: any, asString?: boolean): any;
  1675. /**
  1676. * Adds tags to an object
  1677. * @param obj defines the object to use
  1678. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1679. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1680. */
  1681. static AddTagsTo(obj: any, tagsString: string): void;
  1682. /**
  1683. * @hidden
  1684. */
  1685. static _AddTagTo(obj: any, tag: string): void;
  1686. /**
  1687. * Removes specific tags from a specific object
  1688. * @param obj defines the object to use
  1689. * @param tagsString defines the tags to remove
  1690. */
  1691. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1692. /**
  1693. * @hidden
  1694. */
  1695. static _RemoveTagFrom(obj: any, tag: string): void;
  1696. /**
  1697. * Defines if tags hosted on an object match a given query
  1698. * @param obj defines the object to use
  1699. * @param tagsQuery defines the tag query
  1700. * @returns a boolean
  1701. */
  1702. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1703. }
  1704. }
  1705. declare module "babylonjs/Maths/math.scalar" {
  1706. /**
  1707. * Scalar computation library
  1708. */
  1709. export class Scalar {
  1710. /**
  1711. * Two pi constants convenient for computation.
  1712. */
  1713. static TwoPi: number;
  1714. /**
  1715. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1716. * @param a number
  1717. * @param b number
  1718. * @param epsilon (default = 1.401298E-45)
  1719. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1720. */
  1721. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1722. /**
  1723. * Returns a string : the upper case translation of the number i to hexadecimal.
  1724. * @param i number
  1725. * @returns the upper case translation of the number i to hexadecimal.
  1726. */
  1727. static ToHex(i: number): string;
  1728. /**
  1729. * Returns -1 if value is negative and +1 is value is positive.
  1730. * @param value the value
  1731. * @returns the value itself if it's equal to zero.
  1732. */
  1733. static Sign(value: number): number;
  1734. /**
  1735. * Returns the value itself if it's between min and max.
  1736. * Returns min if the value is lower than min.
  1737. * Returns max if the value is greater than max.
  1738. * @param value the value to clmap
  1739. * @param min the min value to clamp to (default: 0)
  1740. * @param max the max value to clamp to (default: 1)
  1741. * @returns the clamped value
  1742. */
  1743. static Clamp(value: number, min?: number, max?: number): number;
  1744. /**
  1745. * the log2 of value.
  1746. * @param value the value to compute log2 of
  1747. * @returns the log2 of value.
  1748. */
  1749. static Log2(value: number): number;
  1750. /**
  1751. * Loops the value, so that it is never larger than length and never smaller than 0.
  1752. *
  1753. * This is similar to the modulo operator but it works with floating point numbers.
  1754. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1755. * With t = 5 and length = 2.5, the result would be 0.0.
  1756. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1757. * @param value the value
  1758. * @param length the length
  1759. * @returns the looped value
  1760. */
  1761. static Repeat(value: number, length: number): number;
  1762. /**
  1763. * Normalize the value between 0.0 and 1.0 using min and max values
  1764. * @param value value to normalize
  1765. * @param min max to normalize between
  1766. * @param max min to normalize between
  1767. * @returns the normalized value
  1768. */
  1769. static Normalize(value: number, min: number, max: number): number;
  1770. /**
  1771. * Denormalize the value from 0.0 and 1.0 using min and max values
  1772. * @param normalized value to denormalize
  1773. * @param min max to denormalize between
  1774. * @param max min to denormalize between
  1775. * @returns the denormalized value
  1776. */
  1777. static Denormalize(normalized: number, min: number, max: number): number;
  1778. /**
  1779. * Calculates the shortest difference between two given angles given in degrees.
  1780. * @param current current angle in degrees
  1781. * @param target target angle in degrees
  1782. * @returns the delta
  1783. */
  1784. static DeltaAngle(current: number, target: number): number;
  1785. /**
  1786. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1787. * @param tx value
  1788. * @param length length
  1789. * @returns The returned value will move back and forth between 0 and length
  1790. */
  1791. static PingPong(tx: number, length: number): number;
  1792. /**
  1793. * Interpolates between min and max with smoothing at the limits.
  1794. *
  1795. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1796. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1797. * @param from from
  1798. * @param to to
  1799. * @param tx value
  1800. * @returns the smooth stepped value
  1801. */
  1802. static SmoothStep(from: number, to: number, tx: number): number;
  1803. /**
  1804. * Moves a value current towards target.
  1805. *
  1806. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1807. * Negative values of maxDelta pushes the value away from target.
  1808. * @param current current value
  1809. * @param target target value
  1810. * @param maxDelta max distance to move
  1811. * @returns resulting value
  1812. */
  1813. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1814. /**
  1815. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. *
  1817. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1818. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1819. * @param current current value
  1820. * @param target target value
  1821. * @param maxDelta max distance to move
  1822. * @returns resulting angle
  1823. */
  1824. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1825. /**
  1826. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1827. * @param start start value
  1828. * @param end target value
  1829. * @param amount amount to lerp between
  1830. * @returns the lerped value
  1831. */
  1832. static Lerp(start: number, end: number, amount: number): number;
  1833. /**
  1834. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1835. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1836. * @param start start value
  1837. * @param end target value
  1838. * @param amount amount to lerp between
  1839. * @returns the lerped value
  1840. */
  1841. static LerpAngle(start: number, end: number, amount: number): number;
  1842. /**
  1843. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1844. * @param a start value
  1845. * @param b target value
  1846. * @param value value between a and b
  1847. * @returns the inverseLerp value
  1848. */
  1849. static InverseLerp(a: number, b: number, value: number): number;
  1850. /**
  1851. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1852. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1853. * @param value1 spline value
  1854. * @param tangent1 spline value
  1855. * @param value2 spline value
  1856. * @param tangent2 spline value
  1857. * @param amount input value
  1858. * @returns hermite result
  1859. */
  1860. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1861. /**
  1862. * Returns a random float number between and min and max values
  1863. * @param min min value of random
  1864. * @param max max value of random
  1865. * @returns random value
  1866. */
  1867. static RandomRange(min: number, max: number): number;
  1868. /**
  1869. * This function returns percentage of a number in a given range.
  1870. *
  1871. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1872. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1873. * @param number to convert to percentage
  1874. * @param min min range
  1875. * @param max max range
  1876. * @returns the percentage
  1877. */
  1878. static RangeToPercent(number: number, min: number, max: number): number;
  1879. /**
  1880. * This function returns number that corresponds to the percentage in a given range.
  1881. *
  1882. * PercentToRange(0.34,0,100) will return 34.
  1883. * @param percent to convert to number
  1884. * @param min min range
  1885. * @param max max range
  1886. * @returns the number
  1887. */
  1888. static PercentToRange(percent: number, min: number, max: number): number;
  1889. /**
  1890. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1891. * @param angle The angle to normalize in radian.
  1892. * @return The converted angle.
  1893. */
  1894. static NormalizeRadians(angle: number): number;
  1895. }
  1896. }
  1897. declare module "babylonjs/Maths/math.constants" {
  1898. /**
  1899. * Constant used to convert a value to gamma space
  1900. * @ignorenaming
  1901. */
  1902. export const ToGammaSpace: number;
  1903. /**
  1904. * Constant used to convert a value to linear space
  1905. * @ignorenaming
  1906. */
  1907. export const ToLinearSpace = 2.2;
  1908. /**
  1909. * Constant used to define the minimal number value in Babylon.js
  1910. * @ignorenaming
  1911. */
  1912. let Epsilon: number;
  1913. export { Epsilon };
  1914. }
  1915. declare module "babylonjs/Maths/math.viewport" {
  1916. /**
  1917. * Class used to represent a viewport on screen
  1918. */
  1919. export class Viewport {
  1920. /** viewport left coordinate */
  1921. x: number;
  1922. /** viewport top coordinate */
  1923. y: number;
  1924. /**viewport width */
  1925. width: number;
  1926. /** viewport height */
  1927. height: number;
  1928. /**
  1929. * Creates a Viewport object located at (x, y) and sized (width, height)
  1930. * @param x defines viewport left coordinate
  1931. * @param y defines viewport top coordinate
  1932. * @param width defines the viewport width
  1933. * @param height defines the viewport height
  1934. */
  1935. constructor(
  1936. /** viewport left coordinate */
  1937. x: number,
  1938. /** viewport top coordinate */
  1939. y: number,
  1940. /**viewport width */
  1941. width: number,
  1942. /** viewport height */
  1943. height: number);
  1944. /**
  1945. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1946. * @param renderWidth defines the rendering width
  1947. * @param renderHeight defines the rendering height
  1948. * @returns a new Viewport
  1949. */
  1950. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1951. /**
  1952. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1953. * @param renderWidth defines the rendering width
  1954. * @param renderHeight defines the rendering height
  1955. * @param ref defines the target viewport
  1956. * @returns the current viewport
  1957. */
  1958. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1959. /**
  1960. * Returns a new Viewport copied from the current one
  1961. * @returns a new Viewport
  1962. */
  1963. clone(): Viewport;
  1964. }
  1965. }
  1966. declare module "babylonjs/Misc/arrayTools" {
  1967. /**
  1968. * Class containing a set of static utilities functions for arrays.
  1969. */
  1970. export class ArrayTools {
  1971. /**
  1972. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1973. * @param size the number of element to construct and put in the array
  1974. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1975. * @returns a new array filled with new objects
  1976. */
  1977. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1978. }
  1979. }
  1980. declare module "babylonjs/Maths/math.plane" {
  1981. import { DeepImmutable } from "babylonjs/types";
  1982. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1983. /**
  1984. * Represents a plane by the equation ax + by + cz + d = 0
  1985. */
  1986. export class Plane {
  1987. private static _TmpMatrix;
  1988. /**
  1989. * Normal of the plane (a,b,c)
  1990. */
  1991. normal: Vector3;
  1992. /**
  1993. * d component of the plane
  1994. */
  1995. d: number;
  1996. /**
  1997. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1998. * @param a a component of the plane
  1999. * @param b b component of the plane
  2000. * @param c c component of the plane
  2001. * @param d d component of the plane
  2002. */
  2003. constructor(a: number, b: number, c: number, d: number);
  2004. /**
  2005. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2006. */
  2007. asArray(): number[];
  2008. /**
  2009. * @returns a new plane copied from the current Plane.
  2010. */
  2011. clone(): Plane;
  2012. /**
  2013. * @returns the string "Plane".
  2014. */
  2015. getClassName(): string;
  2016. /**
  2017. * @returns the Plane hash code.
  2018. */
  2019. getHashCode(): number;
  2020. /**
  2021. * Normalize the current Plane in place.
  2022. * @returns the updated Plane.
  2023. */
  2024. normalize(): Plane;
  2025. /**
  2026. * Applies a transformation the plane and returns the result
  2027. * @param transformation the transformation matrix to be applied to the plane
  2028. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2029. */
  2030. transform(transformation: DeepImmutable<Matrix>): Plane;
  2031. /**
  2032. * Compute the dot product between the point and the plane normal
  2033. * @param point point to calculate the dot product with
  2034. * @returns the dot product (float) of the point coordinates and the plane normal.
  2035. */
  2036. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2037. /**
  2038. * Updates the current Plane from the plane defined by the three given points.
  2039. * @param point1 one of the points used to contruct the plane
  2040. * @param point2 one of the points used to contruct the plane
  2041. * @param point3 one of the points used to contruct the plane
  2042. * @returns the updated Plane.
  2043. */
  2044. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2045. /**
  2046. * Checks if the plane is facing a given direction
  2047. * @param direction the direction to check if the plane is facing
  2048. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2049. * @returns True is the vector "direction" is the same side than the plane normal.
  2050. */
  2051. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2052. /**
  2053. * Calculates the distance to a point
  2054. * @param point point to calculate distance to
  2055. * @returns the signed distance (float) from the given point to the Plane.
  2056. */
  2057. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2058. /**
  2059. * Creates a plane from an array
  2060. * @param array the array to create a plane from
  2061. * @returns a new Plane from the given array.
  2062. */
  2063. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2064. /**
  2065. * Creates a plane from three points
  2066. * @param point1 point used to create the plane
  2067. * @param point2 point used to create the plane
  2068. * @param point3 point used to create the plane
  2069. * @returns a new Plane defined by the three given points.
  2070. */
  2071. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2072. /**
  2073. * Creates a plane from an origin point and a normal
  2074. * @param origin origin of the plane to be constructed
  2075. * @param normal normal of the plane to be constructed
  2076. * @returns a new Plane the normal vector to this plane at the given origin point.
  2077. * Note : the vector "normal" is updated because normalized.
  2078. */
  2079. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2080. /**
  2081. * Calculates the distance from a plane and a point
  2082. * @param origin origin of the plane to be constructed
  2083. * @param normal normal of the plane to be constructed
  2084. * @param point point to calculate distance to
  2085. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2086. */
  2087. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2088. }
  2089. }
  2090. declare module "babylonjs/Engines/performanceConfigurator" {
  2091. /** @hidden */
  2092. export class PerformanceConfigurator {
  2093. /** @hidden */
  2094. static MatrixUse64Bits: boolean;
  2095. /** @hidden */
  2096. static MatrixTrackPrecisionChange: boolean;
  2097. /** @hidden */
  2098. static MatrixCurrentType: any;
  2099. /** @hidden */
  2100. static MatrixTrackedMatrices: Array<any> | null;
  2101. /** @hidden */
  2102. static SetMatrixPrecision(use64bits: boolean): void;
  2103. }
  2104. }
  2105. declare module "babylonjs/Maths/math.vector" {
  2106. import { Viewport } from "babylonjs/Maths/math.viewport";
  2107. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2108. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2109. import { Plane } from "babylonjs/Maths/math.plane";
  2110. /**
  2111. * Class representing a vector containing 2 coordinates
  2112. */
  2113. export class Vector2 {
  2114. /** defines the first coordinate */
  2115. x: number;
  2116. /** defines the second coordinate */
  2117. y: number;
  2118. /**
  2119. * Creates a new Vector2 from the given x and y coordinates
  2120. * @param x defines the first coordinate
  2121. * @param y defines the second coordinate
  2122. */
  2123. constructor(
  2124. /** defines the first coordinate */
  2125. x?: number,
  2126. /** defines the second coordinate */
  2127. y?: number);
  2128. /**
  2129. * Gets a string with the Vector2 coordinates
  2130. * @returns a string with the Vector2 coordinates
  2131. */
  2132. toString(): string;
  2133. /**
  2134. * Gets class name
  2135. * @returns the string "Vector2"
  2136. */
  2137. getClassName(): string;
  2138. /**
  2139. * Gets current vector hash code
  2140. * @returns the Vector2 hash code as a number
  2141. */
  2142. getHashCode(): number;
  2143. /**
  2144. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2145. * @param array defines the source array
  2146. * @param index defines the offset in source array
  2147. * @returns the current Vector2
  2148. */
  2149. toArray(array: FloatArray, index?: number): Vector2;
  2150. /**
  2151. * Update the current vector from an array
  2152. * @param array defines the destination array
  2153. * @param index defines the offset in the destination array
  2154. * @returns the current Vector3
  2155. */
  2156. fromArray(array: FloatArray, index?: number): Vector2;
  2157. /**
  2158. * Copy the current vector to an array
  2159. * @returns a new array with 2 elements: the Vector2 coordinates.
  2160. */
  2161. asArray(): number[];
  2162. /**
  2163. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2164. * @param source defines the source Vector2
  2165. * @returns the current updated Vector2
  2166. */
  2167. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2168. /**
  2169. * Sets the Vector2 coordinates with the given floats
  2170. * @param x defines the first coordinate
  2171. * @param y defines the second coordinate
  2172. * @returns the current updated Vector2
  2173. */
  2174. copyFromFloats(x: number, y: number): Vector2;
  2175. /**
  2176. * Sets the Vector2 coordinates with the given floats
  2177. * @param x defines the first coordinate
  2178. * @param y defines the second coordinate
  2179. * @returns the current updated Vector2
  2180. */
  2181. set(x: number, y: number): Vector2;
  2182. /**
  2183. * Add another vector with the current one
  2184. * @param otherVector defines the other vector
  2185. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2186. */
  2187. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2188. /**
  2189. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2190. * @param otherVector defines the other vector
  2191. * @param result defines the target vector
  2192. * @returns the unmodified current Vector2
  2193. */
  2194. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2195. /**
  2196. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2197. * @param otherVector defines the other vector
  2198. * @returns the current updated Vector2
  2199. */
  2200. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2201. /**
  2202. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2203. * @param otherVector defines the other vector
  2204. * @returns a new Vector2
  2205. */
  2206. addVector3(otherVector: Vector3): Vector2;
  2207. /**
  2208. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2209. * @param otherVector defines the other vector
  2210. * @returns a new Vector2
  2211. */
  2212. subtract(otherVector: Vector2): Vector2;
  2213. /**
  2214. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2215. * @param otherVector defines the other vector
  2216. * @param result defines the target vector
  2217. * @returns the unmodified current Vector2
  2218. */
  2219. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2220. /**
  2221. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2222. * @param otherVector defines the other vector
  2223. * @returns the current updated Vector2
  2224. */
  2225. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Multiplies in place the current Vector2 coordinates by the given ones
  2228. * @param otherVector defines the other vector
  2229. * @returns the current updated Vector2
  2230. */
  2231. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2232. /**
  2233. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2234. * @param otherVector defines the other vector
  2235. * @returns a new Vector2
  2236. */
  2237. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2238. /**
  2239. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2240. * @param otherVector defines the other vector
  2241. * @param result defines the target vector
  2242. * @returns the unmodified current Vector2
  2243. */
  2244. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2245. /**
  2246. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2247. * @param x defines the first coordinate
  2248. * @param y defines the second coordinate
  2249. * @returns a new Vector2
  2250. */
  2251. multiplyByFloats(x: number, y: number): Vector2;
  2252. /**
  2253. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2254. * @param otherVector defines the other vector
  2255. * @returns a new Vector2
  2256. */
  2257. divide(otherVector: Vector2): Vector2;
  2258. /**
  2259. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2260. * @param otherVector defines the other vector
  2261. * @param result defines the target vector
  2262. * @returns the unmodified current Vector2
  2263. */
  2264. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2265. /**
  2266. * Divides the current Vector2 coordinates by the given ones
  2267. * @param otherVector defines the other vector
  2268. * @returns the current updated Vector2
  2269. */
  2270. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2271. /**
  2272. * Gets a new Vector2 with current Vector2 negated coordinates
  2273. * @returns a new Vector2
  2274. */
  2275. negate(): Vector2;
  2276. /**
  2277. * Negate this vector in place
  2278. * @returns this
  2279. */
  2280. negateInPlace(): Vector2;
  2281. /**
  2282. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2283. * @param result defines the Vector3 object where to store the result
  2284. * @returns the current Vector2
  2285. */
  2286. negateToRef(result: Vector2): Vector2;
  2287. /**
  2288. * Multiply the Vector2 coordinates by scale
  2289. * @param scale defines the scaling factor
  2290. * @returns the current updated Vector2
  2291. */
  2292. scaleInPlace(scale: number): Vector2;
  2293. /**
  2294. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2295. * @param scale defines the scaling factor
  2296. * @returns a new Vector2
  2297. */
  2298. scale(scale: number): Vector2;
  2299. /**
  2300. * Scale the current Vector2 values by a factor to a given Vector2
  2301. * @param scale defines the scale factor
  2302. * @param result defines the Vector2 object where to store the result
  2303. * @returns the unmodified current Vector2
  2304. */
  2305. scaleToRef(scale: number, result: Vector2): Vector2;
  2306. /**
  2307. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2308. * @param scale defines the scale factor
  2309. * @param result defines the Vector2 object where to store the result
  2310. * @returns the unmodified current Vector2
  2311. */
  2312. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2313. /**
  2314. * Gets a boolean if two vectors are equals
  2315. * @param otherVector defines the other vector
  2316. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2317. */
  2318. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2319. /**
  2320. * Gets a boolean if two vectors are equals (using an epsilon value)
  2321. * @param otherVector defines the other vector
  2322. * @param epsilon defines the minimal distance to consider equality
  2323. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2324. */
  2325. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2326. /**
  2327. * Gets a new Vector2 from current Vector2 floored values
  2328. * @returns a new Vector2
  2329. */
  2330. floor(): Vector2;
  2331. /**
  2332. * Gets a new Vector2 from current Vector2 floored values
  2333. * @returns a new Vector2
  2334. */
  2335. fract(): Vector2;
  2336. /**
  2337. * Gets the length of the vector
  2338. * @returns the vector length (float)
  2339. */
  2340. length(): number;
  2341. /**
  2342. * Gets the vector squared length
  2343. * @returns the vector squared length (float)
  2344. */
  2345. lengthSquared(): number;
  2346. /**
  2347. * Normalize the vector
  2348. * @returns the current updated Vector2
  2349. */
  2350. normalize(): Vector2;
  2351. /**
  2352. * Gets a new Vector2 copied from the Vector2
  2353. * @returns a new Vector2
  2354. */
  2355. clone(): Vector2;
  2356. /**
  2357. * Gets a new Vector2(0, 0)
  2358. * @returns a new Vector2
  2359. */
  2360. static Zero(): Vector2;
  2361. /**
  2362. * Gets a new Vector2(1, 1)
  2363. * @returns a new Vector2
  2364. */
  2365. static One(): Vector2;
  2366. /**
  2367. * Gets a new Vector2 set from the given index element of the given array
  2368. * @param array defines the data source
  2369. * @param offset defines the offset in the data source
  2370. * @returns a new Vector2
  2371. */
  2372. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2373. /**
  2374. * Sets "result" from the given index element of the given array
  2375. * @param array defines the data source
  2376. * @param offset defines the offset in the data source
  2377. * @param result defines the target vector
  2378. */
  2379. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2380. /**
  2381. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2382. * @param value1 defines 1st point of control
  2383. * @param value2 defines 2nd point of control
  2384. * @param value3 defines 3rd point of control
  2385. * @param value4 defines 4th point of control
  2386. * @param amount defines the interpolation factor
  2387. * @returns a new Vector2
  2388. */
  2389. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2390. /**
  2391. * 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".
  2392. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2393. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2394. * @param value defines the value to clamp
  2395. * @param min defines the lower limit
  2396. * @param max defines the upper limit
  2397. * @returns a new Vector2
  2398. */
  2399. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2400. /**
  2401. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2402. * @param value1 defines the 1st control point
  2403. * @param tangent1 defines the outgoing tangent
  2404. * @param value2 defines the 2nd control point
  2405. * @param tangent2 defines the incoming tangent
  2406. * @param amount defines the interpolation factor
  2407. * @returns a new Vector2
  2408. */
  2409. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2410. /**
  2411. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2412. * @param start defines the start vector
  2413. * @param end defines the end vector
  2414. * @param amount defines the interpolation factor
  2415. * @returns a new Vector2
  2416. */
  2417. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2418. /**
  2419. * Gets the dot product of the vector "left" and the vector "right"
  2420. * @param left defines first vector
  2421. * @param right defines second vector
  2422. * @returns the dot product (float)
  2423. */
  2424. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2425. /**
  2426. * Returns a new Vector2 equal to the normalized given vector
  2427. * @param vector defines the vector to normalize
  2428. * @returns a new Vector2
  2429. */
  2430. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2431. /**
  2432. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2433. * @param left defines 1st vector
  2434. * @param right defines 2nd vector
  2435. * @returns a new Vector2
  2436. */
  2437. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2438. /**
  2439. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2440. * @param left defines 1st vector
  2441. * @param right defines 2nd vector
  2442. * @returns a new Vector2
  2443. */
  2444. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2445. /**
  2446. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2447. * @param vector defines the vector to transform
  2448. * @param transformation defines the matrix to apply
  2449. * @returns a new Vector2
  2450. */
  2451. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2452. /**
  2453. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2454. * @param vector defines the vector to transform
  2455. * @param transformation defines the matrix to apply
  2456. * @param result defines the target vector
  2457. */
  2458. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2459. /**
  2460. * Determines if a given vector is included in a triangle
  2461. * @param p defines the vector to test
  2462. * @param p0 defines 1st triangle point
  2463. * @param p1 defines 2nd triangle point
  2464. * @param p2 defines 3rd triangle point
  2465. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2466. */
  2467. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2468. /**
  2469. * Gets the distance between the vectors "value1" and "value2"
  2470. * @param value1 defines first vector
  2471. * @param value2 defines second vector
  2472. * @returns the distance between vectors
  2473. */
  2474. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2475. /**
  2476. * Returns the squared distance between the vectors "value1" and "value2"
  2477. * @param value1 defines first vector
  2478. * @param value2 defines second vector
  2479. * @returns the squared distance between vectors
  2480. */
  2481. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2482. /**
  2483. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2484. * @param value1 defines first vector
  2485. * @param value2 defines second vector
  2486. * @returns a new Vector2
  2487. */
  2488. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2489. /**
  2490. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2491. * @param p defines the middle point
  2492. * @param segA defines one point of the segment
  2493. * @param segB defines the other point of the segment
  2494. * @returns the shortest distance
  2495. */
  2496. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2497. }
  2498. /**
  2499. * Class used to store (x,y,z) vector representation
  2500. * A Vector3 is the main object used in 3D geometry
  2501. * It can represent etiher the coordinates of a point the space, either a direction
  2502. * Reminder: js uses a left handed forward facing system
  2503. */
  2504. export class Vector3 {
  2505. private static _UpReadOnly;
  2506. private static _ZeroReadOnly;
  2507. /** @hidden */
  2508. _x: number;
  2509. /** @hidden */
  2510. _y: number;
  2511. /** @hidden */
  2512. _z: number;
  2513. /** @hidden */
  2514. _isDirty: boolean;
  2515. /** Gets or sets the x coordinate */
  2516. get x(): number;
  2517. set x(value: number);
  2518. /** Gets or sets the y coordinate */
  2519. get y(): number;
  2520. set y(value: number);
  2521. /** Gets or sets the z coordinate */
  2522. get z(): number;
  2523. set z(value: number);
  2524. /**
  2525. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2526. * @param x defines the first coordinates (on X axis)
  2527. * @param y defines the second coordinates (on Y axis)
  2528. * @param z defines the third coordinates (on Z axis)
  2529. */
  2530. constructor(x?: number, y?: number, z?: number);
  2531. /**
  2532. * Creates a string representation of the Vector3
  2533. * @returns a string with the Vector3 coordinates.
  2534. */
  2535. toString(): string;
  2536. /**
  2537. * Gets the class name
  2538. * @returns the string "Vector3"
  2539. */
  2540. getClassName(): string;
  2541. /**
  2542. * Creates the Vector3 hash code
  2543. * @returns a number which tends to be unique between Vector3 instances
  2544. */
  2545. getHashCode(): number;
  2546. /**
  2547. * Creates an array containing three elements : the coordinates of the Vector3
  2548. * @returns a new array of numbers
  2549. */
  2550. asArray(): number[];
  2551. /**
  2552. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2553. * @param array defines the destination array
  2554. * @param index defines the offset in the destination array
  2555. * @returns the current Vector3
  2556. */
  2557. toArray(array: FloatArray, index?: number): Vector3;
  2558. /**
  2559. * Update the current vector from an array
  2560. * @param array defines the destination array
  2561. * @param index defines the offset in the destination array
  2562. * @returns the current Vector3
  2563. */
  2564. fromArray(array: FloatArray, index?: number): Vector3;
  2565. /**
  2566. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2567. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2568. */
  2569. toQuaternion(): Quaternion;
  2570. /**
  2571. * Adds the given vector to the current Vector3
  2572. * @param otherVector defines the second operand
  2573. * @returns the current updated Vector3
  2574. */
  2575. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2576. /**
  2577. * Adds the given coordinates to the current Vector3
  2578. * @param x defines the x coordinate of the operand
  2579. * @param y defines the y coordinate of the operand
  2580. * @param z defines the z coordinate of the operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2584. /**
  2585. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2586. * @param otherVector defines the second operand
  2587. * @returns the resulting Vector3
  2588. */
  2589. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Adds the current Vector3 to the given one 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. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2597. /**
  2598. * Subtract the given vector from the current Vector3
  2599. * @param otherVector defines the second operand
  2600. * @returns the current updated Vector3
  2601. */
  2602. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2603. /**
  2604. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2605. * @param otherVector defines the second operand
  2606. * @returns the resulting Vector3
  2607. */
  2608. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2609. /**
  2610. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2611. * @param otherVector defines the second operand
  2612. * @param result defines the Vector3 object where to store the result
  2613. * @returns the current Vector3
  2614. */
  2615. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2618. * @param x defines the x coordinate of the operand
  2619. * @param y defines the y coordinate of the operand
  2620. * @param z defines the z coordinate of the operand
  2621. * @returns the resulting Vector3
  2622. */
  2623. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2624. /**
  2625. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2626. * @param x defines the x coordinate of the operand
  2627. * @param y defines the y coordinate of the operand
  2628. * @param z defines the z coordinate of the operand
  2629. * @param result defines the Vector3 object where to store the result
  2630. * @returns the current Vector3
  2631. */
  2632. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2633. /**
  2634. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2635. * @returns a new Vector3
  2636. */
  2637. negate(): Vector3;
  2638. /**
  2639. * Negate this vector in place
  2640. * @returns this
  2641. */
  2642. negateInPlace(): Vector3;
  2643. /**
  2644. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. negateToRef(result: Vector3): Vector3;
  2649. /**
  2650. * Multiplies the Vector3 coordinates by the float "scale"
  2651. * @param scale defines the multiplier factor
  2652. * @returns the current updated Vector3
  2653. */
  2654. scaleInPlace(scale: number): Vector3;
  2655. /**
  2656. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2657. * @param scale defines the multiplier factor
  2658. * @returns a new Vector3
  2659. */
  2660. scale(scale: number): Vector3;
  2661. /**
  2662. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2663. * @param scale defines the multiplier factor
  2664. * @param result defines the Vector3 object where to store the result
  2665. * @returns the current Vector3
  2666. */
  2667. scaleToRef(scale: number, result: Vector3): Vector3;
  2668. /**
  2669. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2670. * @param scale defines the scale factor
  2671. * @param result defines the Vector3 object where to store the result
  2672. * @returns the unmodified current Vector3
  2673. */
  2674. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2675. /**
  2676. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2677. * @param origin defines the origin of the projection ray
  2678. * @param plane defines the plane to project to
  2679. * @returns the projected vector3
  2680. */
  2681. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2682. /**
  2683. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2684. * @param origin defines the origin of the projection ray
  2685. * @param plane defines the plane to project to
  2686. * @param result defines the Vector3 where to store the result
  2687. */
  2688. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2689. /**
  2690. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2691. * @param otherVector defines the second operand
  2692. * @returns true if both vectors are equals
  2693. */
  2694. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2695. /**
  2696. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2697. * @param otherVector defines the second operand
  2698. * @param epsilon defines the minimal distance to define values as equals
  2699. * @returns true if both vectors are distant less than epsilon
  2700. */
  2701. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2702. /**
  2703. * Returns true if the current Vector3 coordinates equals the given floats
  2704. * @param x defines the x coordinate of the operand
  2705. * @param y defines the y coordinate of the operand
  2706. * @param z defines the z coordinate of the operand
  2707. * @returns true if both vectors are equals
  2708. */
  2709. equalsToFloats(x: number, y: number, z: number): boolean;
  2710. /**
  2711. * Multiplies the current Vector3 coordinates by the given ones
  2712. * @param otherVector defines the second operand
  2713. * @returns the current updated Vector3
  2714. */
  2715. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2716. /**
  2717. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2718. * @param otherVector defines the second operand
  2719. * @returns the new Vector3
  2720. */
  2721. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2722. /**
  2723. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2724. * @param otherVector defines the second operand
  2725. * @param result defines the Vector3 object where to store the result
  2726. * @returns the current Vector3
  2727. */
  2728. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2729. /**
  2730. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2731. * @param x defines the x coordinate of the operand
  2732. * @param y defines the y coordinate of the operand
  2733. * @param z defines the z coordinate of the operand
  2734. * @returns the new Vector3
  2735. */
  2736. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2737. /**
  2738. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2739. * @param otherVector defines the second operand
  2740. * @returns the new Vector3
  2741. */
  2742. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2743. /**
  2744. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2745. * @param otherVector defines the second operand
  2746. * @param result defines the Vector3 object where to store the result
  2747. * @returns the current Vector3
  2748. */
  2749. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2750. /**
  2751. * Divides the current Vector3 coordinates by the given ones.
  2752. * @param otherVector defines the second operand
  2753. * @returns the current updated Vector3
  2754. */
  2755. divideInPlace(otherVector: Vector3): Vector3;
  2756. /**
  2757. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2758. * @param other defines the second operand
  2759. * @returns the current updated Vector3
  2760. */
  2761. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2762. /**
  2763. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2764. * @param other defines the second operand
  2765. * @returns the current updated Vector3
  2766. */
  2767. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2768. /**
  2769. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2770. * @param x defines the x coordinate of the operand
  2771. * @param y defines the y coordinate of the operand
  2772. * @param z defines the z coordinate of the operand
  2773. * @returns the current updated Vector3
  2774. */
  2775. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2776. /**
  2777. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2778. * @param x defines the x coordinate of the operand
  2779. * @param y defines the y coordinate of the operand
  2780. * @param z defines the z coordinate of the operand
  2781. * @returns the current updated Vector3
  2782. */
  2783. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2784. /**
  2785. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2786. * Check if is non uniform within a certain amount of decimal places to account for this
  2787. * @param epsilon the amount the values can differ
  2788. * @returns if the the vector is non uniform to a certain number of decimal places
  2789. */
  2790. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2791. /**
  2792. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2793. */
  2794. get isNonUniform(): boolean;
  2795. /**
  2796. * Gets a new Vector3 from current Vector3 floored values
  2797. * @returns a new Vector3
  2798. */
  2799. floor(): Vector3;
  2800. /**
  2801. * Gets a new Vector3 from current Vector3 floored values
  2802. * @returns a new Vector3
  2803. */
  2804. fract(): Vector3;
  2805. /**
  2806. * Gets the length of the Vector3
  2807. * @returns the length of the Vector3
  2808. */
  2809. length(): number;
  2810. /**
  2811. * Gets the squared length of the Vector3
  2812. * @returns squared length of the Vector3
  2813. */
  2814. lengthSquared(): number;
  2815. /**
  2816. * Normalize the current Vector3.
  2817. * Please note that this is an in place operation.
  2818. * @returns the current updated Vector3
  2819. */
  2820. normalize(): Vector3;
  2821. /**
  2822. * Reorders the x y z properties of the vector in place
  2823. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2824. * @returns the current updated vector
  2825. */
  2826. reorderInPlace(order: string): this;
  2827. /**
  2828. * Rotates the vector around 0,0,0 by a quaternion
  2829. * @param quaternion the rotation quaternion
  2830. * @param result vector to store the result
  2831. * @returns the resulting vector
  2832. */
  2833. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2834. /**
  2835. * Rotates a vector around a given point
  2836. * @param quaternion the rotation quaternion
  2837. * @param point the point to rotate around
  2838. * @param result vector to store the result
  2839. * @returns the resulting vector
  2840. */
  2841. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2842. /**
  2843. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2844. * The cross product is then orthogonal to both current and "other"
  2845. * @param other defines the right operand
  2846. * @returns the cross product
  2847. */
  2848. cross(other: Vector3): Vector3;
  2849. /**
  2850. * Normalize the current Vector3 with the given input length.
  2851. * Please note that this is an in place operation.
  2852. * @param len the length of the vector
  2853. * @returns the current updated Vector3
  2854. */
  2855. normalizeFromLength(len: number): Vector3;
  2856. /**
  2857. * Normalize the current Vector3 to a new vector
  2858. * @returns the new Vector3
  2859. */
  2860. normalizeToNew(): Vector3;
  2861. /**
  2862. * Normalize the current Vector3 to the reference
  2863. * @param reference define the Vector3 to update
  2864. * @returns the updated Vector3
  2865. */
  2866. normalizeToRef(reference: Vector3): Vector3;
  2867. /**
  2868. * Creates a new Vector3 copied from the current Vector3
  2869. * @returns the new Vector3
  2870. */
  2871. clone(): Vector3;
  2872. /**
  2873. * Copies the given vector coordinates to the current Vector3 ones
  2874. * @param source defines the source Vector3
  2875. * @returns the current updated Vector3
  2876. */
  2877. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2878. /**
  2879. * Copies the given floats to the current Vector3 coordinates
  2880. * @param x defines the x coordinate of the operand
  2881. * @param y defines the y coordinate of the operand
  2882. * @param z defines the z coordinate of the operand
  2883. * @returns the current updated Vector3
  2884. */
  2885. copyFromFloats(x: number, y: number, z: number): Vector3;
  2886. /**
  2887. * Copies the given floats to the current Vector3 coordinates
  2888. * @param x defines the x coordinate of the operand
  2889. * @param y defines the y coordinate of the operand
  2890. * @param z defines the z coordinate of the operand
  2891. * @returns the current updated Vector3
  2892. */
  2893. set(x: number, y: number, z: number): Vector3;
  2894. /**
  2895. * Copies the given float to the current Vector3 coordinates
  2896. * @param v defines the x, y and z coordinates of the operand
  2897. * @returns the current updated Vector3
  2898. */
  2899. setAll(v: number): Vector3;
  2900. /**
  2901. * Get the clip factor between two vectors
  2902. * @param vector0 defines the first operand
  2903. * @param vector1 defines the second operand
  2904. * @param axis defines the axis to use
  2905. * @param size defines the size along the axis
  2906. * @returns the clip factor
  2907. */
  2908. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2909. /**
  2910. * Get angle between two vectors
  2911. * @param vector0 angle between vector0 and vector1
  2912. * @param vector1 angle between vector0 and vector1
  2913. * @param normal direction of the normal
  2914. * @return the angle between vector0 and vector1
  2915. */
  2916. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2917. /**
  2918. * Returns a new Vector3 set from the index "offset" of the given array
  2919. * @param array defines the source array
  2920. * @param offset defines the offset in the source array
  2921. * @returns the new Vector3
  2922. */
  2923. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2924. /**
  2925. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2926. * @param array defines the source array
  2927. * @param offset defines the offset in the source array
  2928. * @returns the new Vector3
  2929. * @deprecated Please use FromArray instead.
  2930. */
  2931. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2932. /**
  2933. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2934. * @param array defines the source array
  2935. * @param offset defines the offset in the source array
  2936. * @param result defines the Vector3 where to store the result
  2937. */
  2938. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2939. /**
  2940. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2941. * @param array defines the source array
  2942. * @param offset defines the offset in the source array
  2943. * @param result defines the Vector3 where to store the result
  2944. * @deprecated Please use FromArrayToRef instead.
  2945. */
  2946. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2947. /**
  2948. * Sets the given vector "result" with the given floats.
  2949. * @param x defines the x coordinate of the source
  2950. * @param y defines the y coordinate of the source
  2951. * @param z defines the z coordinate of the source
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2955. /**
  2956. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2957. * @returns a new empty Vector3
  2958. */
  2959. static Zero(): Vector3;
  2960. /**
  2961. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2962. * @returns a new unit Vector3
  2963. */
  2964. static One(): Vector3;
  2965. /**
  2966. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2967. * @returns a new up Vector3
  2968. */
  2969. static Up(): Vector3;
  2970. /**
  2971. * Gets a up Vector3 that must not be updated
  2972. */
  2973. static get UpReadOnly(): DeepImmutable<Vector3>;
  2974. /**
  2975. * Gets a zero Vector3 that must not be updated
  2976. */
  2977. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2978. /**
  2979. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2980. * @returns a new down Vector3
  2981. */
  2982. static Down(): Vector3;
  2983. /**
  2984. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2985. * @param rightHandedSystem is the scene right-handed (negative z)
  2986. * @returns a new forward Vector3
  2987. */
  2988. static Forward(rightHandedSystem?: boolean): Vector3;
  2989. /**
  2990. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2991. * @param rightHandedSystem is the scene right-handed (negative-z)
  2992. * @returns a new forward Vector3
  2993. */
  2994. static Backward(rightHandedSystem?: boolean): Vector3;
  2995. /**
  2996. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2997. * @returns a new right Vector3
  2998. */
  2999. static Right(): Vector3;
  3000. /**
  3001. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3002. * @returns a new left Vector3
  3003. */
  3004. static Left(): Vector3;
  3005. /**
  3006. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3007. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3008. * @param vector defines the Vector3 to transform
  3009. * @param transformation defines the transformation matrix
  3010. * @returns the transformed Vector3
  3011. */
  3012. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3013. /**
  3014. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3015. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3016. * @param vector defines the Vector3 to transform
  3017. * @param transformation defines the transformation matrix
  3018. * @param result defines the Vector3 where to store the result
  3019. */
  3020. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3021. /**
  3022. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3023. * This method computes tranformed coordinates only, not transformed direction vectors
  3024. * @param x define the x coordinate of the source vector
  3025. * @param y define the y coordinate of the source vector
  3026. * @param z define the z coordinate of the source vector
  3027. * @param transformation defines the transformation matrix
  3028. * @param result defines the Vector3 where to store the result
  3029. */
  3030. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3031. /**
  3032. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3033. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3034. * @param vector defines the Vector3 to transform
  3035. * @param transformation defines the transformation matrix
  3036. * @returns the new Vector3
  3037. */
  3038. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3039. /**
  3040. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3041. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3042. * @param vector defines the Vector3 to transform
  3043. * @param transformation defines the transformation matrix
  3044. * @param result defines the Vector3 where to store the result
  3045. */
  3046. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3047. /**
  3048. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3049. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3050. * @param x define the x coordinate of the source vector
  3051. * @param y define the y coordinate of the source vector
  3052. * @param z define the z coordinate of the source vector
  3053. * @param transformation defines the transformation matrix
  3054. * @param result defines the Vector3 where to store the result
  3055. */
  3056. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3057. /**
  3058. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3059. * @param value1 defines the first control point
  3060. * @param value2 defines the second control point
  3061. * @param value3 defines the third control point
  3062. * @param value4 defines the fourth control point
  3063. * @param amount defines the amount on the spline to use
  3064. * @returns the new Vector3
  3065. */
  3066. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3067. /**
  3068. * 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"
  3069. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3070. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3071. * @param value defines the current value
  3072. * @param min defines the lower range value
  3073. * @param max defines the upper range value
  3074. * @returns the new Vector3
  3075. */
  3076. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3077. /**
  3078. * 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"
  3079. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3080. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3081. * @param value defines the current value
  3082. * @param min defines the lower range value
  3083. * @param max defines the upper range value
  3084. * @param result defines the Vector3 where to store the result
  3085. */
  3086. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3087. /**
  3088. * Checks if a given vector is inside a specific range
  3089. * @param v defines the vector to test
  3090. * @param min defines the minimum range
  3091. * @param max defines the maximum range
  3092. */
  3093. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3094. /**
  3095. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3096. * @param value1 defines the first control point
  3097. * @param tangent1 defines the first tangent vector
  3098. * @param value2 defines the second control point
  3099. * @param tangent2 defines the second tangent vector
  3100. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3101. * @returns the new Vector3
  3102. */
  3103. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3104. /**
  3105. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3106. * @param start defines the start value
  3107. * @param end defines the end value
  3108. * @param amount max defines amount between both (between 0 and 1)
  3109. * @returns the new Vector3
  3110. */
  3111. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3112. /**
  3113. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3114. * @param start defines the start value
  3115. * @param end defines the end value
  3116. * @param amount max defines amount between both (between 0 and 1)
  3117. * @param result defines the Vector3 where to store the result
  3118. */
  3119. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3120. /**
  3121. * Returns the dot product (float) between the vectors "left" and "right"
  3122. * @param left defines the left operand
  3123. * @param right defines the right operand
  3124. * @returns the dot product
  3125. */
  3126. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3127. /**
  3128. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3129. * The cross product is then orthogonal to both "left" and "right"
  3130. * @param left defines the left operand
  3131. * @param right defines the right operand
  3132. * @returns the cross product
  3133. */
  3134. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3135. /**
  3136. * Sets the given vector "result" with the cross product of "left" and "right"
  3137. * The cross product is then orthogonal to both "left" and "right"
  3138. * @param left defines the left operand
  3139. * @param right defines the right operand
  3140. * @param result defines the Vector3 where to store the result
  3141. */
  3142. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3143. /**
  3144. * Returns a new Vector3 as the normalization of the given vector
  3145. * @param vector defines the Vector3 to normalize
  3146. * @returns the new Vector3
  3147. */
  3148. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3149. /**
  3150. * Sets the given vector "result" with the normalization of the given first vector
  3151. * @param vector defines the Vector3 to normalize
  3152. * @param result defines the Vector3 where to store the result
  3153. */
  3154. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3155. /**
  3156. * Project a Vector3 onto screen space
  3157. * @param vector defines the Vector3 to project
  3158. * @param world defines the world matrix to use
  3159. * @param transform defines the transform (view x projection) matrix to use
  3160. * @param viewport defines the screen viewport to use
  3161. * @returns the new Vector3
  3162. */
  3163. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3164. /** @hidden */
  3165. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3166. /**
  3167. * Unproject from screen space to object space
  3168. * @param source defines the screen space Vector3 to use
  3169. * @param viewportWidth defines the current width of the viewport
  3170. * @param viewportHeight defines the current height of the viewport
  3171. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3172. * @param transform defines the transform (view x projection) matrix to use
  3173. * @returns the new Vector3
  3174. */
  3175. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3176. /**
  3177. * Unproject from screen space to object space
  3178. * @param source defines the screen space Vector3 to use
  3179. * @param viewportWidth defines the current width of the viewport
  3180. * @param viewportHeight defines the current height of the viewport
  3181. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3182. * @param view defines the view matrix to use
  3183. * @param projection defines the projection matrix to use
  3184. * @returns the new Vector3
  3185. */
  3186. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3187. /**
  3188. * Unproject from screen space to object space
  3189. * @param source defines the screen space Vector3 to use
  3190. * @param viewportWidth defines the current width of the viewport
  3191. * @param viewportHeight defines the current height of the viewport
  3192. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3193. * @param view defines the view matrix to use
  3194. * @param projection defines the projection matrix to use
  3195. * @param result defines the Vector3 where to store the result
  3196. */
  3197. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3198. /**
  3199. * Unproject from screen space to object space
  3200. * @param sourceX defines the screen space x coordinate to use
  3201. * @param sourceY defines the screen space y coordinate to use
  3202. * @param sourceZ defines the screen space z coordinate to use
  3203. * @param viewportWidth defines the current width of the viewport
  3204. * @param viewportHeight defines the current height of the viewport
  3205. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3206. * @param view defines the view matrix to use
  3207. * @param projection defines the projection matrix to use
  3208. * @param result defines the Vector3 where to store the result
  3209. */
  3210. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3211. /**
  3212. * Gets the minimal coordinate values between two Vector3
  3213. * @param left defines the first operand
  3214. * @param right defines the second operand
  3215. * @returns the new Vector3
  3216. */
  3217. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3218. /**
  3219. * Gets the maximal coordinate values between two Vector3
  3220. * @param left defines the first operand
  3221. * @param right defines the second operand
  3222. * @returns the new Vector3
  3223. */
  3224. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3225. /**
  3226. * Returns the distance between the vectors "value1" and "value2"
  3227. * @param value1 defines the first operand
  3228. * @param value2 defines the second operand
  3229. * @returns the distance
  3230. */
  3231. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3232. /**
  3233. * Returns the squared distance between the vectors "value1" and "value2"
  3234. * @param value1 defines the first operand
  3235. * @param value2 defines the second operand
  3236. * @returns the squared distance
  3237. */
  3238. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3239. /**
  3240. * Returns a new Vector3 located at the center between "value1" and "value2"
  3241. * @param value1 defines the first operand
  3242. * @param value2 defines the second operand
  3243. * @returns the new Vector3
  3244. */
  3245. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3246. /**
  3247. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3248. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3249. * to something in order to rotate it from its local system to the given target system
  3250. * Note: axis1, axis2 and axis3 are normalized during this operation
  3251. * @param axis1 defines the first axis
  3252. * @param axis2 defines the second axis
  3253. * @param axis3 defines the third axis
  3254. * @returns a new Vector3
  3255. */
  3256. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3257. /**
  3258. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3259. * @param axis1 defines the first axis
  3260. * @param axis2 defines the second axis
  3261. * @param axis3 defines the third axis
  3262. * @param ref defines the Vector3 where to store the result
  3263. */
  3264. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3265. }
  3266. /**
  3267. * Vector4 class created for EulerAngle class conversion to Quaternion
  3268. */
  3269. export class Vector4 {
  3270. /** x value of the vector */
  3271. x: number;
  3272. /** y value of the vector */
  3273. y: number;
  3274. /** z value of the vector */
  3275. z: number;
  3276. /** w value of the vector */
  3277. w: number;
  3278. /**
  3279. * Creates a Vector4 object from the given floats.
  3280. * @param x x value of the vector
  3281. * @param y y value of the vector
  3282. * @param z z value of the vector
  3283. * @param w w value of the vector
  3284. */
  3285. constructor(
  3286. /** x value of the vector */
  3287. x: number,
  3288. /** y value of the vector */
  3289. y: number,
  3290. /** z value of the vector */
  3291. z: number,
  3292. /** w value of the vector */
  3293. w: number);
  3294. /**
  3295. * Returns the string with the Vector4 coordinates.
  3296. * @returns a string containing all the vector values
  3297. */
  3298. toString(): string;
  3299. /**
  3300. * Returns the string "Vector4".
  3301. * @returns "Vector4"
  3302. */
  3303. getClassName(): string;
  3304. /**
  3305. * Returns the Vector4 hash code.
  3306. * @returns a unique hash code
  3307. */
  3308. getHashCode(): number;
  3309. /**
  3310. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3311. * @returns the resulting array
  3312. */
  3313. asArray(): number[];
  3314. /**
  3315. * Populates the given array from the given index with the Vector4 coordinates.
  3316. * @param array array to populate
  3317. * @param index index of the array to start at (default: 0)
  3318. * @returns the Vector4.
  3319. */
  3320. toArray(array: FloatArray, index?: number): Vector4;
  3321. /**
  3322. * Update the current vector from an array
  3323. * @param array defines the destination array
  3324. * @param index defines the offset in the destination array
  3325. * @returns the current Vector3
  3326. */
  3327. fromArray(array: FloatArray, index?: number): Vector4;
  3328. /**
  3329. * Adds the given vector to the current Vector4.
  3330. * @param otherVector the vector to add
  3331. * @returns the updated Vector4.
  3332. */
  3333. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3336. * @param otherVector the vector to add
  3337. * @returns the resulting vector
  3338. */
  3339. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3342. * @param otherVector the vector to add
  3343. * @param result the vector to store the result
  3344. * @returns the current Vector4.
  3345. */
  3346. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3347. /**
  3348. * Subtract in place the given vector from the current Vector4.
  3349. * @param otherVector the vector to subtract
  3350. * @returns the updated Vector4.
  3351. */
  3352. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3353. /**
  3354. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3355. * @param otherVector the vector to add
  3356. * @returns the new vector with the result
  3357. */
  3358. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3359. /**
  3360. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3361. * @param otherVector the vector to subtract
  3362. * @param result the vector to store the result
  3363. * @returns the current Vector4.
  3364. */
  3365. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3366. /**
  3367. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3368. */
  3369. /**
  3370. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3371. * @param x value to subtract
  3372. * @param y value to subtract
  3373. * @param z value to subtract
  3374. * @param w value to subtract
  3375. * @returns new vector containing the result
  3376. */
  3377. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3378. /**
  3379. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3380. * @param x value to subtract
  3381. * @param y value to subtract
  3382. * @param z value to subtract
  3383. * @param w value to subtract
  3384. * @param result the vector to store the result in
  3385. * @returns the current Vector4.
  3386. */
  3387. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3388. /**
  3389. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3390. * @returns a new vector with the negated values
  3391. */
  3392. negate(): Vector4;
  3393. /**
  3394. * Negate this vector in place
  3395. * @returns this
  3396. */
  3397. negateInPlace(): Vector4;
  3398. /**
  3399. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3400. * @param result defines the Vector3 object where to store the result
  3401. * @returns the current Vector4
  3402. */
  3403. negateToRef(result: Vector4): Vector4;
  3404. /**
  3405. * Multiplies the current Vector4 coordinates by scale (float).
  3406. * @param scale the number to scale with
  3407. * @returns the updated Vector4.
  3408. */
  3409. scaleInPlace(scale: number): Vector4;
  3410. /**
  3411. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3412. * @param scale the number to scale with
  3413. * @returns a new vector with the result
  3414. */
  3415. scale(scale: number): Vector4;
  3416. /**
  3417. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3418. * @param scale the number to scale with
  3419. * @param result a vector to store the result in
  3420. * @returns the current Vector4.
  3421. */
  3422. scaleToRef(scale: number, result: Vector4): Vector4;
  3423. /**
  3424. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3425. * @param scale defines the scale factor
  3426. * @param result defines the Vector4 object where to store the result
  3427. * @returns the unmodified current Vector4
  3428. */
  3429. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3430. /**
  3431. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3432. * @param otherVector the vector to compare against
  3433. * @returns true if they are equal
  3434. */
  3435. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3436. /**
  3437. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3438. * @param otherVector vector to compare against
  3439. * @param epsilon (Default: very small number)
  3440. * @returns true if they are equal
  3441. */
  3442. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3443. /**
  3444. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3445. * @param x x value to compare against
  3446. * @param y y value to compare against
  3447. * @param z z value to compare against
  3448. * @param w w value to compare against
  3449. * @returns true if equal
  3450. */
  3451. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3452. /**
  3453. * Multiplies in place the current Vector4 by the given one.
  3454. * @param otherVector vector to multiple with
  3455. * @returns the updated Vector4.
  3456. */
  3457. multiplyInPlace(otherVector: Vector4): Vector4;
  3458. /**
  3459. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3460. * @param otherVector vector to multiple with
  3461. * @returns resulting new vector
  3462. */
  3463. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3464. /**
  3465. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3466. * @param otherVector vector to multiple with
  3467. * @param result vector to store the result
  3468. * @returns the current Vector4.
  3469. */
  3470. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3471. /**
  3472. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3473. * @param x x value multiply with
  3474. * @param y y value multiply with
  3475. * @param z z value multiply with
  3476. * @param w w value multiply with
  3477. * @returns resulting new vector
  3478. */
  3479. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3480. /**
  3481. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3482. * @param otherVector vector to devide with
  3483. * @returns resulting new vector
  3484. */
  3485. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3486. /**
  3487. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3488. * @param otherVector vector to devide with
  3489. * @param result vector to store the result
  3490. * @returns the current Vector4.
  3491. */
  3492. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3493. /**
  3494. * Divides the current Vector3 coordinates by the given ones.
  3495. * @param otherVector vector to devide with
  3496. * @returns the updated Vector3.
  3497. */
  3498. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3499. /**
  3500. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3501. * @param other defines the second operand
  3502. * @returns the current updated Vector4
  3503. */
  3504. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3505. /**
  3506. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3507. * @param other defines the second operand
  3508. * @returns the current updated Vector4
  3509. */
  3510. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3511. /**
  3512. * Gets a new Vector4 from current Vector4 floored values
  3513. * @returns a new Vector4
  3514. */
  3515. floor(): Vector4;
  3516. /**
  3517. * Gets a new Vector4 from current Vector3 floored values
  3518. * @returns a new Vector4
  3519. */
  3520. fract(): Vector4;
  3521. /**
  3522. * Returns the Vector4 length (float).
  3523. * @returns the length
  3524. */
  3525. length(): number;
  3526. /**
  3527. * Returns the Vector4 squared length (float).
  3528. * @returns the length squared
  3529. */
  3530. lengthSquared(): number;
  3531. /**
  3532. * Normalizes in place the Vector4.
  3533. * @returns the updated Vector4.
  3534. */
  3535. normalize(): Vector4;
  3536. /**
  3537. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3538. * @returns this converted to a new vector3
  3539. */
  3540. toVector3(): Vector3;
  3541. /**
  3542. * Returns a new Vector4 copied from the current one.
  3543. * @returns the new cloned vector
  3544. */
  3545. clone(): Vector4;
  3546. /**
  3547. * Updates the current Vector4 with the given one coordinates.
  3548. * @param source the source vector to copy from
  3549. * @returns the updated Vector4.
  3550. */
  3551. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3552. /**
  3553. * Updates the current Vector4 coordinates with the given floats.
  3554. * @param x float to copy from
  3555. * @param y float to copy from
  3556. * @param z float to copy from
  3557. * @param w float to copy from
  3558. * @returns the updated Vector4.
  3559. */
  3560. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3561. /**
  3562. * Updates the current Vector4 coordinates with the given floats.
  3563. * @param x float to set from
  3564. * @param y float to set from
  3565. * @param z float to set from
  3566. * @param w float to set from
  3567. * @returns the updated Vector4.
  3568. */
  3569. set(x: number, y: number, z: number, w: number): Vector4;
  3570. /**
  3571. * Copies the given float to the current Vector3 coordinates
  3572. * @param v defines the x, y, z and w coordinates of the operand
  3573. * @returns the current updated Vector3
  3574. */
  3575. setAll(v: number): Vector4;
  3576. /**
  3577. * Returns a new Vector4 set from the starting index of the given array.
  3578. * @param array the array to pull values from
  3579. * @param offset the offset into the array to start at
  3580. * @returns the new vector
  3581. */
  3582. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3583. /**
  3584. * Updates the given vector "result" from the starting index of the given array.
  3585. * @param array the array to pull values from
  3586. * @param offset the offset into the array to start at
  3587. * @param result the vector to store the result in
  3588. */
  3589. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3590. /**
  3591. * Updates the given vector "result" from the starting index of the given Float32Array.
  3592. * @param array the array to pull values from
  3593. * @param offset the offset into the array to start at
  3594. * @param result the vector to store the result in
  3595. */
  3596. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3597. /**
  3598. * Updates the given vector "result" coordinates from the given floats.
  3599. * @param x float to set from
  3600. * @param y float to set from
  3601. * @param z float to set from
  3602. * @param w float to set from
  3603. * @param result the vector to the floats in
  3604. */
  3605. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3606. /**
  3607. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3608. * @returns the new vector
  3609. */
  3610. static Zero(): Vector4;
  3611. /**
  3612. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3613. * @returns the new vector
  3614. */
  3615. static One(): Vector4;
  3616. /**
  3617. * Returns a new normalized Vector4 from the given one.
  3618. * @param vector the vector to normalize
  3619. * @returns the vector
  3620. */
  3621. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3622. /**
  3623. * Updates the given vector "result" from the normalization of the given one.
  3624. * @param vector the vector to normalize
  3625. * @param result the vector to store the result in
  3626. */
  3627. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3628. /**
  3629. * Returns a vector with the minimum values from the left and right vectors
  3630. * @param left left vector to minimize
  3631. * @param right right vector to minimize
  3632. * @returns a new vector with the minimum of the left and right vector values
  3633. */
  3634. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3635. /**
  3636. * Returns a vector with the maximum values from the left and right vectors
  3637. * @param left left vector to maximize
  3638. * @param right right vector to maximize
  3639. * @returns a new vector with the maximum of the left and right vector values
  3640. */
  3641. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3642. /**
  3643. * Returns the distance (float) between the vectors "value1" and "value2".
  3644. * @param value1 value to calulate the distance between
  3645. * @param value2 value to calulate the distance between
  3646. * @return the distance between the two vectors
  3647. */
  3648. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3649. /**
  3650. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3651. * @param value1 value to calulate the distance between
  3652. * @param value2 value to calulate the distance between
  3653. * @return the distance between the two vectors squared
  3654. */
  3655. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3656. /**
  3657. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3658. * @param value1 value to calulate the center between
  3659. * @param value2 value to calulate the center between
  3660. * @return the center between the two vectors
  3661. */
  3662. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3663. /**
  3664. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3665. * This methods computes transformed normalized direction vectors only.
  3666. * @param vector the vector to transform
  3667. * @param transformation the transformation matrix to apply
  3668. * @returns the new vector
  3669. */
  3670. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3671. /**
  3672. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3673. * This methods computes transformed normalized direction vectors only.
  3674. * @param vector the vector to transform
  3675. * @param transformation the transformation matrix to apply
  3676. * @param result the vector to store the result in
  3677. */
  3678. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3679. /**
  3680. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3681. * This methods computes transformed normalized direction vectors only.
  3682. * @param x value to transform
  3683. * @param y value to transform
  3684. * @param z value to transform
  3685. * @param w value to transform
  3686. * @param transformation the transformation matrix to apply
  3687. * @param result the vector to store the results in
  3688. */
  3689. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3690. /**
  3691. * Creates a new Vector4 from a Vector3
  3692. * @param source defines the source data
  3693. * @param w defines the 4th component (default is 0)
  3694. * @returns a new Vector4
  3695. */
  3696. static FromVector3(source: Vector3, w?: number): Vector4;
  3697. }
  3698. /**
  3699. * Class used to store quaternion data
  3700. * @see https://en.wikipedia.org/wiki/Quaternion
  3701. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3702. */
  3703. export class Quaternion {
  3704. /** @hidden */
  3705. _x: number;
  3706. /** @hidden */
  3707. _y: number;
  3708. /** @hidden */
  3709. _z: number;
  3710. /** @hidden */
  3711. _w: number;
  3712. /** @hidden */
  3713. _isDirty: boolean;
  3714. /** Gets or sets the x coordinate */
  3715. get x(): number;
  3716. set x(value: number);
  3717. /** Gets or sets the y coordinate */
  3718. get y(): number;
  3719. set y(value: number);
  3720. /** Gets or sets the z coordinate */
  3721. get z(): number;
  3722. set z(value: number);
  3723. /** Gets or sets the w coordinate */
  3724. get w(): number;
  3725. set w(value: number);
  3726. /**
  3727. * Creates a new Quaternion from the given floats
  3728. * @param x defines the first component (0 by default)
  3729. * @param y defines the second component (0 by default)
  3730. * @param z defines the third component (0 by default)
  3731. * @param w defines the fourth component (1.0 by default)
  3732. */
  3733. constructor(x?: number, y?: number, z?: number, w?: number);
  3734. /**
  3735. * Gets a string representation for the current quaternion
  3736. * @returns a string with the Quaternion coordinates
  3737. */
  3738. toString(): string;
  3739. /**
  3740. * Gets the class name of the quaternion
  3741. * @returns the string "Quaternion"
  3742. */
  3743. getClassName(): string;
  3744. /**
  3745. * Gets a hash code for this quaternion
  3746. * @returns the quaternion hash code
  3747. */
  3748. getHashCode(): number;
  3749. /**
  3750. * Copy the quaternion to an array
  3751. * @returns a new array populated with 4 elements from the quaternion coordinates
  3752. */
  3753. asArray(): number[];
  3754. /**
  3755. * Check if two quaternions are equals
  3756. * @param otherQuaternion defines the second operand
  3757. * @return true if the current quaternion and the given one coordinates are strictly equals
  3758. */
  3759. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3760. /**
  3761. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3762. * @param otherQuaternion defines the other quaternion
  3763. * @param epsilon defines the minimal distance to consider equality
  3764. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3765. */
  3766. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3767. /**
  3768. * Clone the current quaternion
  3769. * @returns a new quaternion copied from the current one
  3770. */
  3771. clone(): Quaternion;
  3772. /**
  3773. * Copy a quaternion to the current one
  3774. * @param other defines the other quaternion
  3775. * @returns the updated current quaternion
  3776. */
  3777. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3778. /**
  3779. * Updates the current quaternion with the given float coordinates
  3780. * @param x defines the x coordinate
  3781. * @param y defines the y coordinate
  3782. * @param z defines the z coordinate
  3783. * @param w defines the w coordinate
  3784. * @returns the updated current quaternion
  3785. */
  3786. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3787. /**
  3788. * Updates the current quaternion from the given float coordinates
  3789. * @param x defines the x coordinate
  3790. * @param y defines the y coordinate
  3791. * @param z defines the z coordinate
  3792. * @param w defines the w coordinate
  3793. * @returns the updated current quaternion
  3794. */
  3795. set(x: number, y: number, z: number, w: number): Quaternion;
  3796. /**
  3797. * Adds two quaternions
  3798. * @param other defines the second operand
  3799. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3800. */
  3801. add(other: DeepImmutable<Quaternion>): Quaternion;
  3802. /**
  3803. * Add a quaternion to the current one
  3804. * @param other defines the quaternion to add
  3805. * @returns the current quaternion
  3806. */
  3807. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3808. /**
  3809. * Subtract two quaternions
  3810. * @param other defines the second operand
  3811. * @returns a new quaternion as the subtraction result of the given one from the current one
  3812. */
  3813. subtract(other: Quaternion): Quaternion;
  3814. /**
  3815. * Multiplies the current quaternion by a scale factor
  3816. * @param value defines the scale factor
  3817. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3818. */
  3819. scale(value: number): Quaternion;
  3820. /**
  3821. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3822. * @param scale defines the scale factor
  3823. * @param result defines the Quaternion object where to store the result
  3824. * @returns the unmodified current quaternion
  3825. */
  3826. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3827. /**
  3828. * Multiplies in place the current quaternion by a scale factor
  3829. * @param value defines the scale factor
  3830. * @returns the current modified quaternion
  3831. */
  3832. scaleInPlace(value: number): Quaternion;
  3833. /**
  3834. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3835. * @param scale defines the scale factor
  3836. * @param result defines the Quaternion object where to store the result
  3837. * @returns the unmodified current quaternion
  3838. */
  3839. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3840. /**
  3841. * Multiplies two quaternions
  3842. * @param q1 defines the second operand
  3843. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3844. */
  3845. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3846. /**
  3847. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3848. * @param q1 defines the second operand
  3849. * @param result defines the target quaternion
  3850. * @returns the current quaternion
  3851. */
  3852. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3853. /**
  3854. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3855. * @param q1 defines the second operand
  3856. * @returns the currentupdated quaternion
  3857. */
  3858. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3859. /**
  3860. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3861. * @param ref defines the target quaternion
  3862. * @returns the current quaternion
  3863. */
  3864. conjugateToRef(ref: Quaternion): Quaternion;
  3865. /**
  3866. * Conjugates in place (1-q) the current quaternion
  3867. * @returns the current updated quaternion
  3868. */
  3869. conjugateInPlace(): Quaternion;
  3870. /**
  3871. * Conjugates in place (1-q) the current quaternion
  3872. * @returns a new quaternion
  3873. */
  3874. conjugate(): Quaternion;
  3875. /**
  3876. * Gets length of current quaternion
  3877. * @returns the quaternion length (float)
  3878. */
  3879. length(): number;
  3880. /**
  3881. * Normalize in place the current quaternion
  3882. * @returns the current updated quaternion
  3883. */
  3884. normalize(): Quaternion;
  3885. /**
  3886. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3887. * @param order is a reserved parameter and is ignored for now
  3888. * @returns a new Vector3 containing the Euler angles
  3889. */
  3890. toEulerAngles(order?: string): Vector3;
  3891. /**
  3892. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3893. * @param result defines the vector which will be filled with the Euler angles
  3894. * @returns the current unchanged quaternion
  3895. */
  3896. toEulerAnglesToRef(result: Vector3): Quaternion;
  3897. /**
  3898. * Updates the given rotation matrix with the current quaternion values
  3899. * @param result defines the target matrix
  3900. * @returns the current unchanged quaternion
  3901. */
  3902. toRotationMatrix(result: Matrix): Quaternion;
  3903. /**
  3904. * Updates the current quaternion from the given rotation matrix values
  3905. * @param matrix defines the source matrix
  3906. * @returns the current updated quaternion
  3907. */
  3908. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3909. /**
  3910. * Creates a new quaternion from a rotation matrix
  3911. * @param matrix defines the source matrix
  3912. * @returns a new quaternion created from the given rotation matrix values
  3913. */
  3914. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3915. /**
  3916. * Updates the given quaternion with the given rotation matrix values
  3917. * @param matrix defines the source matrix
  3918. * @param result defines the target quaternion
  3919. */
  3920. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3921. /**
  3922. * Returns the dot product (float) between the quaternions "left" and "right"
  3923. * @param left defines the left operand
  3924. * @param right defines the right operand
  3925. * @returns the dot product
  3926. */
  3927. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3928. /**
  3929. * Checks if the two quaternions are close to each other
  3930. * @param quat0 defines the first quaternion to check
  3931. * @param quat1 defines the second quaternion to check
  3932. * @returns true if the two quaternions are close to each other
  3933. */
  3934. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3935. /**
  3936. * Creates an empty quaternion
  3937. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3938. */
  3939. static Zero(): Quaternion;
  3940. /**
  3941. * Inverse a given quaternion
  3942. * @param q defines the source quaternion
  3943. * @returns a new quaternion as the inverted current quaternion
  3944. */
  3945. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3946. /**
  3947. * Inverse a given quaternion
  3948. * @param q defines the source quaternion
  3949. * @param result the quaternion the result will be stored in
  3950. * @returns the result quaternion
  3951. */
  3952. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3953. /**
  3954. * Creates an identity quaternion
  3955. * @returns the identity quaternion
  3956. */
  3957. static Identity(): Quaternion;
  3958. /**
  3959. * Gets a boolean indicating if the given quaternion is identity
  3960. * @param quaternion defines the quaternion to check
  3961. * @returns true if the quaternion is identity
  3962. */
  3963. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3964. /**
  3965. * Creates a quaternion from a rotation around an axis
  3966. * @param axis defines the axis to use
  3967. * @param angle defines the angle to use
  3968. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3969. */
  3970. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3971. /**
  3972. * Creates a rotation around an axis and stores it into the given quaternion
  3973. * @param axis defines the axis to use
  3974. * @param angle defines the angle to use
  3975. * @param result defines the target quaternion
  3976. * @returns the target quaternion
  3977. */
  3978. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3979. /**
  3980. * Creates a new quaternion from data stored into an array
  3981. * @param array defines the data source
  3982. * @param offset defines the offset in the source array where the data starts
  3983. * @returns a new quaternion
  3984. */
  3985. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3986. /**
  3987. * Updates the given quaternion "result" from the starting index of the given array.
  3988. * @param array the array to pull values from
  3989. * @param offset the offset into the array to start at
  3990. * @param result the quaternion to store the result in
  3991. */
  3992. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3993. /**
  3994. * Create a quaternion from Euler rotation angles
  3995. * @param x Pitch
  3996. * @param y Yaw
  3997. * @param z Roll
  3998. * @returns the new Quaternion
  3999. */
  4000. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4001. /**
  4002. * Updates a quaternion from Euler rotation angles
  4003. * @param x Pitch
  4004. * @param y Yaw
  4005. * @param z Roll
  4006. * @param result the quaternion to store the result
  4007. * @returns the updated quaternion
  4008. */
  4009. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4010. /**
  4011. * Create a quaternion from Euler rotation vector
  4012. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4013. * @returns the new Quaternion
  4014. */
  4015. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4016. /**
  4017. * Updates a quaternion from Euler rotation vector
  4018. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4019. * @param result the quaternion to store the result
  4020. * @returns the updated quaternion
  4021. */
  4022. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4023. /**
  4024. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4025. * @param yaw defines the rotation around Y axis
  4026. * @param pitch defines the rotation around X axis
  4027. * @param roll defines the rotation around Z axis
  4028. * @returns the new quaternion
  4029. */
  4030. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4031. /**
  4032. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4033. * @param yaw defines the rotation around Y axis
  4034. * @param pitch defines the rotation around X axis
  4035. * @param roll defines the rotation around Z axis
  4036. * @param result defines the target quaternion
  4037. */
  4038. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4039. /**
  4040. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4041. * @param alpha defines the rotation around first axis
  4042. * @param beta defines the rotation around second axis
  4043. * @param gamma defines the rotation around third axis
  4044. * @returns the new quaternion
  4045. */
  4046. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4047. /**
  4048. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4049. * @param alpha defines the rotation around first axis
  4050. * @param beta defines the rotation around second axis
  4051. * @param gamma defines the rotation around third axis
  4052. * @param result defines the target quaternion
  4053. */
  4054. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4055. /**
  4056. * 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)
  4057. * @param axis1 defines the first axis
  4058. * @param axis2 defines the second axis
  4059. * @param axis3 defines the third axis
  4060. * @returns the new quaternion
  4061. */
  4062. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4063. /**
  4064. * 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
  4065. * @param axis1 defines the first axis
  4066. * @param axis2 defines the second axis
  4067. * @param axis3 defines the third axis
  4068. * @param ref defines the target quaternion
  4069. */
  4070. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4071. /**
  4072. * Interpolates between two quaternions
  4073. * @param left defines first quaternion
  4074. * @param right defines second quaternion
  4075. * @param amount defines the gradient to use
  4076. * @returns the new interpolated quaternion
  4077. */
  4078. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4079. /**
  4080. * Interpolates between two quaternions and stores it into a target quaternion
  4081. * @param left defines first quaternion
  4082. * @param right defines second quaternion
  4083. * @param amount defines the gradient to use
  4084. * @param result defines the target quaternion
  4085. */
  4086. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4087. /**
  4088. * Interpolate between two quaternions using Hermite interpolation
  4089. * @param value1 defines first quaternion
  4090. * @param tangent1 defines the incoming tangent
  4091. * @param value2 defines second quaternion
  4092. * @param tangent2 defines the outgoing tangent
  4093. * @param amount defines the target quaternion
  4094. * @returns the new interpolated quaternion
  4095. */
  4096. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4097. }
  4098. /**
  4099. * Class used to store matrix data (4x4)
  4100. */
  4101. export class Matrix {
  4102. /**
  4103. * Gets the precision of matrix computations
  4104. */
  4105. static get Use64Bits(): boolean;
  4106. private static _updateFlagSeed;
  4107. private static _identityReadOnly;
  4108. private _isIdentity;
  4109. private _isIdentityDirty;
  4110. private _isIdentity3x2;
  4111. private _isIdentity3x2Dirty;
  4112. /**
  4113. * Gets the update flag of the matrix which is an unique number for the matrix.
  4114. * It will be incremented every time the matrix data change.
  4115. * You can use it to speed the comparison between two versions of the same matrix.
  4116. */
  4117. updateFlag: number;
  4118. private readonly _m;
  4119. /**
  4120. * Gets the internal data of the matrix
  4121. */
  4122. get m(): DeepImmutable<Float32Array | Array<number>>;
  4123. /** @hidden */
  4124. _markAsUpdated(): void;
  4125. /** @hidden */
  4126. private _updateIdentityStatus;
  4127. /**
  4128. * Creates an empty matrix (filled with zeros)
  4129. */
  4130. constructor();
  4131. /**
  4132. * Check if the current matrix is identity
  4133. * @returns true is the matrix is the identity matrix
  4134. */
  4135. isIdentity(): boolean;
  4136. /**
  4137. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4138. * @returns true is the matrix is the identity matrix
  4139. */
  4140. isIdentityAs3x2(): boolean;
  4141. /**
  4142. * Gets the determinant of the matrix
  4143. * @returns the matrix determinant
  4144. */
  4145. determinant(): number;
  4146. /**
  4147. * Returns the matrix as a Float32Array or Array<number>
  4148. * @returns the matrix underlying array
  4149. */
  4150. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4151. /**
  4152. * Returns the matrix as a Float32Array or Array<number>
  4153. * @returns the matrix underlying array.
  4154. */
  4155. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4156. /**
  4157. * Inverts the current matrix in place
  4158. * @returns the current inverted matrix
  4159. */
  4160. invert(): Matrix;
  4161. /**
  4162. * Sets all the matrix elements to zero
  4163. * @returns the current matrix
  4164. */
  4165. reset(): Matrix;
  4166. /**
  4167. * Adds the current matrix with a second one
  4168. * @param other defines the matrix to add
  4169. * @returns a new matrix as the addition of the current matrix and the given one
  4170. */
  4171. add(other: DeepImmutable<Matrix>): Matrix;
  4172. /**
  4173. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4174. * @param other defines the matrix to add
  4175. * @param result defines the target matrix
  4176. * @returns the current matrix
  4177. */
  4178. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4179. /**
  4180. * Adds in place the given matrix to the current matrix
  4181. * @param other defines the second operand
  4182. * @returns the current updated matrix
  4183. */
  4184. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4185. /**
  4186. * Sets the given matrix to the current inverted Matrix
  4187. * @param other defines the target matrix
  4188. * @returns the unmodified current matrix
  4189. */
  4190. invertToRef(other: Matrix): Matrix;
  4191. /**
  4192. * add a value at the specified position in the current Matrix
  4193. * @param index the index of the value within the matrix. between 0 and 15.
  4194. * @param value the value to be added
  4195. * @returns the current updated matrix
  4196. */
  4197. addAtIndex(index: number, value: number): Matrix;
  4198. /**
  4199. * mutiply the specified position in the current Matrix by a value
  4200. * @param index the index of the value within the matrix. between 0 and 15.
  4201. * @param value the value to be added
  4202. * @returns the current updated matrix
  4203. */
  4204. multiplyAtIndex(index: number, value: number): Matrix;
  4205. /**
  4206. * Inserts the translation vector (using 3 floats) in the current matrix
  4207. * @param x defines the 1st component of the translation
  4208. * @param y defines the 2nd component of the translation
  4209. * @param z defines the 3rd component of the translation
  4210. * @returns the current updated matrix
  4211. */
  4212. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4213. /**
  4214. * Adds the translation vector (using 3 floats) in the current matrix
  4215. * @param x defines the 1st component of the translation
  4216. * @param y defines the 2nd component of the translation
  4217. * @param z defines the 3rd component of the translation
  4218. * @returns the current updated matrix
  4219. */
  4220. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4221. /**
  4222. * Inserts the translation vector in the current matrix
  4223. * @param vector3 defines the translation to insert
  4224. * @returns the current updated matrix
  4225. */
  4226. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4227. /**
  4228. * Gets the translation value of the current matrix
  4229. * @returns a new Vector3 as the extracted translation from the matrix
  4230. */
  4231. getTranslation(): Vector3;
  4232. /**
  4233. * Fill a Vector3 with the extracted translation from the matrix
  4234. * @param result defines the Vector3 where to store the translation
  4235. * @returns the current matrix
  4236. */
  4237. getTranslationToRef(result: Vector3): Matrix;
  4238. /**
  4239. * Remove rotation and scaling part from the matrix
  4240. * @returns the updated matrix
  4241. */
  4242. removeRotationAndScaling(): Matrix;
  4243. /**
  4244. * Multiply two matrices
  4245. * @param other defines the second operand
  4246. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4247. */
  4248. multiply(other: DeepImmutable<Matrix>): Matrix;
  4249. /**
  4250. * Copy the current matrix from the given one
  4251. * @param other defines the source matrix
  4252. * @returns the current updated matrix
  4253. */
  4254. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4255. /**
  4256. * Populates the given array from the starting index with the current matrix values
  4257. * @param array defines the target array
  4258. * @param offset defines the offset in the target array where to start storing values
  4259. * @returns the current matrix
  4260. */
  4261. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4262. /**
  4263. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4264. * @param other defines the second operand
  4265. * @param result defines the matrix where to store the multiplication
  4266. * @returns the current matrix
  4267. */
  4268. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4269. /**
  4270. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4271. * @param other defines the second operand
  4272. * @param result defines the array where to store the multiplication
  4273. * @param offset defines the offset in the target array where to start storing values
  4274. * @returns the current matrix
  4275. */
  4276. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4277. /**
  4278. * Check equality between this matrix and a second one
  4279. * @param value defines the second matrix to compare
  4280. * @returns true is the current matrix and the given one values are strictly equal
  4281. */
  4282. equals(value: DeepImmutable<Matrix>): boolean;
  4283. /**
  4284. * Clone the current matrix
  4285. * @returns a new matrix from the current matrix
  4286. */
  4287. clone(): Matrix;
  4288. /**
  4289. * Returns the name of the current matrix class
  4290. * @returns the string "Matrix"
  4291. */
  4292. getClassName(): string;
  4293. /**
  4294. * Gets the hash code of the current matrix
  4295. * @returns the hash code
  4296. */
  4297. getHashCode(): number;
  4298. /**
  4299. * Decomposes the current Matrix into a translation, rotation and scaling components
  4300. * @param scale defines the scale vector3 given as a reference to update
  4301. * @param rotation defines the rotation quaternion given as a reference to update
  4302. * @param translation defines the translation vector3 given as a reference to update
  4303. * @returns true if operation was successful
  4304. */
  4305. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4306. /**
  4307. * Gets specific row of the matrix
  4308. * @param index defines the number of the row to get
  4309. * @returns the index-th row of the current matrix as a new Vector4
  4310. */
  4311. getRow(index: number): Nullable<Vector4>;
  4312. /**
  4313. * Sets the index-th row of the current matrix to the vector4 values
  4314. * @param index defines the number of the row to set
  4315. * @param row defines the target vector4
  4316. * @returns the updated current matrix
  4317. */
  4318. setRow(index: number, row: Vector4): Matrix;
  4319. /**
  4320. * Compute the transpose of the matrix
  4321. * @returns the new transposed matrix
  4322. */
  4323. transpose(): Matrix;
  4324. /**
  4325. * Compute the transpose of the matrix and store it in a given matrix
  4326. * @param result defines the target matrix
  4327. * @returns the current matrix
  4328. */
  4329. transposeToRef(result: Matrix): Matrix;
  4330. /**
  4331. * Sets the index-th row of the current matrix with the given 4 x float values
  4332. * @param index defines the row index
  4333. * @param x defines the x component to set
  4334. * @param y defines the y component to set
  4335. * @param z defines the z component to set
  4336. * @param w defines the w component to set
  4337. * @returns the updated current matrix
  4338. */
  4339. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4340. /**
  4341. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4342. * @param scale defines the scale factor
  4343. * @returns a new matrix
  4344. */
  4345. scale(scale: number): Matrix;
  4346. /**
  4347. * Scale the current matrix values by a factor to a given result matrix
  4348. * @param scale defines the scale factor
  4349. * @param result defines the matrix to store the result
  4350. * @returns the current matrix
  4351. */
  4352. scaleToRef(scale: number, result: Matrix): Matrix;
  4353. /**
  4354. * Scale the current matrix values by a factor and add the result to a given matrix
  4355. * @param scale defines the scale factor
  4356. * @param result defines the Matrix to store the result
  4357. * @returns the current matrix
  4358. */
  4359. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4360. /**
  4361. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4362. * @param ref matrix to store the result
  4363. */
  4364. toNormalMatrix(ref: Matrix): void;
  4365. /**
  4366. * Gets only rotation part of the current matrix
  4367. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4368. */
  4369. getRotationMatrix(): Matrix;
  4370. /**
  4371. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4372. * @param result defines the target matrix to store data to
  4373. * @returns the current matrix
  4374. */
  4375. getRotationMatrixToRef(result: Matrix): Matrix;
  4376. /**
  4377. * Toggles model matrix from being right handed to left handed in place and vice versa
  4378. */
  4379. toggleModelMatrixHandInPlace(): void;
  4380. /**
  4381. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4382. */
  4383. toggleProjectionMatrixHandInPlace(): void;
  4384. /**
  4385. * Creates a matrix from an array
  4386. * @param array defines the source array
  4387. * @param offset defines an offset in the source array
  4388. * @returns a new Matrix set from the starting index of the given array
  4389. */
  4390. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4391. /**
  4392. * Copy the content of an array into a given matrix
  4393. * @param array defines the source array
  4394. * @param offset defines an offset in the source array
  4395. * @param result defines the target matrix
  4396. */
  4397. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4398. /**
  4399. * Stores an array into a matrix after having multiplied each component by a given factor
  4400. * @param array defines the source array
  4401. * @param offset defines the offset in the source array
  4402. * @param scale defines the scaling factor
  4403. * @param result defines the target matrix
  4404. */
  4405. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4406. /**
  4407. * Gets an identity matrix that must not be updated
  4408. */
  4409. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4410. /**
  4411. * Stores a list of values (16) inside a given matrix
  4412. * @param initialM11 defines 1st value of 1st row
  4413. * @param initialM12 defines 2nd value of 1st row
  4414. * @param initialM13 defines 3rd value of 1st row
  4415. * @param initialM14 defines 4th value of 1st row
  4416. * @param initialM21 defines 1st value of 2nd row
  4417. * @param initialM22 defines 2nd value of 2nd row
  4418. * @param initialM23 defines 3rd value of 2nd row
  4419. * @param initialM24 defines 4th value of 2nd row
  4420. * @param initialM31 defines 1st value of 3rd row
  4421. * @param initialM32 defines 2nd value of 3rd row
  4422. * @param initialM33 defines 3rd value of 3rd row
  4423. * @param initialM34 defines 4th value of 3rd row
  4424. * @param initialM41 defines 1st value of 4th row
  4425. * @param initialM42 defines 2nd value of 4th row
  4426. * @param initialM43 defines 3rd value of 4th row
  4427. * @param initialM44 defines 4th value of 4th row
  4428. * @param result defines the target matrix
  4429. */
  4430. 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;
  4431. /**
  4432. * Creates new matrix from a list of values (16)
  4433. * @param initialM11 defines 1st value of 1st row
  4434. * @param initialM12 defines 2nd value of 1st row
  4435. * @param initialM13 defines 3rd value of 1st row
  4436. * @param initialM14 defines 4th value of 1st row
  4437. * @param initialM21 defines 1st value of 2nd row
  4438. * @param initialM22 defines 2nd value of 2nd row
  4439. * @param initialM23 defines 3rd value of 2nd row
  4440. * @param initialM24 defines 4th value of 2nd row
  4441. * @param initialM31 defines 1st value of 3rd row
  4442. * @param initialM32 defines 2nd value of 3rd row
  4443. * @param initialM33 defines 3rd value of 3rd row
  4444. * @param initialM34 defines 4th value of 3rd row
  4445. * @param initialM41 defines 1st value of 4th row
  4446. * @param initialM42 defines 2nd value of 4th row
  4447. * @param initialM43 defines 3rd value of 4th row
  4448. * @param initialM44 defines 4th value of 4th row
  4449. * @returns the new matrix
  4450. */
  4451. 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;
  4452. /**
  4453. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4454. * @param scale defines the scale vector3
  4455. * @param rotation defines the rotation quaternion
  4456. * @param translation defines the translation vector3
  4457. * @returns a new matrix
  4458. */
  4459. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4460. /**
  4461. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4462. * @param scale defines the scale vector3
  4463. * @param rotation defines the rotation quaternion
  4464. * @param translation defines the translation vector3
  4465. * @param result defines the target matrix
  4466. */
  4467. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4468. /**
  4469. * Creates a new identity matrix
  4470. * @returns a new identity matrix
  4471. */
  4472. static Identity(): Matrix;
  4473. /**
  4474. * Creates a new identity matrix and stores the result in a given matrix
  4475. * @param result defines the target matrix
  4476. */
  4477. static IdentityToRef(result: Matrix): void;
  4478. /**
  4479. * Creates a new zero matrix
  4480. * @returns a new zero matrix
  4481. */
  4482. static Zero(): Matrix;
  4483. /**
  4484. * Creates a new rotation matrix for "angle" radians around the X axis
  4485. * @param angle defines the angle (in radians) to use
  4486. * @return the new matrix
  4487. */
  4488. static RotationX(angle: number): Matrix;
  4489. /**
  4490. * Creates a new matrix as the invert of a given matrix
  4491. * @param source defines the source matrix
  4492. * @returns the new matrix
  4493. */
  4494. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4495. /**
  4496. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4497. * @param angle defines the angle (in radians) to use
  4498. * @param result defines the target matrix
  4499. */
  4500. static RotationXToRef(angle: number, result: Matrix): void;
  4501. /**
  4502. * Creates a new rotation matrix for "angle" radians around the Y axis
  4503. * @param angle defines the angle (in radians) to use
  4504. * @return the new matrix
  4505. */
  4506. static RotationY(angle: number): Matrix;
  4507. /**
  4508. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4509. * @param angle defines the angle (in radians) to use
  4510. * @param result defines the target matrix
  4511. */
  4512. static RotationYToRef(angle: number, result: Matrix): void;
  4513. /**
  4514. * Creates a new rotation matrix for "angle" radians around the Z axis
  4515. * @param angle defines the angle (in radians) to use
  4516. * @return the new matrix
  4517. */
  4518. static RotationZ(angle: number): Matrix;
  4519. /**
  4520. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4521. * @param angle defines the angle (in radians) to use
  4522. * @param result defines the target matrix
  4523. */
  4524. static RotationZToRef(angle: number, result: Matrix): void;
  4525. /**
  4526. * Creates a new rotation matrix for "angle" radians around the given axis
  4527. * @param axis defines the axis to use
  4528. * @param angle defines the angle (in radians) to use
  4529. * @return the new matrix
  4530. */
  4531. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4532. /**
  4533. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4534. * @param axis defines the axis to use
  4535. * @param angle defines the angle (in radians) to use
  4536. * @param result defines the target matrix
  4537. */
  4538. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4539. /**
  4540. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4541. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4542. * @param from defines the vector to align
  4543. * @param to defines the vector to align to
  4544. * @param result defines the target matrix
  4545. */
  4546. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4547. /**
  4548. * Creates a rotation matrix
  4549. * @param yaw defines the yaw angle in radians (Y axis)
  4550. * @param pitch defines the pitch angle in radians (X axis)
  4551. * @param roll defines the roll angle in radians (Z axis)
  4552. * @returns the new rotation matrix
  4553. */
  4554. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4555. /**
  4556. * Creates a rotation matrix and stores it in a given matrix
  4557. * @param yaw defines the yaw angle in radians (Y axis)
  4558. * @param pitch defines the pitch angle in radians (X axis)
  4559. * @param roll defines the roll angle in radians (Z axis)
  4560. * @param result defines the target matrix
  4561. */
  4562. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4563. /**
  4564. * Creates a scaling matrix
  4565. * @param x defines the scale factor on X axis
  4566. * @param y defines the scale factor on Y axis
  4567. * @param z defines the scale factor on Z axis
  4568. * @returns the new matrix
  4569. */
  4570. static Scaling(x: number, y: number, z: number): Matrix;
  4571. /**
  4572. * Creates a scaling matrix and stores it in a given matrix
  4573. * @param x defines the scale factor on X axis
  4574. * @param y defines the scale factor on Y axis
  4575. * @param z defines the scale factor on Z axis
  4576. * @param result defines the target matrix
  4577. */
  4578. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4579. /**
  4580. * Creates a translation matrix
  4581. * @param x defines the translation on X axis
  4582. * @param y defines the translation on Y axis
  4583. * @param z defines the translationon Z axis
  4584. * @returns the new matrix
  4585. */
  4586. static Translation(x: number, y: number, z: number): Matrix;
  4587. /**
  4588. * Creates a translation matrix and stores it in a given matrix
  4589. * @param x defines the translation on X axis
  4590. * @param y defines the translation on Y axis
  4591. * @param z defines the translationon Z axis
  4592. * @param result defines the target matrix
  4593. */
  4594. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4595. /**
  4596. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4597. * @param startValue defines the start value
  4598. * @param endValue defines the end value
  4599. * @param gradient defines the gradient factor
  4600. * @returns the new matrix
  4601. */
  4602. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4603. /**
  4604. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4605. * @param startValue defines the start value
  4606. * @param endValue defines the end value
  4607. * @param gradient defines the gradient factor
  4608. * @param result defines the Matrix object where to store data
  4609. */
  4610. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4611. /**
  4612. * Builds a new matrix whose values are computed by:
  4613. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4614. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4615. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4616. * @param startValue defines the first matrix
  4617. * @param endValue defines the second matrix
  4618. * @param gradient defines the gradient between the two matrices
  4619. * @returns the new matrix
  4620. */
  4621. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4622. /**
  4623. * Update a matrix to values which are computed by:
  4624. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4625. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4626. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4627. * @param startValue defines the first matrix
  4628. * @param endValue defines the second matrix
  4629. * @param gradient defines the gradient between the two matrices
  4630. * @param result defines the target matrix
  4631. */
  4632. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, 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 left 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 LookAtLH(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 left 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 LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4651. /**
  4652. * 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"
  4653. * This function works in right handed mode
  4654. * @param eye defines the final position of the entity
  4655. * @param target defines where the entity should look at
  4656. * @param up defines the up vector for the entity
  4657. * @returns the new matrix
  4658. */
  4659. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4660. /**
  4661. * 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".
  4662. * This function works in right handed mode
  4663. * @param eye defines the final position of the entity
  4664. * @param target defines where the entity should look at
  4665. * @param up defines the up vector for the entity
  4666. * @param result defines the target matrix
  4667. */
  4668. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4669. /**
  4670. * Create a left-handed orthographic projection matrix
  4671. * @param width defines the viewport width
  4672. * @param height defines the viewport height
  4673. * @param znear defines the near clip plane
  4674. * @param zfar defines the far clip plane
  4675. * @returns a new matrix as a left-handed orthographic projection matrix
  4676. */
  4677. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4678. /**
  4679. * Store a left-handed orthographic projection to a given matrix
  4680. * @param width defines the viewport width
  4681. * @param height defines the viewport height
  4682. * @param znear defines the near clip plane
  4683. * @param zfar defines the far clip plane
  4684. * @param result defines the target matrix
  4685. */
  4686. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4687. /**
  4688. * Create a left-handed orthographic projection matrix
  4689. * @param left defines the viewport left coordinate
  4690. * @param right defines the viewport right coordinate
  4691. * @param bottom defines the viewport bottom coordinate
  4692. * @param top defines the viewport top coordinate
  4693. * @param znear defines the near clip plane
  4694. * @param zfar defines the far clip plane
  4695. * @returns a new matrix as a left-handed orthographic projection matrix
  4696. */
  4697. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4698. /**
  4699. * Stores a left-handed orthographic projection into a given matrix
  4700. * @param left defines the viewport left coordinate
  4701. * @param right defines the viewport right coordinate
  4702. * @param bottom defines the viewport bottom coordinate
  4703. * @param top defines the viewport top coordinate
  4704. * @param znear defines the near clip plane
  4705. * @param zfar defines the far clip plane
  4706. * @param result defines the target matrix
  4707. */
  4708. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4709. /**
  4710. * Creates a right-handed orthographic projection matrix
  4711. * @param left defines the viewport left coordinate
  4712. * @param right defines the viewport right coordinate
  4713. * @param bottom defines the viewport bottom coordinate
  4714. * @param top defines the viewport top coordinate
  4715. * @param znear defines the near clip plane
  4716. * @param zfar defines the far clip plane
  4717. * @returns a new matrix as a right-handed orthographic projection matrix
  4718. */
  4719. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4720. /**
  4721. * Stores a right-handed orthographic projection into a given matrix
  4722. * @param left defines the viewport left coordinate
  4723. * @param right defines the viewport right coordinate
  4724. * @param bottom defines the viewport bottom coordinate
  4725. * @param top defines the viewport top coordinate
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @param result defines the target matrix
  4729. */
  4730. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4731. /**
  4732. * Creates a left-handed perspective projection matrix
  4733. * @param width defines the viewport width
  4734. * @param height defines the viewport height
  4735. * @param znear defines the near clip plane
  4736. * @param zfar defines the far clip plane
  4737. * @returns a new matrix as a left-handed perspective projection matrix
  4738. */
  4739. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4740. /**
  4741. * Creates a left-handed perspective projection matrix
  4742. * @param fov defines the horizontal field of view
  4743. * @param aspect defines the aspect ratio
  4744. * @param znear defines the near clip plane
  4745. * @param zfar defines the far clip plane
  4746. * @returns a new matrix as a left-handed perspective projection matrix
  4747. */
  4748. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4749. /**
  4750. * Stores a left-handed perspective projection into a given matrix
  4751. * @param fov defines the horizontal field of view
  4752. * @param aspect defines the aspect ratio
  4753. * @param znear defines the near clip plane
  4754. * @param zfar defines the far clip plane
  4755. * @param result defines the target matrix
  4756. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4757. */
  4758. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4759. /**
  4760. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4761. * @param fov defines the horizontal field of view
  4762. * @param aspect defines the aspect ratio
  4763. * @param znear defines the near clip plane
  4764. * @param zfar not used as infinity is used as far clip
  4765. * @param result defines the target matrix
  4766. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4767. */
  4768. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4769. /**
  4770. * Creates a right-handed perspective projection matrix
  4771. * @param fov defines the horizontal field of view
  4772. * @param aspect defines the aspect ratio
  4773. * @param znear defines the near clip plane
  4774. * @param zfar defines the far clip plane
  4775. * @returns a new matrix as a right-handed perspective projection matrix
  4776. */
  4777. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4778. /**
  4779. * Stores a right-handed perspective projection into a given matrix
  4780. * @param fov defines the horizontal field of view
  4781. * @param aspect defines the aspect ratio
  4782. * @param znear defines the near clip plane
  4783. * @param zfar defines the far clip plane
  4784. * @param result defines the target matrix
  4785. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4786. */
  4787. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4788. /**
  4789. * Stores a right-handed perspective projection into a given matrix
  4790. * @param fov defines the horizontal field of view
  4791. * @param aspect defines the aspect ratio
  4792. * @param znear defines the near clip plane
  4793. * @param zfar not used as infinity is used as far clip
  4794. * @param result defines the target matrix
  4795. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4796. */
  4797. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4798. /**
  4799. * Stores a perspective projection for WebVR info a given matrix
  4800. * @param fov defines the field of view
  4801. * @param znear defines the near clip plane
  4802. * @param zfar defines the far clip plane
  4803. * @param result defines the target matrix
  4804. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4805. */
  4806. static PerspectiveFovWebVRToRef(fov: {
  4807. upDegrees: number;
  4808. downDegrees: number;
  4809. leftDegrees: number;
  4810. rightDegrees: number;
  4811. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4812. /**
  4813. * Computes a complete transformation matrix
  4814. * @param viewport defines the viewport to use
  4815. * @param world defines the world matrix
  4816. * @param view defines the view matrix
  4817. * @param projection defines the projection matrix
  4818. * @param zmin defines the near clip plane
  4819. * @param zmax defines the far clip plane
  4820. * @returns the transformation matrix
  4821. */
  4822. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4823. /**
  4824. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4825. * @param matrix defines the matrix to use
  4826. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4827. */
  4828. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4829. /**
  4830. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4831. * @param matrix defines the matrix to use
  4832. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4833. */
  4834. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4835. /**
  4836. * Compute the transpose of a given matrix
  4837. * @param matrix defines the matrix to transpose
  4838. * @returns the new matrix
  4839. */
  4840. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4841. /**
  4842. * Compute the transpose of a matrix and store it in a target matrix
  4843. * @param matrix defines the matrix to transpose
  4844. * @param result defines the target matrix
  4845. */
  4846. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4847. /**
  4848. * Computes a reflection matrix from a plane
  4849. * @param plane defines the reflection plane
  4850. * @returns a new matrix
  4851. */
  4852. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4853. /**
  4854. * Computes a reflection matrix from a plane
  4855. * @param plane defines the reflection plane
  4856. * @param result defines the target matrix
  4857. */
  4858. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4859. /**
  4860. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4861. * @param xaxis defines the value of the 1st axis
  4862. * @param yaxis defines the value of the 2nd axis
  4863. * @param zaxis defines the value of the 3rd axis
  4864. * @param result defines the target matrix
  4865. */
  4866. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4867. /**
  4868. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4869. * @param quat defines the quaternion to use
  4870. * @param result defines the target matrix
  4871. */
  4872. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4873. }
  4874. /**
  4875. * @hidden
  4876. */
  4877. export class TmpVectors {
  4878. static Vector2: Vector2[];
  4879. static Vector3: Vector3[];
  4880. static Vector4: Vector4[];
  4881. static Quaternion: Quaternion[];
  4882. static Matrix: Matrix[];
  4883. }
  4884. }
  4885. declare module "babylonjs/Maths/math.path" {
  4886. import { DeepImmutable, Nullable } from "babylonjs/types";
  4887. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4888. /**
  4889. * Defines potential orientation for back face culling
  4890. */
  4891. export enum Orientation {
  4892. /**
  4893. * Clockwise
  4894. */
  4895. CW = 0,
  4896. /** Counter clockwise */
  4897. CCW = 1
  4898. }
  4899. /** Class used to represent a Bezier curve */
  4900. export class BezierCurve {
  4901. /**
  4902. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4903. * @param t defines the time
  4904. * @param x1 defines the left coordinate on X axis
  4905. * @param y1 defines the left coordinate on Y axis
  4906. * @param x2 defines the right coordinate on X axis
  4907. * @param y2 defines the right coordinate on Y axis
  4908. * @returns the interpolated value
  4909. */
  4910. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4911. }
  4912. /**
  4913. * Defines angle representation
  4914. */
  4915. export class Angle {
  4916. private _radians;
  4917. /**
  4918. * Creates an Angle object of "radians" radians (float).
  4919. * @param radians the angle in radians
  4920. */
  4921. constructor(radians: number);
  4922. /**
  4923. * Get value in degrees
  4924. * @returns the Angle value in degrees (float)
  4925. */
  4926. degrees(): number;
  4927. /**
  4928. * Get value in radians
  4929. * @returns the Angle value in radians (float)
  4930. */
  4931. radians(): number;
  4932. /**
  4933. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4934. * @param a defines first point as the origin
  4935. * @param b defines point
  4936. * @returns a new Angle
  4937. */
  4938. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4939. /**
  4940. * Gets a new Angle object from the given float in radians
  4941. * @param radians defines the angle value in radians
  4942. * @returns a new Angle
  4943. */
  4944. static FromRadians(radians: number): Angle;
  4945. /**
  4946. * Gets a new Angle object from the given float in degrees
  4947. * @param degrees defines the angle value in degrees
  4948. * @returns a new Angle
  4949. */
  4950. static FromDegrees(degrees: number): Angle;
  4951. }
  4952. /**
  4953. * This represents an arc in a 2d space.
  4954. */
  4955. export class Arc2 {
  4956. /** Defines the start point of the arc */
  4957. startPoint: Vector2;
  4958. /** Defines the mid point of the arc */
  4959. midPoint: Vector2;
  4960. /** Defines the end point of the arc */
  4961. endPoint: Vector2;
  4962. /**
  4963. * Defines the center point of the arc.
  4964. */
  4965. centerPoint: Vector2;
  4966. /**
  4967. * Defines the radius of the arc.
  4968. */
  4969. radius: number;
  4970. /**
  4971. * Defines the angle of the arc (from mid point to end point).
  4972. */
  4973. angle: Angle;
  4974. /**
  4975. * Defines the start angle of the arc (from start point to middle point).
  4976. */
  4977. startAngle: Angle;
  4978. /**
  4979. * Defines the orientation of the arc (clock wise/counter clock wise).
  4980. */
  4981. orientation: Orientation;
  4982. /**
  4983. * Creates an Arc object from the three given points : start, middle and end.
  4984. * @param startPoint Defines the start point of the arc
  4985. * @param midPoint Defines the midlle point of the arc
  4986. * @param endPoint Defines the end point of the arc
  4987. */
  4988. constructor(
  4989. /** Defines the start point of the arc */
  4990. startPoint: Vector2,
  4991. /** Defines the mid point of the arc */
  4992. midPoint: Vector2,
  4993. /** Defines the end point of the arc */
  4994. endPoint: Vector2);
  4995. }
  4996. /**
  4997. * Represents a 2D path made up of multiple 2D points
  4998. */
  4999. export class Path2 {
  5000. private _points;
  5001. private _length;
  5002. /**
  5003. * If the path start and end point are the same
  5004. */
  5005. closed: boolean;
  5006. /**
  5007. * Creates a Path2 object from the starting 2D coordinates x and y.
  5008. * @param x the starting points x value
  5009. * @param y the starting points y value
  5010. */
  5011. constructor(x: number, y: number);
  5012. /**
  5013. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5014. * @param x the added points x value
  5015. * @param y the added points y value
  5016. * @returns the updated Path2.
  5017. */
  5018. addLineTo(x: number, y: number): Path2;
  5019. /**
  5020. * 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.
  5021. * @param midX middle point x value
  5022. * @param midY middle point y value
  5023. * @param endX end point x value
  5024. * @param endY end point y value
  5025. * @param numberOfSegments (default: 36)
  5026. * @returns the updated Path2.
  5027. */
  5028. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5029. /**
  5030. * Closes the Path2.
  5031. * @returns the Path2.
  5032. */
  5033. close(): Path2;
  5034. /**
  5035. * Gets the sum of the distance between each sequential point in the path
  5036. * @returns the Path2 total length (float).
  5037. */
  5038. length(): number;
  5039. /**
  5040. * Gets the points which construct the path
  5041. * @returns the Path2 internal array of points.
  5042. */
  5043. getPoints(): Vector2[];
  5044. /**
  5045. * Retreives the point at the distance aways from the starting point
  5046. * @param normalizedLengthPosition the length along the path to retreive the point from
  5047. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5048. */
  5049. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5050. /**
  5051. * Creates a new path starting from an x and y position
  5052. * @param x starting x value
  5053. * @param y starting y value
  5054. * @returns a new Path2 starting at the coordinates (x, y).
  5055. */
  5056. static StartingAt(x: number, y: number): Path2;
  5057. }
  5058. /**
  5059. * Represents a 3D path made up of multiple 3D points
  5060. */
  5061. export class Path3D {
  5062. /**
  5063. * an array of Vector3, the curve axis of the Path3D
  5064. */
  5065. path: Vector3[];
  5066. private _curve;
  5067. private _distances;
  5068. private _tangents;
  5069. private _normals;
  5070. private _binormals;
  5071. private _raw;
  5072. private _alignTangentsWithPath;
  5073. private readonly _pointAtData;
  5074. /**
  5075. * new Path3D(path, normal, raw)
  5076. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5077. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5078. * @param path an array of Vector3, the curve axis of the Path3D
  5079. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5080. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5081. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5082. */
  5083. constructor(
  5084. /**
  5085. * an array of Vector3, the curve axis of the Path3D
  5086. */
  5087. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5088. /**
  5089. * Returns the Path3D array of successive Vector3 designing its curve.
  5090. * @returns the Path3D array of successive Vector3 designing its curve.
  5091. */
  5092. getCurve(): Vector3[];
  5093. /**
  5094. * Returns the Path3D array of successive Vector3 designing its curve.
  5095. * @returns the Path3D array of successive Vector3 designing its curve.
  5096. */
  5097. getPoints(): Vector3[];
  5098. /**
  5099. * @returns the computed length (float) of the path.
  5100. */
  5101. length(): number;
  5102. /**
  5103. * Returns an array populated with tangent vectors on each Path3D curve point.
  5104. * @returns an array populated with tangent vectors on each Path3D curve point.
  5105. */
  5106. getTangents(): Vector3[];
  5107. /**
  5108. * Returns an array populated with normal vectors on each Path3D curve point.
  5109. * @returns an array populated with normal vectors on each Path3D curve point.
  5110. */
  5111. getNormals(): Vector3[];
  5112. /**
  5113. * Returns an array populated with binormal vectors on each Path3D curve point.
  5114. * @returns an array populated with binormal vectors on each Path3D curve point.
  5115. */
  5116. getBinormals(): Vector3[];
  5117. /**
  5118. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5119. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5120. */
  5121. getDistances(): number[];
  5122. /**
  5123. * Returns an interpolated point along this path
  5124. * @param position the position of the point along this path, from 0.0 to 1.0
  5125. * @returns a new Vector3 as the point
  5126. */
  5127. getPointAt(position: number): Vector3;
  5128. /**
  5129. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5130. * @param position the position of the point along this path, from 0.0 to 1.0
  5131. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5132. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5133. */
  5134. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5135. /**
  5136. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5137. * @param position the position of the point along this path, from 0.0 to 1.0
  5138. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5139. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5140. */
  5141. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5142. /**
  5143. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5144. * @param position the position of the point along this path, from 0.0 to 1.0
  5145. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5146. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5147. */
  5148. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5149. /**
  5150. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5151. * @param position the position of the point along this path, from 0.0 to 1.0
  5152. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5153. */
  5154. getDistanceAt(position: number): number;
  5155. /**
  5156. * Returns the array index of the previous point of an interpolated point along this path
  5157. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5158. * @returns the array index
  5159. */
  5160. getPreviousPointIndexAt(position: number): number;
  5161. /**
  5162. * 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)
  5163. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5164. * @returns the sub position
  5165. */
  5166. getSubPositionAt(position: number): number;
  5167. /**
  5168. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5169. * @param target the vector of which to get the closest position to
  5170. * @returns the position of the closest virtual point on this path to the target vector
  5171. */
  5172. getClosestPositionTo(target: Vector3): number;
  5173. /**
  5174. * Returns a sub path (slice) of this path
  5175. * @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
  5176. * @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
  5177. * @returns a sub path (slice) of this path
  5178. */
  5179. slice(start?: number, end?: number): Path3D;
  5180. /**
  5181. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5182. * @param path path which all values are copied into the curves points
  5183. * @param firstNormal which should be projected onto the curve
  5184. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5185. * @returns the same object updated.
  5186. */
  5187. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5188. private _compute;
  5189. private _getFirstNonNullVector;
  5190. private _getLastNonNullVector;
  5191. private _normalVector;
  5192. /**
  5193. * Updates the point at data for an interpolated point along this curve
  5194. * @param position the position of the point along this curve, from 0.0 to 1.0
  5195. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5196. * @returns the (updated) point at data
  5197. */
  5198. private _updatePointAtData;
  5199. /**
  5200. * Updates the point at data from the specified parameters
  5201. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5202. * @param point the interpolated point
  5203. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5204. */
  5205. private _setPointAtData;
  5206. /**
  5207. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5208. */
  5209. private _updateInterpolationMatrix;
  5210. }
  5211. /**
  5212. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5213. * A Curve3 is designed from a series of successive Vector3.
  5214. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5215. */
  5216. export class Curve3 {
  5217. private _points;
  5218. private _length;
  5219. /**
  5220. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5221. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5222. * @param v1 (Vector3) the control point
  5223. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5224. * @param nbPoints (integer) the wanted number of points in the curve
  5225. * @returns the created Curve3
  5226. */
  5227. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5228. /**
  5229. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5230. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5231. * @param v1 (Vector3) the first control point
  5232. * @param v2 (Vector3) the second control point
  5233. * @param v3 (Vector3) the end point of the Cubic Bezier
  5234. * @param nbPoints (integer) the wanted number of points in the curve
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5238. /**
  5239. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5240. * @param p1 (Vector3) the origin point of the Hermite Spline
  5241. * @param t1 (Vector3) the tangent vector at the origin point
  5242. * @param p2 (Vector3) the end point of the Hermite Spline
  5243. * @param t2 (Vector3) the tangent vector at the end point
  5244. * @param nbPoints (integer) the wanted number of points in the curve
  5245. * @returns the created Curve3
  5246. */
  5247. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5248. /**
  5249. * Returns a Curve3 object along a CatmullRom Spline curve :
  5250. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5251. * @param nbPoints (integer) the wanted number of points between each curve control points
  5252. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5253. * @returns the created Curve3
  5254. */
  5255. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5256. /**
  5257. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5258. * A Curve3 is designed from a series of successive Vector3.
  5259. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5260. * @param points points which make up the curve
  5261. */
  5262. constructor(points: Vector3[]);
  5263. /**
  5264. * @returns the Curve3 stored array of successive Vector3
  5265. */
  5266. getPoints(): Vector3[];
  5267. /**
  5268. * @returns the computed length (float) of the curve.
  5269. */
  5270. length(): number;
  5271. /**
  5272. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5273. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5274. * curveA and curveB keep unchanged.
  5275. * @param curve the curve to continue from this curve
  5276. * @returns the newly constructed curve
  5277. */
  5278. continue(curve: DeepImmutable<Curve3>): Curve3;
  5279. private _computeLength;
  5280. }
  5281. }
  5282. declare module "babylonjs/Animations/easing" {
  5283. /**
  5284. * This represents the main contract an easing function should follow.
  5285. * Easing functions are used throughout the animation system.
  5286. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5287. */
  5288. export interface IEasingFunction {
  5289. /**
  5290. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5291. * of the easing function.
  5292. * The link below provides some of the most common examples of easing functions.
  5293. * @see https://easings.net/
  5294. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5295. * @returns the corresponding value on the curve defined by the easing function
  5296. */
  5297. ease(gradient: number): number;
  5298. }
  5299. /**
  5300. * Base class used for every default easing function.
  5301. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5302. */
  5303. export class EasingFunction implements IEasingFunction {
  5304. /**
  5305. * Interpolation follows the mathematical formula associated with the easing function.
  5306. */
  5307. static readonly EASINGMODE_EASEIN: number;
  5308. /**
  5309. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5310. */
  5311. static readonly EASINGMODE_EASEOUT: number;
  5312. /**
  5313. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5314. */
  5315. static readonly EASINGMODE_EASEINOUT: number;
  5316. private _easingMode;
  5317. /**
  5318. * Sets the easing mode of the current function.
  5319. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5320. */
  5321. setEasingMode(easingMode: number): void;
  5322. /**
  5323. * Gets the current easing mode.
  5324. * @returns the easing mode
  5325. */
  5326. getEasingMode(): number;
  5327. /**
  5328. * @hidden
  5329. */
  5330. easeInCore(gradient: number): number;
  5331. /**
  5332. * Given an input gradient between 0 and 1, this returns the corresponding value
  5333. * of the easing function.
  5334. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5335. * @returns the corresponding value on the curve defined by the easing function
  5336. */
  5337. ease(gradient: number): number;
  5338. }
  5339. /**
  5340. * Easing function with a circle shape (see link below).
  5341. * @see https://easings.net/#easeInCirc
  5342. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5343. */
  5344. export class CircleEase extends EasingFunction implements IEasingFunction {
  5345. /** @hidden */
  5346. easeInCore(gradient: number): number;
  5347. }
  5348. /**
  5349. * Easing function with a ease back shape (see link below).
  5350. * @see https://easings.net/#easeInBack
  5351. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5352. */
  5353. export class BackEase extends EasingFunction implements IEasingFunction {
  5354. /** Defines the amplitude of the function */
  5355. amplitude: number;
  5356. /**
  5357. * Instantiates a back ease easing
  5358. * @see https://easings.net/#easeInBack
  5359. * @param amplitude Defines the amplitude of the function
  5360. */
  5361. constructor(
  5362. /** Defines the amplitude of the function */
  5363. amplitude?: number);
  5364. /** @hidden */
  5365. easeInCore(gradient: number): number;
  5366. }
  5367. /**
  5368. * Easing function with a bouncing shape (see link below).
  5369. * @see https://easings.net/#easeInBounce
  5370. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5371. */
  5372. export class BounceEase extends EasingFunction implements IEasingFunction {
  5373. /** Defines the number of bounces */
  5374. bounces: number;
  5375. /** Defines the amplitude of the bounce */
  5376. bounciness: number;
  5377. /**
  5378. * Instantiates a bounce easing
  5379. * @see https://easings.net/#easeInBounce
  5380. * @param bounces Defines the number of bounces
  5381. * @param bounciness Defines the amplitude of the bounce
  5382. */
  5383. constructor(
  5384. /** Defines the number of bounces */
  5385. bounces?: number,
  5386. /** Defines the amplitude of the bounce */
  5387. bounciness?: number);
  5388. /** @hidden */
  5389. easeInCore(gradient: number): number;
  5390. }
  5391. /**
  5392. * Easing function with a power of 3 shape (see link below).
  5393. * @see https://easings.net/#easeInCubic
  5394. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5395. */
  5396. export class CubicEase extends EasingFunction implements IEasingFunction {
  5397. /** @hidden */
  5398. easeInCore(gradient: number): number;
  5399. }
  5400. /**
  5401. * Easing function with an elastic shape (see link below).
  5402. * @see https://easings.net/#easeInElastic
  5403. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5404. */
  5405. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5406. /** Defines the number of oscillations*/
  5407. oscillations: number;
  5408. /** Defines the amplitude of the oscillations*/
  5409. springiness: number;
  5410. /**
  5411. * Instantiates an elastic easing function
  5412. * @see https://easings.net/#easeInElastic
  5413. * @param oscillations Defines the number of oscillations
  5414. * @param springiness Defines the amplitude of the oscillations
  5415. */
  5416. constructor(
  5417. /** Defines the number of oscillations*/
  5418. oscillations?: number,
  5419. /** Defines the amplitude of the oscillations*/
  5420. springiness?: number);
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with an exponential shape (see link below).
  5426. * @see https://easings.net/#easeInExpo
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5430. /** Defines the exponent of the function */
  5431. exponent: number;
  5432. /**
  5433. * Instantiates an exponential easing function
  5434. * @see https://easings.net/#easeInExpo
  5435. * @param exponent Defines the exponent of the function
  5436. */
  5437. constructor(
  5438. /** Defines the exponent of the function */
  5439. exponent?: number);
  5440. /** @hidden */
  5441. easeInCore(gradient: number): number;
  5442. }
  5443. /**
  5444. * Easing function with a power shape (see link below).
  5445. * @see https://easings.net/#easeInQuad
  5446. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5447. */
  5448. export class PowerEase extends EasingFunction implements IEasingFunction {
  5449. /** Defines the power of the function */
  5450. power: number;
  5451. /**
  5452. * Instantiates an power base easing function
  5453. * @see https://easings.net/#easeInQuad
  5454. * @param power Defines the power of the function
  5455. */
  5456. constructor(
  5457. /** Defines the power of the function */
  5458. power?: number);
  5459. /** @hidden */
  5460. easeInCore(gradient: number): number;
  5461. }
  5462. /**
  5463. * Easing function with a power of 2 shape (see link below).
  5464. * @see https://easings.net/#easeInQuad
  5465. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5466. */
  5467. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5468. /** @hidden */
  5469. easeInCore(gradient: number): number;
  5470. }
  5471. /**
  5472. * Easing function with a power of 4 shape (see link below).
  5473. * @see https://easings.net/#easeInQuart
  5474. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5475. */
  5476. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5477. /** @hidden */
  5478. easeInCore(gradient: number): number;
  5479. }
  5480. /**
  5481. * Easing function with a power of 5 shape (see link below).
  5482. * @see https://easings.net/#easeInQuint
  5483. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5484. */
  5485. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5486. /** @hidden */
  5487. easeInCore(gradient: number): number;
  5488. }
  5489. /**
  5490. * Easing function with a sin shape (see link below).
  5491. * @see https://easings.net/#easeInSine
  5492. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5493. */
  5494. export class SineEase extends EasingFunction implements IEasingFunction {
  5495. /** @hidden */
  5496. easeInCore(gradient: number): number;
  5497. }
  5498. /**
  5499. * Easing function with a bezier shape (see link below).
  5500. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5501. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5502. */
  5503. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5504. /** Defines the x component of the start tangent in the bezier curve */
  5505. x1: number;
  5506. /** Defines the y component of the start tangent in the bezier curve */
  5507. y1: number;
  5508. /** Defines the x component of the end tangent in the bezier curve */
  5509. x2: number;
  5510. /** Defines the y component of the end tangent in the bezier curve */
  5511. y2: number;
  5512. /**
  5513. * Instantiates a bezier function
  5514. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5515. * @param x1 Defines the x component of the start tangent in the bezier curve
  5516. * @param y1 Defines the y component of the start tangent in the bezier curve
  5517. * @param x2 Defines the x component of the end tangent in the bezier curve
  5518. * @param y2 Defines the y component of the end tangent in the bezier curve
  5519. */
  5520. constructor(
  5521. /** Defines the x component of the start tangent in the bezier curve */
  5522. x1?: number,
  5523. /** Defines the y component of the start tangent in the bezier curve */
  5524. y1?: number,
  5525. /** Defines the x component of the end tangent in the bezier curve */
  5526. x2?: number,
  5527. /** Defines the y component of the end tangent in the bezier curve */
  5528. y2?: number);
  5529. /** @hidden */
  5530. easeInCore(gradient: number): number;
  5531. }
  5532. }
  5533. declare module "babylonjs/Maths/math.color" {
  5534. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5535. /**
  5536. * Class used to hold a RBG color
  5537. */
  5538. export class Color3 {
  5539. /**
  5540. * Defines the red component (between 0 and 1, default is 0)
  5541. */
  5542. r: number;
  5543. /**
  5544. * Defines the green component (between 0 and 1, default is 0)
  5545. */
  5546. g: number;
  5547. /**
  5548. * Defines the blue component (between 0 and 1, default is 0)
  5549. */
  5550. b: number;
  5551. /**
  5552. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5553. * @param r defines the red component (between 0 and 1, default is 0)
  5554. * @param g defines the green component (between 0 and 1, default is 0)
  5555. * @param b defines the blue component (between 0 and 1, default is 0)
  5556. */
  5557. constructor(
  5558. /**
  5559. * Defines the red component (between 0 and 1, default is 0)
  5560. */
  5561. r?: number,
  5562. /**
  5563. * Defines the green component (between 0 and 1, default is 0)
  5564. */
  5565. g?: number,
  5566. /**
  5567. * Defines the blue component (between 0 and 1, default is 0)
  5568. */
  5569. b?: number);
  5570. /**
  5571. * Creates a string with the Color3 current values
  5572. * @returns the string representation of the Color3 object
  5573. */
  5574. toString(): string;
  5575. /**
  5576. * Returns the string "Color3"
  5577. * @returns "Color3"
  5578. */
  5579. getClassName(): string;
  5580. /**
  5581. * Compute the Color3 hash code
  5582. * @returns an unique number that can be used to hash Color3 objects
  5583. */
  5584. getHashCode(): number;
  5585. /**
  5586. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5587. * @param array defines the array where to store the r,g,b components
  5588. * @param index defines an optional index in the target array to define where to start storing values
  5589. * @returns the current Color3 object
  5590. */
  5591. toArray(array: FloatArray, index?: number): Color3;
  5592. /**
  5593. * Update the current color with values stored in an array from the starting index of the given array
  5594. * @param array defines the source array
  5595. * @param offset defines an offset in the source array
  5596. * @returns the current Color3 object
  5597. */
  5598. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5599. /**
  5600. * Returns a new Color4 object from the current Color3 and the given alpha
  5601. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5602. * @returns a new Color4 object
  5603. */
  5604. toColor4(alpha?: number): Color4;
  5605. /**
  5606. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5607. * @returns the new array
  5608. */
  5609. asArray(): number[];
  5610. /**
  5611. * Returns the luminance value
  5612. * @returns a float value
  5613. */
  5614. toLuminance(): number;
  5615. /**
  5616. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5617. * @param otherColor defines the second operand
  5618. * @returns the new Color3 object
  5619. */
  5620. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5621. /**
  5622. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5623. * @param otherColor defines the second operand
  5624. * @param result defines the Color3 object where to store the result
  5625. * @returns the current Color3
  5626. */
  5627. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5628. /**
  5629. * Determines equality between Color3 objects
  5630. * @param otherColor defines the second operand
  5631. * @returns true if the rgb values are equal to the given ones
  5632. */
  5633. equals(otherColor: DeepImmutable<Color3>): boolean;
  5634. /**
  5635. * Determines equality between the current Color3 object and a set of r,b,g values
  5636. * @param r defines the red component to check
  5637. * @param g defines the green component to check
  5638. * @param b defines the blue component to check
  5639. * @returns true if the rgb values are equal to the given ones
  5640. */
  5641. equalsFloats(r: number, g: number, b: number): boolean;
  5642. /**
  5643. * Multiplies in place each rgb value by scale
  5644. * @param scale defines the scaling factor
  5645. * @returns the updated Color3
  5646. */
  5647. scale(scale: number): Color3;
  5648. /**
  5649. * Multiplies the rgb values by scale and stores the result into "result"
  5650. * @param scale defines the scaling factor
  5651. * @param result defines the Color3 object where to store the result
  5652. * @returns the unmodified current Color3
  5653. */
  5654. scaleToRef(scale: number, result: Color3): Color3;
  5655. /**
  5656. * Scale the current Color3 values by a factor and add the result to a given Color3
  5657. * @param scale defines the scale factor
  5658. * @param result defines color to store the result into
  5659. * @returns the unmodified current Color3
  5660. */
  5661. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5662. /**
  5663. * Clamps the rgb values by the min and max values and stores the result into "result"
  5664. * @param min defines minimum clamping value (default is 0)
  5665. * @param max defines maximum clamping value (default is 1)
  5666. * @param result defines color to store the result into
  5667. * @returns the original Color3
  5668. */
  5669. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5670. /**
  5671. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5672. * @param otherColor defines the second operand
  5673. * @returns the new Color3
  5674. */
  5675. add(otherColor: DeepImmutable<Color3>): Color3;
  5676. /**
  5677. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5678. * @param otherColor defines the second operand
  5679. * @param result defines Color3 object to store the result into
  5680. * @returns the unmodified current Color3
  5681. */
  5682. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5683. /**
  5684. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5685. * @param otherColor defines the second operand
  5686. * @returns the new Color3
  5687. */
  5688. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5689. /**
  5690. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5691. * @param otherColor defines the second operand
  5692. * @param result defines Color3 object to store the result into
  5693. * @returns the unmodified current Color3
  5694. */
  5695. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5696. /**
  5697. * Copy the current object
  5698. * @returns a new Color3 copied the current one
  5699. */
  5700. clone(): Color3;
  5701. /**
  5702. * Copies the rgb values from the source in the current Color3
  5703. * @param source defines the source Color3 object
  5704. * @returns the updated Color3 object
  5705. */
  5706. copyFrom(source: DeepImmutable<Color3>): Color3;
  5707. /**
  5708. * Updates the Color3 rgb values from the given floats
  5709. * @param r defines the red component to read from
  5710. * @param g defines the green component to read from
  5711. * @param b defines the blue component to read from
  5712. * @returns the current Color3 object
  5713. */
  5714. copyFromFloats(r: number, g: number, b: number): Color3;
  5715. /**
  5716. * Updates the Color3 rgb values from the given floats
  5717. * @param r defines the red component to read from
  5718. * @param g defines the green component to read from
  5719. * @param b defines the blue component to read from
  5720. * @returns the current Color3 object
  5721. */
  5722. set(r: number, g: number, b: number): Color3;
  5723. /**
  5724. * Compute the Color3 hexadecimal code as a string
  5725. * @returns a string containing the hexadecimal representation of the Color3 object
  5726. */
  5727. toHexString(): string;
  5728. /**
  5729. * Computes a new Color3 converted from the current one to linear space
  5730. * @returns a new Color3 object
  5731. */
  5732. toLinearSpace(): Color3;
  5733. /**
  5734. * Converts current color in rgb space to HSV values
  5735. * @returns a new color3 representing the HSV values
  5736. */
  5737. toHSV(): Color3;
  5738. /**
  5739. * Converts current color in rgb space to HSV values
  5740. * @param result defines the Color3 where to store the HSV values
  5741. */
  5742. toHSVToRef(result: Color3): void;
  5743. /**
  5744. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5745. * @param convertedColor defines the Color3 object where to store the linear space version
  5746. * @returns the unmodified Color3
  5747. */
  5748. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5749. /**
  5750. * Computes a new Color3 converted from the current one to gamma space
  5751. * @returns a new Color3 object
  5752. */
  5753. toGammaSpace(): Color3;
  5754. /**
  5755. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5756. * @param convertedColor defines the Color3 object where to store the gamma space version
  5757. * @returns the unmodified Color3
  5758. */
  5759. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5760. private static _BlackReadOnly;
  5761. /**
  5762. * Convert Hue, saturation and value to a Color3 (RGB)
  5763. * @param hue defines the hue
  5764. * @param saturation defines the saturation
  5765. * @param value defines the value
  5766. * @param result defines the Color3 where to store the RGB values
  5767. */
  5768. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5769. /**
  5770. * Creates a new Color3 from the string containing valid hexadecimal values
  5771. * @param hex defines a string containing valid hexadecimal values
  5772. * @returns a new Color3 object
  5773. */
  5774. static FromHexString(hex: string): Color3;
  5775. /**
  5776. * Creates a new Color3 from the starting index of the given array
  5777. * @param array defines the source array
  5778. * @param offset defines an offset in the source array
  5779. * @returns a new Color3 object
  5780. */
  5781. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5782. /**
  5783. * Creates a new Color3 from the starting index element of the given array
  5784. * @param array defines the source array to read from
  5785. * @param offset defines the offset in the source array
  5786. * @param result defines the target Color3 object
  5787. */
  5788. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5789. /**
  5790. * Creates a new Color3 from integer values (< 256)
  5791. * @param r defines the red component to read from (value between 0 and 255)
  5792. * @param g defines the green component to read from (value between 0 and 255)
  5793. * @param b defines the blue component to read from (value between 0 and 255)
  5794. * @returns a new Color3 object
  5795. */
  5796. static FromInts(r: number, g: number, b: number): Color3;
  5797. /**
  5798. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5799. * @param start defines the start Color3 value
  5800. * @param end defines the end Color3 value
  5801. * @param amount defines the gradient value between start and end
  5802. * @returns a new Color3 object
  5803. */
  5804. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5805. /**
  5806. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5807. * @param left defines the start value
  5808. * @param right defines the end value
  5809. * @param amount defines the gradient factor
  5810. * @param result defines the Color3 object where to store the result
  5811. */
  5812. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5813. /**
  5814. * Returns a Color3 value containing a red color
  5815. * @returns a new Color3 object
  5816. */
  5817. static Red(): Color3;
  5818. /**
  5819. * Returns a Color3 value containing a green color
  5820. * @returns a new Color3 object
  5821. */
  5822. static Green(): Color3;
  5823. /**
  5824. * Returns a Color3 value containing a blue color
  5825. * @returns a new Color3 object
  5826. */
  5827. static Blue(): Color3;
  5828. /**
  5829. * Returns a Color3 value containing a black color
  5830. * @returns a new Color3 object
  5831. */
  5832. static Black(): Color3;
  5833. /**
  5834. * Gets a Color3 value containing a black color that must not be updated
  5835. */
  5836. static get BlackReadOnly(): DeepImmutable<Color3>;
  5837. /**
  5838. * Returns a Color3 value containing a white color
  5839. * @returns a new Color3 object
  5840. */
  5841. static White(): Color3;
  5842. /**
  5843. * Returns a Color3 value containing a purple color
  5844. * @returns a new Color3 object
  5845. */
  5846. static Purple(): Color3;
  5847. /**
  5848. * Returns a Color3 value containing a magenta color
  5849. * @returns a new Color3 object
  5850. */
  5851. static Magenta(): Color3;
  5852. /**
  5853. * Returns a Color3 value containing a yellow color
  5854. * @returns a new Color3 object
  5855. */
  5856. static Yellow(): Color3;
  5857. /**
  5858. * Returns a Color3 value containing a gray color
  5859. * @returns a new Color3 object
  5860. */
  5861. static Gray(): Color3;
  5862. /**
  5863. * Returns a Color3 value containing a teal color
  5864. * @returns a new Color3 object
  5865. */
  5866. static Teal(): Color3;
  5867. /**
  5868. * Returns a Color3 value containing a random color
  5869. * @returns a new Color3 object
  5870. */
  5871. static Random(): Color3;
  5872. }
  5873. /**
  5874. * Class used to hold a RBGA color
  5875. */
  5876. export class Color4 {
  5877. /**
  5878. * Defines the red component (between 0 and 1, default is 0)
  5879. */
  5880. r: number;
  5881. /**
  5882. * Defines the green component (between 0 and 1, default is 0)
  5883. */
  5884. g: number;
  5885. /**
  5886. * Defines the blue component (between 0 and 1, default is 0)
  5887. */
  5888. b: number;
  5889. /**
  5890. * Defines the alpha component (between 0 and 1, default is 1)
  5891. */
  5892. a: number;
  5893. /**
  5894. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5895. * @param r defines the red component (between 0 and 1, default is 0)
  5896. * @param g defines the green component (between 0 and 1, default is 0)
  5897. * @param b defines the blue component (between 0 and 1, default is 0)
  5898. * @param a defines the alpha component (between 0 and 1, default is 1)
  5899. */
  5900. constructor(
  5901. /**
  5902. * Defines the red component (between 0 and 1, default is 0)
  5903. */
  5904. r?: number,
  5905. /**
  5906. * Defines the green component (between 0 and 1, default is 0)
  5907. */
  5908. g?: number,
  5909. /**
  5910. * Defines the blue component (between 0 and 1, default is 0)
  5911. */
  5912. b?: number,
  5913. /**
  5914. * Defines the alpha component (between 0 and 1, default is 1)
  5915. */
  5916. a?: number);
  5917. /**
  5918. * Adds in place the given Color4 values to the current Color4 object
  5919. * @param right defines the second operand
  5920. * @returns the current updated Color4 object
  5921. */
  5922. addInPlace(right: DeepImmutable<Color4>): Color4;
  5923. /**
  5924. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5925. * @returns the new array
  5926. */
  5927. asArray(): number[];
  5928. /**
  5929. * Stores from the starting index in the given array the Color4 successive values
  5930. * @param array defines the array where to store the r,g,b components
  5931. * @param index defines an optional index in the target array to define where to start storing values
  5932. * @returns the current Color4 object
  5933. */
  5934. toArray(array: number[], index?: number): Color4;
  5935. /**
  5936. * Update the current color with values stored in an array from the starting index of the given array
  5937. * @param array defines the source array
  5938. * @param offset defines an offset in the source array
  5939. * @returns the current Color4 object
  5940. */
  5941. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5942. /**
  5943. * Determines equality between Color4 objects
  5944. * @param otherColor defines the second operand
  5945. * @returns true if the rgba values are equal to the given ones
  5946. */
  5947. equals(otherColor: DeepImmutable<Color4>): boolean;
  5948. /**
  5949. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5950. * @param right defines the second operand
  5951. * @returns a new Color4 object
  5952. */
  5953. add(right: DeepImmutable<Color4>): Color4;
  5954. /**
  5955. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5956. * @param right defines the second operand
  5957. * @returns a new Color4 object
  5958. */
  5959. subtract(right: DeepImmutable<Color4>): Color4;
  5960. /**
  5961. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5962. * @param right defines the second operand
  5963. * @param result defines the Color4 object where to store the result
  5964. * @returns the current Color4 object
  5965. */
  5966. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5967. /**
  5968. * Creates a new Color4 with the current Color4 values multiplied by scale
  5969. * @param scale defines the scaling factor to apply
  5970. * @returns a new Color4 object
  5971. */
  5972. scale(scale: number): Color4;
  5973. /**
  5974. * Multiplies the current Color4 values by scale and stores the result in "result"
  5975. * @param scale defines the scaling factor to apply
  5976. * @param result defines the Color4 object where to store the result
  5977. * @returns the current unmodified Color4
  5978. */
  5979. scaleToRef(scale: number, result: Color4): Color4;
  5980. /**
  5981. * Scale the current Color4 values by a factor and add the result to a given Color4
  5982. * @param scale defines the scale factor
  5983. * @param result defines the Color4 object where to store the result
  5984. * @returns the unmodified current Color4
  5985. */
  5986. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5987. /**
  5988. * Clamps the rgb values by the min and max values and stores the result into "result"
  5989. * @param min defines minimum clamping value (default is 0)
  5990. * @param max defines maximum clamping value (default is 1)
  5991. * @param result defines color to store the result into.
  5992. * @returns the cuurent Color4
  5993. */
  5994. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5995. /**
  5996. * Multipy an Color4 value by another and return a new Color4 object
  5997. * @param color defines the Color4 value to multiply by
  5998. * @returns a new Color4 object
  5999. */
  6000. multiply(color: Color4): Color4;
  6001. /**
  6002. * Multipy a Color4 value by another and push the result in a reference value
  6003. * @param color defines the Color4 value to multiply by
  6004. * @param result defines the Color4 to fill the result in
  6005. * @returns the result Color4
  6006. */
  6007. multiplyToRef(color: Color4, result: Color4): Color4;
  6008. /**
  6009. * Creates a string with the Color4 current values
  6010. * @returns the string representation of the Color4 object
  6011. */
  6012. toString(): string;
  6013. /**
  6014. * Returns the string "Color4"
  6015. * @returns "Color4"
  6016. */
  6017. getClassName(): string;
  6018. /**
  6019. * Compute the Color4 hash code
  6020. * @returns an unique number that can be used to hash Color4 objects
  6021. */
  6022. getHashCode(): number;
  6023. /**
  6024. * Creates a new Color4 copied from the current one
  6025. * @returns a new Color4 object
  6026. */
  6027. clone(): Color4;
  6028. /**
  6029. * Copies the given Color4 values into the current one
  6030. * @param source defines the source Color4 object
  6031. * @returns the current updated Color4 object
  6032. */
  6033. copyFrom(source: Color4): Color4;
  6034. /**
  6035. * Copies the given float values into the current one
  6036. * @param r defines the red component to read from
  6037. * @param g defines the green component to read from
  6038. * @param b defines the blue component to read from
  6039. * @param a defines the alpha component to read from
  6040. * @returns the current updated Color4 object
  6041. */
  6042. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6043. /**
  6044. * Copies the given float values into the current one
  6045. * @param r defines the red component to read from
  6046. * @param g defines the green component to read from
  6047. * @param b defines the blue component to read from
  6048. * @param a defines the alpha component to read from
  6049. * @returns the current updated Color4 object
  6050. */
  6051. set(r: number, g: number, b: number, a: number): Color4;
  6052. /**
  6053. * Compute the Color4 hexadecimal code as a string
  6054. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6055. * @returns a string containing the hexadecimal representation of the Color4 object
  6056. */
  6057. toHexString(returnAsColor3?: boolean): string;
  6058. /**
  6059. * Computes a new Color4 converted from the current one to linear space
  6060. * @returns a new Color4 object
  6061. */
  6062. toLinearSpace(): Color4;
  6063. /**
  6064. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6065. * @param convertedColor defines the Color4 object where to store the linear space version
  6066. * @returns the unmodified Color4
  6067. */
  6068. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6069. /**
  6070. * Computes a new Color4 converted from the current one to gamma space
  6071. * @returns a new Color4 object
  6072. */
  6073. toGammaSpace(): Color4;
  6074. /**
  6075. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6076. * @param convertedColor defines the Color4 object where to store the gamma space version
  6077. * @returns the unmodified Color4
  6078. */
  6079. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6080. /**
  6081. * Creates a new Color4 from the string containing valid hexadecimal values
  6082. * @param hex defines a string containing valid hexadecimal values
  6083. * @returns a new Color4 object
  6084. */
  6085. static FromHexString(hex: string): Color4;
  6086. /**
  6087. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6088. * @param left defines the start value
  6089. * @param right defines the end value
  6090. * @param amount defines the gradient factor
  6091. * @returns a new Color4 object
  6092. */
  6093. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6094. /**
  6095. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6096. * @param left defines the start value
  6097. * @param right defines the end value
  6098. * @param amount defines the gradient factor
  6099. * @param result defines the Color4 object where to store data
  6100. */
  6101. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6102. /**
  6103. * Creates a new Color4 from a Color3 and an alpha value
  6104. * @param color3 defines the source Color3 to read from
  6105. * @param alpha defines the alpha component (1.0 by default)
  6106. * @returns a new Color4 object
  6107. */
  6108. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6109. /**
  6110. * Creates a new Color4 from the starting index element of the given array
  6111. * @param array defines the source array to read from
  6112. * @param offset defines the offset in the source array
  6113. * @returns a new Color4 object
  6114. */
  6115. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6116. /**
  6117. * Creates a new Color4 from the starting index element of the given array
  6118. * @param array defines the source array to read from
  6119. * @param offset defines the offset in the source array
  6120. * @param result defines the target Color4 object
  6121. */
  6122. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6123. /**
  6124. * Creates a new Color3 from integer values (< 256)
  6125. * @param r defines the red component to read from (value between 0 and 255)
  6126. * @param g defines the green component to read from (value between 0 and 255)
  6127. * @param b defines the blue component to read from (value between 0 and 255)
  6128. * @param a defines the alpha component to read from (value between 0 and 255)
  6129. * @returns a new Color3 object
  6130. */
  6131. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6132. /**
  6133. * Check the content of a given array and convert it to an array containing RGBA data
  6134. * If the original array was already containing count * 4 values then it is returned directly
  6135. * @param colors defines the array to check
  6136. * @param count defines the number of RGBA data to expect
  6137. * @returns an array containing count * 4 values (RGBA)
  6138. */
  6139. static CheckColors4(colors: number[], count: number): number[];
  6140. }
  6141. /**
  6142. * @hidden
  6143. */
  6144. export class TmpColors {
  6145. static Color3: Color3[];
  6146. static Color4: Color4[];
  6147. }
  6148. }
  6149. declare module "babylonjs/Animations/animationKey" {
  6150. /**
  6151. * Defines an interface which represents an animation key frame
  6152. */
  6153. export interface IAnimationKey {
  6154. /**
  6155. * Frame of the key frame
  6156. */
  6157. frame: number;
  6158. /**
  6159. * Value at the specifies key frame
  6160. */
  6161. value: any;
  6162. /**
  6163. * The input tangent for the cubic hermite spline
  6164. */
  6165. inTangent?: any;
  6166. /**
  6167. * The output tangent for the cubic hermite spline
  6168. */
  6169. outTangent?: any;
  6170. /**
  6171. * The animation interpolation type
  6172. */
  6173. interpolation?: AnimationKeyInterpolation;
  6174. }
  6175. /**
  6176. * Enum for the animation key frame interpolation type
  6177. */
  6178. export enum AnimationKeyInterpolation {
  6179. /**
  6180. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6181. */
  6182. STEP = 1
  6183. }
  6184. }
  6185. declare module "babylonjs/Animations/animationRange" {
  6186. /**
  6187. * Represents the range of an animation
  6188. */
  6189. export class AnimationRange {
  6190. /**The name of the animation range**/
  6191. name: string;
  6192. /**The starting frame of the animation */
  6193. from: number;
  6194. /**The ending frame of the animation*/
  6195. to: number;
  6196. /**
  6197. * Initializes the range of an animation
  6198. * @param name The name of the animation range
  6199. * @param from The starting frame of the animation
  6200. * @param to The ending frame of the animation
  6201. */
  6202. constructor(
  6203. /**The name of the animation range**/
  6204. name: string,
  6205. /**The starting frame of the animation */
  6206. from: number,
  6207. /**The ending frame of the animation*/
  6208. to: number);
  6209. /**
  6210. * Makes a copy of the animation range
  6211. * @returns A copy of the animation range
  6212. */
  6213. clone(): AnimationRange;
  6214. }
  6215. }
  6216. declare module "babylonjs/Animations/animationEvent" {
  6217. /**
  6218. * Composed of a frame, and an action function
  6219. */
  6220. export class AnimationEvent {
  6221. /** The frame for which the event is triggered **/
  6222. frame: number;
  6223. /** The event to perform when triggered **/
  6224. action: (currentFrame: number) => void;
  6225. /** Specifies if the event should be triggered only once**/
  6226. onlyOnce?: boolean | undefined;
  6227. /**
  6228. * Specifies if the animation event is done
  6229. */
  6230. isDone: boolean;
  6231. /**
  6232. * Initializes the animation event
  6233. * @param frame The frame for which the event is triggered
  6234. * @param action The event to perform when triggered
  6235. * @param onlyOnce Specifies if the event should be triggered only once
  6236. */
  6237. constructor(
  6238. /** The frame for which the event is triggered **/
  6239. frame: number,
  6240. /** The event to perform when triggered **/
  6241. action: (currentFrame: number) => void,
  6242. /** Specifies if the event should be triggered only once**/
  6243. onlyOnce?: boolean | undefined);
  6244. /** @hidden */
  6245. _clone(): AnimationEvent;
  6246. }
  6247. }
  6248. declare module "babylonjs/Behaviors/behavior" {
  6249. import { Nullable } from "babylonjs/types";
  6250. /**
  6251. * Interface used to define a behavior
  6252. */
  6253. export interface Behavior<T> {
  6254. /** gets or sets behavior's name */
  6255. name: string;
  6256. /**
  6257. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6258. */
  6259. init(): void;
  6260. /**
  6261. * Called when the behavior is attached to a target
  6262. * @param target defines the target where the behavior is attached to
  6263. */
  6264. attach(target: T): void;
  6265. /**
  6266. * Called when the behavior is detached from its target
  6267. */
  6268. detach(): void;
  6269. }
  6270. /**
  6271. * Interface implemented by classes supporting behaviors
  6272. */
  6273. export interface IBehaviorAware<T> {
  6274. /**
  6275. * Attach a behavior
  6276. * @param behavior defines the behavior to attach
  6277. * @returns the current host
  6278. */
  6279. addBehavior(behavior: Behavior<T>): T;
  6280. /**
  6281. * Remove a behavior from the current object
  6282. * @param behavior defines the behavior to detach
  6283. * @returns the current host
  6284. */
  6285. removeBehavior(behavior: Behavior<T>): T;
  6286. /**
  6287. * Gets a behavior using its name to search
  6288. * @param name defines the name to search
  6289. * @returns the behavior or null if not found
  6290. */
  6291. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6292. }
  6293. }
  6294. declare module "babylonjs/Misc/smartArray" {
  6295. /**
  6296. * Defines an array and its length.
  6297. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6298. */
  6299. export interface ISmartArrayLike<T> {
  6300. /**
  6301. * The data of the array.
  6302. */
  6303. data: Array<T>;
  6304. /**
  6305. * The active length of the array.
  6306. */
  6307. length: number;
  6308. }
  6309. /**
  6310. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6311. */
  6312. export class SmartArray<T> implements ISmartArrayLike<T> {
  6313. /**
  6314. * The full set of data from the array.
  6315. */
  6316. data: Array<T>;
  6317. /**
  6318. * The active length of the array.
  6319. */
  6320. length: number;
  6321. protected _id: number;
  6322. /**
  6323. * Instantiates a Smart Array.
  6324. * @param capacity defines the default capacity of the array.
  6325. */
  6326. constructor(capacity: number);
  6327. /**
  6328. * Pushes a value at the end of the active data.
  6329. * @param value defines the object to push in the array.
  6330. */
  6331. push(value: T): void;
  6332. /**
  6333. * Iterates over the active data and apply the lambda to them.
  6334. * @param func defines the action to apply on each value.
  6335. */
  6336. forEach(func: (content: T) => void): void;
  6337. /**
  6338. * Sorts the full sets of data.
  6339. * @param compareFn defines the comparison function to apply.
  6340. */
  6341. sort(compareFn: (a: T, b: T) => number): void;
  6342. /**
  6343. * Resets the active data to an empty array.
  6344. */
  6345. reset(): void;
  6346. /**
  6347. * Releases all the data from the array as well as the array.
  6348. */
  6349. dispose(): void;
  6350. /**
  6351. * Concats the active data with a given array.
  6352. * @param array defines the data to concatenate with.
  6353. */
  6354. concat(array: any): void;
  6355. /**
  6356. * Returns the position of a value in the active data.
  6357. * @param value defines the value to find the index for
  6358. * @returns the index if found in the active data otherwise -1
  6359. */
  6360. indexOf(value: T): number;
  6361. /**
  6362. * Returns whether an element is part of the active data.
  6363. * @param value defines the value to look for
  6364. * @returns true if found in the active data otherwise false
  6365. */
  6366. contains(value: T): boolean;
  6367. private static _GlobalId;
  6368. }
  6369. /**
  6370. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6371. * The data in this array can only be present once
  6372. */
  6373. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6374. private _duplicateId;
  6375. /**
  6376. * Pushes a value at the end of the active data.
  6377. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6378. * @param value defines the object to push in the array.
  6379. */
  6380. push(value: T): void;
  6381. /**
  6382. * Pushes a value at the end of the active data.
  6383. * If the data is already present, it won t be added again
  6384. * @param value defines the object to push in the array.
  6385. * @returns true if added false if it was already present
  6386. */
  6387. pushNoDuplicate(value: T): boolean;
  6388. /**
  6389. * Resets the active data to an empty array.
  6390. */
  6391. reset(): void;
  6392. /**
  6393. * Concats the active data with a given array.
  6394. * This ensures no dupplicate will be present in the result.
  6395. * @param array defines the data to concatenate with.
  6396. */
  6397. concatWithNoDuplicate(array: any): void;
  6398. }
  6399. }
  6400. declare module "babylonjs/Cameras/cameraInputsManager" {
  6401. import { Nullable } from "babylonjs/types";
  6402. import { Camera } from "babylonjs/Cameras/camera";
  6403. /**
  6404. * @ignore
  6405. * This is a list of all the different input types that are available in the application.
  6406. * Fo instance: ArcRotateCameraGamepadInput...
  6407. */
  6408. export var CameraInputTypes: {};
  6409. /**
  6410. * This is the contract to implement in order to create a new input class.
  6411. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6412. */
  6413. export interface ICameraInput<TCamera extends Camera> {
  6414. /**
  6415. * Defines the camera the input is attached to.
  6416. */
  6417. camera: Nullable<TCamera>;
  6418. /**
  6419. * Gets the class name of the current intput.
  6420. * @returns the class name
  6421. */
  6422. getClassName(): string;
  6423. /**
  6424. * Get the friendly name associated with the input class.
  6425. * @returns the input friendly name
  6426. */
  6427. getSimpleName(): string;
  6428. /**
  6429. * Attach the input controls to a specific dom element to get the input from.
  6430. * @param element Defines the element the controls should be listened from
  6431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6432. */
  6433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6434. /**
  6435. * Detach the current controls from the specified dom element.
  6436. * @param element Defines the element to stop listening the inputs from
  6437. */
  6438. detachControl(element: Nullable<HTMLElement>): void;
  6439. /**
  6440. * Update the current camera state depending on the inputs that have been used this frame.
  6441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6442. */
  6443. checkInputs?: () => void;
  6444. }
  6445. /**
  6446. * Represents a map of input types to input instance or input index to input instance.
  6447. */
  6448. export interface CameraInputsMap<TCamera extends Camera> {
  6449. /**
  6450. * Accessor to the input by input type.
  6451. */
  6452. [name: string]: ICameraInput<TCamera>;
  6453. /**
  6454. * Accessor to the input by input index.
  6455. */
  6456. [idx: number]: ICameraInput<TCamera>;
  6457. }
  6458. /**
  6459. * This represents the input manager used within a camera.
  6460. * It helps dealing with all the different kind of input attached to a camera.
  6461. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6462. */
  6463. export class CameraInputsManager<TCamera extends Camera> {
  6464. /**
  6465. * Defines the list of inputs attahed to the camera.
  6466. */
  6467. attached: CameraInputsMap<TCamera>;
  6468. /**
  6469. * Defines the dom element the camera is collecting inputs from.
  6470. * This is null if the controls have not been attached.
  6471. */
  6472. attachedElement: Nullable<HTMLElement>;
  6473. /**
  6474. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6475. */
  6476. noPreventDefault: boolean;
  6477. /**
  6478. * Defined the camera the input manager belongs to.
  6479. */
  6480. camera: TCamera;
  6481. /**
  6482. * Update the current camera state depending on the inputs that have been used this frame.
  6483. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6484. */
  6485. checkInputs: () => void;
  6486. /**
  6487. * Instantiate a new Camera Input Manager.
  6488. * @param camera Defines the camera the input manager blongs to
  6489. */
  6490. constructor(camera: TCamera);
  6491. /**
  6492. * Add an input method to a camera
  6493. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6494. * @param input camera input method
  6495. */
  6496. add(input: ICameraInput<TCamera>): void;
  6497. /**
  6498. * Remove a specific input method from a camera
  6499. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6500. * @param inputToRemove camera input method
  6501. */
  6502. remove(inputToRemove: ICameraInput<TCamera>): void;
  6503. /**
  6504. * Remove a specific input type from a camera
  6505. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6506. * @param inputType the type of the input to remove
  6507. */
  6508. removeByType(inputType: string): void;
  6509. private _addCheckInputs;
  6510. /**
  6511. * Attach the input controls to the currently attached dom element to listen the events from.
  6512. * @param input Defines the input to attach
  6513. */
  6514. attachInput(input: ICameraInput<TCamera>): void;
  6515. /**
  6516. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6517. * @param element Defines the dom element to collect the events from
  6518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6519. */
  6520. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6521. /**
  6522. * Detach the current manager inputs controls from a specific dom element.
  6523. * @param element Defines the dom element to collect the events from
  6524. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6525. */
  6526. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6527. /**
  6528. * Rebuild the dynamic inputCheck function from the current list of
  6529. * defined inputs in the manager.
  6530. */
  6531. rebuildInputCheck(): void;
  6532. /**
  6533. * Remove all attached input methods from a camera
  6534. */
  6535. clear(): void;
  6536. /**
  6537. * Serialize the current input manager attached to a camera.
  6538. * This ensures than once parsed,
  6539. * the input associated to the camera will be identical to the current ones
  6540. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6541. */
  6542. serialize(serializedCamera: any): void;
  6543. /**
  6544. * Parses an input manager serialized JSON to restore the previous list of inputs
  6545. * and states associated to a camera.
  6546. * @param parsedCamera Defines the JSON to parse
  6547. */
  6548. parse(parsedCamera: any): void;
  6549. }
  6550. }
  6551. declare module "babylonjs/Meshes/buffer" {
  6552. import { Nullable, DataArray } from "babylonjs/types";
  6553. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6554. /**
  6555. * Class used to store data that will be store in GPU memory
  6556. */
  6557. export class Buffer {
  6558. private _engine;
  6559. private _buffer;
  6560. /** @hidden */
  6561. _data: Nullable<DataArray>;
  6562. private _updatable;
  6563. private _instanced;
  6564. private _divisor;
  6565. /**
  6566. * Gets the byte stride.
  6567. */
  6568. readonly byteStride: number;
  6569. /**
  6570. * Constructor
  6571. * @param engine the engine
  6572. * @param data the data to use for this buffer
  6573. * @param updatable whether the data is updatable
  6574. * @param stride the stride (optional)
  6575. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6576. * @param instanced whether the buffer is instanced (optional)
  6577. * @param useBytes set to true if the stride in in bytes (optional)
  6578. * @param divisor sets an optional divisor for instances (1 by default)
  6579. */
  6580. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6581. /**
  6582. * Create a new VertexBuffer based on the current buffer
  6583. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6584. * @param offset defines offset in the buffer (0 by default)
  6585. * @param size defines the size in floats of attributes (position is 3 for instance)
  6586. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6587. * @param instanced defines if the vertex buffer contains indexed data
  6588. * @param useBytes defines if the offset and stride are in bytes *
  6589. * @param divisor sets an optional divisor for instances (1 by default)
  6590. * @returns the new vertex buffer
  6591. */
  6592. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6593. /**
  6594. * Gets a boolean indicating if the Buffer is updatable?
  6595. * @returns true if the buffer is updatable
  6596. */
  6597. isUpdatable(): boolean;
  6598. /**
  6599. * Gets current buffer's data
  6600. * @returns a DataArray or null
  6601. */
  6602. getData(): Nullable<DataArray>;
  6603. /**
  6604. * Gets underlying native buffer
  6605. * @returns underlying native buffer
  6606. */
  6607. getBuffer(): Nullable<DataBuffer>;
  6608. /**
  6609. * Gets the stride in float32 units (i.e. byte stride / 4).
  6610. * May not be an integer if the byte stride is not divisible by 4.
  6611. * @returns the stride in float32 units
  6612. * @deprecated Please use byteStride instead.
  6613. */
  6614. getStrideSize(): number;
  6615. /**
  6616. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6617. * @param data defines the data to store
  6618. */
  6619. create(data?: Nullable<DataArray>): void;
  6620. /** @hidden */
  6621. _rebuild(): void;
  6622. /**
  6623. * Update current buffer data
  6624. * @param data defines the data to store
  6625. */
  6626. update(data: DataArray): void;
  6627. /**
  6628. * Updates the data directly.
  6629. * @param data the new data
  6630. * @param offset the new offset
  6631. * @param vertexCount the vertex count (optional)
  6632. * @param useBytes set to true if the offset is in bytes
  6633. */
  6634. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6635. /**
  6636. * Release all resources
  6637. */
  6638. dispose(): void;
  6639. }
  6640. /**
  6641. * Specialized buffer used to store vertex data
  6642. */
  6643. export class VertexBuffer {
  6644. /** @hidden */
  6645. _buffer: Buffer;
  6646. private _kind;
  6647. private _size;
  6648. private _ownsBuffer;
  6649. private _instanced;
  6650. private _instanceDivisor;
  6651. /**
  6652. * The byte type.
  6653. */
  6654. static readonly BYTE: number;
  6655. /**
  6656. * The unsigned byte type.
  6657. */
  6658. static readonly UNSIGNED_BYTE: number;
  6659. /**
  6660. * The short type.
  6661. */
  6662. static readonly SHORT: number;
  6663. /**
  6664. * The unsigned short type.
  6665. */
  6666. static readonly UNSIGNED_SHORT: number;
  6667. /**
  6668. * The integer type.
  6669. */
  6670. static readonly INT: number;
  6671. /**
  6672. * The unsigned integer type.
  6673. */
  6674. static readonly UNSIGNED_INT: number;
  6675. /**
  6676. * The float type.
  6677. */
  6678. static readonly FLOAT: number;
  6679. /**
  6680. * Gets or sets the instance divisor when in instanced mode
  6681. */
  6682. get instanceDivisor(): number;
  6683. set instanceDivisor(value: number);
  6684. /**
  6685. * Gets the byte stride.
  6686. */
  6687. readonly byteStride: number;
  6688. /**
  6689. * Gets the byte offset.
  6690. */
  6691. readonly byteOffset: number;
  6692. /**
  6693. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6694. */
  6695. readonly normalized: boolean;
  6696. /**
  6697. * Gets the data type of each component in the array.
  6698. */
  6699. readonly type: number;
  6700. /**
  6701. * Constructor
  6702. * @param engine the engine
  6703. * @param data the data to use for this vertex buffer
  6704. * @param kind the vertex buffer kind
  6705. * @param updatable whether the data is updatable
  6706. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6707. * @param stride the stride (optional)
  6708. * @param instanced whether the buffer is instanced (optional)
  6709. * @param offset the offset of the data (optional)
  6710. * @param size the number of components (optional)
  6711. * @param type the type of the component (optional)
  6712. * @param normalized whether the data contains normalized data (optional)
  6713. * @param useBytes set to true if stride and offset are in bytes (optional)
  6714. * @param divisor defines the instance divisor to use (1 by default)
  6715. */
  6716. 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);
  6717. /** @hidden */
  6718. _rebuild(): void;
  6719. /**
  6720. * Returns the kind of the VertexBuffer (string)
  6721. * @returns a string
  6722. */
  6723. getKind(): string;
  6724. /**
  6725. * Gets a boolean indicating if the VertexBuffer is updatable?
  6726. * @returns true if the buffer is updatable
  6727. */
  6728. isUpdatable(): boolean;
  6729. /**
  6730. * Gets current buffer's data
  6731. * @returns a DataArray or null
  6732. */
  6733. getData(): Nullable<DataArray>;
  6734. /**
  6735. * Gets underlying native buffer
  6736. * @returns underlying native buffer
  6737. */
  6738. getBuffer(): Nullable<DataBuffer>;
  6739. /**
  6740. * Gets the stride in float32 units (i.e. byte stride / 4).
  6741. * May not be an integer if the byte stride is not divisible by 4.
  6742. * @returns the stride in float32 units
  6743. * @deprecated Please use byteStride instead.
  6744. */
  6745. getStrideSize(): number;
  6746. /**
  6747. * Returns the offset as a multiple of the type byte length.
  6748. * @returns the offset in bytes
  6749. * @deprecated Please use byteOffset instead.
  6750. */
  6751. getOffset(): number;
  6752. /**
  6753. * Returns the number of components per vertex attribute (integer)
  6754. * @returns the size in float
  6755. */
  6756. getSize(): number;
  6757. /**
  6758. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6759. * @returns true if this buffer is instanced
  6760. */
  6761. getIsInstanced(): boolean;
  6762. /**
  6763. * Returns the instancing divisor, zero for non-instanced (integer).
  6764. * @returns a number
  6765. */
  6766. getInstanceDivisor(): number;
  6767. /**
  6768. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6769. * @param data defines the data to store
  6770. */
  6771. create(data?: DataArray): void;
  6772. /**
  6773. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6774. * This function will create a new buffer if the current one is not updatable
  6775. * @param data defines the data to store
  6776. */
  6777. update(data: DataArray): void;
  6778. /**
  6779. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6780. * Returns the directly updated WebGLBuffer.
  6781. * @param data the new data
  6782. * @param offset the new offset
  6783. * @param useBytes set to true if the offset is in bytes
  6784. */
  6785. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6786. /**
  6787. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6788. */
  6789. dispose(): void;
  6790. /**
  6791. * Enumerates each value of this vertex buffer as numbers.
  6792. * @param count the number of values to enumerate
  6793. * @param callback the callback function called for each value
  6794. */
  6795. forEach(count: number, callback: (value: number, index: number) => void): void;
  6796. /**
  6797. * Positions
  6798. */
  6799. static readonly PositionKind: string;
  6800. /**
  6801. * Normals
  6802. */
  6803. static readonly NormalKind: string;
  6804. /**
  6805. * Tangents
  6806. */
  6807. static readonly TangentKind: string;
  6808. /**
  6809. * Texture coordinates
  6810. */
  6811. static readonly UVKind: string;
  6812. /**
  6813. * Texture coordinates 2
  6814. */
  6815. static readonly UV2Kind: string;
  6816. /**
  6817. * Texture coordinates 3
  6818. */
  6819. static readonly UV3Kind: string;
  6820. /**
  6821. * Texture coordinates 4
  6822. */
  6823. static readonly UV4Kind: string;
  6824. /**
  6825. * Texture coordinates 5
  6826. */
  6827. static readonly UV5Kind: string;
  6828. /**
  6829. * Texture coordinates 6
  6830. */
  6831. static readonly UV6Kind: string;
  6832. /**
  6833. * Colors
  6834. */
  6835. static readonly ColorKind: string;
  6836. /**
  6837. * Matrix indices (for bones)
  6838. */
  6839. static readonly MatricesIndicesKind: string;
  6840. /**
  6841. * Matrix weights (for bones)
  6842. */
  6843. static readonly MatricesWeightsKind: string;
  6844. /**
  6845. * Additional matrix indices (for bones)
  6846. */
  6847. static readonly MatricesIndicesExtraKind: string;
  6848. /**
  6849. * Additional matrix weights (for bones)
  6850. */
  6851. static readonly MatricesWeightsExtraKind: string;
  6852. /**
  6853. * Deduces the stride given a kind.
  6854. * @param kind The kind string to deduce
  6855. * @returns The deduced stride
  6856. */
  6857. static DeduceStride(kind: string): number;
  6858. /**
  6859. * Gets the byte length of the given type.
  6860. * @param type the type
  6861. * @returns the number of bytes
  6862. */
  6863. static GetTypeByteLength(type: number): number;
  6864. /**
  6865. * Enumerates each value of the given parameters as numbers.
  6866. * @param data the data to enumerate
  6867. * @param byteOffset the byte offset of the data
  6868. * @param byteStride the byte stride of the data
  6869. * @param componentCount the number of components per element
  6870. * @param componentType the type of the component
  6871. * @param count the number of values to enumerate
  6872. * @param normalized whether the data is normalized
  6873. * @param callback the callback function called for each value
  6874. */
  6875. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6876. private static _GetFloatValue;
  6877. }
  6878. }
  6879. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6880. import { Vector3 } from "babylonjs/Maths/math.vector";
  6881. import { Mesh } from "babylonjs/Meshes/mesh";
  6882. /**
  6883. * The options Interface for creating a Capsule Mesh
  6884. */
  6885. export interface ICreateCapsuleOptions {
  6886. /** The Orientation of the capsule. Default : Vector3.Up() */
  6887. orientation?: Vector3;
  6888. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6889. subdivisions: number;
  6890. /** Number of cylindrical segments on the capsule. */
  6891. tessellation: number;
  6892. /** Height or Length of the capsule. */
  6893. height: number;
  6894. /** Radius of the capsule. */
  6895. radius: number;
  6896. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6897. capSubdivisions: number;
  6898. /** Overwrite for the top radius. */
  6899. radiusTop?: number;
  6900. /** Overwrite for the bottom radius. */
  6901. radiusBottom?: number;
  6902. /** Overwrite for the top capSubdivisions. */
  6903. topCapSubdivisions?: number;
  6904. /** Overwrite for the bottom capSubdivisions. */
  6905. bottomCapSubdivisions?: number;
  6906. }
  6907. /**
  6908. * Class containing static functions to help procedurally build meshes
  6909. */
  6910. export class CapsuleBuilder {
  6911. /**
  6912. * Creates a capsule or a pill mesh
  6913. * @param name defines the name of the mesh
  6914. * @param options The constructors options.
  6915. * @param scene The scene the mesh is scoped to.
  6916. * @returns Capsule Mesh
  6917. */
  6918. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6919. }
  6920. }
  6921. declare module "babylonjs/Collisions/intersectionInfo" {
  6922. import { Nullable } from "babylonjs/types";
  6923. /**
  6924. * @hidden
  6925. */
  6926. export class IntersectionInfo {
  6927. bu: Nullable<number>;
  6928. bv: Nullable<number>;
  6929. distance: number;
  6930. faceId: number;
  6931. subMeshId: number;
  6932. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6933. }
  6934. }
  6935. declare module "babylonjs/Culling/boundingSphere" {
  6936. import { DeepImmutable } from "babylonjs/types";
  6937. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6938. import { Plane } from "babylonjs/Maths/math.plane";
  6939. /**
  6940. * Class used to store bounding sphere information
  6941. */
  6942. export class BoundingSphere {
  6943. /**
  6944. * Gets the center of the bounding sphere in local space
  6945. */
  6946. readonly center: Vector3;
  6947. /**
  6948. * Radius of the bounding sphere in local space
  6949. */
  6950. radius: number;
  6951. /**
  6952. * Gets the center of the bounding sphere in world space
  6953. */
  6954. readonly centerWorld: Vector3;
  6955. /**
  6956. * Radius of the bounding sphere in world space
  6957. */
  6958. radiusWorld: number;
  6959. /**
  6960. * Gets the minimum vector in local space
  6961. */
  6962. readonly minimum: Vector3;
  6963. /**
  6964. * Gets the maximum vector in local space
  6965. */
  6966. readonly maximum: Vector3;
  6967. private _worldMatrix;
  6968. private static readonly TmpVector3;
  6969. /**
  6970. * Creates a new bounding sphere
  6971. * @param min defines the minimum vector (in local space)
  6972. * @param max defines the maximum vector (in local space)
  6973. * @param worldMatrix defines the new world matrix
  6974. */
  6975. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6976. /**
  6977. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6978. * @param min defines the new minimum vector (in local space)
  6979. * @param max defines the new maximum vector (in local space)
  6980. * @param worldMatrix defines the new world matrix
  6981. */
  6982. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6983. /**
  6984. * Scale the current bounding sphere by applying a scale factor
  6985. * @param factor defines the scale factor to apply
  6986. * @returns the current bounding box
  6987. */
  6988. scale(factor: number): BoundingSphere;
  6989. /**
  6990. * Gets the world matrix of the bounding box
  6991. * @returns a matrix
  6992. */
  6993. getWorldMatrix(): DeepImmutable<Matrix>;
  6994. /** @hidden */
  6995. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6996. /**
  6997. * Tests if the bounding sphere is intersecting the frustum planes
  6998. * @param frustumPlanes defines the frustum planes to test
  6999. * @returns true if there is an intersection
  7000. */
  7001. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7002. /**
  7003. * Tests if the bounding sphere center is in between the frustum planes.
  7004. * Used for optimistic fast inclusion.
  7005. * @param frustumPlanes defines the frustum planes to test
  7006. * @returns true if the sphere center is in between the frustum planes
  7007. */
  7008. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7009. /**
  7010. * Tests if a point is inside the bounding sphere
  7011. * @param point defines the point to test
  7012. * @returns true if the point is inside the bounding sphere
  7013. */
  7014. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7015. /**
  7016. * Checks if two sphere intersct
  7017. * @param sphere0 sphere 0
  7018. * @param sphere1 sphere 1
  7019. * @returns true if the speres intersect
  7020. */
  7021. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7022. }
  7023. }
  7024. declare module "babylonjs/Culling/boundingBox" {
  7025. import { DeepImmutable } from "babylonjs/types";
  7026. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7027. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7028. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7029. import { Plane } from "babylonjs/Maths/math.plane";
  7030. /**
  7031. * Class used to store bounding box information
  7032. */
  7033. export class BoundingBox implements ICullable {
  7034. /**
  7035. * Gets the 8 vectors representing the bounding box in local space
  7036. */
  7037. readonly vectors: Vector3[];
  7038. /**
  7039. * Gets the center of the bounding box in local space
  7040. */
  7041. readonly center: Vector3;
  7042. /**
  7043. * Gets the center of the bounding box in world space
  7044. */
  7045. readonly centerWorld: Vector3;
  7046. /**
  7047. * Gets the extend size in local space
  7048. */
  7049. readonly extendSize: Vector3;
  7050. /**
  7051. * Gets the extend size in world space
  7052. */
  7053. readonly extendSizeWorld: Vector3;
  7054. /**
  7055. * Gets the OBB (object bounding box) directions
  7056. */
  7057. readonly directions: Vector3[];
  7058. /**
  7059. * Gets the 8 vectors representing the bounding box in world space
  7060. */
  7061. readonly vectorsWorld: Vector3[];
  7062. /**
  7063. * Gets the minimum vector in world space
  7064. */
  7065. readonly minimumWorld: Vector3;
  7066. /**
  7067. * Gets the maximum vector in world space
  7068. */
  7069. readonly maximumWorld: Vector3;
  7070. /**
  7071. * Gets the minimum vector in local space
  7072. */
  7073. readonly minimum: Vector3;
  7074. /**
  7075. * Gets the maximum vector in local space
  7076. */
  7077. readonly maximum: Vector3;
  7078. private _worldMatrix;
  7079. private static readonly TmpVector3;
  7080. /**
  7081. * @hidden
  7082. */
  7083. _tag: number;
  7084. /**
  7085. * Creates a new bounding box
  7086. * @param min defines the minimum vector (in local space)
  7087. * @param max defines the maximum vector (in local space)
  7088. * @param worldMatrix defines the new world matrix
  7089. */
  7090. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7091. /**
  7092. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7093. * @param min defines the new minimum vector (in local space)
  7094. * @param max defines the new maximum vector (in local space)
  7095. * @param worldMatrix defines the new world matrix
  7096. */
  7097. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7098. /**
  7099. * Scale the current bounding box by applying a scale factor
  7100. * @param factor defines the scale factor to apply
  7101. * @returns the current bounding box
  7102. */
  7103. scale(factor: number): BoundingBox;
  7104. /**
  7105. * Gets the world matrix of the bounding box
  7106. * @returns a matrix
  7107. */
  7108. getWorldMatrix(): DeepImmutable<Matrix>;
  7109. /** @hidden */
  7110. _update(world: DeepImmutable<Matrix>): void;
  7111. /**
  7112. * Tests if the bounding box is intersecting the frustum planes
  7113. * @param frustumPlanes defines the frustum planes to test
  7114. * @returns true if there is an intersection
  7115. */
  7116. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7117. /**
  7118. * Tests if the bounding box is entirely inside the frustum planes
  7119. * @param frustumPlanes defines the frustum planes to test
  7120. * @returns true if there is an inclusion
  7121. */
  7122. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7123. /**
  7124. * Tests if a point is inside the bounding box
  7125. * @param point defines the point to test
  7126. * @returns true if the point is inside the bounding box
  7127. */
  7128. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7129. /**
  7130. * Tests if the bounding box intersects with a bounding sphere
  7131. * @param sphere defines the sphere to test
  7132. * @returns true if there is an intersection
  7133. */
  7134. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7135. /**
  7136. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7137. * @param min defines the min vector to use
  7138. * @param max defines the max vector to use
  7139. * @returns true if there is an intersection
  7140. */
  7141. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7142. /**
  7143. * Tests if two bounding boxes are intersections
  7144. * @param box0 defines the first box to test
  7145. * @param box1 defines the second box to test
  7146. * @returns true if there is an intersection
  7147. */
  7148. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7149. /**
  7150. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7151. * @param minPoint defines the minimum vector of the bounding box
  7152. * @param maxPoint defines the maximum vector of the bounding box
  7153. * @param sphereCenter defines the sphere center
  7154. * @param sphereRadius defines the sphere radius
  7155. * @returns true if there is an intersection
  7156. */
  7157. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7158. /**
  7159. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7160. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7161. * @param frustumPlanes defines the frustum planes to test
  7162. * @return true if there is an inclusion
  7163. */
  7164. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7165. /**
  7166. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7167. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7168. * @param frustumPlanes defines the frustum planes to test
  7169. * @return true if there is an intersection
  7170. */
  7171. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7172. }
  7173. }
  7174. declare module "babylonjs/Collisions/collider" {
  7175. import { Nullable, IndicesArray } from "babylonjs/types";
  7176. import { Vector3 } from "babylonjs/Maths/math.vector";
  7177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7178. import { Plane } from "babylonjs/Maths/math.plane";
  7179. /** @hidden */
  7180. export class Collider {
  7181. /** Define if a collision was found */
  7182. collisionFound: boolean;
  7183. /**
  7184. * Define last intersection point in local space
  7185. */
  7186. intersectionPoint: Vector3;
  7187. /**
  7188. * Define last collided mesh
  7189. */
  7190. collidedMesh: Nullable<AbstractMesh>;
  7191. private _collisionPoint;
  7192. private _planeIntersectionPoint;
  7193. private _tempVector;
  7194. private _tempVector2;
  7195. private _tempVector3;
  7196. private _tempVector4;
  7197. private _edge;
  7198. private _baseToVertex;
  7199. private _destinationPoint;
  7200. private _slidePlaneNormal;
  7201. private _displacementVector;
  7202. /** @hidden */
  7203. _radius: Vector3;
  7204. /** @hidden */
  7205. _retry: number;
  7206. private _velocity;
  7207. private _basePoint;
  7208. private _epsilon;
  7209. /** @hidden */
  7210. _velocityWorldLength: number;
  7211. /** @hidden */
  7212. _basePointWorld: Vector3;
  7213. private _velocityWorld;
  7214. private _normalizedVelocity;
  7215. /** @hidden */
  7216. _initialVelocity: Vector3;
  7217. /** @hidden */
  7218. _initialPosition: Vector3;
  7219. private _nearestDistance;
  7220. private _collisionMask;
  7221. get collisionMask(): number;
  7222. set collisionMask(mask: number);
  7223. /**
  7224. * Gets the plane normal used to compute the sliding response (in local space)
  7225. */
  7226. get slidePlaneNormal(): Vector3;
  7227. /** @hidden */
  7228. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7229. /** @hidden */
  7230. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7231. /** @hidden */
  7232. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7233. /** @hidden */
  7234. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7235. /** @hidden */
  7236. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7237. /** @hidden */
  7238. _getResponse(pos: Vector3, vel: Vector3): void;
  7239. }
  7240. }
  7241. declare module "babylonjs/Culling/boundingInfo" {
  7242. import { DeepImmutable } from "babylonjs/types";
  7243. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7244. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7245. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7246. import { Plane } from "babylonjs/Maths/math.plane";
  7247. import { Collider } from "babylonjs/Collisions/collider";
  7248. /**
  7249. * Interface for cullable objects
  7250. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7251. */
  7252. export interface ICullable {
  7253. /**
  7254. * Checks if the object or part of the object is in the frustum
  7255. * @param frustumPlanes Camera near/planes
  7256. * @returns true if the object is in frustum otherwise false
  7257. */
  7258. isInFrustum(frustumPlanes: Plane[]): boolean;
  7259. /**
  7260. * Checks if a cullable object (mesh...) is in the camera frustum
  7261. * Unlike isInFrustum this cheks the full bounding box
  7262. * @param frustumPlanes Camera near/planes
  7263. * @returns true if the object is in frustum otherwise false
  7264. */
  7265. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7266. }
  7267. /**
  7268. * Info for a bounding data of a mesh
  7269. */
  7270. export class BoundingInfo implements ICullable {
  7271. /**
  7272. * Bounding box for the mesh
  7273. */
  7274. readonly boundingBox: BoundingBox;
  7275. /**
  7276. * Bounding sphere for the mesh
  7277. */
  7278. readonly boundingSphere: BoundingSphere;
  7279. private _isLocked;
  7280. private static readonly TmpVector3;
  7281. /**
  7282. * Constructs bounding info
  7283. * @param minimum min vector of the bounding box/sphere
  7284. * @param maximum max vector of the bounding box/sphere
  7285. * @param worldMatrix defines the new world matrix
  7286. */
  7287. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7288. /**
  7289. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7290. * @param min defines the new minimum vector (in local space)
  7291. * @param max defines the new maximum vector (in local space)
  7292. * @param worldMatrix defines the new world matrix
  7293. */
  7294. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7295. /**
  7296. * min vector of the bounding box/sphere
  7297. */
  7298. get minimum(): Vector3;
  7299. /**
  7300. * max vector of the bounding box/sphere
  7301. */
  7302. get maximum(): Vector3;
  7303. /**
  7304. * If the info is locked and won't be updated to avoid perf overhead
  7305. */
  7306. get isLocked(): boolean;
  7307. set isLocked(value: boolean);
  7308. /**
  7309. * Updates the bounding sphere and box
  7310. * @param world world matrix to be used to update
  7311. */
  7312. update(world: DeepImmutable<Matrix>): void;
  7313. /**
  7314. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7315. * @param center New center of the bounding info
  7316. * @param extend New extend of the bounding info
  7317. * @returns the current bounding info
  7318. */
  7319. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7320. /**
  7321. * Scale the current bounding info by applying a scale factor
  7322. * @param factor defines the scale factor to apply
  7323. * @returns the current bounding info
  7324. */
  7325. scale(factor: number): BoundingInfo;
  7326. /**
  7327. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7328. * @param frustumPlanes defines the frustum to test
  7329. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7330. * @returns true if the bounding info is in the frustum planes
  7331. */
  7332. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7333. /**
  7334. * Gets the world distance between the min and max points of the bounding box
  7335. */
  7336. get diagonalLength(): number;
  7337. /**
  7338. * Checks if a cullable object (mesh...) is in the camera frustum
  7339. * Unlike isInFrustum this cheks the full bounding box
  7340. * @param frustumPlanes Camera near/planes
  7341. * @returns true if the object is in frustum otherwise false
  7342. */
  7343. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7344. /** @hidden */
  7345. _checkCollision(collider: Collider): boolean;
  7346. /**
  7347. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7348. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7349. * @param point the point to check intersection with
  7350. * @returns if the point intersects
  7351. */
  7352. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7353. /**
  7354. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7355. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7356. * @param boundingInfo the bounding info to check intersection with
  7357. * @param precise if the intersection should be done using OBB
  7358. * @returns if the bounding info intersects
  7359. */
  7360. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7361. }
  7362. }
  7363. declare module "babylonjs/Maths/math.functions" {
  7364. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7365. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7366. /**
  7367. * Extracts minimum and maximum values from a list of indexed positions
  7368. * @param positions defines the positions to use
  7369. * @param indices defines the indices to the positions
  7370. * @param indexStart defines the start index
  7371. * @param indexCount defines the end index
  7372. * @param bias defines bias value to add to the result
  7373. * @return minimum and maximum values
  7374. */
  7375. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7376. minimum: Vector3;
  7377. maximum: Vector3;
  7378. };
  7379. /**
  7380. * Extracts minimum and maximum values from a list of positions
  7381. * @param positions defines the positions to use
  7382. * @param start defines the start index in the positions array
  7383. * @param count defines the number of positions to handle
  7384. * @param bias defines bias value to add to the result
  7385. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7386. * @return minimum and maximum values
  7387. */
  7388. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7389. minimum: Vector3;
  7390. maximum: Vector3;
  7391. };
  7392. }
  7393. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7394. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7395. /** @hidden */
  7396. export class WebGLDataBuffer extends DataBuffer {
  7397. private _buffer;
  7398. constructor(resource: WebGLBuffer);
  7399. get underlyingResource(): any;
  7400. }
  7401. }
  7402. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7403. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7404. import { Nullable } from "babylonjs/types";
  7405. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7406. /** @hidden */
  7407. export class WebGLPipelineContext implements IPipelineContext {
  7408. engine: ThinEngine;
  7409. program: Nullable<WebGLProgram>;
  7410. context?: WebGLRenderingContext;
  7411. vertexShader?: WebGLShader;
  7412. fragmentShader?: WebGLShader;
  7413. isParallelCompiled: boolean;
  7414. onCompiled?: () => void;
  7415. transformFeedback?: WebGLTransformFeedback | null;
  7416. vertexCompilationError: Nullable<string>;
  7417. fragmentCompilationError: Nullable<string>;
  7418. programLinkError: Nullable<string>;
  7419. programValidationError: Nullable<string>;
  7420. get isAsync(): boolean;
  7421. get isReady(): boolean;
  7422. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7423. _getVertexShaderCode(): string | null;
  7424. _getFragmentShaderCode(): string | null;
  7425. }
  7426. }
  7427. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7428. import { FloatArray, Nullable } from "babylonjs/types";
  7429. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7430. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7431. module "babylonjs/Engines/thinEngine" {
  7432. interface ThinEngine {
  7433. /**
  7434. * Create an uniform buffer
  7435. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7436. * @param elements defines the content of the uniform buffer
  7437. * @returns the webGL uniform buffer
  7438. */
  7439. createUniformBuffer(elements: FloatArray): DataBuffer;
  7440. /**
  7441. * Create a dynamic uniform buffer
  7442. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7443. * @param elements defines the content of the uniform buffer
  7444. * @returns the webGL uniform buffer
  7445. */
  7446. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7447. /**
  7448. * Update an existing uniform buffer
  7449. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7450. * @param uniformBuffer defines the target uniform buffer
  7451. * @param elements defines the content to update
  7452. * @param offset defines the offset in the uniform buffer where update should start
  7453. * @param count defines the size of the data to update
  7454. */
  7455. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7456. /**
  7457. * Bind an uniform buffer to the current webGL context
  7458. * @param buffer defines the buffer to bind
  7459. */
  7460. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7461. /**
  7462. * Bind a buffer to the current webGL context at a given location
  7463. * @param buffer defines the buffer to bind
  7464. * @param location defines the index where to bind the buffer
  7465. */
  7466. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7467. /**
  7468. * Bind a specific block at a given index in a specific shader program
  7469. * @param pipelineContext defines the pipeline context to use
  7470. * @param blockName defines the block name
  7471. * @param index defines the index where to bind the block
  7472. */
  7473. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7474. }
  7475. }
  7476. }
  7477. declare module "babylonjs/Materials/uniformBuffer" {
  7478. import { Nullable, FloatArray } from "babylonjs/types";
  7479. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7480. import { Engine } from "babylonjs/Engines/engine";
  7481. import { Effect } from "babylonjs/Materials/effect";
  7482. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7483. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7484. import { Color3 } from "babylonjs/Maths/math.color";
  7485. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7486. /**
  7487. * Uniform buffer objects.
  7488. *
  7489. * Handles blocks of uniform on the GPU.
  7490. *
  7491. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7492. *
  7493. * For more information, please refer to :
  7494. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7495. */
  7496. export class UniformBuffer {
  7497. private _engine;
  7498. private _buffer;
  7499. private _data;
  7500. private _bufferData;
  7501. private _dynamic?;
  7502. private _uniformLocations;
  7503. private _uniformSizes;
  7504. private _uniformLocationPointer;
  7505. private _needSync;
  7506. private _noUBO;
  7507. private _currentEffect;
  7508. /** @hidden */
  7509. _alreadyBound: boolean;
  7510. private static _MAX_UNIFORM_SIZE;
  7511. private static _tempBuffer;
  7512. /**
  7513. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7518. /**
  7519. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7520. * This is dynamic to allow compat with webgl 1 and 2.
  7521. * You will need to pass the name of the uniform as well as the value.
  7522. */
  7523. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7524. /**
  7525. * Lambda to Update a single float in a uniform buffer.
  7526. * This is dynamic to allow compat with webgl 1 and 2.
  7527. * You will need to pass the name of the uniform as well as the value.
  7528. */
  7529. updateFloat: (name: string, x: number) => void;
  7530. /**
  7531. * Lambda to Update a vec2 of float in a uniform buffer.
  7532. * This is dynamic to allow compat with webgl 1 and 2.
  7533. * You will need to pass the name of the uniform as well as the value.
  7534. */
  7535. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7536. /**
  7537. * Lambda to Update a vec3 of float in a uniform buffer.
  7538. * This is dynamic to allow compat with webgl 1 and 2.
  7539. * You will need to pass the name of the uniform as well as the value.
  7540. */
  7541. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7542. /**
  7543. * Lambda to Update a vec4 of float in a uniform buffer.
  7544. * This is dynamic to allow compat with webgl 1 and 2.
  7545. * You will need to pass the name of the uniform as well as the value.
  7546. */
  7547. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7548. /**
  7549. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7550. * This is dynamic to allow compat with webgl 1 and 2.
  7551. * You will need to pass the name of the uniform as well as the value.
  7552. */
  7553. updateMatrix: (name: string, mat: Matrix) => void;
  7554. /**
  7555. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7556. * This is dynamic to allow compat with webgl 1 and 2.
  7557. * You will need to pass the name of the uniform as well as the value.
  7558. */
  7559. updateVector3: (name: string, vector: Vector3) => void;
  7560. /**
  7561. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7562. * This is dynamic to allow compat with webgl 1 and 2.
  7563. * You will need to pass the name of the uniform as well as the value.
  7564. */
  7565. updateVector4: (name: string, vector: Vector4) => void;
  7566. /**
  7567. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7568. * This is dynamic to allow compat with webgl 1 and 2.
  7569. * You will need to pass the name of the uniform as well as the value.
  7570. */
  7571. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7572. /**
  7573. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7574. * This is dynamic to allow compat with webgl 1 and 2.
  7575. * You will need to pass the name of the uniform as well as the value.
  7576. */
  7577. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7578. /**
  7579. * Instantiates a new Uniform buffer objects.
  7580. *
  7581. * Handles blocks of uniform on the GPU.
  7582. *
  7583. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7584. *
  7585. * For more information, please refer to :
  7586. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7587. * @param engine Define the engine the buffer is associated with
  7588. * @param data Define the data contained in the buffer
  7589. * @param dynamic Define if the buffer is updatable
  7590. */
  7591. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7592. /**
  7593. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7594. * or just falling back on setUniformXXX calls.
  7595. */
  7596. get useUbo(): boolean;
  7597. /**
  7598. * Indicates if the WebGL underlying uniform buffer is in sync
  7599. * with the javascript cache data.
  7600. */
  7601. get isSync(): boolean;
  7602. /**
  7603. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7604. * Also, a dynamic UniformBuffer will disable cache verification and always
  7605. * update the underlying WebGL uniform buffer to the GPU.
  7606. * @returns if Dynamic, otherwise false
  7607. */
  7608. isDynamic(): boolean;
  7609. /**
  7610. * The data cache on JS side.
  7611. * @returns the underlying data as a float array
  7612. */
  7613. getData(): Float32Array;
  7614. /**
  7615. * The underlying WebGL Uniform buffer.
  7616. * @returns the webgl buffer
  7617. */
  7618. getBuffer(): Nullable<DataBuffer>;
  7619. /**
  7620. * std140 layout specifies how to align data within an UBO structure.
  7621. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7622. * for specs.
  7623. */
  7624. private _fillAlignment;
  7625. /**
  7626. * Adds an uniform in the buffer.
  7627. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7628. * for the layout to be correct !
  7629. * @param name Name of the uniform, as used in the uniform block in the shader.
  7630. * @param size Data size, or data directly.
  7631. */
  7632. addUniform(name: string, size: number | number[]): void;
  7633. /**
  7634. * Adds a Matrix 4x4 to the uniform buffer.
  7635. * @param name Name of the uniform, as used in the uniform block in the shader.
  7636. * @param mat A 4x4 matrix.
  7637. */
  7638. addMatrix(name: string, mat: Matrix): void;
  7639. /**
  7640. * Adds a vec2 to the uniform buffer.
  7641. * @param name Name of the uniform, as used in the uniform block in the shader.
  7642. * @param x Define the x component value of the vec2
  7643. * @param y Define the y component value of the vec2
  7644. */
  7645. addFloat2(name: string, x: number, y: number): void;
  7646. /**
  7647. * Adds a vec3 to the uniform buffer.
  7648. * @param name Name of the uniform, as used in the uniform block in the shader.
  7649. * @param x Define the x component value of the vec3
  7650. * @param y Define the y component value of the vec3
  7651. * @param z Define the z component value of the vec3
  7652. */
  7653. addFloat3(name: string, x: number, y: number, z: number): void;
  7654. /**
  7655. * Adds a vec3 to the uniform buffer.
  7656. * @param name Name of the uniform, as used in the uniform block in the shader.
  7657. * @param color Define the vec3 from a Color
  7658. */
  7659. addColor3(name: string, color: Color3): void;
  7660. /**
  7661. * Adds a vec4 to the uniform buffer.
  7662. * @param name Name of the uniform, as used in the uniform block in the shader.
  7663. * @param color Define the rgb components from a Color
  7664. * @param alpha Define the a component of the vec4
  7665. */
  7666. addColor4(name: string, color: Color3, alpha: number): void;
  7667. /**
  7668. * Adds a vec3 to the uniform buffer.
  7669. * @param name Name of the uniform, as used in the uniform block in the shader.
  7670. * @param vector Define the vec3 components from a Vector
  7671. */
  7672. addVector3(name: string, vector: Vector3): void;
  7673. /**
  7674. * Adds a Matrix 3x3 to the uniform buffer.
  7675. * @param name Name of the uniform, as used in the uniform block in the shader.
  7676. */
  7677. addMatrix3x3(name: string): void;
  7678. /**
  7679. * Adds a Matrix 2x2 to the uniform buffer.
  7680. * @param name Name of the uniform, as used in the uniform block in the shader.
  7681. */
  7682. addMatrix2x2(name: string): void;
  7683. /**
  7684. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7685. */
  7686. create(): void;
  7687. /** @hidden */
  7688. _rebuild(): void;
  7689. /**
  7690. * Updates the WebGL Uniform Buffer on the GPU.
  7691. * If the `dynamic` flag is set to true, no cache comparison is done.
  7692. * Otherwise, the buffer will be updated only if the cache differs.
  7693. */
  7694. update(): void;
  7695. /**
  7696. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7697. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7698. * @param data Define the flattened data
  7699. * @param size Define the size of the data.
  7700. */
  7701. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7702. private _valueCache;
  7703. private _cacheMatrix;
  7704. private _updateMatrix3x3ForUniform;
  7705. private _updateMatrix3x3ForEffect;
  7706. private _updateMatrix2x2ForEffect;
  7707. private _updateMatrix2x2ForUniform;
  7708. private _updateFloatForEffect;
  7709. private _updateFloatForUniform;
  7710. private _updateFloat2ForEffect;
  7711. private _updateFloat2ForUniform;
  7712. private _updateFloat3ForEffect;
  7713. private _updateFloat3ForUniform;
  7714. private _updateFloat4ForEffect;
  7715. private _updateFloat4ForUniform;
  7716. private _updateMatrixForEffect;
  7717. private _updateMatrixForUniform;
  7718. private _updateVector3ForEffect;
  7719. private _updateVector3ForUniform;
  7720. private _updateVector4ForEffect;
  7721. private _updateVector4ForUniform;
  7722. private _updateColor3ForEffect;
  7723. private _updateColor3ForUniform;
  7724. private _updateColor4ForEffect;
  7725. private _updateColor4ForUniform;
  7726. /**
  7727. * Sets a sampler uniform on the effect.
  7728. * @param name Define the name of the sampler.
  7729. * @param texture Define the texture to set in the sampler
  7730. */
  7731. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7732. /**
  7733. * Directly updates the value of the uniform in the cache AND on the GPU.
  7734. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7735. * @param data Define the flattened data
  7736. */
  7737. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7738. /**
  7739. * Binds this uniform buffer to an effect.
  7740. * @param effect Define the effect to bind the buffer to
  7741. * @param name Name of the uniform block in the shader.
  7742. */
  7743. bindToEffect(effect: Effect, name: string): void;
  7744. /**
  7745. * Disposes the uniform buffer.
  7746. */
  7747. dispose(): void;
  7748. }
  7749. }
  7750. declare module "babylonjs/Misc/iInspectable" {
  7751. /**
  7752. * Enum that determines the text-wrapping mode to use.
  7753. */
  7754. export enum InspectableType {
  7755. /**
  7756. * Checkbox for booleans
  7757. */
  7758. Checkbox = 0,
  7759. /**
  7760. * Sliders for numbers
  7761. */
  7762. Slider = 1,
  7763. /**
  7764. * Vector3
  7765. */
  7766. Vector3 = 2,
  7767. /**
  7768. * Quaternions
  7769. */
  7770. Quaternion = 3,
  7771. /**
  7772. * Color3
  7773. */
  7774. Color3 = 4,
  7775. /**
  7776. * String
  7777. */
  7778. String = 5
  7779. }
  7780. /**
  7781. * Interface used to define custom inspectable properties.
  7782. * This interface is used by the inspector to display custom property grids
  7783. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7784. */
  7785. export interface IInspectable {
  7786. /**
  7787. * Gets the label to display
  7788. */
  7789. label: string;
  7790. /**
  7791. * Gets the name of the property to edit
  7792. */
  7793. propertyName: string;
  7794. /**
  7795. * Gets the type of the editor to use
  7796. */
  7797. type: InspectableType;
  7798. /**
  7799. * Gets the minimum value of the property when using in "slider" mode
  7800. */
  7801. min?: number;
  7802. /**
  7803. * Gets the maximum value of the property when using in "slider" mode
  7804. */
  7805. max?: number;
  7806. /**
  7807. * Gets the setp to use when using in "slider" mode
  7808. */
  7809. step?: number;
  7810. }
  7811. }
  7812. declare module "babylonjs/Misc/timingTools" {
  7813. /**
  7814. * Class used to provide helper for timing
  7815. */
  7816. export class TimingTools {
  7817. /**
  7818. * Polyfill for setImmediate
  7819. * @param action defines the action to execute after the current execution block
  7820. */
  7821. static SetImmediate(action: () => void): void;
  7822. }
  7823. }
  7824. declare module "babylonjs/Misc/instantiationTools" {
  7825. /**
  7826. * Class used to enable instatition of objects by class name
  7827. */
  7828. export class InstantiationTools {
  7829. /**
  7830. * Use this object to register external classes like custom textures or material
  7831. * to allow the laoders to instantiate them
  7832. */
  7833. static RegisteredExternalClasses: {
  7834. [key: string]: Object;
  7835. };
  7836. /**
  7837. * Tries to instantiate a new object from a given class name
  7838. * @param className defines the class name to instantiate
  7839. * @returns the new object or null if the system was not able to do the instantiation
  7840. */
  7841. static Instantiate(className: string): any;
  7842. }
  7843. }
  7844. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7845. /**
  7846. * Define options used to create a depth texture
  7847. */
  7848. export class DepthTextureCreationOptions {
  7849. /** Specifies whether or not a stencil should be allocated in the texture */
  7850. generateStencil?: boolean;
  7851. /** Specifies whether or not bilinear filtering is enable on the texture */
  7852. bilinearFiltering?: boolean;
  7853. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7854. comparisonFunction?: number;
  7855. /** Specifies if the created texture is a cube texture */
  7856. isCube?: boolean;
  7857. }
  7858. }
  7859. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7860. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7861. import { Nullable } from "babylonjs/types";
  7862. import { Scene } from "babylonjs/scene";
  7863. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7864. module "babylonjs/Engines/thinEngine" {
  7865. interface ThinEngine {
  7866. /**
  7867. * Creates a depth stencil cube texture.
  7868. * This is only available in WebGL 2.
  7869. * @param size The size of face edge in the cube texture.
  7870. * @param options The options defining the cube texture.
  7871. * @returns The cube texture
  7872. */
  7873. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7874. /**
  7875. * Creates a cube texture
  7876. * @param rootUrl defines the url where the files to load is located
  7877. * @param scene defines the current scene
  7878. * @param files defines the list of files to load (1 per face)
  7879. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7880. * @param onLoad defines an optional callback raised when the texture is loaded
  7881. * @param onError defines an optional callback raised if there is an issue to load the texture
  7882. * @param format defines the format of the data
  7883. * @param forcedExtension defines the extension to use to pick the right loader
  7884. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7885. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7886. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7887. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7888. * @returns the cube texture as an InternalTexture
  7889. */
  7890. 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;
  7891. /**
  7892. * Creates a cube texture
  7893. * @param rootUrl defines the url where the files to load is located
  7894. * @param scene defines the current scene
  7895. * @param files defines the list of files to load (1 per face)
  7896. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7897. * @param onLoad defines an optional callback raised when the texture is loaded
  7898. * @param onError defines an optional callback raised if there is an issue to load the texture
  7899. * @param format defines the format of the data
  7900. * @param forcedExtension defines the extension to use to pick the right loader
  7901. * @returns the cube texture as an InternalTexture
  7902. */
  7903. 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;
  7904. /**
  7905. * Creates a cube texture
  7906. * @param rootUrl defines the url where the files to load is located
  7907. * @param scene defines the current scene
  7908. * @param files defines the list of files to load (1 per face)
  7909. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7910. * @param onLoad defines an optional callback raised when the texture is loaded
  7911. * @param onError defines an optional callback raised if there is an issue to load the texture
  7912. * @param format defines the format of the data
  7913. * @param forcedExtension defines the extension to use to pick the right loader
  7914. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7915. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7916. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7917. * @returns the cube texture as an InternalTexture
  7918. */
  7919. 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;
  7920. /** @hidden */
  7921. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7922. /** @hidden */
  7923. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7924. /** @hidden */
  7925. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7926. /** @hidden */
  7927. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7928. /**
  7929. * @hidden
  7930. */
  7931. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7932. }
  7933. }
  7934. }
  7935. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7936. import { Nullable } from "babylonjs/types";
  7937. import { Scene } from "babylonjs/scene";
  7938. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7939. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7940. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7941. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7942. import { Observable } from "babylonjs/Misc/observable";
  7943. /**
  7944. * Class for creating a cube texture
  7945. */
  7946. export class CubeTexture extends BaseTexture {
  7947. private _delayedOnLoad;
  7948. /**
  7949. * Observable triggered once the texture has been loaded.
  7950. */
  7951. onLoadObservable: Observable<CubeTexture>;
  7952. /**
  7953. * The url of the texture
  7954. */
  7955. url: string;
  7956. /**
  7957. * Gets or sets the center of the bounding box associated with the cube texture.
  7958. * It must define where the camera used to render the texture was set
  7959. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7960. */
  7961. boundingBoxPosition: Vector3;
  7962. private _boundingBoxSize;
  7963. /**
  7964. * Gets or sets the size of the bounding box associated with the cube texture
  7965. * When defined, the cubemap will switch to local mode
  7966. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7967. * @example https://www.babylonjs-playground.com/#RNASML
  7968. */
  7969. set boundingBoxSize(value: Vector3);
  7970. /**
  7971. * Returns the bounding box size
  7972. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7973. */
  7974. get boundingBoxSize(): Vector3;
  7975. protected _rotationY: number;
  7976. /**
  7977. * Sets texture matrix rotation angle around Y axis in radians.
  7978. */
  7979. set rotationY(value: number);
  7980. /**
  7981. * Gets texture matrix rotation angle around Y axis radians.
  7982. */
  7983. get rotationY(): number;
  7984. /**
  7985. * Are mip maps generated for this texture or not.
  7986. */
  7987. get noMipmap(): boolean;
  7988. private _noMipmap;
  7989. private _files;
  7990. protected _forcedExtension: Nullable<string>;
  7991. private _extensions;
  7992. private _textureMatrix;
  7993. private _format;
  7994. private _createPolynomials;
  7995. /**
  7996. * Creates a cube texture from an array of image urls
  7997. * @param files defines an array of image urls
  7998. * @param scene defines the hosting scene
  7999. * @param noMipmap specifies if mip maps are not used
  8000. * @returns a cube texture
  8001. */
  8002. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8003. /**
  8004. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8005. * @param url defines the url of the prefiltered texture
  8006. * @param scene defines the scene the texture is attached to
  8007. * @param forcedExtension defines the extension of the file if different from the url
  8008. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8009. * @return the prefiltered texture
  8010. */
  8011. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8012. /**
  8013. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8014. * as prefiltered data.
  8015. * @param rootUrl defines the url of the texture or the root name of the six images
  8016. * @param null defines the scene or engine the texture is attached to
  8017. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8018. * @param noMipmap defines if mipmaps should be created or not
  8019. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8020. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8021. * @param onError defines a callback triggered in case of error during load
  8022. * @param format defines the internal format to use for the texture once loaded
  8023. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8024. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8025. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8026. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8027. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8028. * @return the cube texture
  8029. */
  8030. 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);
  8031. /**
  8032. * Get the current class name of the texture useful for serialization or dynamic coding.
  8033. * @returns "CubeTexture"
  8034. */
  8035. getClassName(): string;
  8036. /**
  8037. * Update the url (and optional buffer) of this texture if url was null during construction.
  8038. * @param url the url of the texture
  8039. * @param forcedExtension defines the extension to use
  8040. * @param onLoad callback called when the texture is loaded (defaults to null)
  8041. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8042. */
  8043. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8044. /**
  8045. * Delays loading of the cube texture
  8046. * @param forcedExtension defines the extension to use
  8047. */
  8048. delayLoad(forcedExtension?: string): void;
  8049. /**
  8050. * Returns the reflection texture matrix
  8051. * @returns the reflection texture matrix
  8052. */
  8053. getReflectionTextureMatrix(): Matrix;
  8054. /**
  8055. * Sets the reflection texture matrix
  8056. * @param value Reflection texture matrix
  8057. */
  8058. setReflectionTextureMatrix(value: Matrix): void;
  8059. /**
  8060. * Parses text to create a cube texture
  8061. * @param parsedTexture define the serialized text to read from
  8062. * @param scene defines the hosting scene
  8063. * @param rootUrl defines the root url of the cube texture
  8064. * @returns a cube texture
  8065. */
  8066. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8067. /**
  8068. * Makes a clone, or deep copy, of the cube texture
  8069. * @returns a new cube texture
  8070. */
  8071. clone(): CubeTexture;
  8072. }
  8073. }
  8074. declare module "babylonjs/Materials/materialDefines" {
  8075. /**
  8076. * Manages the defines for the Material
  8077. */
  8078. export class MaterialDefines {
  8079. /** @hidden */
  8080. protected _keys: string[];
  8081. private _isDirty;
  8082. /** @hidden */
  8083. _renderId: number;
  8084. /** @hidden */
  8085. _areLightsDirty: boolean;
  8086. /** @hidden */
  8087. _areLightsDisposed: boolean;
  8088. /** @hidden */
  8089. _areAttributesDirty: boolean;
  8090. /** @hidden */
  8091. _areTexturesDirty: boolean;
  8092. /** @hidden */
  8093. _areFresnelDirty: boolean;
  8094. /** @hidden */
  8095. _areMiscDirty: boolean;
  8096. /** @hidden */
  8097. _areImageProcessingDirty: boolean;
  8098. /** @hidden */
  8099. _normals: boolean;
  8100. /** @hidden */
  8101. _uvs: boolean;
  8102. /** @hidden */
  8103. _needNormals: boolean;
  8104. /** @hidden */
  8105. _needUVs: boolean;
  8106. [id: string]: any;
  8107. /**
  8108. * Specifies if the material needs to be re-calculated
  8109. */
  8110. get isDirty(): boolean;
  8111. /**
  8112. * Marks the material to indicate that it has been re-calculated
  8113. */
  8114. markAsProcessed(): void;
  8115. /**
  8116. * Marks the material to indicate that it needs to be re-calculated
  8117. */
  8118. markAsUnprocessed(): void;
  8119. /**
  8120. * Marks the material to indicate all of its defines need to be re-calculated
  8121. */
  8122. markAllAsDirty(): void;
  8123. /**
  8124. * Marks the material to indicate that image processing needs to be re-calculated
  8125. */
  8126. markAsImageProcessingDirty(): void;
  8127. /**
  8128. * Marks the material to indicate the lights need to be re-calculated
  8129. * @param disposed Defines whether the light is dirty due to dispose or not
  8130. */
  8131. markAsLightDirty(disposed?: boolean): void;
  8132. /**
  8133. * Marks the attribute state as changed
  8134. */
  8135. markAsAttributesDirty(): void;
  8136. /**
  8137. * Marks the texture state as changed
  8138. */
  8139. markAsTexturesDirty(): void;
  8140. /**
  8141. * Marks the fresnel state as changed
  8142. */
  8143. markAsFresnelDirty(): void;
  8144. /**
  8145. * Marks the misc state as changed
  8146. */
  8147. markAsMiscDirty(): void;
  8148. /**
  8149. * Rebuilds the material defines
  8150. */
  8151. rebuild(): void;
  8152. /**
  8153. * Specifies if two material defines are equal
  8154. * @param other - A material define instance to compare to
  8155. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8156. */
  8157. isEqual(other: MaterialDefines): boolean;
  8158. /**
  8159. * Clones this instance's defines to another instance
  8160. * @param other - material defines to clone values to
  8161. */
  8162. cloneTo(other: MaterialDefines): void;
  8163. /**
  8164. * Resets the material define values
  8165. */
  8166. reset(): void;
  8167. /**
  8168. * Converts the material define values to a string
  8169. * @returns - String of material define information
  8170. */
  8171. toString(): string;
  8172. }
  8173. }
  8174. declare module "babylonjs/Materials/colorCurves" {
  8175. import { Effect } from "babylonjs/Materials/effect";
  8176. /**
  8177. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8178. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8179. * 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;
  8180. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8181. */
  8182. export class ColorCurves {
  8183. private _dirty;
  8184. private _tempColor;
  8185. private _globalCurve;
  8186. private _highlightsCurve;
  8187. private _midtonesCurve;
  8188. private _shadowsCurve;
  8189. private _positiveCurve;
  8190. private _negativeCurve;
  8191. private _globalHue;
  8192. private _globalDensity;
  8193. private _globalSaturation;
  8194. private _globalExposure;
  8195. /**
  8196. * Gets the global Hue value.
  8197. * 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).
  8198. */
  8199. get globalHue(): number;
  8200. /**
  8201. * Sets the global Hue value.
  8202. * 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).
  8203. */
  8204. set globalHue(value: number);
  8205. /**
  8206. * Gets the global Density value.
  8207. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8208. * Values less than zero provide a filter of opposite hue.
  8209. */
  8210. get globalDensity(): number;
  8211. /**
  8212. * Sets the global Density value.
  8213. * 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.
  8214. * Values less than zero provide a filter of opposite hue.
  8215. */
  8216. set globalDensity(value: number);
  8217. /**
  8218. * Gets the global Saturation value.
  8219. * 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.
  8220. */
  8221. get globalSaturation(): number;
  8222. /**
  8223. * Sets the global Saturation value.
  8224. * 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.
  8225. */
  8226. set globalSaturation(value: number);
  8227. /**
  8228. * Gets the global Exposure value.
  8229. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8230. */
  8231. get globalExposure(): number;
  8232. /**
  8233. * Sets the global Exposure value.
  8234. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8235. */
  8236. set globalExposure(value: number);
  8237. private _highlightsHue;
  8238. private _highlightsDensity;
  8239. private _highlightsSaturation;
  8240. private _highlightsExposure;
  8241. /**
  8242. * Gets the highlights Hue value.
  8243. * 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).
  8244. */
  8245. get highlightsHue(): number;
  8246. /**
  8247. * Sets the highlights Hue value.
  8248. * 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).
  8249. */
  8250. set highlightsHue(value: number);
  8251. /**
  8252. * Gets the highlights Density value.
  8253. * 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.
  8254. * Values less than zero provide a filter of opposite hue.
  8255. */
  8256. get highlightsDensity(): number;
  8257. /**
  8258. * Sets the highlights Density value.
  8259. * 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.
  8260. * Values less than zero provide a filter of opposite hue.
  8261. */
  8262. set highlightsDensity(value: number);
  8263. /**
  8264. * Gets the highlights Saturation value.
  8265. * 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.
  8266. */
  8267. get highlightsSaturation(): number;
  8268. /**
  8269. * Sets the highlights Saturation value.
  8270. * 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.
  8271. */
  8272. set highlightsSaturation(value: number);
  8273. /**
  8274. * Gets the highlights Exposure value.
  8275. * 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.
  8276. */
  8277. get highlightsExposure(): number;
  8278. /**
  8279. * Sets the highlights Exposure value.
  8280. * 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.
  8281. */
  8282. set highlightsExposure(value: number);
  8283. private _midtonesHue;
  8284. private _midtonesDensity;
  8285. private _midtonesSaturation;
  8286. private _midtonesExposure;
  8287. /**
  8288. * Gets the midtones Hue value.
  8289. * 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).
  8290. */
  8291. get midtonesHue(): number;
  8292. /**
  8293. * Sets the midtones Hue value.
  8294. * 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).
  8295. */
  8296. set midtonesHue(value: number);
  8297. /**
  8298. * Gets the midtones Density value.
  8299. * 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.
  8300. * Values less than zero provide a filter of opposite hue.
  8301. */
  8302. get midtonesDensity(): number;
  8303. /**
  8304. * Sets the midtones Density value.
  8305. * 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.
  8306. * Values less than zero provide a filter of opposite hue.
  8307. */
  8308. set midtonesDensity(value: number);
  8309. /**
  8310. * Gets the midtones Saturation value.
  8311. * 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.
  8312. */
  8313. get midtonesSaturation(): number;
  8314. /**
  8315. * Sets the midtones Saturation value.
  8316. * 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.
  8317. */
  8318. set midtonesSaturation(value: number);
  8319. /**
  8320. * Gets the midtones Exposure value.
  8321. * 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.
  8322. */
  8323. get midtonesExposure(): number;
  8324. /**
  8325. * Sets the midtones Exposure value.
  8326. * 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.
  8327. */
  8328. set midtonesExposure(value: number);
  8329. private _shadowsHue;
  8330. private _shadowsDensity;
  8331. private _shadowsSaturation;
  8332. private _shadowsExposure;
  8333. /**
  8334. * Gets the shadows Hue value.
  8335. * 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).
  8336. */
  8337. get shadowsHue(): number;
  8338. /**
  8339. * Sets the shadows Hue value.
  8340. * 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).
  8341. */
  8342. set shadowsHue(value: number);
  8343. /**
  8344. * Gets the shadows Density value.
  8345. * 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.
  8346. * Values less than zero provide a filter of opposite hue.
  8347. */
  8348. get shadowsDensity(): number;
  8349. /**
  8350. * Sets the shadows Density value.
  8351. * 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.
  8352. * Values less than zero provide a filter of opposite hue.
  8353. */
  8354. set shadowsDensity(value: number);
  8355. /**
  8356. * Gets the shadows Saturation value.
  8357. * 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.
  8358. */
  8359. get shadowsSaturation(): number;
  8360. /**
  8361. * Sets the shadows Saturation value.
  8362. * 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.
  8363. */
  8364. set shadowsSaturation(value: number);
  8365. /**
  8366. * Gets the shadows Exposure value.
  8367. * 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.
  8368. */
  8369. get shadowsExposure(): number;
  8370. /**
  8371. * Sets the shadows Exposure value.
  8372. * 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.
  8373. */
  8374. set shadowsExposure(value: number);
  8375. /**
  8376. * Returns the class name
  8377. * @returns The class name
  8378. */
  8379. getClassName(): string;
  8380. /**
  8381. * Binds the color curves to the shader.
  8382. * @param colorCurves The color curve to bind
  8383. * @param effect The effect to bind to
  8384. * @param positiveUniform The positive uniform shader parameter
  8385. * @param neutralUniform The neutral uniform shader parameter
  8386. * @param negativeUniform The negative uniform shader parameter
  8387. */
  8388. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8389. /**
  8390. * Prepare the list of uniforms associated with the ColorCurves effects.
  8391. * @param uniformsList The list of uniforms used in the effect
  8392. */
  8393. static PrepareUniforms(uniformsList: string[]): void;
  8394. /**
  8395. * Returns color grading data based on a hue, density, saturation and exposure value.
  8396. * @param filterHue The hue of the color filter.
  8397. * @param filterDensity The density of the color filter.
  8398. * @param saturation The saturation.
  8399. * @param exposure The exposure.
  8400. * @param result The result data container.
  8401. */
  8402. private getColorGradingDataToRef;
  8403. /**
  8404. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8405. * @param value The input slider value in range [-100,100].
  8406. * @returns Adjusted value.
  8407. */
  8408. private static applyColorGradingSliderNonlinear;
  8409. /**
  8410. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8411. * @param hue The hue (H) input.
  8412. * @param saturation The saturation (S) input.
  8413. * @param brightness The brightness (B) input.
  8414. * @result An RGBA color represented as Vector4.
  8415. */
  8416. private static fromHSBToRef;
  8417. /**
  8418. * Returns a value clamped between min and max
  8419. * @param value The value to clamp
  8420. * @param min The minimum of value
  8421. * @param max The maximum of value
  8422. * @returns The clamped value.
  8423. */
  8424. private static clamp;
  8425. /**
  8426. * Clones the current color curve instance.
  8427. * @return The cloned curves
  8428. */
  8429. clone(): ColorCurves;
  8430. /**
  8431. * Serializes the current color curve instance to a json representation.
  8432. * @return a JSON representation
  8433. */
  8434. serialize(): any;
  8435. /**
  8436. * Parses the color curve from a json representation.
  8437. * @param source the JSON source to parse
  8438. * @return The parsed curves
  8439. */
  8440. static Parse(source: any): ColorCurves;
  8441. }
  8442. }
  8443. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8444. import { Observable } from "babylonjs/Misc/observable";
  8445. import { Nullable } from "babylonjs/types";
  8446. import { Color4 } from "babylonjs/Maths/math.color";
  8447. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8448. import { Effect } from "babylonjs/Materials/effect";
  8449. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8450. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8451. /**
  8452. * Interface to follow in your material defines to integrate easily the
  8453. * Image proccessing functions.
  8454. * @hidden
  8455. */
  8456. export interface IImageProcessingConfigurationDefines {
  8457. IMAGEPROCESSING: boolean;
  8458. VIGNETTE: boolean;
  8459. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8460. VIGNETTEBLENDMODEOPAQUE: boolean;
  8461. TONEMAPPING: boolean;
  8462. TONEMAPPING_ACES: boolean;
  8463. CONTRAST: boolean;
  8464. EXPOSURE: boolean;
  8465. COLORCURVES: boolean;
  8466. COLORGRADING: boolean;
  8467. COLORGRADING3D: boolean;
  8468. SAMPLER3DGREENDEPTH: boolean;
  8469. SAMPLER3DBGRMAP: boolean;
  8470. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8471. }
  8472. /**
  8473. * @hidden
  8474. */
  8475. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8476. IMAGEPROCESSING: boolean;
  8477. VIGNETTE: boolean;
  8478. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8479. VIGNETTEBLENDMODEOPAQUE: boolean;
  8480. TONEMAPPING: boolean;
  8481. TONEMAPPING_ACES: boolean;
  8482. CONTRAST: boolean;
  8483. COLORCURVES: boolean;
  8484. COLORGRADING: boolean;
  8485. COLORGRADING3D: boolean;
  8486. SAMPLER3DGREENDEPTH: boolean;
  8487. SAMPLER3DBGRMAP: boolean;
  8488. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8489. EXPOSURE: boolean;
  8490. constructor();
  8491. }
  8492. /**
  8493. * This groups together the common properties used for image processing either in direct forward pass
  8494. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8495. * or not.
  8496. */
  8497. export class ImageProcessingConfiguration {
  8498. /**
  8499. * Default tone mapping applied in BabylonJS.
  8500. */
  8501. static readonly TONEMAPPING_STANDARD: number;
  8502. /**
  8503. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8504. * to other engines rendering to increase portability.
  8505. */
  8506. static readonly TONEMAPPING_ACES: number;
  8507. /**
  8508. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8509. */
  8510. colorCurves: Nullable<ColorCurves>;
  8511. private _colorCurvesEnabled;
  8512. /**
  8513. * Gets wether the color curves effect is enabled.
  8514. */
  8515. get colorCurvesEnabled(): boolean;
  8516. /**
  8517. * Sets wether the color curves effect is enabled.
  8518. */
  8519. set colorCurvesEnabled(value: boolean);
  8520. private _colorGradingTexture;
  8521. /**
  8522. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8523. */
  8524. get colorGradingTexture(): Nullable<BaseTexture>;
  8525. /**
  8526. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8527. */
  8528. set colorGradingTexture(value: Nullable<BaseTexture>);
  8529. private _colorGradingEnabled;
  8530. /**
  8531. * Gets wether the color grading effect is enabled.
  8532. */
  8533. get colorGradingEnabled(): boolean;
  8534. /**
  8535. * Sets wether the color grading effect is enabled.
  8536. */
  8537. set colorGradingEnabled(value: boolean);
  8538. private _colorGradingWithGreenDepth;
  8539. /**
  8540. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8541. */
  8542. get colorGradingWithGreenDepth(): boolean;
  8543. /**
  8544. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8545. */
  8546. set colorGradingWithGreenDepth(value: boolean);
  8547. private _colorGradingBGR;
  8548. /**
  8549. * Gets wether the color grading texture contains BGR values.
  8550. */
  8551. get colorGradingBGR(): boolean;
  8552. /**
  8553. * Sets wether the color grading texture contains BGR values.
  8554. */
  8555. set colorGradingBGR(value: boolean);
  8556. /** @hidden */
  8557. _exposure: number;
  8558. /**
  8559. * Gets the Exposure used in the effect.
  8560. */
  8561. get exposure(): number;
  8562. /**
  8563. * Sets the Exposure used in the effect.
  8564. */
  8565. set exposure(value: number);
  8566. private _toneMappingEnabled;
  8567. /**
  8568. * Gets wether the tone mapping effect is enabled.
  8569. */
  8570. get toneMappingEnabled(): boolean;
  8571. /**
  8572. * Sets wether the tone mapping effect is enabled.
  8573. */
  8574. set toneMappingEnabled(value: boolean);
  8575. private _toneMappingType;
  8576. /**
  8577. * Gets the type of tone mapping effect.
  8578. */
  8579. get toneMappingType(): number;
  8580. /**
  8581. * Sets the type of tone mapping effect used in BabylonJS.
  8582. */
  8583. set toneMappingType(value: number);
  8584. protected _contrast: number;
  8585. /**
  8586. * Gets the contrast used in the effect.
  8587. */
  8588. get contrast(): number;
  8589. /**
  8590. * Sets the contrast used in the effect.
  8591. */
  8592. set contrast(value: number);
  8593. /**
  8594. * Vignette stretch size.
  8595. */
  8596. vignetteStretch: number;
  8597. /**
  8598. * Vignette centre X Offset.
  8599. */
  8600. vignetteCentreX: number;
  8601. /**
  8602. * Vignette centre Y Offset.
  8603. */
  8604. vignetteCentreY: number;
  8605. /**
  8606. * Vignette weight or intensity of the vignette effect.
  8607. */
  8608. vignetteWeight: number;
  8609. /**
  8610. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8611. * if vignetteEnabled is set to true.
  8612. */
  8613. vignetteColor: Color4;
  8614. /**
  8615. * Camera field of view used by the Vignette effect.
  8616. */
  8617. vignetteCameraFov: number;
  8618. private _vignetteBlendMode;
  8619. /**
  8620. * Gets the vignette blend mode allowing different kind of effect.
  8621. */
  8622. get vignetteBlendMode(): number;
  8623. /**
  8624. * Sets the vignette blend mode allowing different kind of effect.
  8625. */
  8626. set vignetteBlendMode(value: number);
  8627. private _vignetteEnabled;
  8628. /**
  8629. * Gets wether the vignette effect is enabled.
  8630. */
  8631. get vignetteEnabled(): boolean;
  8632. /**
  8633. * Sets wether the vignette effect is enabled.
  8634. */
  8635. set vignetteEnabled(value: boolean);
  8636. private _applyByPostProcess;
  8637. /**
  8638. * Gets wether the image processing is applied through a post process or not.
  8639. */
  8640. get applyByPostProcess(): boolean;
  8641. /**
  8642. * Sets wether the image processing is applied through a post process or not.
  8643. */
  8644. set applyByPostProcess(value: boolean);
  8645. private _isEnabled;
  8646. /**
  8647. * Gets wether the image processing is enabled or not.
  8648. */
  8649. get isEnabled(): boolean;
  8650. /**
  8651. * Sets wether the image processing is enabled or not.
  8652. */
  8653. set isEnabled(value: boolean);
  8654. /**
  8655. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8656. */
  8657. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8658. /**
  8659. * Method called each time the image processing information changes requires to recompile the effect.
  8660. */
  8661. protected _updateParameters(): void;
  8662. /**
  8663. * Gets the current class name.
  8664. * @return "ImageProcessingConfiguration"
  8665. */
  8666. getClassName(): string;
  8667. /**
  8668. * Prepare the list of uniforms associated with the Image Processing effects.
  8669. * @param uniforms The list of uniforms used in the effect
  8670. * @param defines the list of defines currently in use
  8671. */
  8672. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8673. /**
  8674. * Prepare the list of samplers associated with the Image Processing effects.
  8675. * @param samplersList The list of uniforms used in the effect
  8676. * @param defines the list of defines currently in use
  8677. */
  8678. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8679. /**
  8680. * Prepare the list of defines associated to the shader.
  8681. * @param defines the list of defines to complete
  8682. * @param forPostProcess Define if we are currently in post process mode or not
  8683. */
  8684. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8685. /**
  8686. * Returns true if all the image processing information are ready.
  8687. * @returns True if ready, otherwise, false
  8688. */
  8689. isReady(): boolean;
  8690. /**
  8691. * Binds the image processing to the shader.
  8692. * @param effect The effect to bind to
  8693. * @param overrideAspectRatio Override the aspect ratio of the effect
  8694. */
  8695. bind(effect: Effect, overrideAspectRatio?: number): void;
  8696. /**
  8697. * Clones the current image processing instance.
  8698. * @return The cloned image processing
  8699. */
  8700. clone(): ImageProcessingConfiguration;
  8701. /**
  8702. * Serializes the current image processing instance to a json representation.
  8703. * @return a JSON representation
  8704. */
  8705. serialize(): any;
  8706. /**
  8707. * Parses the image processing from a json representation.
  8708. * @param source the JSON source to parse
  8709. * @return The parsed image processing
  8710. */
  8711. static Parse(source: any): ImageProcessingConfiguration;
  8712. private static _VIGNETTEMODE_MULTIPLY;
  8713. private static _VIGNETTEMODE_OPAQUE;
  8714. /**
  8715. * Used to apply the vignette as a mix with the pixel color.
  8716. */
  8717. static get VIGNETTEMODE_MULTIPLY(): number;
  8718. /**
  8719. * Used to apply the vignette as a replacement of the pixel color.
  8720. */
  8721. static get VIGNETTEMODE_OPAQUE(): number;
  8722. }
  8723. }
  8724. declare module "babylonjs/Shaders/postprocess.vertex" {
  8725. /** @hidden */
  8726. export var postprocessVertexShader: {
  8727. name: string;
  8728. shader: string;
  8729. };
  8730. }
  8731. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8732. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8733. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8734. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8735. /**
  8736. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8737. */
  8738. export type RenderTargetTextureSize = number | {
  8739. width: number;
  8740. height: number;
  8741. layers?: number;
  8742. };
  8743. module "babylonjs/Engines/thinEngine" {
  8744. interface ThinEngine {
  8745. /**
  8746. * Creates a new render target texture
  8747. * @param size defines the size of the texture
  8748. * @param options defines the options used to create the texture
  8749. * @returns a new render target texture stored in an InternalTexture
  8750. */
  8751. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8752. /**
  8753. * Creates a depth stencil texture.
  8754. * This is only available in WebGL 2 or with the depth texture extension available.
  8755. * @param size The size of face edge in the texture.
  8756. * @param options The options defining the texture.
  8757. * @returns The texture
  8758. */
  8759. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8760. /** @hidden */
  8761. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8762. }
  8763. }
  8764. }
  8765. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8766. /**
  8767. * Defines the kind of connection point for node based material
  8768. */
  8769. export enum NodeMaterialBlockConnectionPointTypes {
  8770. /** Float */
  8771. Float = 1,
  8772. /** Int */
  8773. Int = 2,
  8774. /** Vector2 */
  8775. Vector2 = 4,
  8776. /** Vector3 */
  8777. Vector3 = 8,
  8778. /** Vector4 */
  8779. Vector4 = 16,
  8780. /** Color3 */
  8781. Color3 = 32,
  8782. /** Color4 */
  8783. Color4 = 64,
  8784. /** Matrix */
  8785. Matrix = 128,
  8786. /** Custom object */
  8787. Object = 256,
  8788. /** Detect type based on connection */
  8789. AutoDetect = 1024,
  8790. /** Output type that will be defined by input type */
  8791. BasedOnInput = 2048
  8792. }
  8793. }
  8794. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8795. /**
  8796. * Enum used to define the target of a block
  8797. */
  8798. export enum NodeMaterialBlockTargets {
  8799. /** Vertex shader */
  8800. Vertex = 1,
  8801. /** Fragment shader */
  8802. Fragment = 2,
  8803. /** Neutral */
  8804. Neutral = 4,
  8805. /** Vertex and Fragment */
  8806. VertexAndFragment = 3
  8807. }
  8808. }
  8809. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8810. /**
  8811. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8812. */
  8813. export enum NodeMaterialBlockConnectionPointMode {
  8814. /** Value is an uniform */
  8815. Uniform = 0,
  8816. /** Value is a mesh attribute */
  8817. Attribute = 1,
  8818. /** Value is a varying between vertex and fragment shaders */
  8819. Varying = 2,
  8820. /** Mode is undefined */
  8821. Undefined = 3
  8822. }
  8823. }
  8824. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8825. /**
  8826. * Enum used to define system values e.g. values automatically provided by the system
  8827. */
  8828. export enum NodeMaterialSystemValues {
  8829. /** World */
  8830. World = 1,
  8831. /** View */
  8832. View = 2,
  8833. /** Projection */
  8834. Projection = 3,
  8835. /** ViewProjection */
  8836. ViewProjection = 4,
  8837. /** WorldView */
  8838. WorldView = 5,
  8839. /** WorldViewProjection */
  8840. WorldViewProjection = 6,
  8841. /** CameraPosition */
  8842. CameraPosition = 7,
  8843. /** Fog Color */
  8844. FogColor = 8,
  8845. /** Delta time */
  8846. DeltaTime = 9
  8847. }
  8848. }
  8849. declare module "babylonjs/Maths/math.axis" {
  8850. import { Vector3 } from "babylonjs/Maths/math.vector";
  8851. /** Defines supported spaces */
  8852. export enum Space {
  8853. /** Local (object) space */
  8854. LOCAL = 0,
  8855. /** World space */
  8856. WORLD = 1,
  8857. /** Bone space */
  8858. BONE = 2
  8859. }
  8860. /** Defines the 3 main axes */
  8861. export class Axis {
  8862. /** X axis */
  8863. static X: Vector3;
  8864. /** Y axis */
  8865. static Y: Vector3;
  8866. /** Z axis */
  8867. static Z: Vector3;
  8868. }
  8869. }
  8870. declare module "babylonjs/Maths/math.frustum" {
  8871. import { Matrix } from "babylonjs/Maths/math.vector";
  8872. import { DeepImmutable } from "babylonjs/types";
  8873. import { Plane } from "babylonjs/Maths/math.plane";
  8874. /**
  8875. * Represents a camera frustum
  8876. */
  8877. export class Frustum {
  8878. /**
  8879. * Gets the planes representing the frustum
  8880. * @param transform matrix to be applied to the returned planes
  8881. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8882. */
  8883. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8884. /**
  8885. * Gets the near frustum plane transformed by the transform matrix
  8886. * @param transform transformation matrix to be applied to the resulting frustum plane
  8887. * @param frustumPlane the resuling frustum plane
  8888. */
  8889. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8890. /**
  8891. * Gets the far frustum plane transformed by the transform matrix
  8892. * @param transform transformation matrix to be applied to the resulting frustum plane
  8893. * @param frustumPlane the resuling frustum plane
  8894. */
  8895. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8896. /**
  8897. * Gets the left frustum plane transformed by the transform matrix
  8898. * @param transform transformation matrix to be applied to the resulting frustum plane
  8899. * @param frustumPlane the resuling frustum plane
  8900. */
  8901. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8902. /**
  8903. * Gets the right frustum plane transformed by the transform matrix
  8904. * @param transform transformation matrix to be applied to the resulting frustum plane
  8905. * @param frustumPlane the resuling frustum plane
  8906. */
  8907. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8908. /**
  8909. * Gets the top frustum plane transformed by the transform matrix
  8910. * @param transform transformation matrix to be applied to the resulting frustum plane
  8911. * @param frustumPlane the resuling frustum plane
  8912. */
  8913. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8914. /**
  8915. * Gets the bottom frustum plane transformed by the transform matrix
  8916. * @param transform transformation matrix to be applied to the resulting frustum plane
  8917. * @param frustumPlane the resuling frustum plane
  8918. */
  8919. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8920. /**
  8921. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8922. * @param transform transformation matrix to be applied to the resulting frustum planes
  8923. * @param frustumPlanes the resuling frustum planes
  8924. */
  8925. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8926. }
  8927. }
  8928. declare module "babylonjs/Maths/math.size" {
  8929. /**
  8930. * Interface for the size containing width and height
  8931. */
  8932. export interface ISize {
  8933. /**
  8934. * Width
  8935. */
  8936. width: number;
  8937. /**
  8938. * Heighht
  8939. */
  8940. height: number;
  8941. }
  8942. /**
  8943. * Size containing widht and height
  8944. */
  8945. export class Size implements ISize {
  8946. /**
  8947. * Width
  8948. */
  8949. width: number;
  8950. /**
  8951. * Height
  8952. */
  8953. height: number;
  8954. /**
  8955. * Creates a Size object from the given width and height (floats).
  8956. * @param width width of the new size
  8957. * @param height height of the new size
  8958. */
  8959. constructor(width: number, height: number);
  8960. /**
  8961. * Returns a string with the Size width and height
  8962. * @returns a string with the Size width and height
  8963. */
  8964. toString(): string;
  8965. /**
  8966. * "Size"
  8967. * @returns the string "Size"
  8968. */
  8969. getClassName(): string;
  8970. /**
  8971. * Returns the Size hash code.
  8972. * @returns a hash code for a unique width and height
  8973. */
  8974. getHashCode(): number;
  8975. /**
  8976. * Updates the current size from the given one.
  8977. * @param src the given size
  8978. */
  8979. copyFrom(src: Size): void;
  8980. /**
  8981. * Updates in place the current Size from the given floats.
  8982. * @param width width of the new size
  8983. * @param height height of the new size
  8984. * @returns the updated Size.
  8985. */
  8986. copyFromFloats(width: number, height: number): Size;
  8987. /**
  8988. * Updates in place the current Size from the given floats.
  8989. * @param width width to set
  8990. * @param height height to set
  8991. * @returns the updated Size.
  8992. */
  8993. set(width: number, height: number): Size;
  8994. /**
  8995. * Multiplies the width and height by numbers
  8996. * @param w factor to multiple the width by
  8997. * @param h factor to multiple the height by
  8998. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8999. */
  9000. multiplyByFloats(w: number, h: number): Size;
  9001. /**
  9002. * Clones the size
  9003. * @returns a new Size copied from the given one.
  9004. */
  9005. clone(): Size;
  9006. /**
  9007. * True if the current Size and the given one width and height are strictly equal.
  9008. * @param other the other size to compare against
  9009. * @returns True if the current Size and the given one width and height are strictly equal.
  9010. */
  9011. equals(other: Size): boolean;
  9012. /**
  9013. * The surface of the Size : width * height (float).
  9014. */
  9015. get surface(): number;
  9016. /**
  9017. * Create a new size of zero
  9018. * @returns a new Size set to (0.0, 0.0)
  9019. */
  9020. static Zero(): Size;
  9021. /**
  9022. * Sums the width and height of two sizes
  9023. * @param otherSize size to add to this size
  9024. * @returns a new Size set as the addition result of the current Size and the given one.
  9025. */
  9026. add(otherSize: Size): Size;
  9027. /**
  9028. * Subtracts the width and height of two
  9029. * @param otherSize size to subtract to this size
  9030. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9031. */
  9032. subtract(otherSize: Size): Size;
  9033. /**
  9034. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9035. * @param start starting size to lerp between
  9036. * @param end end size to lerp between
  9037. * @param amount amount to lerp between the start and end values
  9038. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9039. */
  9040. static Lerp(start: Size, end: Size, amount: number): Size;
  9041. }
  9042. }
  9043. declare module "babylonjs/Maths/math.vertexFormat" {
  9044. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9045. /**
  9046. * Contains position and normal vectors for a vertex
  9047. */
  9048. export class PositionNormalVertex {
  9049. /** the position of the vertex (defaut: 0,0,0) */
  9050. position: Vector3;
  9051. /** the normal of the vertex (defaut: 0,1,0) */
  9052. normal: Vector3;
  9053. /**
  9054. * Creates a PositionNormalVertex
  9055. * @param position the position of the vertex (defaut: 0,0,0)
  9056. * @param normal the normal of the vertex (defaut: 0,1,0)
  9057. */
  9058. constructor(
  9059. /** the position of the vertex (defaut: 0,0,0) */
  9060. position?: Vector3,
  9061. /** the normal of the vertex (defaut: 0,1,0) */
  9062. normal?: Vector3);
  9063. /**
  9064. * Clones the PositionNormalVertex
  9065. * @returns the cloned PositionNormalVertex
  9066. */
  9067. clone(): PositionNormalVertex;
  9068. }
  9069. /**
  9070. * Contains position, normal and uv vectors for a vertex
  9071. */
  9072. export class PositionNormalTextureVertex {
  9073. /** the position of the vertex (defaut: 0,0,0) */
  9074. position: Vector3;
  9075. /** the normal of the vertex (defaut: 0,1,0) */
  9076. normal: Vector3;
  9077. /** the uv of the vertex (default: 0,0) */
  9078. uv: Vector2;
  9079. /**
  9080. * Creates a PositionNormalTextureVertex
  9081. * @param position the position of the vertex (defaut: 0,0,0)
  9082. * @param normal the normal of the vertex (defaut: 0,1,0)
  9083. * @param uv the uv of the vertex (default: 0,0)
  9084. */
  9085. constructor(
  9086. /** the position of the vertex (defaut: 0,0,0) */
  9087. position?: Vector3,
  9088. /** the normal of the vertex (defaut: 0,1,0) */
  9089. normal?: Vector3,
  9090. /** the uv of the vertex (default: 0,0) */
  9091. uv?: Vector2);
  9092. /**
  9093. * Clones the PositionNormalTextureVertex
  9094. * @returns the cloned PositionNormalTextureVertex
  9095. */
  9096. clone(): PositionNormalTextureVertex;
  9097. }
  9098. }
  9099. declare module "babylonjs/Maths/math" {
  9100. export * from "babylonjs/Maths/math.axis";
  9101. export * from "babylonjs/Maths/math.color";
  9102. export * from "babylonjs/Maths/math.constants";
  9103. export * from "babylonjs/Maths/math.frustum";
  9104. export * from "babylonjs/Maths/math.path";
  9105. export * from "babylonjs/Maths/math.plane";
  9106. export * from "babylonjs/Maths/math.size";
  9107. export * from "babylonjs/Maths/math.vector";
  9108. export * from "babylonjs/Maths/math.vertexFormat";
  9109. export * from "babylonjs/Maths/math.viewport";
  9110. }
  9111. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9112. /**
  9113. * Enum defining the type of animations supported by InputBlock
  9114. */
  9115. export enum AnimatedInputBlockTypes {
  9116. /** No animation */
  9117. None = 0,
  9118. /** Time based animation. Will only work for floats */
  9119. Time = 1
  9120. }
  9121. }
  9122. declare module "babylonjs/Lights/shadowLight" {
  9123. import { Camera } from "babylonjs/Cameras/camera";
  9124. import { Scene } from "babylonjs/scene";
  9125. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9127. import { Light } from "babylonjs/Lights/light";
  9128. /**
  9129. * Interface describing all the common properties and methods a shadow light needs to implement.
  9130. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9131. * as well as binding the different shadow properties to the effects.
  9132. */
  9133. export interface IShadowLight extends Light {
  9134. /**
  9135. * The light id in the scene (used in scene.findLighById for instance)
  9136. */
  9137. id: string;
  9138. /**
  9139. * The position the shdow will be casted from.
  9140. */
  9141. position: Vector3;
  9142. /**
  9143. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9144. */
  9145. direction: Vector3;
  9146. /**
  9147. * The transformed position. Position of the light in world space taking parenting in account.
  9148. */
  9149. transformedPosition: Vector3;
  9150. /**
  9151. * The transformed direction. Direction of the light in world space taking parenting in account.
  9152. */
  9153. transformedDirection: Vector3;
  9154. /**
  9155. * The friendly name of the light in the scene.
  9156. */
  9157. name: string;
  9158. /**
  9159. * Defines the shadow projection clipping minimum z value.
  9160. */
  9161. shadowMinZ: number;
  9162. /**
  9163. * Defines the shadow projection clipping maximum z value.
  9164. */
  9165. shadowMaxZ: number;
  9166. /**
  9167. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9168. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9169. */
  9170. computeTransformedInformation(): boolean;
  9171. /**
  9172. * Gets the scene the light belongs to.
  9173. * @returns The scene
  9174. */
  9175. getScene(): Scene;
  9176. /**
  9177. * Callback defining a custom Projection Matrix Builder.
  9178. * This can be used to override the default projection matrix computation.
  9179. */
  9180. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9181. /**
  9182. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9183. * @param matrix The materix to updated with the projection information
  9184. * @param viewMatrix The transform matrix of the light
  9185. * @param renderList The list of mesh to render in the map
  9186. * @returns The current light
  9187. */
  9188. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9189. /**
  9190. * Gets the current depth scale used in ESM.
  9191. * @returns The scale
  9192. */
  9193. getDepthScale(): number;
  9194. /**
  9195. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9196. * @returns true if a cube texture needs to be use
  9197. */
  9198. needCube(): boolean;
  9199. /**
  9200. * Detects if the projection matrix requires to be recomputed this frame.
  9201. * @returns true if it requires to be recomputed otherwise, false.
  9202. */
  9203. needProjectionMatrixCompute(): boolean;
  9204. /**
  9205. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9206. */
  9207. forceProjectionMatrixCompute(): void;
  9208. /**
  9209. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9210. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9211. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9212. */
  9213. getShadowDirection(faceIndex?: number): Vector3;
  9214. /**
  9215. * Gets the minZ used for shadow according to both the scene and the light.
  9216. * @param activeCamera The camera we are returning the min for
  9217. * @returns the depth min z
  9218. */
  9219. getDepthMinZ(activeCamera: Camera): number;
  9220. /**
  9221. * Gets the maxZ used for shadow according to both the scene and the light.
  9222. * @param activeCamera The camera we are returning the max for
  9223. * @returns the depth max z
  9224. */
  9225. getDepthMaxZ(activeCamera: Camera): number;
  9226. }
  9227. /**
  9228. * Base implementation IShadowLight
  9229. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9230. */
  9231. export abstract class ShadowLight extends Light implements IShadowLight {
  9232. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9233. protected _position: Vector3;
  9234. protected _setPosition(value: Vector3): void;
  9235. /**
  9236. * Sets the position the shadow will be casted from. Also use as the light position for both
  9237. * point and spot lights.
  9238. */
  9239. get position(): Vector3;
  9240. /**
  9241. * Sets the position the shadow will be casted from. Also use as the light position for both
  9242. * point and spot lights.
  9243. */
  9244. set position(value: Vector3);
  9245. protected _direction: Vector3;
  9246. protected _setDirection(value: Vector3): void;
  9247. /**
  9248. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9249. * Also use as the light direction on spot and directional lights.
  9250. */
  9251. get direction(): Vector3;
  9252. /**
  9253. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9254. * Also use as the light direction on spot and directional lights.
  9255. */
  9256. set direction(value: Vector3);
  9257. protected _shadowMinZ: number;
  9258. /**
  9259. * Gets the shadow projection clipping minimum z value.
  9260. */
  9261. get shadowMinZ(): number;
  9262. /**
  9263. * Sets the shadow projection clipping minimum z value.
  9264. */
  9265. set shadowMinZ(value: number);
  9266. protected _shadowMaxZ: number;
  9267. /**
  9268. * Sets the shadow projection clipping maximum z value.
  9269. */
  9270. get shadowMaxZ(): number;
  9271. /**
  9272. * Gets the shadow projection clipping maximum z value.
  9273. */
  9274. set shadowMaxZ(value: number);
  9275. /**
  9276. * Callback defining a custom Projection Matrix Builder.
  9277. * This can be used to override the default projection matrix computation.
  9278. */
  9279. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9280. /**
  9281. * The transformed position. Position of the light in world space taking parenting in account.
  9282. */
  9283. transformedPosition: Vector3;
  9284. /**
  9285. * The transformed direction. Direction of the light in world space taking parenting in account.
  9286. */
  9287. transformedDirection: Vector3;
  9288. private _needProjectionMatrixCompute;
  9289. /**
  9290. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9291. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9292. */
  9293. computeTransformedInformation(): boolean;
  9294. /**
  9295. * Return the depth scale used for the shadow map.
  9296. * @returns the depth scale.
  9297. */
  9298. getDepthScale(): number;
  9299. /**
  9300. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9301. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9302. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9303. */
  9304. getShadowDirection(faceIndex?: number): Vector3;
  9305. /**
  9306. * Returns the ShadowLight absolute position in the World.
  9307. * @returns the position vector in world space
  9308. */
  9309. getAbsolutePosition(): Vector3;
  9310. /**
  9311. * Sets the ShadowLight direction toward the passed target.
  9312. * @param target The point to target in local space
  9313. * @returns the updated ShadowLight direction
  9314. */
  9315. setDirectionToTarget(target: Vector3): Vector3;
  9316. /**
  9317. * Returns the light rotation in euler definition.
  9318. * @returns the x y z rotation in local space.
  9319. */
  9320. getRotation(): Vector3;
  9321. /**
  9322. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9323. * @returns true if a cube texture needs to be use
  9324. */
  9325. needCube(): boolean;
  9326. /**
  9327. * Detects if the projection matrix requires to be recomputed this frame.
  9328. * @returns true if it requires to be recomputed otherwise, false.
  9329. */
  9330. needProjectionMatrixCompute(): boolean;
  9331. /**
  9332. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9333. */
  9334. forceProjectionMatrixCompute(): void;
  9335. /** @hidden */
  9336. _initCache(): void;
  9337. /** @hidden */
  9338. _isSynchronized(): boolean;
  9339. /**
  9340. * Computes the world matrix of the node
  9341. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9342. * @returns the world matrix
  9343. */
  9344. computeWorldMatrix(force?: boolean): Matrix;
  9345. /**
  9346. * Gets the minZ used for shadow according to both the scene and the light.
  9347. * @param activeCamera The camera we are returning the min for
  9348. * @returns the depth min z
  9349. */
  9350. getDepthMinZ(activeCamera: Camera): number;
  9351. /**
  9352. * Gets the maxZ used for shadow according to both the scene and the light.
  9353. * @param activeCamera The camera we are returning the max for
  9354. * @returns the depth max z
  9355. */
  9356. getDepthMaxZ(activeCamera: Camera): number;
  9357. /**
  9358. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9359. * @param matrix The materix to updated with the projection information
  9360. * @param viewMatrix The transform matrix of the light
  9361. * @param renderList The list of mesh to render in the map
  9362. * @returns The current light
  9363. */
  9364. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9365. }
  9366. }
  9367. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9368. /** @hidden */
  9369. export var packingFunctions: {
  9370. name: string;
  9371. shader: string;
  9372. };
  9373. }
  9374. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9375. /** @hidden */
  9376. export var bayerDitherFunctions: {
  9377. name: string;
  9378. shader: string;
  9379. };
  9380. }
  9381. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9382. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9383. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9384. /** @hidden */
  9385. export var shadowMapFragmentDeclaration: {
  9386. name: string;
  9387. shader: string;
  9388. };
  9389. }
  9390. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9391. /** @hidden */
  9392. export var clipPlaneFragmentDeclaration: {
  9393. name: string;
  9394. shader: string;
  9395. };
  9396. }
  9397. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9398. /** @hidden */
  9399. export var clipPlaneFragment: {
  9400. name: string;
  9401. shader: string;
  9402. };
  9403. }
  9404. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9405. /** @hidden */
  9406. export var shadowMapFragment: {
  9407. name: string;
  9408. shader: string;
  9409. };
  9410. }
  9411. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9412. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9413. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9414. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9415. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9416. /** @hidden */
  9417. export var shadowMapPixelShader: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9423. /** @hidden */
  9424. export var bonesDeclaration: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9430. /** @hidden */
  9431. export var morphTargetsVertexGlobalDeclaration: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9437. /** @hidden */
  9438. export var morphTargetsVertexDeclaration: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9444. /** @hidden */
  9445. export var instancesDeclaration: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9451. /** @hidden */
  9452. export var helperFunctions: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9458. /** @hidden */
  9459. export var shadowMapVertexDeclaration: {
  9460. name: string;
  9461. shader: string;
  9462. };
  9463. }
  9464. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9465. /** @hidden */
  9466. export var clipPlaneVertexDeclaration: {
  9467. name: string;
  9468. shader: string;
  9469. };
  9470. }
  9471. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9472. /** @hidden */
  9473. export var morphTargetsVertex: {
  9474. name: string;
  9475. shader: string;
  9476. };
  9477. }
  9478. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9479. /** @hidden */
  9480. export var instancesVertex: {
  9481. name: string;
  9482. shader: string;
  9483. };
  9484. }
  9485. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9486. /** @hidden */
  9487. export var bonesVertex: {
  9488. name: string;
  9489. shader: string;
  9490. };
  9491. }
  9492. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9493. /** @hidden */
  9494. export var shadowMapVertexNormalBias: {
  9495. name: string;
  9496. shader: string;
  9497. };
  9498. }
  9499. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9500. /** @hidden */
  9501. export var shadowMapVertexMetric: {
  9502. name: string;
  9503. shader: string;
  9504. };
  9505. }
  9506. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9507. /** @hidden */
  9508. export var clipPlaneVertex: {
  9509. name: string;
  9510. shader: string;
  9511. };
  9512. }
  9513. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9514. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9515. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9516. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9517. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9518. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9519. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9520. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9521. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9522. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9523. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9524. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9525. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9526. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9527. /** @hidden */
  9528. export var shadowMapVertexShader: {
  9529. name: string;
  9530. shader: string;
  9531. };
  9532. }
  9533. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9534. /** @hidden */
  9535. export var depthBoxBlurPixelShader: {
  9536. name: string;
  9537. shader: string;
  9538. };
  9539. }
  9540. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9541. /** @hidden */
  9542. export var shadowMapFragmentSoftTransparentShadow: {
  9543. name: string;
  9544. shader: string;
  9545. };
  9546. }
  9547. declare module "babylonjs/Materials/effectFallbacks" {
  9548. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9549. import { Effect } from "babylonjs/Materials/effect";
  9550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9551. /**
  9552. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9553. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9554. */
  9555. export class EffectFallbacks implements IEffectFallbacks {
  9556. private _defines;
  9557. private _currentRank;
  9558. private _maxRank;
  9559. private _mesh;
  9560. /**
  9561. * Removes the fallback from the bound mesh.
  9562. */
  9563. unBindMesh(): void;
  9564. /**
  9565. * Adds a fallback on the specified property.
  9566. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9567. * @param define The name of the define in the shader
  9568. */
  9569. addFallback(rank: number, define: string): void;
  9570. /**
  9571. * Sets the mesh to use CPU skinning when needing to fallback.
  9572. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9573. * @param mesh The mesh to use the fallbacks.
  9574. */
  9575. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9576. /**
  9577. * Checks to see if more fallbacks are still availible.
  9578. */
  9579. get hasMoreFallbacks(): boolean;
  9580. /**
  9581. * Removes the defines that should be removed when falling back.
  9582. * @param currentDefines defines the current define statements for the shader.
  9583. * @param effect defines the current effect we try to compile
  9584. * @returns The resulting defines with defines of the current rank removed.
  9585. */
  9586. reduce(currentDefines: string, effect: Effect): string;
  9587. }
  9588. }
  9589. declare module "babylonjs/Actions/action" {
  9590. import { Observable } from "babylonjs/Misc/observable";
  9591. import { Condition } from "babylonjs/Actions/condition";
  9592. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9593. import { Nullable } from "babylonjs/types";
  9594. import { Scene } from "babylonjs/scene";
  9595. import { ActionManager } from "babylonjs/Actions/actionManager";
  9596. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9597. import { Node } from "babylonjs/node";
  9598. /**
  9599. * Interface used to define Action
  9600. */
  9601. export interface IAction {
  9602. /**
  9603. * Trigger for the action
  9604. */
  9605. trigger: number;
  9606. /** Options of the trigger */
  9607. triggerOptions: any;
  9608. /**
  9609. * Gets the trigger parameters
  9610. * @returns the trigger parameters
  9611. */
  9612. getTriggerParameter(): any;
  9613. /**
  9614. * Internal only - executes current action event
  9615. * @hidden
  9616. */
  9617. _executeCurrent(evt?: ActionEvent): void;
  9618. /**
  9619. * Serialize placeholder for child classes
  9620. * @param parent of child
  9621. * @returns the serialized object
  9622. */
  9623. serialize(parent: any): any;
  9624. /**
  9625. * Internal only
  9626. * @hidden
  9627. */
  9628. _prepare(): void;
  9629. /**
  9630. * Internal only - manager for action
  9631. * @hidden
  9632. */
  9633. _actionManager: Nullable<AbstractActionManager>;
  9634. /**
  9635. * Adds action to chain of actions, may be a DoNothingAction
  9636. * @param action defines the next action to execute
  9637. * @returns The action passed in
  9638. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9639. */
  9640. then(action: IAction): IAction;
  9641. }
  9642. /**
  9643. * The action to be carried out following a trigger
  9644. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9645. */
  9646. export class Action implements IAction {
  9647. /** the trigger, with or without parameters, for the action */
  9648. triggerOptions: any;
  9649. /**
  9650. * Trigger for the action
  9651. */
  9652. trigger: number;
  9653. /**
  9654. * Internal only - manager for action
  9655. * @hidden
  9656. */
  9657. _actionManager: ActionManager;
  9658. private _nextActiveAction;
  9659. private _child;
  9660. private _condition?;
  9661. private _triggerParameter;
  9662. /**
  9663. * An event triggered prior to action being executed.
  9664. */
  9665. onBeforeExecuteObservable: Observable<Action>;
  9666. /**
  9667. * Creates a new Action
  9668. * @param triggerOptions the trigger, with or without parameters, for the action
  9669. * @param condition an optional determinant of action
  9670. */
  9671. constructor(
  9672. /** the trigger, with or without parameters, for the action */
  9673. triggerOptions: any, condition?: Condition);
  9674. /**
  9675. * Internal only
  9676. * @hidden
  9677. */
  9678. _prepare(): void;
  9679. /**
  9680. * Gets the trigger parameters
  9681. * @returns the trigger parameters
  9682. */
  9683. getTriggerParameter(): any;
  9684. /**
  9685. * Internal only - executes current action event
  9686. * @hidden
  9687. */
  9688. _executeCurrent(evt?: ActionEvent): void;
  9689. /**
  9690. * Execute placeholder for child classes
  9691. * @param evt optional action event
  9692. */
  9693. execute(evt?: ActionEvent): void;
  9694. /**
  9695. * Skips to next active action
  9696. */
  9697. skipToNextActiveAction(): void;
  9698. /**
  9699. * Adds action to chain of actions, may be a DoNothingAction
  9700. * @param action defines the next action to execute
  9701. * @returns The action passed in
  9702. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9703. */
  9704. then(action: Action): Action;
  9705. /**
  9706. * Internal only
  9707. * @hidden
  9708. */
  9709. _getProperty(propertyPath: string): string;
  9710. /**
  9711. * Internal only
  9712. * @hidden
  9713. */
  9714. _getEffectiveTarget(target: any, propertyPath: string): any;
  9715. /**
  9716. * Serialize placeholder for child classes
  9717. * @param parent of child
  9718. * @returns the serialized object
  9719. */
  9720. serialize(parent: any): any;
  9721. /**
  9722. * Internal only called by serialize
  9723. * @hidden
  9724. */
  9725. protected _serialize(serializedAction: any, parent?: any): any;
  9726. /**
  9727. * Internal only
  9728. * @hidden
  9729. */
  9730. static _SerializeValueAsString: (value: any) => string;
  9731. /**
  9732. * Internal only
  9733. * @hidden
  9734. */
  9735. static _GetTargetProperty: (target: Scene | Node) => {
  9736. name: string;
  9737. targetType: string;
  9738. value: string;
  9739. };
  9740. }
  9741. }
  9742. declare module "babylonjs/Actions/condition" {
  9743. import { ActionManager } from "babylonjs/Actions/actionManager";
  9744. /**
  9745. * A Condition applied to an Action
  9746. */
  9747. export class Condition {
  9748. /**
  9749. * Internal only - manager for action
  9750. * @hidden
  9751. */
  9752. _actionManager: ActionManager;
  9753. /**
  9754. * Internal only
  9755. * @hidden
  9756. */
  9757. _evaluationId: number;
  9758. /**
  9759. * Internal only
  9760. * @hidden
  9761. */
  9762. _currentResult: boolean;
  9763. /**
  9764. * Creates a new Condition
  9765. * @param actionManager the manager of the action the condition is applied to
  9766. */
  9767. constructor(actionManager: ActionManager);
  9768. /**
  9769. * Check if the current condition is valid
  9770. * @returns a boolean
  9771. */
  9772. isValid(): boolean;
  9773. /**
  9774. * Internal only
  9775. * @hidden
  9776. */
  9777. _getProperty(propertyPath: string): string;
  9778. /**
  9779. * Internal only
  9780. * @hidden
  9781. */
  9782. _getEffectiveTarget(target: any, propertyPath: string): any;
  9783. /**
  9784. * Serialize placeholder for child classes
  9785. * @returns the serialized object
  9786. */
  9787. serialize(): any;
  9788. /**
  9789. * Internal only
  9790. * @hidden
  9791. */
  9792. protected _serialize(serializedCondition: any): any;
  9793. }
  9794. /**
  9795. * Defines specific conditional operators as extensions of Condition
  9796. */
  9797. export class ValueCondition extends Condition {
  9798. /** path to specify the property of the target the conditional operator uses */
  9799. propertyPath: string;
  9800. /** the value compared by the conditional operator against the current value of the property */
  9801. value: any;
  9802. /** the conditional operator, default ValueCondition.IsEqual */
  9803. operator: number;
  9804. /**
  9805. * Internal only
  9806. * @hidden
  9807. */
  9808. private static _IsEqual;
  9809. /**
  9810. * Internal only
  9811. * @hidden
  9812. */
  9813. private static _IsDifferent;
  9814. /**
  9815. * Internal only
  9816. * @hidden
  9817. */
  9818. private static _IsGreater;
  9819. /**
  9820. * Internal only
  9821. * @hidden
  9822. */
  9823. private static _IsLesser;
  9824. /**
  9825. * returns the number for IsEqual
  9826. */
  9827. static get IsEqual(): number;
  9828. /**
  9829. * Returns the number for IsDifferent
  9830. */
  9831. static get IsDifferent(): number;
  9832. /**
  9833. * Returns the number for IsGreater
  9834. */
  9835. static get IsGreater(): number;
  9836. /**
  9837. * Returns the number for IsLesser
  9838. */
  9839. static get IsLesser(): number;
  9840. /**
  9841. * Internal only The action manager for the condition
  9842. * @hidden
  9843. */
  9844. _actionManager: ActionManager;
  9845. /**
  9846. * Internal only
  9847. * @hidden
  9848. */
  9849. private _target;
  9850. /**
  9851. * Internal only
  9852. * @hidden
  9853. */
  9854. private _effectiveTarget;
  9855. /**
  9856. * Internal only
  9857. * @hidden
  9858. */
  9859. private _property;
  9860. /**
  9861. * Creates a new ValueCondition
  9862. * @param actionManager manager for the action the condition applies to
  9863. * @param target for the action
  9864. * @param propertyPath path to specify the property of the target the conditional operator uses
  9865. * @param value the value compared by the conditional operator against the current value of the property
  9866. * @param operator the conditional operator, default ValueCondition.IsEqual
  9867. */
  9868. constructor(actionManager: ActionManager, target: any,
  9869. /** path to specify the property of the target the conditional operator uses */
  9870. propertyPath: string,
  9871. /** the value compared by the conditional operator against the current value of the property */
  9872. value: any,
  9873. /** the conditional operator, default ValueCondition.IsEqual */
  9874. operator?: number);
  9875. /**
  9876. * Compares the given value with the property value for the specified conditional operator
  9877. * @returns the result of the comparison
  9878. */
  9879. isValid(): boolean;
  9880. /**
  9881. * Serialize the ValueCondition into a JSON compatible object
  9882. * @returns serialization object
  9883. */
  9884. serialize(): any;
  9885. /**
  9886. * Gets the name of the conditional operator for the ValueCondition
  9887. * @param operator the conditional operator
  9888. * @returns the name
  9889. */
  9890. static GetOperatorName(operator: number): string;
  9891. }
  9892. /**
  9893. * Defines a predicate condition as an extension of Condition
  9894. */
  9895. export class PredicateCondition extends Condition {
  9896. /** defines the predicate function used to validate the condition */
  9897. predicate: () => boolean;
  9898. /**
  9899. * Internal only - manager for action
  9900. * @hidden
  9901. */
  9902. _actionManager: ActionManager;
  9903. /**
  9904. * Creates a new PredicateCondition
  9905. * @param actionManager manager for the action the condition applies to
  9906. * @param predicate defines the predicate function used to validate the condition
  9907. */
  9908. constructor(actionManager: ActionManager,
  9909. /** defines the predicate function used to validate the condition */
  9910. predicate: () => boolean);
  9911. /**
  9912. * @returns the validity of the predicate condition
  9913. */
  9914. isValid(): boolean;
  9915. }
  9916. /**
  9917. * Defines a state condition as an extension of Condition
  9918. */
  9919. export class StateCondition extends Condition {
  9920. /** Value to compare with target state */
  9921. value: string;
  9922. /**
  9923. * Internal only - manager for action
  9924. * @hidden
  9925. */
  9926. _actionManager: ActionManager;
  9927. /**
  9928. * Internal only
  9929. * @hidden
  9930. */
  9931. private _target;
  9932. /**
  9933. * Creates a new StateCondition
  9934. * @param actionManager manager for the action the condition applies to
  9935. * @param target of the condition
  9936. * @param value to compare with target state
  9937. */
  9938. constructor(actionManager: ActionManager, target: any,
  9939. /** Value to compare with target state */
  9940. value: string);
  9941. /**
  9942. * Gets a boolean indicating if the current condition is met
  9943. * @returns the validity of the state
  9944. */
  9945. isValid(): boolean;
  9946. /**
  9947. * Serialize the StateCondition into a JSON compatible object
  9948. * @returns serialization object
  9949. */
  9950. serialize(): any;
  9951. }
  9952. }
  9953. declare module "babylonjs/Actions/directActions" {
  9954. import { Action } from "babylonjs/Actions/action";
  9955. import { Condition } from "babylonjs/Actions/condition";
  9956. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9957. /**
  9958. * This defines an action responsible to toggle a boolean once triggered.
  9959. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9960. */
  9961. export class SwitchBooleanAction extends Action {
  9962. /**
  9963. * The path to the boolean property in the target object
  9964. */
  9965. propertyPath: string;
  9966. private _target;
  9967. private _effectiveTarget;
  9968. private _property;
  9969. /**
  9970. * Instantiate the action
  9971. * @param triggerOptions defines the trigger options
  9972. * @param target defines the object containing the boolean
  9973. * @param propertyPath defines the path to the boolean property in the target object
  9974. * @param condition defines the trigger related conditions
  9975. */
  9976. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9977. /** @hidden */
  9978. _prepare(): void;
  9979. /**
  9980. * Execute the action toggle the boolean value.
  9981. */
  9982. execute(): void;
  9983. /**
  9984. * Serializes the actions and its related information.
  9985. * @param parent defines the object to serialize in
  9986. * @returns the serialized object
  9987. */
  9988. serialize(parent: any): any;
  9989. }
  9990. /**
  9991. * This defines an action responsible to set a the state field of the target
  9992. * to a desired value once triggered.
  9993. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9994. */
  9995. export class SetStateAction extends Action {
  9996. /**
  9997. * The value to store in the state field.
  9998. */
  9999. value: string;
  10000. private _target;
  10001. /**
  10002. * Instantiate the action
  10003. * @param triggerOptions defines the trigger options
  10004. * @param target defines the object containing the state property
  10005. * @param value defines the value to store in the state field
  10006. * @param condition defines the trigger related conditions
  10007. */
  10008. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10009. /**
  10010. * Execute the action and store the value on the target state property.
  10011. */
  10012. execute(): void;
  10013. /**
  10014. * Serializes the actions and its related information.
  10015. * @param parent defines the object to serialize in
  10016. * @returns the serialized object
  10017. */
  10018. serialize(parent: any): any;
  10019. }
  10020. /**
  10021. * This defines an action responsible to set a property of the target
  10022. * to a desired value once triggered.
  10023. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10024. */
  10025. export class SetValueAction extends Action {
  10026. /**
  10027. * The path of the property to set in the target.
  10028. */
  10029. propertyPath: string;
  10030. /**
  10031. * The value to set in the property
  10032. */
  10033. value: any;
  10034. private _target;
  10035. private _effectiveTarget;
  10036. private _property;
  10037. /**
  10038. * Instantiate the action
  10039. * @param triggerOptions defines the trigger options
  10040. * @param target defines the object containing the property
  10041. * @param propertyPath defines the path of the property to set in the target
  10042. * @param value defines the value to set in the property
  10043. * @param condition defines the trigger related conditions
  10044. */
  10045. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10046. /** @hidden */
  10047. _prepare(): void;
  10048. /**
  10049. * Execute the action and set the targetted property to the desired value.
  10050. */
  10051. execute(): void;
  10052. /**
  10053. * Serializes the actions and its related information.
  10054. * @param parent defines the object to serialize in
  10055. * @returns the serialized object
  10056. */
  10057. serialize(parent: any): any;
  10058. }
  10059. /**
  10060. * This defines an action responsible to increment the target value
  10061. * to a desired value once triggered.
  10062. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10063. */
  10064. export class IncrementValueAction extends Action {
  10065. /**
  10066. * The path of the property to increment in the target.
  10067. */
  10068. propertyPath: string;
  10069. /**
  10070. * The value we should increment the property by.
  10071. */
  10072. value: any;
  10073. private _target;
  10074. private _effectiveTarget;
  10075. private _property;
  10076. /**
  10077. * Instantiate the action
  10078. * @param triggerOptions defines the trigger options
  10079. * @param target defines the object containing the property
  10080. * @param propertyPath defines the path of the property to increment in the target
  10081. * @param value defines the value value we should increment the property by
  10082. * @param condition defines the trigger related conditions
  10083. */
  10084. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10085. /** @hidden */
  10086. _prepare(): void;
  10087. /**
  10088. * Execute the action and increment the target of the value amount.
  10089. */
  10090. execute(): void;
  10091. /**
  10092. * Serializes the actions and its related information.
  10093. * @param parent defines the object to serialize in
  10094. * @returns the serialized object
  10095. */
  10096. serialize(parent: any): any;
  10097. }
  10098. /**
  10099. * This defines an action responsible to start an animation once triggered.
  10100. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10101. */
  10102. export class PlayAnimationAction extends Action {
  10103. /**
  10104. * Where the animation should start (animation frame)
  10105. */
  10106. from: number;
  10107. /**
  10108. * Where the animation should stop (animation frame)
  10109. */
  10110. to: number;
  10111. /**
  10112. * Define if the animation should loop or stop after the first play.
  10113. */
  10114. loop?: boolean;
  10115. private _target;
  10116. /**
  10117. * Instantiate the action
  10118. * @param triggerOptions defines the trigger options
  10119. * @param target defines the target animation or animation name
  10120. * @param from defines from where the animation should start (animation frame)
  10121. * @param end defines where the animation should stop (animation frame)
  10122. * @param loop defines if the animation should loop or stop after the first play
  10123. * @param condition defines the trigger related conditions
  10124. */
  10125. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10126. /** @hidden */
  10127. _prepare(): void;
  10128. /**
  10129. * Execute the action and play the animation.
  10130. */
  10131. execute(): void;
  10132. /**
  10133. * Serializes the actions and its related information.
  10134. * @param parent defines the object to serialize in
  10135. * @returns the serialized object
  10136. */
  10137. serialize(parent: any): any;
  10138. }
  10139. /**
  10140. * This defines an action responsible to stop an animation once triggered.
  10141. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10142. */
  10143. export class StopAnimationAction extends Action {
  10144. private _target;
  10145. /**
  10146. * Instantiate the action
  10147. * @param triggerOptions defines the trigger options
  10148. * @param target defines the target animation or animation name
  10149. * @param condition defines the trigger related conditions
  10150. */
  10151. constructor(triggerOptions: any, target: any, condition?: Condition);
  10152. /** @hidden */
  10153. _prepare(): void;
  10154. /**
  10155. * Execute the action and stop the animation.
  10156. */
  10157. execute(): void;
  10158. /**
  10159. * Serializes the actions and its related information.
  10160. * @param parent defines the object to serialize in
  10161. * @returns the serialized object
  10162. */
  10163. serialize(parent: any): any;
  10164. }
  10165. /**
  10166. * This defines an action responsible that does nothing once triggered.
  10167. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10168. */
  10169. export class DoNothingAction extends Action {
  10170. /**
  10171. * Instantiate the action
  10172. * @param triggerOptions defines the trigger options
  10173. * @param condition defines the trigger related conditions
  10174. */
  10175. constructor(triggerOptions?: any, condition?: Condition);
  10176. /**
  10177. * Execute the action and do nothing.
  10178. */
  10179. execute(): void;
  10180. /**
  10181. * Serializes the actions and its related information.
  10182. * @param parent defines the object to serialize in
  10183. * @returns the serialized object
  10184. */
  10185. serialize(parent: any): any;
  10186. }
  10187. /**
  10188. * This defines an action responsible to trigger several actions once triggered.
  10189. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10190. */
  10191. export class CombineAction extends Action {
  10192. /**
  10193. * The list of aggregated animations to run.
  10194. */
  10195. children: Action[];
  10196. /**
  10197. * Instantiate the action
  10198. * @param triggerOptions defines the trigger options
  10199. * @param children defines the list of aggregated animations to run
  10200. * @param condition defines the trigger related conditions
  10201. */
  10202. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10203. /** @hidden */
  10204. _prepare(): void;
  10205. /**
  10206. * Execute the action and executes all the aggregated actions.
  10207. */
  10208. execute(evt: ActionEvent): void;
  10209. /**
  10210. * Serializes the actions and its related information.
  10211. * @param parent defines the object to serialize in
  10212. * @returns the serialized object
  10213. */
  10214. serialize(parent: any): any;
  10215. }
  10216. /**
  10217. * This defines an action responsible to run code (external event) once triggered.
  10218. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10219. */
  10220. export class ExecuteCodeAction extends Action {
  10221. /**
  10222. * The callback function to run.
  10223. */
  10224. func: (evt: ActionEvent) => void;
  10225. /**
  10226. * Instantiate the action
  10227. * @param triggerOptions defines the trigger options
  10228. * @param func defines the callback function to run
  10229. * @param condition defines the trigger related conditions
  10230. */
  10231. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10232. /**
  10233. * Execute the action and run the attached code.
  10234. */
  10235. execute(evt: ActionEvent): void;
  10236. }
  10237. /**
  10238. * This defines an action responsible to set the parent property of the target once triggered.
  10239. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10240. */
  10241. export class SetParentAction extends Action {
  10242. private _parent;
  10243. private _target;
  10244. /**
  10245. * Instantiate the action
  10246. * @param triggerOptions defines the trigger options
  10247. * @param target defines the target containing the parent property
  10248. * @param parent defines from where the animation should start (animation frame)
  10249. * @param condition defines the trigger related conditions
  10250. */
  10251. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10252. /** @hidden */
  10253. _prepare(): void;
  10254. /**
  10255. * Execute the action and set the parent property.
  10256. */
  10257. execute(): void;
  10258. /**
  10259. * Serializes the actions and its related information.
  10260. * @param parent defines the object to serialize in
  10261. * @returns the serialized object
  10262. */
  10263. serialize(parent: any): any;
  10264. }
  10265. }
  10266. declare module "babylonjs/Actions/actionManager" {
  10267. import { Nullable } from "babylonjs/types";
  10268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10269. import { Scene } from "babylonjs/scene";
  10270. import { IAction } from "babylonjs/Actions/action";
  10271. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10272. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10273. /**
  10274. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10275. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10276. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10277. */
  10278. export class ActionManager extends AbstractActionManager {
  10279. /**
  10280. * Nothing
  10281. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10282. */
  10283. static readonly NothingTrigger: number;
  10284. /**
  10285. * On pick
  10286. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10287. */
  10288. static readonly OnPickTrigger: number;
  10289. /**
  10290. * On left pick
  10291. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10292. */
  10293. static readonly OnLeftPickTrigger: number;
  10294. /**
  10295. * On right pick
  10296. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10297. */
  10298. static readonly OnRightPickTrigger: number;
  10299. /**
  10300. * On center pick
  10301. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10302. */
  10303. static readonly OnCenterPickTrigger: number;
  10304. /**
  10305. * On pick down
  10306. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10307. */
  10308. static readonly OnPickDownTrigger: number;
  10309. /**
  10310. * On double pick
  10311. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10312. */
  10313. static readonly OnDoublePickTrigger: number;
  10314. /**
  10315. * On pick up
  10316. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10317. */
  10318. static readonly OnPickUpTrigger: number;
  10319. /**
  10320. * On pick out.
  10321. * This trigger will only be raised if you also declared a OnPickDown
  10322. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10323. */
  10324. static readonly OnPickOutTrigger: number;
  10325. /**
  10326. * On long press
  10327. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10328. */
  10329. static readonly OnLongPressTrigger: number;
  10330. /**
  10331. * On pointer over
  10332. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10333. */
  10334. static readonly OnPointerOverTrigger: number;
  10335. /**
  10336. * On pointer out
  10337. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10338. */
  10339. static readonly OnPointerOutTrigger: number;
  10340. /**
  10341. * On every frame
  10342. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10343. */
  10344. static readonly OnEveryFrameTrigger: number;
  10345. /**
  10346. * On intersection enter
  10347. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10348. */
  10349. static readonly OnIntersectionEnterTrigger: number;
  10350. /**
  10351. * On intersection exit
  10352. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10353. */
  10354. static readonly OnIntersectionExitTrigger: number;
  10355. /**
  10356. * On key down
  10357. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10358. */
  10359. static readonly OnKeyDownTrigger: number;
  10360. /**
  10361. * On key up
  10362. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10363. */
  10364. static readonly OnKeyUpTrigger: number;
  10365. private _scene;
  10366. /**
  10367. * Creates a new action manager
  10368. * @param scene defines the hosting scene
  10369. */
  10370. constructor(scene: Scene);
  10371. /**
  10372. * Releases all associated resources
  10373. */
  10374. dispose(): void;
  10375. /**
  10376. * Gets hosting scene
  10377. * @returns the hosting scene
  10378. */
  10379. getScene(): Scene;
  10380. /**
  10381. * Does this action manager handles actions of any of the given triggers
  10382. * @param triggers defines the triggers to be tested
  10383. * @return a boolean indicating whether one (or more) of the triggers is handled
  10384. */
  10385. hasSpecificTriggers(triggers: number[]): boolean;
  10386. /**
  10387. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10388. * speed.
  10389. * @param triggerA defines the trigger to be tested
  10390. * @param triggerB defines the trigger to be tested
  10391. * @return a boolean indicating whether one (or more) of the triggers is handled
  10392. */
  10393. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10394. /**
  10395. * Does this action manager handles actions of a given trigger
  10396. * @param trigger defines the trigger to be tested
  10397. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10398. * @return whether the trigger is handled
  10399. */
  10400. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10401. /**
  10402. * Does this action manager has pointer triggers
  10403. */
  10404. get hasPointerTriggers(): boolean;
  10405. /**
  10406. * Does this action manager has pick triggers
  10407. */
  10408. get hasPickTriggers(): boolean;
  10409. /**
  10410. * Registers an action to this action manager
  10411. * @param action defines the action to be registered
  10412. * @return the action amended (prepared) after registration
  10413. */
  10414. registerAction(action: IAction): Nullable<IAction>;
  10415. /**
  10416. * Unregisters an action to this action manager
  10417. * @param action defines the action to be unregistered
  10418. * @return a boolean indicating whether the action has been unregistered
  10419. */
  10420. unregisterAction(action: IAction): Boolean;
  10421. /**
  10422. * Process a specific trigger
  10423. * @param trigger defines the trigger to process
  10424. * @param evt defines the event details to be processed
  10425. */
  10426. processTrigger(trigger: number, evt?: IActionEvent): void;
  10427. /** @hidden */
  10428. _getEffectiveTarget(target: any, propertyPath: string): any;
  10429. /** @hidden */
  10430. _getProperty(propertyPath: string): string;
  10431. /**
  10432. * Serialize this manager to a JSON object
  10433. * @param name defines the property name to store this manager
  10434. * @returns a JSON representation of this manager
  10435. */
  10436. serialize(name: string): any;
  10437. /**
  10438. * Creates a new ActionManager from a JSON data
  10439. * @param parsedActions defines the JSON data to read from
  10440. * @param object defines the hosting mesh
  10441. * @param scene defines the hosting scene
  10442. */
  10443. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10444. /**
  10445. * Get a trigger name by index
  10446. * @param trigger defines the trigger index
  10447. * @returns a trigger name
  10448. */
  10449. static GetTriggerName(trigger: number): string;
  10450. }
  10451. }
  10452. declare module "babylonjs/Sprites/sprite" {
  10453. import { Vector3 } from "babylonjs/Maths/math.vector";
  10454. import { Nullable } from "babylonjs/types";
  10455. import { ActionManager } from "babylonjs/Actions/actionManager";
  10456. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10457. import { Color4 } from "babylonjs/Maths/math.color";
  10458. import { Observable } from "babylonjs/Misc/observable";
  10459. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10460. import { Animation } from "babylonjs/Animations/animation";
  10461. /**
  10462. * Class used to represent a sprite
  10463. * @see https://doc.babylonjs.com/babylon101/sprites
  10464. */
  10465. export class Sprite implements IAnimatable {
  10466. /** defines the name */
  10467. name: string;
  10468. /** Gets or sets the current world position */
  10469. position: Vector3;
  10470. /** Gets or sets the main color */
  10471. color: Color4;
  10472. /** Gets or sets the width */
  10473. width: number;
  10474. /** Gets or sets the height */
  10475. height: number;
  10476. /** Gets or sets rotation angle */
  10477. angle: number;
  10478. /** Gets or sets the cell index in the sprite sheet */
  10479. cellIndex: number;
  10480. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10481. cellRef: string;
  10482. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10483. invertU: boolean;
  10484. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10485. invertV: boolean;
  10486. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10487. disposeWhenFinishedAnimating: boolean;
  10488. /** Gets the list of attached animations */
  10489. animations: Nullable<Array<Animation>>;
  10490. /** Gets or sets a boolean indicating if the sprite can be picked */
  10491. isPickable: boolean;
  10492. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10493. useAlphaForPicking: boolean;
  10494. /** @hidden */
  10495. _xOffset: number;
  10496. /** @hidden */
  10497. _yOffset: number;
  10498. /** @hidden */
  10499. _xSize: number;
  10500. /** @hidden */
  10501. _ySize: number;
  10502. /**
  10503. * Gets or sets the associated action manager
  10504. */
  10505. actionManager: Nullable<ActionManager>;
  10506. /**
  10507. * An event triggered when the control has been disposed
  10508. */
  10509. onDisposeObservable: Observable<Sprite>;
  10510. private _animationStarted;
  10511. private _loopAnimation;
  10512. private _fromIndex;
  10513. private _toIndex;
  10514. private _delay;
  10515. private _direction;
  10516. private _manager;
  10517. private _time;
  10518. private _onAnimationEnd;
  10519. /**
  10520. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10521. */
  10522. isVisible: boolean;
  10523. /**
  10524. * Gets or sets the sprite size
  10525. */
  10526. get size(): number;
  10527. set size(value: number);
  10528. /**
  10529. * Returns a boolean indicating if the animation is started
  10530. */
  10531. get animationStarted(): boolean;
  10532. /**
  10533. * Gets or sets the unique id of the sprite
  10534. */
  10535. uniqueId: number;
  10536. /**
  10537. * Gets the manager of this sprite
  10538. */
  10539. get manager(): ISpriteManager;
  10540. /**
  10541. * Creates a new Sprite
  10542. * @param name defines the name
  10543. * @param manager defines the manager
  10544. */
  10545. constructor(
  10546. /** defines the name */
  10547. name: string, manager: ISpriteManager);
  10548. /**
  10549. * Returns the string "Sprite"
  10550. * @returns "Sprite"
  10551. */
  10552. getClassName(): string;
  10553. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10554. get fromIndex(): number;
  10555. set fromIndex(value: number);
  10556. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10557. get toIndex(): number;
  10558. set toIndex(value: number);
  10559. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10560. get loopAnimation(): boolean;
  10561. set loopAnimation(value: boolean);
  10562. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10563. get delay(): number;
  10564. set delay(value: number);
  10565. /**
  10566. * Starts an animation
  10567. * @param from defines the initial key
  10568. * @param to defines the end key
  10569. * @param loop defines if the animation must loop
  10570. * @param delay defines the start delay (in ms)
  10571. * @param onAnimationEnd defines a callback to call when animation ends
  10572. */
  10573. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10574. /** Stops current animation (if any) */
  10575. stopAnimation(): void;
  10576. /** @hidden */
  10577. _animate(deltaTime: number): void;
  10578. /** Release associated resources */
  10579. dispose(): void;
  10580. /**
  10581. * Serializes the sprite to a JSON object
  10582. * @returns the JSON object
  10583. */
  10584. serialize(): any;
  10585. /**
  10586. * Parses a JSON object to create a new sprite
  10587. * @param parsedSprite The JSON object to parse
  10588. * @param manager defines the hosting manager
  10589. * @returns the new sprite
  10590. */
  10591. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10592. }
  10593. }
  10594. declare module "babylonjs/Collisions/pickingInfo" {
  10595. import { Nullable } from "babylonjs/types";
  10596. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10598. import { Sprite } from "babylonjs/Sprites/sprite";
  10599. import { Ray } from "babylonjs/Culling/ray";
  10600. /**
  10601. * Information about the result of picking within a scene
  10602. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10603. */
  10604. export class PickingInfo {
  10605. /** @hidden */
  10606. _pickingUnavailable: boolean;
  10607. /**
  10608. * If the pick collided with an object
  10609. */
  10610. hit: boolean;
  10611. /**
  10612. * Distance away where the pick collided
  10613. */
  10614. distance: number;
  10615. /**
  10616. * The location of pick collision
  10617. */
  10618. pickedPoint: Nullable<Vector3>;
  10619. /**
  10620. * The mesh corresponding the the pick collision
  10621. */
  10622. pickedMesh: Nullable<AbstractMesh>;
  10623. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10624. bu: number;
  10625. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10626. bv: number;
  10627. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10628. faceId: number;
  10629. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10630. subMeshFaceId: number;
  10631. /** Id of the the submesh that was picked */
  10632. subMeshId: number;
  10633. /** If a sprite was picked, this will be the sprite the pick collided with */
  10634. pickedSprite: Nullable<Sprite>;
  10635. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10636. thinInstanceIndex: number;
  10637. /**
  10638. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10639. */
  10640. originMesh: Nullable<AbstractMesh>;
  10641. /**
  10642. * The ray that was used to perform the picking.
  10643. */
  10644. ray: Nullable<Ray>;
  10645. /**
  10646. * Gets the normal correspodning to the face the pick collided with
  10647. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10648. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10649. * @returns The normal correspodning to the face the pick collided with
  10650. */
  10651. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10652. /**
  10653. * Gets the texture coordinates of where the pick occured
  10654. * @returns the vector containing the coordnates of the texture
  10655. */
  10656. getTextureCoordinates(): Nullable<Vector2>;
  10657. }
  10658. }
  10659. declare module "babylonjs/Culling/ray" {
  10660. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10661. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10663. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10664. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10665. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10666. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10667. import { Plane } from "babylonjs/Maths/math.plane";
  10668. /**
  10669. * Class representing a ray with position and direction
  10670. */
  10671. export class Ray {
  10672. /** origin point */
  10673. origin: Vector3;
  10674. /** direction */
  10675. direction: Vector3;
  10676. /** length of the ray */
  10677. length: number;
  10678. private static readonly _TmpVector3;
  10679. private _tmpRay;
  10680. /**
  10681. * Creates a new ray
  10682. * @param origin origin point
  10683. * @param direction direction
  10684. * @param length length of the ray
  10685. */
  10686. constructor(
  10687. /** origin point */
  10688. origin: Vector3,
  10689. /** direction */
  10690. direction: Vector3,
  10691. /** length of the ray */
  10692. length?: number);
  10693. /**
  10694. * Checks if the ray intersects a box
  10695. * This does not account for the ray lenght by design to improve perfs.
  10696. * @param minimum bound of the box
  10697. * @param maximum bound of the box
  10698. * @param intersectionTreshold extra extend to be added to the box in all direction
  10699. * @returns if the box was hit
  10700. */
  10701. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10702. /**
  10703. * Checks if the ray intersects a box
  10704. * This does not account for the ray lenght by design to improve perfs.
  10705. * @param box the bounding box to check
  10706. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10707. * @returns if the box was hit
  10708. */
  10709. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10710. /**
  10711. * If the ray hits a sphere
  10712. * @param sphere the bounding sphere to check
  10713. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10714. * @returns true if it hits the sphere
  10715. */
  10716. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10717. /**
  10718. * If the ray hits a triange
  10719. * @param vertex0 triangle vertex
  10720. * @param vertex1 triangle vertex
  10721. * @param vertex2 triangle vertex
  10722. * @returns intersection information if hit
  10723. */
  10724. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10725. /**
  10726. * Checks if ray intersects a plane
  10727. * @param plane the plane to check
  10728. * @returns the distance away it was hit
  10729. */
  10730. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10731. /**
  10732. * Calculate the intercept of a ray on a given axis
  10733. * @param axis to check 'x' | 'y' | 'z'
  10734. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10735. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10736. */
  10737. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10738. /**
  10739. * Checks if ray intersects a mesh
  10740. * @param mesh the mesh to check
  10741. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10742. * @returns picking info of the intersecton
  10743. */
  10744. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10745. /**
  10746. * Checks if ray intersects a mesh
  10747. * @param meshes the meshes to check
  10748. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10749. * @param results array to store result in
  10750. * @returns Array of picking infos
  10751. */
  10752. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10753. private _comparePickingInfo;
  10754. private static smallnum;
  10755. private static rayl;
  10756. /**
  10757. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10758. * @param sega the first point of the segment to test the intersection against
  10759. * @param segb the second point of the segment to test the intersection against
  10760. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10761. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10762. */
  10763. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10764. /**
  10765. * Update the ray from viewport position
  10766. * @param x position
  10767. * @param y y position
  10768. * @param viewportWidth viewport width
  10769. * @param viewportHeight viewport height
  10770. * @param world world matrix
  10771. * @param view view matrix
  10772. * @param projection projection matrix
  10773. * @returns this ray updated
  10774. */
  10775. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10776. /**
  10777. * Creates a ray with origin and direction of 0,0,0
  10778. * @returns the new ray
  10779. */
  10780. static Zero(): Ray;
  10781. /**
  10782. * Creates a new ray from screen space and viewport
  10783. * @param x position
  10784. * @param y y position
  10785. * @param viewportWidth viewport width
  10786. * @param viewportHeight viewport height
  10787. * @param world world matrix
  10788. * @param view view matrix
  10789. * @param projection projection matrix
  10790. * @returns new ray
  10791. */
  10792. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10793. /**
  10794. * 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
  10795. * transformed to the given world matrix.
  10796. * @param origin The origin point
  10797. * @param end The end point
  10798. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10799. * @returns the new ray
  10800. */
  10801. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10802. /**
  10803. * Transforms a ray by a matrix
  10804. * @param ray ray to transform
  10805. * @param matrix matrix to apply
  10806. * @returns the resulting new ray
  10807. */
  10808. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10809. /**
  10810. * Transforms a ray by a matrix
  10811. * @param ray ray to transform
  10812. * @param matrix matrix to apply
  10813. * @param result ray to store result in
  10814. */
  10815. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10816. /**
  10817. * Unproject a ray from screen space to object space
  10818. * @param sourceX defines the screen space x coordinate to use
  10819. * @param sourceY defines the screen space y coordinate to use
  10820. * @param viewportWidth defines the current width of the viewport
  10821. * @param viewportHeight defines the current height of the viewport
  10822. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10823. * @param view defines the view matrix to use
  10824. * @param projection defines the projection matrix to use
  10825. */
  10826. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10827. }
  10828. /**
  10829. * Type used to define predicate used to select faces when a mesh intersection is detected
  10830. */
  10831. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10832. module "babylonjs/scene" {
  10833. interface Scene {
  10834. /** @hidden */
  10835. _tempPickingRay: Nullable<Ray>;
  10836. /** @hidden */
  10837. _cachedRayForTransform: Ray;
  10838. /** @hidden */
  10839. _pickWithRayInverseMatrix: Matrix;
  10840. /** @hidden */
  10841. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10842. /** @hidden */
  10843. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10844. /** @hidden */
  10845. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10846. }
  10847. }
  10848. }
  10849. declare module "babylonjs/sceneComponent" {
  10850. import { Scene } from "babylonjs/scene";
  10851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10852. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10853. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10854. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10855. import { Nullable } from "babylonjs/types";
  10856. import { Camera } from "babylonjs/Cameras/camera";
  10857. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10858. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10859. import { AbstractScene } from "babylonjs/abstractScene";
  10860. import { Mesh } from "babylonjs/Meshes/mesh";
  10861. /**
  10862. * Groups all the scene component constants in one place to ease maintenance.
  10863. * @hidden
  10864. */
  10865. export class SceneComponentConstants {
  10866. static readonly NAME_EFFECTLAYER: string;
  10867. static readonly NAME_LAYER: string;
  10868. static readonly NAME_LENSFLARESYSTEM: string;
  10869. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10870. static readonly NAME_PARTICLESYSTEM: string;
  10871. static readonly NAME_GAMEPAD: string;
  10872. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10873. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10874. static readonly NAME_PREPASSRENDERER: string;
  10875. static readonly NAME_DEPTHRENDERER: string;
  10876. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10877. static readonly NAME_SPRITE: string;
  10878. static readonly NAME_SUBSURFACE: string;
  10879. static readonly NAME_OUTLINERENDERER: string;
  10880. static readonly NAME_PROCEDURALTEXTURE: string;
  10881. static readonly NAME_SHADOWGENERATOR: string;
  10882. static readonly NAME_OCTREE: string;
  10883. static readonly NAME_PHYSICSENGINE: string;
  10884. static readonly NAME_AUDIO: string;
  10885. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10886. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10887. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10888. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10889. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10890. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10891. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10892. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10893. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10894. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10895. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10896. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10897. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10898. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10899. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10900. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10901. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10902. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10903. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10904. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10905. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10906. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10907. static readonly STEP_AFTERRENDER_AUDIO: number;
  10908. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10909. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10910. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10911. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10912. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10913. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10914. static readonly STEP_POINTERMOVE_SPRITE: number;
  10915. static readonly STEP_POINTERDOWN_SPRITE: number;
  10916. static readonly STEP_POINTERUP_SPRITE: number;
  10917. }
  10918. /**
  10919. * This represents a scene component.
  10920. *
  10921. * This is used to decouple the dependency the scene is having on the different workloads like
  10922. * layers, post processes...
  10923. */
  10924. export interface ISceneComponent {
  10925. /**
  10926. * The name of the component. Each component must have a unique name.
  10927. */
  10928. name: string;
  10929. /**
  10930. * The scene the component belongs to.
  10931. */
  10932. scene: Scene;
  10933. /**
  10934. * Register the component to one instance of a scene.
  10935. */
  10936. register(): void;
  10937. /**
  10938. * Rebuilds the elements related to this component in case of
  10939. * context lost for instance.
  10940. */
  10941. rebuild(): void;
  10942. /**
  10943. * Disposes the component and the associated ressources.
  10944. */
  10945. dispose(): void;
  10946. }
  10947. /**
  10948. * This represents a SERIALIZABLE scene component.
  10949. *
  10950. * This extends Scene Component to add Serialization methods on top.
  10951. */
  10952. export interface ISceneSerializableComponent extends ISceneComponent {
  10953. /**
  10954. * Adds all the elements from the container to the scene
  10955. * @param container the container holding the elements
  10956. */
  10957. addFromContainer(container: AbstractScene): void;
  10958. /**
  10959. * Removes all the elements in the container from the scene
  10960. * @param container contains the elements to remove
  10961. * @param dispose if the removed element should be disposed (default: false)
  10962. */
  10963. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10964. /**
  10965. * Serializes the component data to the specified json object
  10966. * @param serializationObject The object to serialize to
  10967. */
  10968. serialize(serializationObject: any): void;
  10969. }
  10970. /**
  10971. * Strong typing of a Mesh related stage step action
  10972. */
  10973. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10974. /**
  10975. * Strong typing of a Evaluate Sub Mesh related stage step action
  10976. */
  10977. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10978. /**
  10979. * Strong typing of a Active Mesh related stage step action
  10980. */
  10981. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10982. /**
  10983. * Strong typing of a Camera related stage step action
  10984. */
  10985. export type CameraStageAction = (camera: Camera) => void;
  10986. /**
  10987. * Strong typing of a Camera Frame buffer related stage step action
  10988. */
  10989. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10990. /**
  10991. * Strong typing of a Render Target related stage step action
  10992. */
  10993. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10994. /**
  10995. * Strong typing of a RenderingGroup related stage step action
  10996. */
  10997. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10998. /**
  10999. * Strong typing of a Mesh Render related stage step action
  11000. */
  11001. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11002. /**
  11003. * Strong typing of a simple stage step action
  11004. */
  11005. export type SimpleStageAction = () => void;
  11006. /**
  11007. * Strong typing of a render target action.
  11008. */
  11009. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11010. /**
  11011. * Strong typing of a pointer move action.
  11012. */
  11013. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11014. /**
  11015. * Strong typing of a pointer up/down action.
  11016. */
  11017. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11018. /**
  11019. * Representation of a stage in the scene (Basically a list of ordered steps)
  11020. * @hidden
  11021. */
  11022. export class Stage<T extends Function> extends Array<{
  11023. index: number;
  11024. component: ISceneComponent;
  11025. action: T;
  11026. }> {
  11027. /**
  11028. * Hide ctor from the rest of the world.
  11029. * @param items The items to add.
  11030. */
  11031. private constructor();
  11032. /**
  11033. * Creates a new Stage.
  11034. * @returns A new instance of a Stage
  11035. */
  11036. static Create<T extends Function>(): Stage<T>;
  11037. /**
  11038. * Registers a step in an ordered way in the targeted stage.
  11039. * @param index Defines the position to register the step in
  11040. * @param component Defines the component attached to the step
  11041. * @param action Defines the action to launch during the step
  11042. */
  11043. registerStep(index: number, component: ISceneComponent, action: T): void;
  11044. /**
  11045. * Clears all the steps from the stage.
  11046. */
  11047. clear(): void;
  11048. }
  11049. }
  11050. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11051. import { Nullable } from "babylonjs/types";
  11052. import { Observable } from "babylonjs/Misc/observable";
  11053. import { Scene } from "babylonjs/scene";
  11054. import { Sprite } from "babylonjs/Sprites/sprite";
  11055. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11056. import { Ray } from "babylonjs/Culling/ray";
  11057. import { Camera } from "babylonjs/Cameras/camera";
  11058. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11059. import { ISceneComponent } from "babylonjs/sceneComponent";
  11060. module "babylonjs/scene" {
  11061. interface Scene {
  11062. /** @hidden */
  11063. _pointerOverSprite: Nullable<Sprite>;
  11064. /** @hidden */
  11065. _pickedDownSprite: Nullable<Sprite>;
  11066. /** @hidden */
  11067. _tempSpritePickingRay: Nullable<Ray>;
  11068. /**
  11069. * All of the sprite managers added to this scene
  11070. * @see https://doc.babylonjs.com/babylon101/sprites
  11071. */
  11072. spriteManagers: Array<ISpriteManager>;
  11073. /**
  11074. * An event triggered when sprites rendering is about to start
  11075. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11076. */
  11077. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11078. /**
  11079. * An event triggered when sprites rendering is done
  11080. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11081. */
  11082. onAfterSpritesRenderingObservable: Observable<Scene>;
  11083. /** @hidden */
  11084. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11085. /** Launch a ray to try to pick a sprite in the scene
  11086. * @param x position on screen
  11087. * @param y position on screen
  11088. * @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
  11089. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11090. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11091. * @returns a PickingInfo
  11092. */
  11093. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11094. /** Use the given ray to pick a sprite in the scene
  11095. * @param ray The ray (in world space) to use to pick meshes
  11096. * @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
  11097. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11098. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11099. * @returns a PickingInfo
  11100. */
  11101. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11102. /** @hidden */
  11103. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11104. /** Launch a ray to try to pick sprites in the scene
  11105. * @param x position on screen
  11106. * @param y position on screen
  11107. * @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
  11108. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11109. * @returns a PickingInfo array
  11110. */
  11111. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11112. /** Use the given ray to pick sprites in the scene
  11113. * @param ray The ray (in world space) to use to pick meshes
  11114. * @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
  11115. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11116. * @returns a PickingInfo array
  11117. */
  11118. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11119. /**
  11120. * Force the sprite under the pointer
  11121. * @param sprite defines the sprite to use
  11122. */
  11123. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11124. /**
  11125. * Gets the sprite under the pointer
  11126. * @returns a Sprite or null if no sprite is under the pointer
  11127. */
  11128. getPointerOverSprite(): Nullable<Sprite>;
  11129. }
  11130. }
  11131. /**
  11132. * Defines the sprite scene component responsible to manage sprites
  11133. * in a given scene.
  11134. */
  11135. export class SpriteSceneComponent implements ISceneComponent {
  11136. /**
  11137. * The component name helpfull to identify the component in the list of scene components.
  11138. */
  11139. readonly name: string;
  11140. /**
  11141. * The scene the component belongs to.
  11142. */
  11143. scene: Scene;
  11144. /** @hidden */
  11145. private _spritePredicate;
  11146. /**
  11147. * Creates a new instance of the component for the given scene
  11148. * @param scene Defines the scene to register the component in
  11149. */
  11150. constructor(scene: Scene);
  11151. /**
  11152. * Registers the component in a given scene
  11153. */
  11154. register(): void;
  11155. /**
  11156. * Rebuilds the elements related to this component in case of
  11157. * context lost for instance.
  11158. */
  11159. rebuild(): void;
  11160. /**
  11161. * Disposes the component and the associated ressources.
  11162. */
  11163. dispose(): void;
  11164. private _pickSpriteButKeepRay;
  11165. private _pointerMove;
  11166. private _pointerDown;
  11167. private _pointerUp;
  11168. }
  11169. }
  11170. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11171. /** @hidden */
  11172. export var fogFragmentDeclaration: {
  11173. name: string;
  11174. shader: string;
  11175. };
  11176. }
  11177. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11178. /** @hidden */
  11179. export var fogFragment: {
  11180. name: string;
  11181. shader: string;
  11182. };
  11183. }
  11184. declare module "babylonjs/Shaders/sprites.fragment" {
  11185. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11186. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11187. /** @hidden */
  11188. export var spritesPixelShader: {
  11189. name: string;
  11190. shader: string;
  11191. };
  11192. }
  11193. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11194. /** @hidden */
  11195. export var fogVertexDeclaration: {
  11196. name: string;
  11197. shader: string;
  11198. };
  11199. }
  11200. declare module "babylonjs/Shaders/sprites.vertex" {
  11201. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11202. /** @hidden */
  11203. export var spritesVertexShader: {
  11204. name: string;
  11205. shader: string;
  11206. };
  11207. }
  11208. declare module "babylonjs/Sprites/spriteManager" {
  11209. import { IDisposable, Scene } from "babylonjs/scene";
  11210. import { Nullable } from "babylonjs/types";
  11211. import { Observable } from "babylonjs/Misc/observable";
  11212. import { Sprite } from "babylonjs/Sprites/sprite";
  11213. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11214. import { Camera } from "babylonjs/Cameras/camera";
  11215. import { Texture } from "babylonjs/Materials/Textures/texture";
  11216. import "babylonjs/Shaders/sprites.fragment";
  11217. import "babylonjs/Shaders/sprites.vertex";
  11218. import { Ray } from "babylonjs/Culling/ray";
  11219. /**
  11220. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11221. */
  11222. export interface ISpriteManager extends IDisposable {
  11223. /**
  11224. * Gets manager's name
  11225. */
  11226. name: string;
  11227. /**
  11228. * Restricts the camera to viewing objects with the same layerMask.
  11229. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11230. */
  11231. layerMask: number;
  11232. /**
  11233. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11234. */
  11235. isPickable: boolean;
  11236. /**
  11237. * Gets the hosting scene
  11238. */
  11239. scene: Scene;
  11240. /**
  11241. * Specifies the rendering group id for this mesh (0 by default)
  11242. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11243. */
  11244. renderingGroupId: number;
  11245. /**
  11246. * Defines the list of sprites managed by the manager.
  11247. */
  11248. sprites: Array<Sprite>;
  11249. /**
  11250. * Gets or sets the spritesheet texture
  11251. */
  11252. texture: Texture;
  11253. /** Defines the default width of a cell in the spritesheet */
  11254. cellWidth: number;
  11255. /** Defines the default height of a cell in the spritesheet */
  11256. cellHeight: number;
  11257. /**
  11258. * Tests the intersection of a sprite with a specific ray.
  11259. * @param ray The ray we are sending to test the collision
  11260. * @param camera The camera space we are sending rays in
  11261. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11262. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11263. * @returns picking info or null.
  11264. */
  11265. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11266. /**
  11267. * Intersects the sprites with a ray
  11268. * @param ray defines the ray to intersect with
  11269. * @param camera defines the current active camera
  11270. * @param predicate defines a predicate used to select candidate sprites
  11271. * @returns null if no hit or a PickingInfo array
  11272. */
  11273. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11274. /**
  11275. * Renders the list of sprites on screen.
  11276. */
  11277. render(): void;
  11278. }
  11279. /**
  11280. * Class used to manage multiple sprites on the same spritesheet
  11281. * @see https://doc.babylonjs.com/babylon101/sprites
  11282. */
  11283. export class SpriteManager implements ISpriteManager {
  11284. /** defines the manager's name */
  11285. name: string;
  11286. /** Define the Url to load snippets */
  11287. static SnippetUrl: string;
  11288. /** Snippet ID if the manager was created from the snippet server */
  11289. snippetId: string;
  11290. /** Gets the list of sprites */
  11291. sprites: Sprite[];
  11292. /** Gets or sets the rendering group id (0 by default) */
  11293. renderingGroupId: number;
  11294. /** Gets or sets camera layer mask */
  11295. layerMask: number;
  11296. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11297. fogEnabled: boolean;
  11298. /** Gets or sets a boolean indicating if the sprites are pickable */
  11299. isPickable: boolean;
  11300. /** Defines the default width of a cell in the spritesheet */
  11301. cellWidth: number;
  11302. /** Defines the default height of a cell in the spritesheet */
  11303. cellHeight: number;
  11304. /** Associative array from JSON sprite data file */
  11305. private _cellData;
  11306. /** Array of sprite names from JSON sprite data file */
  11307. private _spriteMap;
  11308. /** True when packed cell data from JSON file is ready*/
  11309. private _packedAndReady;
  11310. private _textureContent;
  11311. private _useInstancing;
  11312. /**
  11313. * An event triggered when the manager is disposed.
  11314. */
  11315. onDisposeObservable: Observable<SpriteManager>;
  11316. private _onDisposeObserver;
  11317. /**
  11318. * Callback called when the manager is disposed
  11319. */
  11320. set onDispose(callback: () => void);
  11321. private _capacity;
  11322. private _fromPacked;
  11323. private _spriteTexture;
  11324. private _epsilon;
  11325. private _scene;
  11326. private _vertexData;
  11327. private _buffer;
  11328. private _vertexBuffers;
  11329. private _spriteBuffer;
  11330. private _indexBuffer;
  11331. private _effectBase;
  11332. private _effectFog;
  11333. private _vertexBufferSize;
  11334. /**
  11335. * Gets or sets the unique id of the sprite
  11336. */
  11337. uniqueId: number;
  11338. /**
  11339. * Gets the array of sprites
  11340. */
  11341. get children(): Sprite[];
  11342. /**
  11343. * Gets the hosting scene
  11344. */
  11345. get scene(): Scene;
  11346. /**
  11347. * Gets the capacity of the manager
  11348. */
  11349. get capacity(): number;
  11350. /**
  11351. * Gets or sets the spritesheet texture
  11352. */
  11353. get texture(): Texture;
  11354. set texture(value: Texture);
  11355. private _blendMode;
  11356. /**
  11357. * Blend mode use to render the particle, it can be any of
  11358. * the static Constants.ALPHA_x properties provided in this class.
  11359. * Default value is Constants.ALPHA_COMBINE
  11360. */
  11361. get blendMode(): number;
  11362. set blendMode(blendMode: number);
  11363. /** Disables writing to the depth buffer when rendering the sprites.
  11364. * It can be handy to disable depth writing when using textures without alpha channel
  11365. * and setting some specific blend modes.
  11366. */
  11367. disableDepthWrite: boolean;
  11368. /**
  11369. * Creates a new sprite manager
  11370. * @param name defines the manager's name
  11371. * @param imgUrl defines the sprite sheet url
  11372. * @param capacity defines the maximum allowed number of sprites
  11373. * @param cellSize defines the size of a sprite cell
  11374. * @param scene defines the hosting scene
  11375. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11376. * @param samplingMode defines the smapling mode to use with spritesheet
  11377. * @param fromPacked set to false; do not alter
  11378. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11379. */
  11380. constructor(
  11381. /** defines the manager's name */
  11382. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11383. /**
  11384. * Returns the string "SpriteManager"
  11385. * @returns "SpriteManager"
  11386. */
  11387. getClassName(): string;
  11388. private _makePacked;
  11389. private _appendSpriteVertex;
  11390. private _checkTextureAlpha;
  11391. /**
  11392. * Intersects the sprites with a ray
  11393. * @param ray defines the ray to intersect with
  11394. * @param camera defines the current active camera
  11395. * @param predicate defines a predicate used to select candidate sprites
  11396. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11397. * @returns null if no hit or a PickingInfo
  11398. */
  11399. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11400. /**
  11401. * Intersects the sprites with a ray
  11402. * @param ray defines the ray to intersect with
  11403. * @param camera defines the current active camera
  11404. * @param predicate defines a predicate used to select candidate sprites
  11405. * @returns null if no hit or a PickingInfo array
  11406. */
  11407. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11408. /**
  11409. * Render all child sprites
  11410. */
  11411. render(): void;
  11412. /**
  11413. * Release associated resources
  11414. */
  11415. dispose(): void;
  11416. /**
  11417. * Serializes the sprite manager to a JSON object
  11418. * @param serializeTexture defines if the texture must be serialized as well
  11419. * @returns the JSON object
  11420. */
  11421. serialize(serializeTexture?: boolean): any;
  11422. /**
  11423. * Parses a JSON object to create a new sprite manager.
  11424. * @param parsedManager The JSON object to parse
  11425. * @param scene The scene to create the sprite managerin
  11426. * @param rootUrl The root url to use to load external dependencies like texture
  11427. * @returns the new sprite manager
  11428. */
  11429. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11430. /**
  11431. * Creates a sprite manager from a snippet saved in a remote file
  11432. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11433. * @param url defines the url to load from
  11434. * @param scene defines the hosting scene
  11435. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11436. * @returns a promise that will resolve to the new sprite manager
  11437. */
  11438. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11439. /**
  11440. * Creates a sprite manager from a snippet saved by the sprite editor
  11441. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11442. * @param scene defines the hosting scene
  11443. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11444. * @returns a promise that will resolve to the new sprite manager
  11445. */
  11446. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11447. }
  11448. }
  11449. declare module "babylonjs/Misc/gradients" {
  11450. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11451. /** Interface used by value gradients (color, factor, ...) */
  11452. export interface IValueGradient {
  11453. /**
  11454. * Gets or sets the gradient value (between 0 and 1)
  11455. */
  11456. gradient: number;
  11457. }
  11458. /** Class used to store color4 gradient */
  11459. export class ColorGradient implements IValueGradient {
  11460. /**
  11461. * Gets or sets the gradient value (between 0 and 1)
  11462. */
  11463. gradient: number;
  11464. /**
  11465. * Gets or sets first associated color
  11466. */
  11467. color1: Color4;
  11468. /**
  11469. * Gets or sets second associated color
  11470. */
  11471. color2?: Color4 | undefined;
  11472. /**
  11473. * Creates a new color4 gradient
  11474. * @param gradient gets or sets the gradient value (between 0 and 1)
  11475. * @param color1 gets or sets first associated color
  11476. * @param color2 gets or sets first second color
  11477. */
  11478. constructor(
  11479. /**
  11480. * Gets or sets the gradient value (between 0 and 1)
  11481. */
  11482. gradient: number,
  11483. /**
  11484. * Gets or sets first associated color
  11485. */
  11486. color1: Color4,
  11487. /**
  11488. * Gets or sets second associated color
  11489. */
  11490. color2?: Color4 | undefined);
  11491. /**
  11492. * Will get a color picked randomly between color1 and color2.
  11493. * If color2 is undefined then color1 will be used
  11494. * @param result defines the target Color4 to store the result in
  11495. */
  11496. getColorToRef(result: Color4): void;
  11497. }
  11498. /** Class used to store color 3 gradient */
  11499. export class Color3Gradient implements IValueGradient {
  11500. /**
  11501. * Gets or sets the gradient value (between 0 and 1)
  11502. */
  11503. gradient: number;
  11504. /**
  11505. * Gets or sets the associated color
  11506. */
  11507. color: Color3;
  11508. /**
  11509. * Creates a new color3 gradient
  11510. * @param gradient gets or sets the gradient value (between 0 and 1)
  11511. * @param color gets or sets associated color
  11512. */
  11513. constructor(
  11514. /**
  11515. * Gets or sets the gradient value (between 0 and 1)
  11516. */
  11517. gradient: number,
  11518. /**
  11519. * Gets or sets the associated color
  11520. */
  11521. color: Color3);
  11522. }
  11523. /** Class used to store factor gradient */
  11524. export class FactorGradient implements IValueGradient {
  11525. /**
  11526. * Gets or sets the gradient value (between 0 and 1)
  11527. */
  11528. gradient: number;
  11529. /**
  11530. * Gets or sets first associated factor
  11531. */
  11532. factor1: number;
  11533. /**
  11534. * Gets or sets second associated factor
  11535. */
  11536. factor2?: number | undefined;
  11537. /**
  11538. * Creates a new factor gradient
  11539. * @param gradient gets or sets the gradient value (between 0 and 1)
  11540. * @param factor1 gets or sets first associated factor
  11541. * @param factor2 gets or sets second associated factor
  11542. */
  11543. constructor(
  11544. /**
  11545. * Gets or sets the gradient value (between 0 and 1)
  11546. */
  11547. gradient: number,
  11548. /**
  11549. * Gets or sets first associated factor
  11550. */
  11551. factor1: number,
  11552. /**
  11553. * Gets or sets second associated factor
  11554. */
  11555. factor2?: number | undefined);
  11556. /**
  11557. * Will get a number picked randomly between factor1 and factor2.
  11558. * If factor2 is undefined then factor1 will be used
  11559. * @returns the picked number
  11560. */
  11561. getFactor(): number;
  11562. }
  11563. /**
  11564. * Helper used to simplify some generic gradient tasks
  11565. */
  11566. export class GradientHelper {
  11567. /**
  11568. * Gets the current gradient from an array of IValueGradient
  11569. * @param ratio defines the current ratio to get
  11570. * @param gradients defines the array of IValueGradient
  11571. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11572. */
  11573. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11574. }
  11575. }
  11576. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11577. import { Nullable } from "babylonjs/types";
  11578. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11579. import { Scene } from "babylonjs/scene";
  11580. module "babylonjs/Engines/thinEngine" {
  11581. interface ThinEngine {
  11582. /**
  11583. * Creates a raw texture
  11584. * @param data defines the data to store in the texture
  11585. * @param width defines the width of the texture
  11586. * @param height defines the height of the texture
  11587. * @param format defines the format of the data
  11588. * @param generateMipMaps defines if the engine should generate the mip levels
  11589. * @param invertY defines if data must be stored with Y axis inverted
  11590. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11591. * @param compression defines the compression used (null by default)
  11592. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11593. * @returns the raw texture inside an InternalTexture
  11594. */
  11595. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11596. /**
  11597. * Update a raw texture
  11598. * @param texture defines the texture to update
  11599. * @param data defines the data to store in the texture
  11600. * @param format defines the format of the data
  11601. * @param invertY defines if data must be stored with Y axis inverted
  11602. */
  11603. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11604. /**
  11605. * Update a raw texture
  11606. * @param texture defines the texture to update
  11607. * @param data defines the data to store in the texture
  11608. * @param format defines the format of the data
  11609. * @param invertY defines if data must be stored with Y axis inverted
  11610. * @param compression defines the compression used (null by default)
  11611. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11612. */
  11613. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11614. /**
  11615. * Creates a new raw cube texture
  11616. * @param data defines the array of data to use to create each face
  11617. * @param size defines the size of the textures
  11618. * @param format defines the format of the data
  11619. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11620. * @param generateMipMaps defines if the engine should generate the mip levels
  11621. * @param invertY defines if data must be stored with Y axis inverted
  11622. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11623. * @param compression defines the compression used (null by default)
  11624. * @returns the cube texture as an InternalTexture
  11625. */
  11626. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11627. /**
  11628. * Update a raw cube texture
  11629. * @param texture defines the texture to udpdate
  11630. * @param data defines the data to store
  11631. * @param format defines the data format
  11632. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11633. * @param invertY defines if data must be stored with Y axis inverted
  11634. */
  11635. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11636. /**
  11637. * Update a raw cube texture
  11638. * @param texture defines the texture to udpdate
  11639. * @param data defines the data to store
  11640. * @param format defines the data format
  11641. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11642. * @param invertY defines if data must be stored with Y axis inverted
  11643. * @param compression defines the compression used (null by default)
  11644. */
  11645. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11646. /**
  11647. * Update a raw cube texture
  11648. * @param texture defines the texture to udpdate
  11649. * @param data defines the data to store
  11650. * @param format defines the data format
  11651. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11652. * @param invertY defines if data must be stored with Y axis inverted
  11653. * @param compression defines the compression used (null by default)
  11654. * @param level defines which level of the texture to update
  11655. */
  11656. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11657. /**
  11658. * Creates a new raw cube texture from a specified url
  11659. * @param url defines the url where the data is located
  11660. * @param scene defines the current scene
  11661. * @param size defines the size of the textures
  11662. * @param format defines the format of the data
  11663. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11664. * @param noMipmap defines if the engine should avoid generating the mip levels
  11665. * @param callback defines a callback used to extract texture data from loaded data
  11666. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11667. * @param onLoad defines a callback called when texture is loaded
  11668. * @param onError defines a callback called if there is an error
  11669. * @returns the cube texture as an InternalTexture
  11670. */
  11671. 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;
  11672. /**
  11673. * Creates a new raw cube texture from a specified url
  11674. * @param url defines the url where the data is located
  11675. * @param scene defines the current scene
  11676. * @param size defines the size of the textures
  11677. * @param format defines the format of the data
  11678. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11679. * @param noMipmap defines if the engine should avoid generating the mip levels
  11680. * @param callback defines a callback used to extract texture data from loaded data
  11681. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11682. * @param onLoad defines a callback called when texture is loaded
  11683. * @param onError defines a callback called if there is an error
  11684. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11685. * @param invertY defines if data must be stored with Y axis inverted
  11686. * @returns the cube texture as an InternalTexture
  11687. */
  11688. 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;
  11689. /**
  11690. * Creates a new raw 3D texture
  11691. * @param data defines the data used to create the texture
  11692. * @param width defines the width of the texture
  11693. * @param height defines the height of the texture
  11694. * @param depth defines the depth of the texture
  11695. * @param format defines the format of the texture
  11696. * @param generateMipMaps defines if the engine must generate mip levels
  11697. * @param invertY defines if data must be stored with Y axis inverted
  11698. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11699. * @param compression defines the compressed used (can be null)
  11700. * @param textureType defines the compressed used (can be null)
  11701. * @returns a new raw 3D texture (stored in an InternalTexture)
  11702. */
  11703. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11704. /**
  11705. * Update a raw 3D texture
  11706. * @param texture defines the texture to update
  11707. * @param data defines the data to store
  11708. * @param format defines the data format
  11709. * @param invertY defines if data must be stored with Y axis inverted
  11710. */
  11711. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11712. /**
  11713. * Update a raw 3D texture
  11714. * @param texture defines the texture to update
  11715. * @param data defines the data to store
  11716. * @param format defines the data format
  11717. * @param invertY defines if data must be stored with Y axis inverted
  11718. * @param compression defines the used compression (can be null)
  11719. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11720. */
  11721. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11722. /**
  11723. * Creates a new raw 2D array texture
  11724. * @param data defines the data used to create the texture
  11725. * @param width defines the width of the texture
  11726. * @param height defines the height of the texture
  11727. * @param depth defines the number of layers of the texture
  11728. * @param format defines the format of the texture
  11729. * @param generateMipMaps defines if the engine must generate mip levels
  11730. * @param invertY defines if data must be stored with Y axis inverted
  11731. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11732. * @param compression defines the compressed used (can be null)
  11733. * @param textureType defines the compressed used (can be null)
  11734. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11735. */
  11736. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11737. /**
  11738. * Update a raw 2D array texture
  11739. * @param texture defines the texture to update
  11740. * @param data defines the data to store
  11741. * @param format defines the data format
  11742. * @param invertY defines if data must be stored with Y axis inverted
  11743. */
  11744. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11745. /**
  11746. * Update a raw 2D array texture
  11747. * @param texture defines the texture to update
  11748. * @param data defines the data to store
  11749. * @param format defines the data format
  11750. * @param invertY defines if data must be stored with Y axis inverted
  11751. * @param compression defines the used compression (can be null)
  11752. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11753. */
  11754. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11755. }
  11756. }
  11757. }
  11758. declare module "babylonjs/Materials/Textures/rawTexture" {
  11759. import { Texture } from "babylonjs/Materials/Textures/texture";
  11760. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11761. import { Nullable } from "babylonjs/types";
  11762. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11763. import { Scene } from "babylonjs/scene";
  11764. /**
  11765. * Raw texture can help creating a texture directly from an array of data.
  11766. * This can be super useful if you either get the data from an uncompressed source or
  11767. * if you wish to create your texture pixel by pixel.
  11768. */
  11769. export class RawTexture extends Texture {
  11770. /**
  11771. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11772. */
  11773. format: number;
  11774. /**
  11775. * Instantiates a new RawTexture.
  11776. * Raw texture can help creating a texture directly from an array of data.
  11777. * This can be super useful if you either get the data from an uncompressed source or
  11778. * if you wish to create your texture pixel by pixel.
  11779. * @param data define the array of data to use to create the texture
  11780. * @param width define the width of the texture
  11781. * @param height define the height of the texture
  11782. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11783. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11784. * @param generateMipMaps define whether mip maps should be generated or not
  11785. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11786. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11787. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11788. */
  11789. constructor(data: ArrayBufferView, width: number, height: number,
  11790. /**
  11791. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11792. */
  11793. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11794. /**
  11795. * Updates the texture underlying data.
  11796. * @param data Define the new data of the texture
  11797. */
  11798. update(data: ArrayBufferView): void;
  11799. /**
  11800. * Creates a luminance texture from some data.
  11801. * @param data Define the texture data
  11802. * @param width Define the width of the texture
  11803. * @param height Define the height of the texture
  11804. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11805. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11806. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11807. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11808. * @returns the luminance texture
  11809. */
  11810. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11811. /**
  11812. * Creates a luminance alpha texture from some data.
  11813. * @param data Define the texture data
  11814. * @param width Define the width of the texture
  11815. * @param height Define the height of the texture
  11816. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11817. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11818. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11819. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11820. * @returns the luminance alpha texture
  11821. */
  11822. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11823. /**
  11824. * Creates an alpha texture from some data.
  11825. * @param data Define the texture data
  11826. * @param width Define the width of the texture
  11827. * @param height Define the height of the texture
  11828. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11829. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11830. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11831. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11832. * @returns the alpha texture
  11833. */
  11834. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11835. /**
  11836. * Creates a RGB texture from some data.
  11837. * @param data Define the texture data
  11838. * @param width Define the width of the texture
  11839. * @param height Define the height of the texture
  11840. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11841. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11842. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11843. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11844. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11845. * @returns the RGB alpha texture
  11846. */
  11847. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11848. /**
  11849. * Creates a RGBA texture from some data.
  11850. * @param data Define the texture data
  11851. * @param width Define the width of the texture
  11852. * @param height Define the height of the texture
  11853. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11854. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11855. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11856. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11857. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11858. * @returns the RGBA texture
  11859. */
  11860. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11861. /**
  11862. * Creates a R texture from some data.
  11863. * @param data Define the texture data
  11864. * @param width Define the width of the texture
  11865. * @param height Define the height of the texture
  11866. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11867. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11868. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11869. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11870. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11871. * @returns the R texture
  11872. */
  11873. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11874. }
  11875. }
  11876. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11877. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11878. import { IndicesArray, DataArray } from "babylonjs/types";
  11879. module "babylonjs/Engines/thinEngine" {
  11880. interface ThinEngine {
  11881. /**
  11882. * Update a dynamic index buffer
  11883. * @param indexBuffer defines the target index buffer
  11884. * @param indices defines the data to update
  11885. * @param offset defines the offset in the target index buffer where update should start
  11886. */
  11887. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11888. /**
  11889. * Updates a dynamic vertex buffer.
  11890. * @param vertexBuffer the vertex buffer to update
  11891. * @param data the data used to update the vertex buffer
  11892. * @param byteOffset the byte offset of the data
  11893. * @param byteLength the byte length of the data
  11894. */
  11895. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11896. }
  11897. }
  11898. }
  11899. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11900. import { Scene } from "babylonjs/scene";
  11901. import { ISceneComponent } from "babylonjs/sceneComponent";
  11902. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11903. module "babylonjs/abstractScene" {
  11904. interface AbstractScene {
  11905. /**
  11906. * The list of procedural textures added to the scene
  11907. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11908. */
  11909. proceduralTextures: Array<ProceduralTexture>;
  11910. }
  11911. }
  11912. /**
  11913. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11914. * in a given scene.
  11915. */
  11916. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11917. /**
  11918. * The component name helpfull to identify the component in the list of scene components.
  11919. */
  11920. readonly name: string;
  11921. /**
  11922. * The scene the component belongs to.
  11923. */
  11924. scene: Scene;
  11925. /**
  11926. * Creates a new instance of the component for the given scene
  11927. * @param scene Defines the scene to register the component in
  11928. */
  11929. constructor(scene: Scene);
  11930. /**
  11931. * Registers the component in a given scene
  11932. */
  11933. register(): void;
  11934. /**
  11935. * Rebuilds the elements related to this component in case of
  11936. * context lost for instance.
  11937. */
  11938. rebuild(): void;
  11939. /**
  11940. * Disposes the component and the associated ressources.
  11941. */
  11942. dispose(): void;
  11943. private _beforeClear;
  11944. }
  11945. }
  11946. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11947. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11948. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11949. module "babylonjs/Engines/thinEngine" {
  11950. interface ThinEngine {
  11951. /**
  11952. * Creates a new render target cube texture
  11953. * @param size defines the size of the texture
  11954. * @param options defines the options used to create the texture
  11955. * @returns a new render target cube texture stored in an InternalTexture
  11956. */
  11957. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11958. }
  11959. }
  11960. }
  11961. declare module "babylonjs/Shaders/procedural.vertex" {
  11962. /** @hidden */
  11963. export var proceduralVertexShader: {
  11964. name: string;
  11965. shader: string;
  11966. };
  11967. }
  11968. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11969. import { Observable } from "babylonjs/Misc/observable";
  11970. import { Nullable } from "babylonjs/types";
  11971. import { Scene } from "babylonjs/scene";
  11972. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11973. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11974. import { Effect } from "babylonjs/Materials/effect";
  11975. import { Texture } from "babylonjs/Materials/Textures/texture";
  11976. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11977. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11978. import "babylonjs/Shaders/procedural.vertex";
  11979. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  11980. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  11981. /**
  11982. * 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.
  11983. * This is the base class of any Procedural texture and contains most of the shareable code.
  11984. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11985. */
  11986. export class ProceduralTexture extends Texture {
  11987. /**
  11988. * Define if the texture is enabled or not (disabled texture will not render)
  11989. */
  11990. isEnabled: boolean;
  11991. /**
  11992. * Define if the texture must be cleared before rendering (default is true)
  11993. */
  11994. autoClear: boolean;
  11995. /**
  11996. * Callback called when the texture is generated
  11997. */
  11998. onGenerated: () => void;
  11999. /**
  12000. * Event raised when the texture is generated
  12001. */
  12002. onGeneratedObservable: Observable<ProceduralTexture>;
  12003. /**
  12004. * Event raised before the texture is generated
  12005. */
  12006. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12007. /**
  12008. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12009. */
  12010. nodeMaterialSource: Nullable<NodeMaterial>;
  12011. /** @hidden */
  12012. _generateMipMaps: boolean;
  12013. /** @hidden **/
  12014. _effect: Effect;
  12015. /** @hidden */
  12016. _textures: {
  12017. [key: string]: Texture;
  12018. };
  12019. /** @hidden */
  12020. protected _fallbackTexture: Nullable<Texture>;
  12021. private _size;
  12022. private _currentRefreshId;
  12023. private _frameId;
  12024. private _refreshRate;
  12025. private _vertexBuffers;
  12026. private _indexBuffer;
  12027. private _uniforms;
  12028. private _samplers;
  12029. private _fragment;
  12030. private _floats;
  12031. private _ints;
  12032. private _floatsArrays;
  12033. private _colors3;
  12034. private _colors4;
  12035. private _vectors2;
  12036. private _vectors3;
  12037. private _matrices;
  12038. private _fallbackTextureUsed;
  12039. private _fullEngine;
  12040. private _cachedDefines;
  12041. private _contentUpdateId;
  12042. private _contentData;
  12043. /**
  12044. * Instantiates a new procedural texture.
  12045. * 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.
  12046. * This is the base class of any Procedural texture and contains most of the shareable code.
  12047. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12048. * @param name Define the name of the texture
  12049. * @param size Define the size of the texture to create
  12050. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12051. * @param scene Define the scene the texture belongs to
  12052. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12053. * @param generateMipMaps Define if the texture should creates mip maps or not
  12054. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12055. */
  12056. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  12057. /**
  12058. * The effect that is created when initializing the post process.
  12059. * @returns The created effect corresponding the the postprocess.
  12060. */
  12061. getEffect(): Effect;
  12062. /**
  12063. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12064. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12065. */
  12066. getContent(): Nullable<ArrayBufferView>;
  12067. private _createIndexBuffer;
  12068. /** @hidden */
  12069. _rebuild(): void;
  12070. /**
  12071. * Resets the texture in order to recreate its associated resources.
  12072. * This can be called in case of context loss
  12073. */
  12074. reset(): void;
  12075. protected _getDefines(): string;
  12076. /**
  12077. * Is the texture ready to be used ? (rendered at least once)
  12078. * @returns true if ready, otherwise, false.
  12079. */
  12080. isReady(): boolean;
  12081. /**
  12082. * Resets the refresh counter of the texture and start bak from scratch.
  12083. * Could be useful to regenerate the texture if it is setup to render only once.
  12084. */
  12085. resetRefreshCounter(): void;
  12086. /**
  12087. * Set the fragment shader to use in order to render the texture.
  12088. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12089. */
  12090. setFragment(fragment: any): void;
  12091. /**
  12092. * Define the refresh rate of the texture or the rendering frequency.
  12093. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12094. */
  12095. get refreshRate(): number;
  12096. set refreshRate(value: number);
  12097. /** @hidden */
  12098. _shouldRender(): boolean;
  12099. /**
  12100. * Get the size the texture is rendering at.
  12101. * @returns the size (on cube texture it is always squared)
  12102. */
  12103. getRenderSize(): RenderTargetTextureSize;
  12104. /**
  12105. * Resize the texture to new value.
  12106. * @param size Define the new size the texture should have
  12107. * @param generateMipMaps Define whether the new texture should create mip maps
  12108. */
  12109. resize(size: number, generateMipMaps: boolean): void;
  12110. private _checkUniform;
  12111. /**
  12112. * Set a texture in the shader program used to render.
  12113. * @param name Define the name of the uniform samplers as defined in the shader
  12114. * @param texture Define the texture to bind to this sampler
  12115. * @return the texture itself allowing "fluent" like uniform updates
  12116. */
  12117. setTexture(name: string, texture: Texture): ProceduralTexture;
  12118. /**
  12119. * Set a float in the shader.
  12120. * @param name Define the name of the uniform as defined in the shader
  12121. * @param value Define the value to give to the uniform
  12122. * @return the texture itself allowing "fluent" like uniform updates
  12123. */
  12124. setFloat(name: string, value: number): ProceduralTexture;
  12125. /**
  12126. * Set a int in the shader.
  12127. * @param name Define the name of the uniform as defined in the shader
  12128. * @param value Define the value to give to the uniform
  12129. * @return the texture itself allowing "fluent" like uniform updates
  12130. */
  12131. setInt(name: string, value: number): ProceduralTexture;
  12132. /**
  12133. * Set an array of floats in the shader.
  12134. * @param name Define the name of the uniform as defined in the shader
  12135. * @param value Define the value to give to the uniform
  12136. * @return the texture itself allowing "fluent" like uniform updates
  12137. */
  12138. setFloats(name: string, value: number[]): ProceduralTexture;
  12139. /**
  12140. * Set a vec3 in the shader from a Color3.
  12141. * @param name Define the name of the uniform as defined in the shader
  12142. * @param value Define the value to give to the uniform
  12143. * @return the texture itself allowing "fluent" like uniform updates
  12144. */
  12145. setColor3(name: string, value: Color3): ProceduralTexture;
  12146. /**
  12147. * Set a vec4 in the shader from a Color4.
  12148. * @param name Define the name of the uniform as defined in the shader
  12149. * @param value Define the value to give to the uniform
  12150. * @return the texture itself allowing "fluent" like uniform updates
  12151. */
  12152. setColor4(name: string, value: Color4): ProceduralTexture;
  12153. /**
  12154. * Set a vec2 in the shader from a Vector2.
  12155. * @param name Define the name of the uniform as defined in the shader
  12156. * @param value Define the value to give to the uniform
  12157. * @return the texture itself allowing "fluent" like uniform updates
  12158. */
  12159. setVector2(name: string, value: Vector2): ProceduralTexture;
  12160. /**
  12161. * Set a vec3 in the shader from a Vector3.
  12162. * @param name Define the name of the uniform as defined in the shader
  12163. * @param value Define the value to give to the uniform
  12164. * @return the texture itself allowing "fluent" like uniform updates
  12165. */
  12166. setVector3(name: string, value: Vector3): ProceduralTexture;
  12167. /**
  12168. * Set a mat4 in the shader from a MAtrix.
  12169. * @param name Define the name of the uniform as defined in the shader
  12170. * @param value Define the value to give to the uniform
  12171. * @return the texture itself allowing "fluent" like uniform updates
  12172. */
  12173. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12174. /**
  12175. * Render the texture to its associated render target.
  12176. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12177. */
  12178. render(useCameraPostProcess?: boolean): void;
  12179. /**
  12180. * Clone the texture.
  12181. * @returns the cloned texture
  12182. */
  12183. clone(): ProceduralTexture;
  12184. /**
  12185. * Dispose the texture and release its asoociated resources.
  12186. */
  12187. dispose(): void;
  12188. }
  12189. }
  12190. declare module "babylonjs/Particles/baseParticleSystem" {
  12191. import { Nullable } from "babylonjs/types";
  12192. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12194. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12195. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12196. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12197. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12198. import { Color4 } from "babylonjs/Maths/math.color";
  12199. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12200. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12201. import { Animation } from "babylonjs/Animations/animation";
  12202. import { Scene } from "babylonjs/scene";
  12203. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12204. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12205. /**
  12206. * This represents the base class for particle system in Babylon.
  12207. * 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.
  12208. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12209. * @example https://doc.babylonjs.com/babylon101/particles
  12210. */
  12211. export class BaseParticleSystem {
  12212. /**
  12213. * Source color is added to the destination color without alpha affecting the result
  12214. */
  12215. static BLENDMODE_ONEONE: number;
  12216. /**
  12217. * Blend current color and particle color using particle’s alpha
  12218. */
  12219. static BLENDMODE_STANDARD: number;
  12220. /**
  12221. * Add current color and particle color multiplied by particle’s alpha
  12222. */
  12223. static BLENDMODE_ADD: number;
  12224. /**
  12225. * Multiply current color with particle color
  12226. */
  12227. static BLENDMODE_MULTIPLY: number;
  12228. /**
  12229. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12230. */
  12231. static BLENDMODE_MULTIPLYADD: number;
  12232. /**
  12233. * List of animations used by the particle system.
  12234. */
  12235. animations: Animation[];
  12236. /**
  12237. * Gets or sets the unique id of the particle system
  12238. */
  12239. uniqueId: number;
  12240. /**
  12241. * The id of the Particle system.
  12242. */
  12243. id: string;
  12244. /**
  12245. * The friendly name of the Particle system.
  12246. */
  12247. name: string;
  12248. /**
  12249. * Snippet ID if the particle system was created from the snippet server
  12250. */
  12251. snippetId: string;
  12252. /**
  12253. * The rendering group used by the Particle system to chose when to render.
  12254. */
  12255. renderingGroupId: number;
  12256. /**
  12257. * The emitter represents the Mesh or position we are attaching the particle system to.
  12258. */
  12259. emitter: Nullable<AbstractMesh | Vector3>;
  12260. /**
  12261. * The maximum number of particles to emit per frame
  12262. */
  12263. emitRate: number;
  12264. /**
  12265. * If you want to launch only a few particles at once, that can be done, as well.
  12266. */
  12267. manualEmitCount: number;
  12268. /**
  12269. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12270. */
  12271. updateSpeed: number;
  12272. /**
  12273. * The amount of time the particle system is running (depends of the overall update speed).
  12274. */
  12275. targetStopDuration: number;
  12276. /**
  12277. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12278. */
  12279. disposeOnStop: boolean;
  12280. /**
  12281. * Minimum power of emitting particles.
  12282. */
  12283. minEmitPower: number;
  12284. /**
  12285. * Maximum power of emitting particles.
  12286. */
  12287. maxEmitPower: number;
  12288. /**
  12289. * Minimum life time of emitting particles.
  12290. */
  12291. minLifeTime: number;
  12292. /**
  12293. * Maximum life time of emitting particles.
  12294. */
  12295. maxLifeTime: number;
  12296. /**
  12297. * Minimum Size of emitting particles.
  12298. */
  12299. minSize: number;
  12300. /**
  12301. * Maximum Size of emitting particles.
  12302. */
  12303. maxSize: number;
  12304. /**
  12305. * Minimum scale of emitting particles on X axis.
  12306. */
  12307. minScaleX: number;
  12308. /**
  12309. * Maximum scale of emitting particles on X axis.
  12310. */
  12311. maxScaleX: number;
  12312. /**
  12313. * Minimum scale of emitting particles on Y axis.
  12314. */
  12315. minScaleY: number;
  12316. /**
  12317. * Maximum scale of emitting particles on Y axis.
  12318. */
  12319. maxScaleY: number;
  12320. /**
  12321. * Gets or sets the minimal initial rotation in radians.
  12322. */
  12323. minInitialRotation: number;
  12324. /**
  12325. * Gets or sets the maximal initial rotation in radians.
  12326. */
  12327. maxInitialRotation: number;
  12328. /**
  12329. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12330. */
  12331. minAngularSpeed: number;
  12332. /**
  12333. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12334. */
  12335. maxAngularSpeed: number;
  12336. /**
  12337. * The texture used to render each particle. (this can be a spritesheet)
  12338. */
  12339. particleTexture: Nullable<BaseTexture>;
  12340. /**
  12341. * The layer mask we are rendering the particles through.
  12342. */
  12343. layerMask: number;
  12344. /**
  12345. * This can help using your own shader to render the particle system.
  12346. * The according effect will be created
  12347. */
  12348. customShader: any;
  12349. /**
  12350. * By default particle system starts as soon as they are created. This prevents the
  12351. * automatic start to happen and let you decide when to start emitting particles.
  12352. */
  12353. preventAutoStart: boolean;
  12354. private _noiseTexture;
  12355. /**
  12356. * Gets or sets a texture used to add random noise to particle positions
  12357. */
  12358. get noiseTexture(): Nullable<ProceduralTexture>;
  12359. set noiseTexture(value: Nullable<ProceduralTexture>);
  12360. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12361. noiseStrength: Vector3;
  12362. /**
  12363. * Callback triggered when the particle animation is ending.
  12364. */
  12365. onAnimationEnd: Nullable<() => void>;
  12366. /**
  12367. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12368. */
  12369. blendMode: number;
  12370. /**
  12371. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12372. * to override the particles.
  12373. */
  12374. forceDepthWrite: boolean;
  12375. /** 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 */
  12376. preWarmCycles: number;
  12377. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12378. preWarmStepOffset: number;
  12379. /**
  12380. * 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)
  12381. */
  12382. spriteCellChangeSpeed: number;
  12383. /**
  12384. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12385. */
  12386. startSpriteCellID: number;
  12387. /**
  12388. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12389. */
  12390. endSpriteCellID: number;
  12391. /**
  12392. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12393. */
  12394. spriteCellWidth: number;
  12395. /**
  12396. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12397. */
  12398. spriteCellHeight: number;
  12399. /**
  12400. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12401. */
  12402. spriteRandomStartCell: boolean;
  12403. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12404. translationPivot: Vector2;
  12405. /** @hidden */
  12406. protected _isAnimationSheetEnabled: boolean;
  12407. /**
  12408. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12409. */
  12410. beginAnimationOnStart: boolean;
  12411. /**
  12412. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12413. */
  12414. beginAnimationFrom: number;
  12415. /**
  12416. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12417. */
  12418. beginAnimationTo: number;
  12419. /**
  12420. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12421. */
  12422. beginAnimationLoop: boolean;
  12423. /**
  12424. * Gets or sets a world offset applied to all particles
  12425. */
  12426. worldOffset: Vector3;
  12427. /**
  12428. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12429. */
  12430. get isAnimationSheetEnabled(): boolean;
  12431. set isAnimationSheetEnabled(value: boolean);
  12432. /**
  12433. * Get hosting scene
  12434. * @returns the scene
  12435. */
  12436. getScene(): Nullable<Scene>;
  12437. /**
  12438. * You can use gravity if you want to give an orientation to your particles.
  12439. */
  12440. gravity: Vector3;
  12441. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12442. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12443. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12444. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12445. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12446. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12447. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12448. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12449. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12450. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12451. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12452. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12453. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12454. /**
  12455. * Defines the delay in milliseconds before starting the system (0 by default)
  12456. */
  12457. startDelay: number;
  12458. /**
  12459. * Gets the current list of drag gradients.
  12460. * You must use addDragGradient and removeDragGradient to udpate this list
  12461. * @returns the list of drag gradients
  12462. */
  12463. getDragGradients(): Nullable<Array<FactorGradient>>;
  12464. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12465. limitVelocityDamping: number;
  12466. /**
  12467. * Gets the current list of limit velocity gradients.
  12468. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12469. * @returns the list of limit velocity gradients
  12470. */
  12471. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12472. /**
  12473. * Gets the current list of color gradients.
  12474. * You must use addColorGradient and removeColorGradient to udpate this list
  12475. * @returns the list of color gradients
  12476. */
  12477. getColorGradients(): Nullable<Array<ColorGradient>>;
  12478. /**
  12479. * Gets the current list of size gradients.
  12480. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12481. * @returns the list of size gradients
  12482. */
  12483. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12484. /**
  12485. * Gets the current list of color remap gradients.
  12486. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12487. * @returns the list of color remap gradients
  12488. */
  12489. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12490. /**
  12491. * Gets the current list of alpha remap gradients.
  12492. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12493. * @returns the list of alpha remap gradients
  12494. */
  12495. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12496. /**
  12497. * Gets the current list of life time gradients.
  12498. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12499. * @returns the list of life time gradients
  12500. */
  12501. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12502. /**
  12503. * Gets the current list of angular speed gradients.
  12504. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12505. * @returns the list of angular speed gradients
  12506. */
  12507. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12508. /**
  12509. * Gets the current list of velocity gradients.
  12510. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12511. * @returns the list of velocity gradients
  12512. */
  12513. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12514. /**
  12515. * Gets the current list of start size gradients.
  12516. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12517. * @returns the list of start size gradients
  12518. */
  12519. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12520. /**
  12521. * Gets the current list of emit rate gradients.
  12522. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12523. * @returns the list of emit rate gradients
  12524. */
  12525. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12526. /**
  12527. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12528. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12529. */
  12530. get direction1(): Vector3;
  12531. set direction1(value: Vector3);
  12532. /**
  12533. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12534. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12535. */
  12536. get direction2(): Vector3;
  12537. set direction2(value: Vector3);
  12538. /**
  12539. * 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.
  12540. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12541. */
  12542. get minEmitBox(): Vector3;
  12543. set minEmitBox(value: Vector3);
  12544. /**
  12545. * 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.
  12546. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12547. */
  12548. get maxEmitBox(): Vector3;
  12549. set maxEmitBox(value: Vector3);
  12550. /**
  12551. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12552. */
  12553. color1: Color4;
  12554. /**
  12555. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12556. */
  12557. color2: Color4;
  12558. /**
  12559. * Color the particle will have at the end of its lifetime
  12560. */
  12561. colorDead: Color4;
  12562. /**
  12563. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12564. */
  12565. textureMask: Color4;
  12566. /**
  12567. * The particle emitter type defines the emitter used by the particle system.
  12568. * It can be for example box, sphere, or cone...
  12569. */
  12570. particleEmitterType: IParticleEmitterType;
  12571. /** @hidden */
  12572. _isSubEmitter: boolean;
  12573. /**
  12574. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12575. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12576. */
  12577. billboardMode: number;
  12578. protected _isBillboardBased: boolean;
  12579. /**
  12580. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12581. */
  12582. get isBillboardBased(): boolean;
  12583. set isBillboardBased(value: boolean);
  12584. /**
  12585. * The scene the particle system belongs to.
  12586. */
  12587. protected _scene: Nullable<Scene>;
  12588. /**
  12589. * The engine the particle system belongs to.
  12590. */
  12591. protected _engine: ThinEngine;
  12592. /**
  12593. * Local cache of defines for image processing.
  12594. */
  12595. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12596. /**
  12597. * Default configuration related to image processing available in the standard Material.
  12598. */
  12599. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12600. /**
  12601. * Gets the image processing configuration used either in this material.
  12602. */
  12603. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12604. /**
  12605. * Sets the Default image processing configuration used either in the this material.
  12606. *
  12607. * If sets to null, the scene one is in use.
  12608. */
  12609. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12610. /**
  12611. * Attaches a new image processing configuration to the Standard Material.
  12612. * @param configuration
  12613. */
  12614. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12615. /** @hidden */
  12616. protected _reset(): void;
  12617. /** @hidden */
  12618. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12619. /**
  12620. * Instantiates a particle system.
  12621. * 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.
  12622. * @param name The name of the particle system
  12623. */
  12624. constructor(name: string);
  12625. /**
  12626. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12629. * @returns the emitter
  12630. */
  12631. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12632. /**
  12633. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12634. * @param radius The radius of the hemisphere to emit from
  12635. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12636. * @returns the emitter
  12637. */
  12638. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12639. /**
  12640. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12641. * @param radius The radius of the sphere to emit from
  12642. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12643. * @returns the emitter
  12644. */
  12645. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12646. /**
  12647. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12648. * @param radius The radius of the sphere to emit from
  12649. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12650. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12651. * @returns the emitter
  12652. */
  12653. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12654. /**
  12655. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12656. * @param radius The radius of the emission cylinder
  12657. * @param height The height of the emission cylinder
  12658. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12659. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12660. * @returns the emitter
  12661. */
  12662. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12663. /**
  12664. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12665. * @param radius The radius of the cylinder to emit from
  12666. * @param height The height of the emission cylinder
  12667. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12668. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12669. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12670. * @returns the emitter
  12671. */
  12672. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12673. /**
  12674. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12675. * @param radius The radius of the cone to emit from
  12676. * @param angle The base angle of the cone
  12677. * @returns the emitter
  12678. */
  12679. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12680. /**
  12681. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12682. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12683. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12684. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12685. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12686. * @returns the emitter
  12687. */
  12688. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12689. }
  12690. }
  12691. declare module "babylonjs/Particles/subEmitter" {
  12692. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12693. import { Scene } from "babylonjs/scene";
  12694. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12695. /**
  12696. * Type of sub emitter
  12697. */
  12698. export enum SubEmitterType {
  12699. /**
  12700. * Attached to the particle over it's lifetime
  12701. */
  12702. ATTACHED = 0,
  12703. /**
  12704. * Created when the particle dies
  12705. */
  12706. END = 1
  12707. }
  12708. /**
  12709. * Sub emitter class used to emit particles from an existing particle
  12710. */
  12711. export class SubEmitter {
  12712. /**
  12713. * the particle system to be used by the sub emitter
  12714. */
  12715. particleSystem: ParticleSystem;
  12716. /**
  12717. * Type of the submitter (Default: END)
  12718. */
  12719. type: SubEmitterType;
  12720. /**
  12721. * 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)
  12722. * Note: This only is supported when using an emitter of type Mesh
  12723. */
  12724. inheritDirection: boolean;
  12725. /**
  12726. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12727. */
  12728. inheritedVelocityAmount: number;
  12729. /**
  12730. * Creates a sub emitter
  12731. * @param particleSystem the particle system to be used by the sub emitter
  12732. */
  12733. constructor(
  12734. /**
  12735. * the particle system to be used by the sub emitter
  12736. */
  12737. particleSystem: ParticleSystem);
  12738. /**
  12739. * Clones the sub emitter
  12740. * @returns the cloned sub emitter
  12741. */
  12742. clone(): SubEmitter;
  12743. /**
  12744. * Serialize current object to a JSON object
  12745. * @returns the serialized object
  12746. */
  12747. serialize(): any;
  12748. /** @hidden */
  12749. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12750. /**
  12751. * Creates a new SubEmitter from a serialized JSON version
  12752. * @param serializationObject defines the JSON object to read from
  12753. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12754. * @param rootUrl defines the rootUrl for data loading
  12755. * @returns a new SubEmitter
  12756. */
  12757. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12758. /** Release associated resources */
  12759. dispose(): void;
  12760. }
  12761. }
  12762. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12763. /** @hidden */
  12764. export var imageProcessingDeclaration: {
  12765. name: string;
  12766. shader: string;
  12767. };
  12768. }
  12769. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12770. /** @hidden */
  12771. export var imageProcessingFunctions: {
  12772. name: string;
  12773. shader: string;
  12774. };
  12775. }
  12776. declare module "babylonjs/Shaders/particles.fragment" {
  12777. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12778. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12779. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12780. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12781. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12782. /** @hidden */
  12783. export var particlesPixelShader: {
  12784. name: string;
  12785. shader: string;
  12786. };
  12787. }
  12788. declare module "babylonjs/Shaders/particles.vertex" {
  12789. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12790. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12791. /** @hidden */
  12792. export var particlesVertexShader: {
  12793. name: string;
  12794. shader: string;
  12795. };
  12796. }
  12797. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12798. import { Nullable } from "babylonjs/types";
  12799. import { Plane } from "babylonjs/Maths/math";
  12800. /**
  12801. * Interface used to define entities containing multiple clip planes
  12802. */
  12803. export interface IClipPlanesHolder {
  12804. /**
  12805. * Gets or sets the active clipplane 1
  12806. */
  12807. clipPlane: Nullable<Plane>;
  12808. /**
  12809. * Gets or sets the active clipplane 2
  12810. */
  12811. clipPlane2: Nullable<Plane>;
  12812. /**
  12813. * Gets or sets the active clipplane 3
  12814. */
  12815. clipPlane3: Nullable<Plane>;
  12816. /**
  12817. * Gets or sets the active clipplane 4
  12818. */
  12819. clipPlane4: Nullable<Plane>;
  12820. /**
  12821. * Gets or sets the active clipplane 5
  12822. */
  12823. clipPlane5: Nullable<Plane>;
  12824. /**
  12825. * Gets or sets the active clipplane 6
  12826. */
  12827. clipPlane6: Nullable<Plane>;
  12828. }
  12829. }
  12830. declare module "babylonjs/Materials/thinMaterialHelper" {
  12831. import { Effect } from "babylonjs/Materials/effect";
  12832. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12833. /**
  12834. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12835. *
  12836. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12837. *
  12838. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12839. */
  12840. export class ThinMaterialHelper {
  12841. /**
  12842. * Binds the clip plane information from the holder to the effect.
  12843. * @param effect The effect we are binding the data to
  12844. * @param holder The entity containing the clip plane information
  12845. */
  12846. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12847. }
  12848. }
  12849. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12850. module "babylonjs/Engines/thinEngine" {
  12851. interface ThinEngine {
  12852. /**
  12853. * Sets alpha constants used by some alpha blending modes
  12854. * @param r defines the red component
  12855. * @param g defines the green component
  12856. * @param b defines the blue component
  12857. * @param a defines the alpha component
  12858. */
  12859. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12860. /**
  12861. * Sets the current alpha mode
  12862. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12863. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12864. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12865. */
  12866. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12867. /**
  12868. * Gets the current alpha mode
  12869. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12870. * @returns the current alpha mode
  12871. */
  12872. getAlphaMode(): number;
  12873. /**
  12874. * Sets the current alpha equation
  12875. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12876. */
  12877. setAlphaEquation(equation: number): void;
  12878. /**
  12879. * Gets the current alpha equation.
  12880. * @returns the current alpha equation
  12881. */
  12882. getAlphaEquation(): number;
  12883. }
  12884. }
  12885. }
  12886. declare module "babylonjs/Particles/particleSystem" {
  12887. import { Nullable } from "babylonjs/types";
  12888. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12889. import { Observable } from "babylonjs/Misc/observable";
  12890. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12891. import { Effect } from "babylonjs/Materials/effect";
  12892. import { IDisposable } from "babylonjs/scene";
  12893. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12894. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12895. import { Particle } from "babylonjs/Particles/particle";
  12896. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12897. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12898. import "babylonjs/Shaders/particles.fragment";
  12899. import "babylonjs/Shaders/particles.vertex";
  12900. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12901. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12902. import "babylonjs/Engines/Extensions/engine.alpha";
  12903. import { Scene } from "babylonjs/scene";
  12904. /**
  12905. * This represents a particle system in Babylon.
  12906. * 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.
  12907. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12908. * @example https://doc.babylonjs.com/babylon101/particles
  12909. */
  12910. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12911. /**
  12912. * Billboard mode will only apply to Y axis
  12913. */
  12914. static readonly BILLBOARDMODE_Y: number;
  12915. /**
  12916. * Billboard mode will apply to all axes
  12917. */
  12918. static readonly BILLBOARDMODE_ALL: number;
  12919. /**
  12920. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12921. */
  12922. static readonly BILLBOARDMODE_STRETCHED: number;
  12923. /**
  12924. * This function can be defined to provide custom update for active particles.
  12925. * This function will be called instead of regular update (age, position, color, etc.).
  12926. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12927. */
  12928. updateFunction: (particles: Particle[]) => void;
  12929. private _emitterWorldMatrix;
  12930. /**
  12931. * This function can be defined to specify initial direction for every new particle.
  12932. * It by default use the emitterType defined function
  12933. */
  12934. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12935. /**
  12936. * This function can be defined to specify initial position for every new particle.
  12937. * It by default use the emitterType defined function
  12938. */
  12939. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12940. /**
  12941. * @hidden
  12942. */
  12943. _inheritedVelocityOffset: Vector3;
  12944. /**
  12945. * An event triggered when the system is disposed
  12946. */
  12947. onDisposeObservable: Observable<IParticleSystem>;
  12948. private _onDisposeObserver;
  12949. /**
  12950. * Sets a callback that will be triggered when the system is disposed
  12951. */
  12952. set onDispose(callback: () => void);
  12953. private _particles;
  12954. private _epsilon;
  12955. private _capacity;
  12956. private _stockParticles;
  12957. private _newPartsExcess;
  12958. private _vertexData;
  12959. private _vertexBuffer;
  12960. private _vertexBuffers;
  12961. private _spriteBuffer;
  12962. private _indexBuffer;
  12963. private _effect;
  12964. private _customEffect;
  12965. private _cachedDefines;
  12966. private _scaledColorStep;
  12967. private _colorDiff;
  12968. private _scaledDirection;
  12969. private _scaledGravity;
  12970. private _currentRenderId;
  12971. private _alive;
  12972. private _useInstancing;
  12973. private _started;
  12974. private _stopped;
  12975. private _actualFrame;
  12976. private _scaledUpdateSpeed;
  12977. private _vertexBufferSize;
  12978. /** @hidden */
  12979. _currentEmitRateGradient: Nullable<FactorGradient>;
  12980. /** @hidden */
  12981. _currentEmitRate1: number;
  12982. /** @hidden */
  12983. _currentEmitRate2: number;
  12984. /** @hidden */
  12985. _currentStartSizeGradient: Nullable<FactorGradient>;
  12986. /** @hidden */
  12987. _currentStartSize1: number;
  12988. /** @hidden */
  12989. _currentStartSize2: number;
  12990. private readonly _rawTextureWidth;
  12991. private _rampGradientsTexture;
  12992. private _useRampGradients;
  12993. /** Gets or sets a matrix to use to compute projection */
  12994. defaultProjectionMatrix: Matrix;
  12995. /** Gets or sets a matrix to use to compute view */
  12996. defaultViewMatrix: Matrix;
  12997. /** Gets or sets a boolean indicating that ramp gradients must be used
  12998. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12999. */
  13000. get useRampGradients(): boolean;
  13001. set useRampGradients(value: boolean);
  13002. /**
  13003. * 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.
  13004. * 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: [])
  13005. */
  13006. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13007. private _subEmitters;
  13008. /**
  13009. * @hidden
  13010. * If the particle systems emitter should be disposed when the particle system is disposed
  13011. */
  13012. _disposeEmitterOnDispose: boolean;
  13013. /**
  13014. * The current active Sub-systems, this property is used by the root particle system only.
  13015. */
  13016. activeSubSystems: Array<ParticleSystem>;
  13017. /**
  13018. * Specifies if the particles are updated in emitter local space or world space
  13019. */
  13020. isLocal: boolean;
  13021. private _rootParticleSystem;
  13022. /**
  13023. * Gets the current list of active particles
  13024. */
  13025. get particles(): Particle[];
  13026. /**
  13027. * Gets the number of particles active at the same time.
  13028. * @returns The number of active particles.
  13029. */
  13030. getActiveCount(): number;
  13031. /**
  13032. * Returns the string "ParticleSystem"
  13033. * @returns a string containing the class name
  13034. */
  13035. getClassName(): string;
  13036. /**
  13037. * Gets a boolean indicating that the system is stopping
  13038. * @returns true if the system is currently stopping
  13039. */
  13040. isStopping(): boolean;
  13041. /**
  13042. * Gets the custom effect used to render the particles
  13043. * @param blendMode Blend mode for which the effect should be retrieved
  13044. * @returns The effect
  13045. */
  13046. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13047. /**
  13048. * Sets the custom effect used to render the particles
  13049. * @param effect The effect to set
  13050. * @param blendMode Blend mode for which the effect should be set
  13051. */
  13052. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13053. /** @hidden */
  13054. private _onBeforeDrawParticlesObservable;
  13055. /**
  13056. * Observable that will be called just before the particles are drawn
  13057. */
  13058. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13059. /**
  13060. * Gets the name of the particle vertex shader
  13061. */
  13062. get vertexShaderName(): string;
  13063. /**
  13064. * Instantiates a particle system.
  13065. * 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.
  13066. * @param name The name of the particle system
  13067. * @param capacity The max number of particles alive at the same time
  13068. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13069. * @param customEffect a custom effect used to change the way particles are rendered by default
  13070. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13071. * @param epsilon Offset used to render the particles
  13072. */
  13073. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13074. private _addFactorGradient;
  13075. private _removeFactorGradient;
  13076. /**
  13077. * Adds a new life time gradient
  13078. * @param gradient defines the gradient to use (between 0 and 1)
  13079. * @param factor defines the life time factor to affect to the specified gradient
  13080. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13081. * @returns the current particle system
  13082. */
  13083. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13084. /**
  13085. * Remove a specific life time gradient
  13086. * @param gradient defines the gradient to remove
  13087. * @returns the current particle system
  13088. */
  13089. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13090. /**
  13091. * Adds a new size gradient
  13092. * @param gradient defines the gradient to use (between 0 and 1)
  13093. * @param factor defines the size factor to affect to the specified gradient
  13094. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13095. * @returns the current particle system
  13096. */
  13097. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13098. /**
  13099. * Remove a specific size gradient
  13100. * @param gradient defines the gradient to remove
  13101. * @returns the current particle system
  13102. */
  13103. removeSizeGradient(gradient: number): IParticleSystem;
  13104. /**
  13105. * Adds a new color remap gradient
  13106. * @param gradient defines the gradient to use (between 0 and 1)
  13107. * @param min defines the color remap minimal range
  13108. * @param max defines the color remap maximal range
  13109. * @returns the current particle system
  13110. */
  13111. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13112. /**
  13113. * Remove a specific color remap gradient
  13114. * @param gradient defines the gradient to remove
  13115. * @returns the current particle system
  13116. */
  13117. removeColorRemapGradient(gradient: number): IParticleSystem;
  13118. /**
  13119. * Adds a new alpha remap gradient
  13120. * @param gradient defines the gradient to use (between 0 and 1)
  13121. * @param min defines the alpha remap minimal range
  13122. * @param max defines the alpha remap maximal range
  13123. * @returns the current particle system
  13124. */
  13125. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13126. /**
  13127. * Remove a specific alpha remap gradient
  13128. * @param gradient defines the gradient to remove
  13129. * @returns the current particle system
  13130. */
  13131. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13132. /**
  13133. * Adds a new angular speed gradient
  13134. * @param gradient defines the gradient to use (between 0 and 1)
  13135. * @param factor defines the angular speed to affect to the specified gradient
  13136. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13137. * @returns the current particle system
  13138. */
  13139. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13140. /**
  13141. * Remove a specific angular speed gradient
  13142. * @param gradient defines the gradient to remove
  13143. * @returns the current particle system
  13144. */
  13145. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13146. /**
  13147. * Adds a new velocity gradient
  13148. * @param gradient defines the gradient to use (between 0 and 1)
  13149. * @param factor defines the velocity to affect to the specified gradient
  13150. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13151. * @returns the current particle system
  13152. */
  13153. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13154. /**
  13155. * Remove a specific velocity gradient
  13156. * @param gradient defines the gradient to remove
  13157. * @returns the current particle system
  13158. */
  13159. removeVelocityGradient(gradient: number): IParticleSystem;
  13160. /**
  13161. * Adds a new limit velocity gradient
  13162. * @param gradient defines the gradient to use (between 0 and 1)
  13163. * @param factor defines the limit velocity value to affect to the specified gradient
  13164. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13165. * @returns the current particle system
  13166. */
  13167. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13168. /**
  13169. * Remove a specific limit velocity gradient
  13170. * @param gradient defines the gradient to remove
  13171. * @returns the current particle system
  13172. */
  13173. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13174. /**
  13175. * Adds a new drag gradient
  13176. * @param gradient defines the gradient to use (between 0 and 1)
  13177. * @param factor defines the drag value to affect to the specified gradient
  13178. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13179. * @returns the current particle system
  13180. */
  13181. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13182. /**
  13183. * Remove a specific drag gradient
  13184. * @param gradient defines the gradient to remove
  13185. * @returns the current particle system
  13186. */
  13187. removeDragGradient(gradient: number): IParticleSystem;
  13188. /**
  13189. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13190. * @param gradient defines the gradient to use (between 0 and 1)
  13191. * @param factor defines the emit rate value to affect to the specified gradient
  13192. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13193. * @returns the current particle system
  13194. */
  13195. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13196. /**
  13197. * Remove a specific emit rate gradient
  13198. * @param gradient defines the gradient to remove
  13199. * @returns the current particle system
  13200. */
  13201. removeEmitRateGradient(gradient: number): IParticleSystem;
  13202. /**
  13203. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13204. * @param gradient defines the gradient to use (between 0 and 1)
  13205. * @param factor defines the start size value to affect to the specified gradient
  13206. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13207. * @returns the current particle system
  13208. */
  13209. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13210. /**
  13211. * Remove a specific start size gradient
  13212. * @param gradient defines the gradient to remove
  13213. * @returns the current particle system
  13214. */
  13215. removeStartSizeGradient(gradient: number): IParticleSystem;
  13216. private _createRampGradientTexture;
  13217. /**
  13218. * Gets the current list of ramp gradients.
  13219. * You must use addRampGradient and removeRampGradient to udpate this list
  13220. * @returns the list of ramp gradients
  13221. */
  13222. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13223. /** Force the system to rebuild all gradients that need to be resync */
  13224. forceRefreshGradients(): void;
  13225. private _syncRampGradientTexture;
  13226. /**
  13227. * Adds a new ramp gradient used to remap particle colors
  13228. * @param gradient defines the gradient to use (between 0 and 1)
  13229. * @param color defines the color to affect to the specified gradient
  13230. * @returns the current particle system
  13231. */
  13232. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13233. /**
  13234. * Remove a specific ramp gradient
  13235. * @param gradient defines the gradient to remove
  13236. * @returns the current particle system
  13237. */
  13238. removeRampGradient(gradient: number): ParticleSystem;
  13239. /**
  13240. * Adds a new color gradient
  13241. * @param gradient defines the gradient to use (between 0 and 1)
  13242. * @param color1 defines the color to affect to the specified gradient
  13243. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13244. * @returns this particle system
  13245. */
  13246. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13247. /**
  13248. * Remove a specific color gradient
  13249. * @param gradient defines the gradient to remove
  13250. * @returns this particle system
  13251. */
  13252. removeColorGradient(gradient: number): IParticleSystem;
  13253. private _fetchR;
  13254. protected _reset(): void;
  13255. private _resetEffect;
  13256. private _createVertexBuffers;
  13257. private _createIndexBuffer;
  13258. /**
  13259. * Gets the maximum number of particles active at the same time.
  13260. * @returns The max number of active particles.
  13261. */
  13262. getCapacity(): number;
  13263. /**
  13264. * Gets whether there are still active particles in the system.
  13265. * @returns True if it is alive, otherwise false.
  13266. */
  13267. isAlive(): boolean;
  13268. /**
  13269. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13270. * @returns True if it has been started, otherwise false.
  13271. */
  13272. isStarted(): boolean;
  13273. private _prepareSubEmitterInternalArray;
  13274. /**
  13275. * Starts the particle system and begins to emit
  13276. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13277. */
  13278. start(delay?: number): void;
  13279. /**
  13280. * Stops the particle system.
  13281. * @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.
  13282. */
  13283. stop(stopSubEmitters?: boolean): void;
  13284. /**
  13285. * Remove all active particles
  13286. */
  13287. reset(): void;
  13288. /**
  13289. * @hidden (for internal use only)
  13290. */
  13291. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13292. /**
  13293. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13294. * Its lifetime will start back at 0.
  13295. */
  13296. recycleParticle: (particle: Particle) => void;
  13297. private _stopSubEmitters;
  13298. private _createParticle;
  13299. private _removeFromRoot;
  13300. private _emitFromParticle;
  13301. private _update;
  13302. /** @hidden */
  13303. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13304. /** @hidden */
  13305. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13306. /**
  13307. * Fill the defines array according to the current settings of the particle system
  13308. * @param defines Array to be updated
  13309. * @param blendMode blend mode to take into account when updating the array
  13310. */
  13311. fillDefines(defines: Array<string>, blendMode: number): void;
  13312. /**
  13313. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13314. * @param uniforms Uniforms array to fill
  13315. * @param attributes Attributes array to fill
  13316. * @param samplers Samplers array to fill
  13317. */
  13318. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13319. /** @hidden */
  13320. private _getEffect;
  13321. /**
  13322. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13323. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13324. */
  13325. animate(preWarmOnly?: boolean): void;
  13326. private _appendParticleVertices;
  13327. /**
  13328. * Rebuilds the particle system.
  13329. */
  13330. rebuild(): void;
  13331. /**
  13332. * Is this system ready to be used/rendered
  13333. * @return true if the system is ready
  13334. */
  13335. isReady(): boolean;
  13336. private _render;
  13337. /**
  13338. * Renders the particle system in its current state.
  13339. * @returns the current number of particles
  13340. */
  13341. render(): number;
  13342. /**
  13343. * Disposes the particle system and free the associated resources
  13344. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13345. */
  13346. dispose(disposeTexture?: boolean): void;
  13347. /**
  13348. * Clones the particle system.
  13349. * @param name The name of the cloned object
  13350. * @param newEmitter The new emitter to use
  13351. * @returns the cloned particle system
  13352. */
  13353. clone(name: string, newEmitter: any): ParticleSystem;
  13354. /**
  13355. * Serializes the particle system to a JSON object
  13356. * @param serializeTexture defines if the texture must be serialized as well
  13357. * @returns the JSON object
  13358. */
  13359. serialize(serializeTexture?: boolean): any;
  13360. /** @hidden */
  13361. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13362. /** @hidden */
  13363. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13364. /**
  13365. * Parses a JSON object to create a particle system.
  13366. * @param parsedParticleSystem The JSON object to parse
  13367. * @param sceneOrEngine The scene or the engine to create the particle system in
  13368. * @param rootUrl The root url to use to load external dependencies like texture
  13369. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13370. * @returns the Parsed particle system
  13371. */
  13372. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13373. }
  13374. }
  13375. declare module "babylonjs/Particles/particle" {
  13376. import { Nullable } from "babylonjs/types";
  13377. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13378. import { Color4 } from "babylonjs/Maths/math.color";
  13379. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13380. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13381. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13382. /**
  13383. * A particle represents one of the element emitted by a particle system.
  13384. * This is mainly define by its coordinates, direction, velocity and age.
  13385. */
  13386. export class Particle {
  13387. /**
  13388. * The particle system the particle belongs to.
  13389. */
  13390. particleSystem: ParticleSystem;
  13391. private static _Count;
  13392. /**
  13393. * Unique ID of the particle
  13394. */
  13395. id: number;
  13396. /**
  13397. * The world position of the particle in the scene.
  13398. */
  13399. position: Vector3;
  13400. /**
  13401. * The world direction of the particle in the scene.
  13402. */
  13403. direction: Vector3;
  13404. /**
  13405. * The color of the particle.
  13406. */
  13407. color: Color4;
  13408. /**
  13409. * The color change of the particle per step.
  13410. */
  13411. colorStep: Color4;
  13412. /**
  13413. * Defines how long will the life of the particle be.
  13414. */
  13415. lifeTime: number;
  13416. /**
  13417. * The current age of the particle.
  13418. */
  13419. age: number;
  13420. /**
  13421. * The current size of the particle.
  13422. */
  13423. size: number;
  13424. /**
  13425. * The current scale of the particle.
  13426. */
  13427. scale: Vector2;
  13428. /**
  13429. * The current angle of the particle.
  13430. */
  13431. angle: number;
  13432. /**
  13433. * Defines how fast is the angle changing.
  13434. */
  13435. angularSpeed: number;
  13436. /**
  13437. * Defines the cell index used by the particle to be rendered from a sprite.
  13438. */
  13439. cellIndex: number;
  13440. /**
  13441. * The information required to support color remapping
  13442. */
  13443. remapData: Vector4;
  13444. /** @hidden */
  13445. _randomCellOffset?: number;
  13446. /** @hidden */
  13447. _initialDirection: Nullable<Vector3>;
  13448. /** @hidden */
  13449. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13450. /** @hidden */
  13451. _initialStartSpriteCellID: number;
  13452. /** @hidden */
  13453. _initialEndSpriteCellID: number;
  13454. /** @hidden */
  13455. _currentColorGradient: Nullable<ColorGradient>;
  13456. /** @hidden */
  13457. _currentColor1: Color4;
  13458. /** @hidden */
  13459. _currentColor2: Color4;
  13460. /** @hidden */
  13461. _currentSizeGradient: Nullable<FactorGradient>;
  13462. /** @hidden */
  13463. _currentSize1: number;
  13464. /** @hidden */
  13465. _currentSize2: number;
  13466. /** @hidden */
  13467. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13468. /** @hidden */
  13469. _currentAngularSpeed1: number;
  13470. /** @hidden */
  13471. _currentAngularSpeed2: number;
  13472. /** @hidden */
  13473. _currentVelocityGradient: Nullable<FactorGradient>;
  13474. /** @hidden */
  13475. _currentVelocity1: number;
  13476. /** @hidden */
  13477. _currentVelocity2: number;
  13478. /** @hidden */
  13479. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13480. /** @hidden */
  13481. _currentLimitVelocity1: number;
  13482. /** @hidden */
  13483. _currentLimitVelocity2: number;
  13484. /** @hidden */
  13485. _currentDragGradient: Nullable<FactorGradient>;
  13486. /** @hidden */
  13487. _currentDrag1: number;
  13488. /** @hidden */
  13489. _currentDrag2: number;
  13490. /** @hidden */
  13491. _randomNoiseCoordinates1: Vector3;
  13492. /** @hidden */
  13493. _randomNoiseCoordinates2: Vector3;
  13494. /** @hidden */
  13495. _localPosition?: Vector3;
  13496. /**
  13497. * Creates a new instance Particle
  13498. * @param particleSystem the particle system the particle belongs to
  13499. */
  13500. constructor(
  13501. /**
  13502. * The particle system the particle belongs to.
  13503. */
  13504. particleSystem: ParticleSystem);
  13505. private updateCellInfoFromSystem;
  13506. /**
  13507. * Defines how the sprite cell index is updated for the particle
  13508. */
  13509. updateCellIndex(): void;
  13510. /** @hidden */
  13511. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13512. /** @hidden */
  13513. _inheritParticleInfoToSubEmitters(): void;
  13514. /** @hidden */
  13515. _reset(): void;
  13516. /**
  13517. * Copy the properties of particle to another one.
  13518. * @param other the particle to copy the information to.
  13519. */
  13520. copyTo(other: Particle): void;
  13521. }
  13522. }
  13523. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13524. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13525. import { Effect } from "babylonjs/Materials/effect";
  13526. import { Particle } from "babylonjs/Particles/particle";
  13527. import { Nullable } from "babylonjs/types";
  13528. import { Scene } from "babylonjs/scene";
  13529. /**
  13530. * Particle emitter represents a volume emitting particles.
  13531. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13532. */
  13533. export interface IParticleEmitterType {
  13534. /**
  13535. * Called by the particle System when the direction is computed for the created particle.
  13536. * @param worldMatrix is the world matrix of the particle system
  13537. * @param directionToUpdate is the direction vector to update with the result
  13538. * @param particle is the particle we are computed the direction for
  13539. * @param isLocal defines if the direction should be set in local space
  13540. */
  13541. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13542. /**
  13543. * Called by the particle System when the position is computed for the created particle.
  13544. * @param worldMatrix is the world matrix of the particle system
  13545. * @param positionToUpdate is the position vector to update with the result
  13546. * @param particle is the particle we are computed the position for
  13547. * @param isLocal defines if the position should be set in local space
  13548. */
  13549. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13550. /**
  13551. * Clones the current emitter and returns a copy of it
  13552. * @returns the new emitter
  13553. */
  13554. clone(): IParticleEmitterType;
  13555. /**
  13556. * Called by the GPUParticleSystem to setup the update shader
  13557. * @param effect defines the update shader
  13558. */
  13559. applyToShader(effect: Effect): void;
  13560. /**
  13561. * Returns a string to use to update the GPU particles update shader
  13562. * @returns the effect defines string
  13563. */
  13564. getEffectDefines(): string;
  13565. /**
  13566. * Returns a string representing the class name
  13567. * @returns a string containing the class name
  13568. */
  13569. getClassName(): string;
  13570. /**
  13571. * Serializes the particle system to a JSON object.
  13572. * @returns the JSON object
  13573. */
  13574. serialize(): any;
  13575. /**
  13576. * Parse properties from a JSON object
  13577. * @param serializationObject defines the JSON object
  13578. * @param scene defines the hosting scene
  13579. */
  13580. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13581. }
  13582. }
  13583. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13584. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13585. import { Effect } from "babylonjs/Materials/effect";
  13586. import { Particle } from "babylonjs/Particles/particle";
  13587. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13588. /**
  13589. * Particle emitter emitting particles from the inside of a box.
  13590. * It emits the particles randomly between 2 given directions.
  13591. */
  13592. export class BoxParticleEmitter implements IParticleEmitterType {
  13593. /**
  13594. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13595. */
  13596. direction1: Vector3;
  13597. /**
  13598. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13599. */
  13600. direction2: Vector3;
  13601. /**
  13602. * 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.
  13603. */
  13604. minEmitBox: Vector3;
  13605. /**
  13606. * 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.
  13607. */
  13608. maxEmitBox: Vector3;
  13609. /**
  13610. * Creates a new instance BoxParticleEmitter
  13611. */
  13612. constructor();
  13613. /**
  13614. * Called by the particle System when the direction is computed for the created particle.
  13615. * @param worldMatrix is the world matrix of the particle system
  13616. * @param directionToUpdate is the direction vector to update with the result
  13617. * @param particle is the particle we are computed the direction for
  13618. * @param isLocal defines if the direction should be set in local space
  13619. */
  13620. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13621. /**
  13622. * Called by the particle System when the position is computed for the created particle.
  13623. * @param worldMatrix is the world matrix of the particle system
  13624. * @param positionToUpdate is the position vector to update with the result
  13625. * @param particle is the particle we are computed the position for
  13626. * @param isLocal defines if the position should be set in local space
  13627. */
  13628. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13629. /**
  13630. * Clones the current emitter and returns a copy of it
  13631. * @returns the new emitter
  13632. */
  13633. clone(): BoxParticleEmitter;
  13634. /**
  13635. * Called by the GPUParticleSystem to setup the update shader
  13636. * @param effect defines the update shader
  13637. */
  13638. applyToShader(effect: Effect): void;
  13639. /**
  13640. * Returns a string to use to update the GPU particles update shader
  13641. * @returns a string containng the defines string
  13642. */
  13643. getEffectDefines(): string;
  13644. /**
  13645. * Returns the string "BoxParticleEmitter"
  13646. * @returns a string containing the class name
  13647. */
  13648. getClassName(): string;
  13649. /**
  13650. * Serializes the particle system to a JSON object.
  13651. * @returns the JSON object
  13652. */
  13653. serialize(): any;
  13654. /**
  13655. * Parse properties from a JSON object
  13656. * @param serializationObject defines the JSON object
  13657. */
  13658. parse(serializationObject: any): void;
  13659. }
  13660. }
  13661. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13662. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13663. import { Effect } from "babylonjs/Materials/effect";
  13664. import { Particle } from "babylonjs/Particles/particle";
  13665. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13666. /**
  13667. * Particle emitter emitting particles from the inside of a cone.
  13668. * It emits the particles alongside the cone volume from the base to the particle.
  13669. * The emission direction might be randomized.
  13670. */
  13671. export class ConeParticleEmitter implements IParticleEmitterType {
  13672. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13673. directionRandomizer: number;
  13674. private _radius;
  13675. private _angle;
  13676. private _height;
  13677. /**
  13678. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13679. */
  13680. radiusRange: number;
  13681. /**
  13682. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13683. */
  13684. heightRange: number;
  13685. /**
  13686. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13687. */
  13688. emitFromSpawnPointOnly: boolean;
  13689. /**
  13690. * Gets or sets the radius of the emission cone
  13691. */
  13692. get radius(): number;
  13693. set radius(value: number);
  13694. /**
  13695. * Gets or sets the angle of the emission cone
  13696. */
  13697. get angle(): number;
  13698. set angle(value: number);
  13699. private _buildHeight;
  13700. /**
  13701. * Creates a new instance ConeParticleEmitter
  13702. * @param radius the radius of the emission cone (1 by default)
  13703. * @param angle the cone base angle (PI by default)
  13704. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13705. */
  13706. constructor(radius?: number, angle?: number,
  13707. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13708. directionRandomizer?: number);
  13709. /**
  13710. * Called by the particle System when the direction is computed for the created particle.
  13711. * @param worldMatrix is the world matrix of the particle system
  13712. * @param directionToUpdate is the direction vector to update with the result
  13713. * @param particle is the particle we are computed the direction for
  13714. * @param isLocal defines if the direction should be set in local space
  13715. */
  13716. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13717. /**
  13718. * Called by the particle System when the position is computed for the created particle.
  13719. * @param worldMatrix is the world matrix of the particle system
  13720. * @param positionToUpdate is the position vector to update with the result
  13721. * @param particle is the particle we are computed the position for
  13722. * @param isLocal defines if the position should be set in local space
  13723. */
  13724. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13725. /**
  13726. * Clones the current emitter and returns a copy of it
  13727. * @returns the new emitter
  13728. */
  13729. clone(): ConeParticleEmitter;
  13730. /**
  13731. * Called by the GPUParticleSystem to setup the update shader
  13732. * @param effect defines the update shader
  13733. */
  13734. applyToShader(effect: Effect): void;
  13735. /**
  13736. * Returns a string to use to update the GPU particles update shader
  13737. * @returns a string containng the defines string
  13738. */
  13739. getEffectDefines(): string;
  13740. /**
  13741. * Returns the string "ConeParticleEmitter"
  13742. * @returns a string containing the class name
  13743. */
  13744. getClassName(): string;
  13745. /**
  13746. * Serializes the particle system to a JSON object.
  13747. * @returns the JSON object
  13748. */
  13749. serialize(): any;
  13750. /**
  13751. * Parse properties from a JSON object
  13752. * @param serializationObject defines the JSON object
  13753. */
  13754. parse(serializationObject: any): void;
  13755. }
  13756. }
  13757. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13758. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13759. import { Effect } from "babylonjs/Materials/effect";
  13760. import { Particle } from "babylonjs/Particles/particle";
  13761. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13762. /**
  13763. * Particle emitter emitting particles from the inside of a cylinder.
  13764. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13765. */
  13766. export class CylinderParticleEmitter implements IParticleEmitterType {
  13767. /**
  13768. * The radius of the emission cylinder.
  13769. */
  13770. radius: number;
  13771. /**
  13772. * The height of the emission cylinder.
  13773. */
  13774. height: number;
  13775. /**
  13776. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13777. */
  13778. radiusRange: number;
  13779. /**
  13780. * How much to randomize the particle direction [0-1].
  13781. */
  13782. directionRandomizer: number;
  13783. /**
  13784. * Creates a new instance CylinderParticleEmitter
  13785. * @param radius the radius of the emission cylinder (1 by default)
  13786. * @param height the height of the emission cylinder (1 by default)
  13787. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13788. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13789. */
  13790. constructor(
  13791. /**
  13792. * The radius of the emission cylinder.
  13793. */
  13794. radius?: number,
  13795. /**
  13796. * The height of the emission cylinder.
  13797. */
  13798. height?: number,
  13799. /**
  13800. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13801. */
  13802. radiusRange?: number,
  13803. /**
  13804. * How much to randomize the particle direction [0-1].
  13805. */
  13806. directionRandomizer?: number);
  13807. /**
  13808. * Called by the particle System when the direction is computed for the created particle.
  13809. * @param worldMatrix is the world matrix of the particle system
  13810. * @param directionToUpdate is the direction vector to update with the result
  13811. * @param particle is the particle we are computed the direction for
  13812. * @param isLocal defines if the direction should be set in local space
  13813. */
  13814. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13815. /**
  13816. * Called by the particle System when the position is computed for the created particle.
  13817. * @param worldMatrix is the world matrix of the particle system
  13818. * @param positionToUpdate is the position vector to update with the result
  13819. * @param particle is the particle we are computed the position for
  13820. * @param isLocal defines if the position should be set in local space
  13821. */
  13822. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13823. /**
  13824. * Clones the current emitter and returns a copy of it
  13825. * @returns the new emitter
  13826. */
  13827. clone(): CylinderParticleEmitter;
  13828. /**
  13829. * Called by the GPUParticleSystem to setup the update shader
  13830. * @param effect defines the update shader
  13831. */
  13832. applyToShader(effect: Effect): void;
  13833. /**
  13834. * Returns a string to use to update the GPU particles update shader
  13835. * @returns a string containng the defines string
  13836. */
  13837. getEffectDefines(): string;
  13838. /**
  13839. * Returns the string "CylinderParticleEmitter"
  13840. * @returns a string containing the class name
  13841. */
  13842. getClassName(): string;
  13843. /**
  13844. * Serializes the particle system to a JSON object.
  13845. * @returns the JSON object
  13846. */
  13847. serialize(): any;
  13848. /**
  13849. * Parse properties from a JSON object
  13850. * @param serializationObject defines the JSON object
  13851. */
  13852. parse(serializationObject: any): void;
  13853. }
  13854. /**
  13855. * Particle emitter emitting particles from the inside of a cylinder.
  13856. * It emits the particles randomly between two vectors.
  13857. */
  13858. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13859. /**
  13860. * The min limit of the emission direction.
  13861. */
  13862. direction1: Vector3;
  13863. /**
  13864. * The max limit of the emission direction.
  13865. */
  13866. direction2: Vector3;
  13867. /**
  13868. * Creates a new instance CylinderDirectedParticleEmitter
  13869. * @param radius the radius of the emission cylinder (1 by default)
  13870. * @param height the height of the emission cylinder (1 by default)
  13871. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13872. * @param direction1 the min limit of the emission direction (up vector by default)
  13873. * @param direction2 the max limit of the emission direction (up vector by default)
  13874. */
  13875. constructor(radius?: number, height?: number, radiusRange?: number,
  13876. /**
  13877. * The min limit of the emission direction.
  13878. */
  13879. direction1?: Vector3,
  13880. /**
  13881. * The max limit of the emission direction.
  13882. */
  13883. direction2?: Vector3);
  13884. /**
  13885. * Called by the particle System when the direction is computed for the created particle.
  13886. * @param worldMatrix is the world matrix of the particle system
  13887. * @param directionToUpdate is the direction vector to update with the result
  13888. * @param particle is the particle we are computed the direction for
  13889. */
  13890. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13891. /**
  13892. * Clones the current emitter and returns a copy of it
  13893. * @returns the new emitter
  13894. */
  13895. clone(): CylinderDirectedParticleEmitter;
  13896. /**
  13897. * Called by the GPUParticleSystem to setup the update shader
  13898. * @param effect defines the update shader
  13899. */
  13900. applyToShader(effect: Effect): void;
  13901. /**
  13902. * Returns a string to use to update the GPU particles update shader
  13903. * @returns a string containng the defines string
  13904. */
  13905. getEffectDefines(): string;
  13906. /**
  13907. * Returns the string "CylinderDirectedParticleEmitter"
  13908. * @returns a string containing the class name
  13909. */
  13910. getClassName(): string;
  13911. /**
  13912. * Serializes the particle system to a JSON object.
  13913. * @returns the JSON object
  13914. */
  13915. serialize(): any;
  13916. /**
  13917. * Parse properties from a JSON object
  13918. * @param serializationObject defines the JSON object
  13919. */
  13920. parse(serializationObject: any): void;
  13921. }
  13922. }
  13923. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13924. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13925. import { Effect } from "babylonjs/Materials/effect";
  13926. import { Particle } from "babylonjs/Particles/particle";
  13927. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13928. /**
  13929. * Particle emitter emitting particles from the inside of a hemisphere.
  13930. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13931. */
  13932. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13933. /**
  13934. * The radius of the emission hemisphere.
  13935. */
  13936. radius: number;
  13937. /**
  13938. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13939. */
  13940. radiusRange: number;
  13941. /**
  13942. * How much to randomize the particle direction [0-1].
  13943. */
  13944. directionRandomizer: number;
  13945. /**
  13946. * Creates a new instance HemisphericParticleEmitter
  13947. * @param radius the radius of the emission hemisphere (1 by default)
  13948. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13949. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13950. */
  13951. constructor(
  13952. /**
  13953. * The radius of the emission hemisphere.
  13954. */
  13955. radius?: number,
  13956. /**
  13957. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13958. */
  13959. radiusRange?: number,
  13960. /**
  13961. * How much to randomize the particle direction [0-1].
  13962. */
  13963. directionRandomizer?: number);
  13964. /**
  13965. * Called by the particle System when the direction is computed for the created particle.
  13966. * @param worldMatrix is the world matrix of the particle system
  13967. * @param directionToUpdate is the direction vector to update with the result
  13968. * @param particle is the particle we are computed the direction for
  13969. * @param isLocal defines if the direction should be set in local space
  13970. */
  13971. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13972. /**
  13973. * Called by the particle System when the position is computed for the created particle.
  13974. * @param worldMatrix is the world matrix of the particle system
  13975. * @param positionToUpdate is the position vector to update with the result
  13976. * @param particle is the particle we are computed the position for
  13977. * @param isLocal defines if the position should be set in local space
  13978. */
  13979. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13980. /**
  13981. * Clones the current emitter and returns a copy of it
  13982. * @returns the new emitter
  13983. */
  13984. clone(): HemisphericParticleEmitter;
  13985. /**
  13986. * Called by the GPUParticleSystem to setup the update shader
  13987. * @param effect defines the update shader
  13988. */
  13989. applyToShader(effect: Effect): void;
  13990. /**
  13991. * Returns a string to use to update the GPU particles update shader
  13992. * @returns a string containng the defines string
  13993. */
  13994. getEffectDefines(): string;
  13995. /**
  13996. * Returns the string "HemisphericParticleEmitter"
  13997. * @returns a string containing the class name
  13998. */
  13999. getClassName(): string;
  14000. /**
  14001. * Serializes the particle system to a JSON object.
  14002. * @returns the JSON object
  14003. */
  14004. serialize(): any;
  14005. /**
  14006. * Parse properties from a JSON object
  14007. * @param serializationObject defines the JSON object
  14008. */
  14009. parse(serializationObject: any): void;
  14010. }
  14011. }
  14012. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14013. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14014. import { Effect } from "babylonjs/Materials/effect";
  14015. import { Particle } from "babylonjs/Particles/particle";
  14016. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14017. /**
  14018. * Particle emitter emitting particles from a point.
  14019. * It emits the particles randomly between 2 given directions.
  14020. */
  14021. export class PointParticleEmitter implements IParticleEmitterType {
  14022. /**
  14023. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14024. */
  14025. direction1: Vector3;
  14026. /**
  14027. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14028. */
  14029. direction2: Vector3;
  14030. /**
  14031. * Creates a new instance PointParticleEmitter
  14032. */
  14033. constructor();
  14034. /**
  14035. * Called by the particle System when the direction is computed for the created particle.
  14036. * @param worldMatrix is the world matrix of the particle system
  14037. * @param directionToUpdate is the direction vector to update with the result
  14038. * @param particle is the particle we are computed the direction for
  14039. * @param isLocal defines if the direction should be set in local space
  14040. */
  14041. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14042. /**
  14043. * Called by the particle System when the position is computed for the created particle.
  14044. * @param worldMatrix is the world matrix of the particle system
  14045. * @param positionToUpdate is the position vector to update with the result
  14046. * @param particle is the particle we are computed the position for
  14047. * @param isLocal defines if the position should be set in local space
  14048. */
  14049. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14050. /**
  14051. * Clones the current emitter and returns a copy of it
  14052. * @returns the new emitter
  14053. */
  14054. clone(): PointParticleEmitter;
  14055. /**
  14056. * Called by the GPUParticleSystem to setup the update shader
  14057. * @param effect defines the update shader
  14058. */
  14059. applyToShader(effect: Effect): void;
  14060. /**
  14061. * Returns a string to use to update the GPU particles update shader
  14062. * @returns a string containng the defines string
  14063. */
  14064. getEffectDefines(): string;
  14065. /**
  14066. * Returns the string "PointParticleEmitter"
  14067. * @returns a string containing the class name
  14068. */
  14069. getClassName(): string;
  14070. /**
  14071. * Serializes the particle system to a JSON object.
  14072. * @returns the JSON object
  14073. */
  14074. serialize(): any;
  14075. /**
  14076. * Parse properties from a JSON object
  14077. * @param serializationObject defines the JSON object
  14078. */
  14079. parse(serializationObject: any): void;
  14080. }
  14081. }
  14082. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14083. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14084. import { Effect } from "babylonjs/Materials/effect";
  14085. import { Particle } from "babylonjs/Particles/particle";
  14086. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14087. /**
  14088. * Particle emitter emitting particles from the inside of a sphere.
  14089. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14090. */
  14091. export class SphereParticleEmitter implements IParticleEmitterType {
  14092. /**
  14093. * The radius of the emission sphere.
  14094. */
  14095. radius: number;
  14096. /**
  14097. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14098. */
  14099. radiusRange: number;
  14100. /**
  14101. * How much to randomize the particle direction [0-1].
  14102. */
  14103. directionRandomizer: number;
  14104. /**
  14105. * Creates a new instance SphereParticleEmitter
  14106. * @param radius the radius of the emission sphere (1 by default)
  14107. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14108. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14109. */
  14110. constructor(
  14111. /**
  14112. * The radius of the emission sphere.
  14113. */
  14114. radius?: number,
  14115. /**
  14116. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14117. */
  14118. radiusRange?: number,
  14119. /**
  14120. * How much to randomize the particle direction [0-1].
  14121. */
  14122. directionRandomizer?: number);
  14123. /**
  14124. * Called by the particle System when the direction is computed for the created particle.
  14125. * @param worldMatrix is the world matrix of the particle system
  14126. * @param directionToUpdate is the direction vector to update with the result
  14127. * @param particle is the particle we are computed the direction for
  14128. * @param isLocal defines if the direction should be set in local space
  14129. */
  14130. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14131. /**
  14132. * Called by the particle System when the position is computed for the created particle.
  14133. * @param worldMatrix is the world matrix of the particle system
  14134. * @param positionToUpdate is the position vector to update with the result
  14135. * @param particle is the particle we are computed the position for
  14136. * @param isLocal defines if the position should be set in local space
  14137. */
  14138. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14139. /**
  14140. * Clones the current emitter and returns a copy of it
  14141. * @returns the new emitter
  14142. */
  14143. clone(): SphereParticleEmitter;
  14144. /**
  14145. * Called by the GPUParticleSystem to setup the update shader
  14146. * @param effect defines the update shader
  14147. */
  14148. applyToShader(effect: Effect): void;
  14149. /**
  14150. * Returns a string to use to update the GPU particles update shader
  14151. * @returns a string containng the defines string
  14152. */
  14153. getEffectDefines(): string;
  14154. /**
  14155. * Returns the string "SphereParticleEmitter"
  14156. * @returns a string containing the class name
  14157. */
  14158. getClassName(): string;
  14159. /**
  14160. * Serializes the particle system to a JSON object.
  14161. * @returns the JSON object
  14162. */
  14163. serialize(): any;
  14164. /**
  14165. * Parse properties from a JSON object
  14166. * @param serializationObject defines the JSON object
  14167. */
  14168. parse(serializationObject: any): void;
  14169. }
  14170. /**
  14171. * Particle emitter emitting particles from the inside of a sphere.
  14172. * It emits the particles randomly between two vectors.
  14173. */
  14174. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14175. /**
  14176. * The min limit of the emission direction.
  14177. */
  14178. direction1: Vector3;
  14179. /**
  14180. * The max limit of the emission direction.
  14181. */
  14182. direction2: Vector3;
  14183. /**
  14184. * Creates a new instance SphereDirectedParticleEmitter
  14185. * @param radius the radius of the emission sphere (1 by default)
  14186. * @param direction1 the min limit of the emission direction (up vector by default)
  14187. * @param direction2 the max limit of the emission direction (up vector by default)
  14188. */
  14189. constructor(radius?: number,
  14190. /**
  14191. * The min limit of the emission direction.
  14192. */
  14193. direction1?: Vector3,
  14194. /**
  14195. * The max limit of the emission direction.
  14196. */
  14197. direction2?: Vector3);
  14198. /**
  14199. * Called by the particle System when the direction is computed for the created particle.
  14200. * @param worldMatrix is the world matrix of the particle system
  14201. * @param directionToUpdate is the direction vector to update with the result
  14202. * @param particle is the particle we are computed the direction for
  14203. */
  14204. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14205. /**
  14206. * Clones the current emitter and returns a copy of it
  14207. * @returns the new emitter
  14208. */
  14209. clone(): SphereDirectedParticleEmitter;
  14210. /**
  14211. * Called by the GPUParticleSystem to setup the update shader
  14212. * @param effect defines the update shader
  14213. */
  14214. applyToShader(effect: Effect): void;
  14215. /**
  14216. * Returns a string to use to update the GPU particles update shader
  14217. * @returns a string containng the defines string
  14218. */
  14219. getEffectDefines(): string;
  14220. /**
  14221. * Returns the string "SphereDirectedParticleEmitter"
  14222. * @returns a string containing the class name
  14223. */
  14224. getClassName(): string;
  14225. /**
  14226. * Serializes the particle system to a JSON object.
  14227. * @returns the JSON object
  14228. */
  14229. serialize(): any;
  14230. /**
  14231. * Parse properties from a JSON object
  14232. * @param serializationObject defines the JSON object
  14233. */
  14234. parse(serializationObject: any): void;
  14235. }
  14236. }
  14237. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14238. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14239. import { Effect } from "babylonjs/Materials/effect";
  14240. import { Particle } from "babylonjs/Particles/particle";
  14241. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14242. import { Nullable } from "babylonjs/types";
  14243. /**
  14244. * Particle emitter emitting particles from a custom list of positions.
  14245. */
  14246. export class CustomParticleEmitter implements IParticleEmitterType {
  14247. /**
  14248. * Gets or sets the position generator that will create the inital position of each particle.
  14249. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14250. */
  14251. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14252. /**
  14253. * Gets or sets the destination generator that will create the final destination of each particle.
  14254. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14255. */
  14256. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14257. /**
  14258. * Creates a new instance CustomParticleEmitter
  14259. */
  14260. constructor();
  14261. /**
  14262. * Called by the particle System when the direction is computed for the created particle.
  14263. * @param worldMatrix is the world matrix of the particle system
  14264. * @param directionToUpdate is the direction vector to update with the result
  14265. * @param particle is the particle we are computed the direction for
  14266. * @param isLocal defines if the direction should be set in local space
  14267. */
  14268. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14269. /**
  14270. * Called by the particle System when the position is computed for the created particle.
  14271. * @param worldMatrix is the world matrix of the particle system
  14272. * @param positionToUpdate is the position vector to update with the result
  14273. * @param particle is the particle we are computed the position for
  14274. * @param isLocal defines if the position should be set in local space
  14275. */
  14276. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14277. /**
  14278. * Clones the current emitter and returns a copy of it
  14279. * @returns the new emitter
  14280. */
  14281. clone(): CustomParticleEmitter;
  14282. /**
  14283. * Called by the GPUParticleSystem to setup the update shader
  14284. * @param effect defines the update shader
  14285. */
  14286. applyToShader(effect: Effect): void;
  14287. /**
  14288. * Returns a string to use to update the GPU particles update shader
  14289. * @returns a string containng the defines string
  14290. */
  14291. getEffectDefines(): string;
  14292. /**
  14293. * Returns the string "PointParticleEmitter"
  14294. * @returns a string containing the class name
  14295. */
  14296. getClassName(): string;
  14297. /**
  14298. * Serializes the particle system to a JSON object.
  14299. * @returns the JSON object
  14300. */
  14301. serialize(): any;
  14302. /**
  14303. * Parse properties from a JSON object
  14304. * @param serializationObject defines the JSON object
  14305. */
  14306. parse(serializationObject: any): void;
  14307. }
  14308. }
  14309. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14310. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14311. import { Effect } from "babylonjs/Materials/effect";
  14312. import { Particle } from "babylonjs/Particles/particle";
  14313. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14314. import { Nullable } from "babylonjs/types";
  14315. import { Scene } from "babylonjs/scene";
  14316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14317. /**
  14318. * Particle emitter emitting particles from the inside of a box.
  14319. * It emits the particles randomly between 2 given directions.
  14320. */
  14321. export class MeshParticleEmitter implements IParticleEmitterType {
  14322. private _indices;
  14323. private _positions;
  14324. private _normals;
  14325. private _storedNormal;
  14326. private _mesh;
  14327. /**
  14328. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14329. */
  14330. direction1: Vector3;
  14331. /**
  14332. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14333. */
  14334. direction2: Vector3;
  14335. /**
  14336. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14337. */
  14338. useMeshNormalsForDirection: boolean;
  14339. /** Defines the mesh to use as source */
  14340. get mesh(): Nullable<AbstractMesh>;
  14341. set mesh(value: Nullable<AbstractMesh>);
  14342. /**
  14343. * Creates a new instance MeshParticleEmitter
  14344. * @param mesh defines the mesh to use as source
  14345. */
  14346. constructor(mesh?: Nullable<AbstractMesh>);
  14347. /**
  14348. * Called by the particle System when the direction is computed for the created particle.
  14349. * @param worldMatrix is the world matrix of the particle system
  14350. * @param directionToUpdate is the direction vector to update with the result
  14351. * @param particle is the particle we are computed the direction for
  14352. * @param isLocal defines if the direction should be set in local space
  14353. */
  14354. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14355. /**
  14356. * Called by the particle System when the position is computed for the created particle.
  14357. * @param worldMatrix is the world matrix of the particle system
  14358. * @param positionToUpdate is the position vector to update with the result
  14359. * @param particle is the particle we are computed the position for
  14360. * @param isLocal defines if the position should be set in local space
  14361. */
  14362. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14363. /**
  14364. * Clones the current emitter and returns a copy of it
  14365. * @returns the new emitter
  14366. */
  14367. clone(): MeshParticleEmitter;
  14368. /**
  14369. * Called by the GPUParticleSystem to setup the update shader
  14370. * @param effect defines the update shader
  14371. */
  14372. applyToShader(effect: Effect): void;
  14373. /**
  14374. * Returns a string to use to update the GPU particles update shader
  14375. * @returns a string containng the defines string
  14376. */
  14377. getEffectDefines(): string;
  14378. /**
  14379. * Returns the string "BoxParticleEmitter"
  14380. * @returns a string containing the class name
  14381. */
  14382. getClassName(): string;
  14383. /**
  14384. * Serializes the particle system to a JSON object.
  14385. * @returns the JSON object
  14386. */
  14387. serialize(): any;
  14388. /**
  14389. * Parse properties from a JSON object
  14390. * @param serializationObject defines the JSON object
  14391. * @param scene defines the hosting scene
  14392. */
  14393. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14394. }
  14395. }
  14396. declare module "babylonjs/Particles/EmitterTypes/index" {
  14397. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14398. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14399. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14400. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14401. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14402. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14403. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14404. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14405. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14406. }
  14407. declare module "babylonjs/Particles/IParticleSystem" {
  14408. import { Nullable } from "babylonjs/types";
  14409. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14410. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14411. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14412. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14413. import { Scene } from "babylonjs/scene";
  14414. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14415. import { Effect } from "babylonjs/Materials/effect";
  14416. import { Observable } from "babylonjs/Misc/observable";
  14417. import { Animation } from "babylonjs/Animations/animation";
  14418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14419. /**
  14420. * Interface representing a particle system in Babylon.js.
  14421. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14422. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14423. */
  14424. export interface IParticleSystem {
  14425. /**
  14426. * List of animations used by the particle system.
  14427. */
  14428. animations: Animation[];
  14429. /**
  14430. * The id of the Particle system.
  14431. */
  14432. id: string;
  14433. /**
  14434. * The name of the Particle system.
  14435. */
  14436. name: string;
  14437. /**
  14438. * The emitter represents the Mesh or position we are attaching the particle system to.
  14439. */
  14440. emitter: Nullable<AbstractMesh | Vector3>;
  14441. /**
  14442. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14443. */
  14444. isBillboardBased: boolean;
  14445. /**
  14446. * The rendering group used by the Particle system to chose when to render.
  14447. */
  14448. renderingGroupId: number;
  14449. /**
  14450. * The layer mask we are rendering the particles through.
  14451. */
  14452. layerMask: number;
  14453. /**
  14454. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14455. */
  14456. updateSpeed: number;
  14457. /**
  14458. * The amount of time the particle system is running (depends of the overall update speed).
  14459. */
  14460. targetStopDuration: number;
  14461. /**
  14462. * The texture used to render each particle. (this can be a spritesheet)
  14463. */
  14464. particleTexture: Nullable<BaseTexture>;
  14465. /**
  14466. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14467. */
  14468. blendMode: number;
  14469. /**
  14470. * Minimum life time of emitting particles.
  14471. */
  14472. minLifeTime: number;
  14473. /**
  14474. * Maximum life time of emitting particles.
  14475. */
  14476. maxLifeTime: number;
  14477. /**
  14478. * Minimum Size of emitting particles.
  14479. */
  14480. minSize: number;
  14481. /**
  14482. * Maximum Size of emitting particles.
  14483. */
  14484. maxSize: number;
  14485. /**
  14486. * Minimum scale of emitting particles on X axis.
  14487. */
  14488. minScaleX: number;
  14489. /**
  14490. * Maximum scale of emitting particles on X axis.
  14491. */
  14492. maxScaleX: number;
  14493. /**
  14494. * Minimum scale of emitting particles on Y axis.
  14495. */
  14496. minScaleY: number;
  14497. /**
  14498. * Maximum scale of emitting particles on Y axis.
  14499. */
  14500. maxScaleY: number;
  14501. /**
  14502. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14503. */
  14504. color1: Color4;
  14505. /**
  14506. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14507. */
  14508. color2: Color4;
  14509. /**
  14510. * Color the particle will have at the end of its lifetime.
  14511. */
  14512. colorDead: Color4;
  14513. /**
  14514. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14515. */
  14516. emitRate: number;
  14517. /**
  14518. * You can use gravity if you want to give an orientation to your particles.
  14519. */
  14520. gravity: Vector3;
  14521. /**
  14522. * Minimum power of emitting particles.
  14523. */
  14524. minEmitPower: number;
  14525. /**
  14526. * Maximum power of emitting particles.
  14527. */
  14528. maxEmitPower: number;
  14529. /**
  14530. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14531. */
  14532. minAngularSpeed: number;
  14533. /**
  14534. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14535. */
  14536. maxAngularSpeed: number;
  14537. /**
  14538. * Gets or sets the minimal initial rotation in radians.
  14539. */
  14540. minInitialRotation: number;
  14541. /**
  14542. * Gets or sets the maximal initial rotation in radians.
  14543. */
  14544. maxInitialRotation: number;
  14545. /**
  14546. * The particle emitter type defines the emitter used by the particle system.
  14547. * It can be for example box, sphere, or cone...
  14548. */
  14549. particleEmitterType: Nullable<IParticleEmitterType>;
  14550. /**
  14551. * Defines the delay in milliseconds before starting the system (0 by default)
  14552. */
  14553. startDelay: number;
  14554. /**
  14555. * 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
  14556. */
  14557. preWarmCycles: number;
  14558. /**
  14559. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14560. */
  14561. preWarmStepOffset: number;
  14562. /**
  14563. * 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)
  14564. */
  14565. spriteCellChangeSpeed: number;
  14566. /**
  14567. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14568. */
  14569. startSpriteCellID: number;
  14570. /**
  14571. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14572. */
  14573. endSpriteCellID: number;
  14574. /**
  14575. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14576. */
  14577. spriteCellWidth: number;
  14578. /**
  14579. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14580. */
  14581. spriteCellHeight: number;
  14582. /**
  14583. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14584. */
  14585. spriteRandomStartCell: boolean;
  14586. /**
  14587. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14588. */
  14589. isAnimationSheetEnabled: boolean;
  14590. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14591. translationPivot: Vector2;
  14592. /**
  14593. * Gets or sets a texture used to add random noise to particle positions
  14594. */
  14595. noiseTexture: Nullable<BaseTexture>;
  14596. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14597. noiseStrength: Vector3;
  14598. /**
  14599. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14600. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14601. */
  14602. billboardMode: number;
  14603. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14604. limitVelocityDamping: number;
  14605. /**
  14606. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14607. */
  14608. beginAnimationOnStart: boolean;
  14609. /**
  14610. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14611. */
  14612. beginAnimationFrom: number;
  14613. /**
  14614. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14615. */
  14616. beginAnimationTo: number;
  14617. /**
  14618. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14619. */
  14620. beginAnimationLoop: boolean;
  14621. /**
  14622. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14623. */
  14624. disposeOnStop: boolean;
  14625. /**
  14626. * Specifies if the particles are updated in emitter local space or world space
  14627. */
  14628. isLocal: boolean;
  14629. /** Snippet ID if the particle system was created from the snippet server */
  14630. snippetId: string;
  14631. /** Gets or sets a matrix to use to compute projection */
  14632. defaultProjectionMatrix: Matrix;
  14633. /**
  14634. * Gets the maximum number of particles active at the same time.
  14635. * @returns The max number of active particles.
  14636. */
  14637. getCapacity(): number;
  14638. /**
  14639. * Gets the number of particles active at the same time.
  14640. * @returns The number of active particles.
  14641. */
  14642. getActiveCount(): number;
  14643. /**
  14644. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14645. * @returns True if it has been started, otherwise false.
  14646. */
  14647. isStarted(): boolean;
  14648. /**
  14649. * Animates the particle system for this frame.
  14650. */
  14651. animate(): void;
  14652. /**
  14653. * Renders the particle system in its current state.
  14654. * @returns the current number of particles
  14655. */
  14656. render(): number;
  14657. /**
  14658. * Dispose the particle system and frees its associated resources.
  14659. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14660. */
  14661. dispose(disposeTexture?: boolean): void;
  14662. /**
  14663. * An event triggered when the system is disposed
  14664. */
  14665. onDisposeObservable: Observable<IParticleSystem>;
  14666. /**
  14667. * Clones the particle system.
  14668. * @param name The name of the cloned object
  14669. * @param newEmitter The new emitter to use
  14670. * @returns the cloned particle system
  14671. */
  14672. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14673. /**
  14674. * Serializes the particle system to a JSON object
  14675. * @param serializeTexture defines if the texture must be serialized as well
  14676. * @returns the JSON object
  14677. */
  14678. serialize(serializeTexture: boolean): any;
  14679. /**
  14680. * Rebuild the particle system
  14681. */
  14682. rebuild(): void;
  14683. /** Force the system to rebuild all gradients that need to be resync */
  14684. forceRefreshGradients(): void;
  14685. /**
  14686. * Starts the particle system and begins to emit
  14687. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14688. */
  14689. start(delay?: number): void;
  14690. /**
  14691. * Stops the particle system.
  14692. */
  14693. stop(): void;
  14694. /**
  14695. * Remove all active particles
  14696. */
  14697. reset(): void;
  14698. /**
  14699. * Gets a boolean indicating that the system is stopping
  14700. * @returns true if the system is currently stopping
  14701. */
  14702. isStopping(): boolean;
  14703. /**
  14704. * Is this system ready to be used/rendered
  14705. * @return true if the system is ready
  14706. */
  14707. isReady(): boolean;
  14708. /**
  14709. * Returns the string "ParticleSystem"
  14710. * @returns a string containing the class name
  14711. */
  14712. getClassName(): string;
  14713. /**
  14714. * Gets the custom effect used to render the particles
  14715. * @param blendMode Blend mode for which the effect should be retrieved
  14716. * @returns The effect
  14717. */
  14718. getCustomEffect(blendMode: number): Nullable<Effect>;
  14719. /**
  14720. * Sets the custom effect used to render the particles
  14721. * @param effect The effect to set
  14722. * @param blendMode Blend mode for which the effect should be set
  14723. */
  14724. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14725. /**
  14726. * Fill the defines array according to the current settings of the particle system
  14727. * @param defines Array to be updated
  14728. * @param blendMode blend mode to take into account when updating the array
  14729. */
  14730. fillDefines(defines: Array<string>, blendMode: number): void;
  14731. /**
  14732. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14733. * @param uniforms Uniforms array to fill
  14734. * @param attributes Attributes array to fill
  14735. * @param samplers Samplers array to fill
  14736. */
  14737. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14738. /**
  14739. * Observable that will be called just before the particles are drawn
  14740. */
  14741. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14742. /**
  14743. * Gets the name of the particle vertex shader
  14744. */
  14745. vertexShaderName: string;
  14746. /**
  14747. * Adds a new color gradient
  14748. * @param gradient defines the gradient to use (between 0 and 1)
  14749. * @param color1 defines the color to affect to the specified gradient
  14750. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14751. * @returns the current particle system
  14752. */
  14753. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14754. /**
  14755. * Remove a specific color gradient
  14756. * @param gradient defines the gradient to remove
  14757. * @returns the current particle system
  14758. */
  14759. removeColorGradient(gradient: number): IParticleSystem;
  14760. /**
  14761. * Adds a new size gradient
  14762. * @param gradient defines the gradient to use (between 0 and 1)
  14763. * @param factor defines the size factor to affect to the specified gradient
  14764. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14765. * @returns the current particle system
  14766. */
  14767. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14768. /**
  14769. * Remove a specific size gradient
  14770. * @param gradient defines the gradient to remove
  14771. * @returns the current particle system
  14772. */
  14773. removeSizeGradient(gradient: number): IParticleSystem;
  14774. /**
  14775. * Gets the current list of color gradients.
  14776. * You must use addColorGradient and removeColorGradient to udpate this list
  14777. * @returns the list of color gradients
  14778. */
  14779. getColorGradients(): Nullable<Array<ColorGradient>>;
  14780. /**
  14781. * Gets the current list of size gradients.
  14782. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14783. * @returns the list of size gradients
  14784. */
  14785. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14786. /**
  14787. * Gets the current list of angular speed gradients.
  14788. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14789. * @returns the list of angular speed gradients
  14790. */
  14791. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14792. /**
  14793. * Adds a new angular speed gradient
  14794. * @param gradient defines the gradient to use (between 0 and 1)
  14795. * @param factor defines the angular speed to affect to the specified gradient
  14796. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14797. * @returns the current particle system
  14798. */
  14799. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14800. /**
  14801. * Remove a specific angular speed gradient
  14802. * @param gradient defines the gradient to remove
  14803. * @returns the current particle system
  14804. */
  14805. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14806. /**
  14807. * Gets the current list of velocity gradients.
  14808. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14809. * @returns the list of velocity gradients
  14810. */
  14811. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14812. /**
  14813. * Adds a new velocity gradient
  14814. * @param gradient defines the gradient to use (between 0 and 1)
  14815. * @param factor defines the velocity to affect to the specified gradient
  14816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14817. * @returns the current particle system
  14818. */
  14819. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14820. /**
  14821. * Remove a specific velocity gradient
  14822. * @param gradient defines the gradient to remove
  14823. * @returns the current particle system
  14824. */
  14825. removeVelocityGradient(gradient: number): IParticleSystem;
  14826. /**
  14827. * Gets the current list of limit velocity gradients.
  14828. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14829. * @returns the list of limit velocity gradients
  14830. */
  14831. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14832. /**
  14833. * Adds a new limit velocity gradient
  14834. * @param gradient defines the gradient to use (between 0 and 1)
  14835. * @param factor defines the limit velocity to affect to the specified gradient
  14836. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14837. * @returns the current particle system
  14838. */
  14839. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14840. /**
  14841. * Remove a specific limit velocity gradient
  14842. * @param gradient defines the gradient to remove
  14843. * @returns the current particle system
  14844. */
  14845. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14846. /**
  14847. * Adds a new drag gradient
  14848. * @param gradient defines the gradient to use (between 0 and 1)
  14849. * @param factor defines the drag to affect to the specified gradient
  14850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14851. * @returns the current particle system
  14852. */
  14853. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14854. /**
  14855. * Remove a specific drag gradient
  14856. * @param gradient defines the gradient to remove
  14857. * @returns the current particle system
  14858. */
  14859. removeDragGradient(gradient: number): IParticleSystem;
  14860. /**
  14861. * Gets the current list of drag gradients.
  14862. * You must use addDragGradient and removeDragGradient to udpate this list
  14863. * @returns the list of drag gradients
  14864. */
  14865. getDragGradients(): Nullable<Array<FactorGradient>>;
  14866. /**
  14867. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14868. * @param gradient defines the gradient to use (between 0 and 1)
  14869. * @param factor defines the emit rate to affect to the specified gradient
  14870. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14871. * @returns the current particle system
  14872. */
  14873. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14874. /**
  14875. * Remove a specific emit rate gradient
  14876. * @param gradient defines the gradient to remove
  14877. * @returns the current particle system
  14878. */
  14879. removeEmitRateGradient(gradient: number): IParticleSystem;
  14880. /**
  14881. * Gets the current list of emit rate gradients.
  14882. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14883. * @returns the list of emit rate gradients
  14884. */
  14885. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14886. /**
  14887. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14888. * @param gradient defines the gradient to use (between 0 and 1)
  14889. * @param factor defines the start size to affect to the specified gradient
  14890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14891. * @returns the current particle system
  14892. */
  14893. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14894. /**
  14895. * Remove a specific start size gradient
  14896. * @param gradient defines the gradient to remove
  14897. * @returns the current particle system
  14898. */
  14899. removeStartSizeGradient(gradient: number): IParticleSystem;
  14900. /**
  14901. * Gets the current list of start size gradients.
  14902. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14903. * @returns the list of start size gradients
  14904. */
  14905. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14906. /**
  14907. * Adds a new life time gradient
  14908. * @param gradient defines the gradient to use (between 0 and 1)
  14909. * @param factor defines the life time factor to affect to the specified gradient
  14910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14911. * @returns the current particle system
  14912. */
  14913. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14914. /**
  14915. * Remove a specific life time gradient
  14916. * @param gradient defines the gradient to remove
  14917. * @returns the current particle system
  14918. */
  14919. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14920. /**
  14921. * Gets the current list of life time gradients.
  14922. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14923. * @returns the list of life time gradients
  14924. */
  14925. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14926. /**
  14927. * Gets the current list of color gradients.
  14928. * You must use addColorGradient and removeColorGradient to udpate this list
  14929. * @returns the list of color gradients
  14930. */
  14931. getColorGradients(): Nullable<Array<ColorGradient>>;
  14932. /**
  14933. * Adds a new ramp gradient used to remap particle colors
  14934. * @param gradient defines the gradient to use (between 0 and 1)
  14935. * @param color defines the color to affect to the specified gradient
  14936. * @returns the current particle system
  14937. */
  14938. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14939. /**
  14940. * Gets the current list of ramp gradients.
  14941. * You must use addRampGradient and removeRampGradient to udpate this list
  14942. * @returns the list of ramp gradients
  14943. */
  14944. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14945. /** Gets or sets a boolean indicating that ramp gradients must be used
  14946. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14947. */
  14948. useRampGradients: boolean;
  14949. /**
  14950. * Adds a new color remap gradient
  14951. * @param gradient defines the gradient to use (between 0 and 1)
  14952. * @param min defines the color remap minimal range
  14953. * @param max defines the color remap maximal range
  14954. * @returns the current particle system
  14955. */
  14956. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14957. /**
  14958. * Gets the current list of color remap gradients.
  14959. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14960. * @returns the list of color remap gradients
  14961. */
  14962. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14963. /**
  14964. * Adds a new alpha remap gradient
  14965. * @param gradient defines the gradient to use (between 0 and 1)
  14966. * @param min defines the alpha remap minimal range
  14967. * @param max defines the alpha remap maximal range
  14968. * @returns the current particle system
  14969. */
  14970. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14971. /**
  14972. * Gets the current list of alpha remap gradients.
  14973. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14974. * @returns the list of alpha remap gradients
  14975. */
  14976. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14977. /**
  14978. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14979. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14980. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14981. * @returns the emitter
  14982. */
  14983. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14984. /**
  14985. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14986. * @param radius The radius of the hemisphere to emit from
  14987. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14988. * @returns the emitter
  14989. */
  14990. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14991. /**
  14992. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14993. * @param radius The radius of the sphere to emit from
  14994. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14995. * @returns the emitter
  14996. */
  14997. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14998. /**
  14999. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15000. * @param radius The radius of the sphere to emit from
  15001. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15002. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15003. * @returns the emitter
  15004. */
  15005. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15006. /**
  15007. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15008. * @param radius The radius of the emission cylinder
  15009. * @param height The height of the emission cylinder
  15010. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15011. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15012. * @returns the emitter
  15013. */
  15014. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15015. /**
  15016. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15017. * @param radius The radius of the cylinder to emit from
  15018. * @param height The height of the emission cylinder
  15019. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15020. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15021. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15022. * @returns the emitter
  15023. */
  15024. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15025. /**
  15026. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15027. * @param radius The radius of the cone to emit from
  15028. * @param angle The base angle of the cone
  15029. * @returns the emitter
  15030. */
  15031. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15032. /**
  15033. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15034. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15035. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15036. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15037. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15038. * @returns the emitter
  15039. */
  15040. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15041. /**
  15042. * Get hosting scene
  15043. * @returns the scene
  15044. */
  15045. getScene(): Nullable<Scene>;
  15046. }
  15047. }
  15048. declare module "babylonjs/Meshes/transformNode" {
  15049. import { DeepImmutable } from "babylonjs/types";
  15050. import { Observable } from "babylonjs/Misc/observable";
  15051. import { Nullable } from "babylonjs/types";
  15052. import { Camera } from "babylonjs/Cameras/camera";
  15053. import { Scene } from "babylonjs/scene";
  15054. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15055. import { Node } from "babylonjs/node";
  15056. import { Bone } from "babylonjs/Bones/bone";
  15057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15058. import { Space } from "babylonjs/Maths/math.axis";
  15059. /**
  15060. * 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.
  15061. * @see https://doc.babylonjs.com/how_to/transformnode
  15062. */
  15063. export class TransformNode extends Node {
  15064. /**
  15065. * Object will not rotate to face the camera
  15066. */
  15067. static BILLBOARDMODE_NONE: number;
  15068. /**
  15069. * Object will rotate to face the camera but only on the x axis
  15070. */
  15071. static BILLBOARDMODE_X: number;
  15072. /**
  15073. * Object will rotate to face the camera but only on the y axis
  15074. */
  15075. static BILLBOARDMODE_Y: number;
  15076. /**
  15077. * Object will rotate to face the camera but only on the z axis
  15078. */
  15079. static BILLBOARDMODE_Z: number;
  15080. /**
  15081. * Object will rotate to face the camera
  15082. */
  15083. static BILLBOARDMODE_ALL: number;
  15084. /**
  15085. * Object will rotate to face the camera's position instead of orientation
  15086. */
  15087. static BILLBOARDMODE_USE_POSITION: number;
  15088. private static _TmpRotation;
  15089. private static _TmpScaling;
  15090. private static _TmpTranslation;
  15091. private _forward;
  15092. private _forwardInverted;
  15093. private _up;
  15094. private _right;
  15095. private _rightInverted;
  15096. private _position;
  15097. private _rotation;
  15098. private _rotationQuaternion;
  15099. protected _scaling: Vector3;
  15100. protected _isDirty: boolean;
  15101. private _transformToBoneReferal;
  15102. private _isAbsoluteSynced;
  15103. private _billboardMode;
  15104. /**
  15105. * Gets or sets the billboard mode. Default is 0.
  15106. *
  15107. * | Value | Type | Description |
  15108. * | --- | --- | --- |
  15109. * | 0 | BILLBOARDMODE_NONE | |
  15110. * | 1 | BILLBOARDMODE_X | |
  15111. * | 2 | BILLBOARDMODE_Y | |
  15112. * | 4 | BILLBOARDMODE_Z | |
  15113. * | 7 | BILLBOARDMODE_ALL | |
  15114. *
  15115. */
  15116. get billboardMode(): number;
  15117. set billboardMode(value: number);
  15118. private _preserveParentRotationForBillboard;
  15119. /**
  15120. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15121. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15122. */
  15123. get preserveParentRotationForBillboard(): boolean;
  15124. set preserveParentRotationForBillboard(value: boolean);
  15125. /**
  15126. * 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
  15127. */
  15128. scalingDeterminant: number;
  15129. private _infiniteDistance;
  15130. /**
  15131. * Gets or sets the distance of the object to max, often used by skybox
  15132. */
  15133. get infiniteDistance(): boolean;
  15134. set infiniteDistance(value: boolean);
  15135. /**
  15136. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15137. * By default the system will update normals to compensate
  15138. */
  15139. ignoreNonUniformScaling: boolean;
  15140. /**
  15141. * 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
  15142. */
  15143. reIntegrateRotationIntoRotationQuaternion: boolean;
  15144. /** @hidden */
  15145. _poseMatrix: Nullable<Matrix>;
  15146. /** @hidden */
  15147. _localMatrix: Matrix;
  15148. private _usePivotMatrix;
  15149. private _absolutePosition;
  15150. private _absoluteScaling;
  15151. private _absoluteRotationQuaternion;
  15152. private _pivotMatrix;
  15153. private _pivotMatrixInverse;
  15154. /** @hidden */
  15155. _postMultiplyPivotMatrix: boolean;
  15156. protected _isWorldMatrixFrozen: boolean;
  15157. /** @hidden */
  15158. _indexInSceneTransformNodesArray: number;
  15159. /**
  15160. * An event triggered after the world matrix is updated
  15161. */
  15162. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15163. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15164. /**
  15165. * Gets a string identifying the name of the class
  15166. * @returns "TransformNode" string
  15167. */
  15168. getClassName(): string;
  15169. /**
  15170. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15171. */
  15172. get position(): Vector3;
  15173. set position(newPosition: Vector3);
  15174. /**
  15175. * 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)).
  15176. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15177. */
  15178. get rotation(): Vector3;
  15179. set rotation(newRotation: Vector3);
  15180. /**
  15181. * 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)).
  15182. */
  15183. get scaling(): Vector3;
  15184. set scaling(newScaling: Vector3);
  15185. /**
  15186. * 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).
  15187. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15188. */
  15189. get rotationQuaternion(): Nullable<Quaternion>;
  15190. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15191. /**
  15192. * The forward direction of that transform in world space.
  15193. */
  15194. get forward(): Vector3;
  15195. /**
  15196. * The up direction of that transform in world space.
  15197. */
  15198. get up(): Vector3;
  15199. /**
  15200. * The right direction of that transform in world space.
  15201. */
  15202. get right(): Vector3;
  15203. /**
  15204. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15205. * @param matrix the matrix to copy the pose from
  15206. * @returns this TransformNode.
  15207. */
  15208. updatePoseMatrix(matrix: Matrix): TransformNode;
  15209. /**
  15210. * Returns the mesh Pose matrix.
  15211. * @returns the pose matrix
  15212. */
  15213. getPoseMatrix(): Matrix;
  15214. /** @hidden */
  15215. _isSynchronized(): boolean;
  15216. /** @hidden */
  15217. _initCache(): void;
  15218. /**
  15219. * Flag the transform node as dirty (Forcing it to update everything)
  15220. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15221. * @returns this transform node
  15222. */
  15223. markAsDirty(property: string): TransformNode;
  15224. /**
  15225. * Returns the current mesh absolute position.
  15226. * Returns a Vector3.
  15227. */
  15228. get absolutePosition(): Vector3;
  15229. /**
  15230. * Returns the current mesh absolute scaling.
  15231. * Returns a Vector3.
  15232. */
  15233. get absoluteScaling(): Vector3;
  15234. /**
  15235. * Returns the current mesh absolute rotation.
  15236. * Returns a Quaternion.
  15237. */
  15238. get absoluteRotationQuaternion(): Quaternion;
  15239. /**
  15240. * Sets a new matrix to apply before all other transformation
  15241. * @param matrix defines the transform matrix
  15242. * @returns the current TransformNode
  15243. */
  15244. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15245. /**
  15246. * Sets a new pivot matrix to the current node
  15247. * @param matrix defines the new pivot matrix to use
  15248. * @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
  15249. * @returns the current TransformNode
  15250. */
  15251. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15252. /**
  15253. * Returns the mesh pivot matrix.
  15254. * Default : Identity.
  15255. * @returns the matrix
  15256. */
  15257. getPivotMatrix(): Matrix;
  15258. /**
  15259. * Instantiate (when possible) or clone that node with its hierarchy
  15260. * @param newParent defines the new parent to use for the instance (or clone)
  15261. * @param options defines options to configure how copy is done
  15262. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15263. * @returns an instance (or a clone) of the current node with its hiearchy
  15264. */
  15265. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15266. doNotInstantiate: boolean;
  15267. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15268. /**
  15269. * Prevents the World matrix to be computed any longer
  15270. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15271. * @returns the TransformNode.
  15272. */
  15273. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15274. /**
  15275. * Allows back the World matrix computation.
  15276. * @returns the TransformNode.
  15277. */
  15278. unfreezeWorldMatrix(): this;
  15279. /**
  15280. * True if the World matrix has been frozen.
  15281. */
  15282. get isWorldMatrixFrozen(): boolean;
  15283. /**
  15284. * Retuns the mesh absolute position in the World.
  15285. * @returns a Vector3.
  15286. */
  15287. getAbsolutePosition(): Vector3;
  15288. /**
  15289. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15290. * @param absolutePosition the absolute position to set
  15291. * @returns the TransformNode.
  15292. */
  15293. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15294. /**
  15295. * Sets the mesh position in its local space.
  15296. * @param vector3 the position to set in localspace
  15297. * @returns the TransformNode.
  15298. */
  15299. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15300. /**
  15301. * Returns the mesh position in the local space from the current World matrix values.
  15302. * @returns a new Vector3.
  15303. */
  15304. getPositionExpressedInLocalSpace(): Vector3;
  15305. /**
  15306. * Translates the mesh along the passed Vector3 in its local space.
  15307. * @param vector3 the distance to translate in localspace
  15308. * @returns the TransformNode.
  15309. */
  15310. locallyTranslate(vector3: Vector3): TransformNode;
  15311. private static _lookAtVectorCache;
  15312. /**
  15313. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15314. * @param targetPoint the position (must be in same space as current mesh) to look at
  15315. * @param yawCor optional yaw (y-axis) correction in radians
  15316. * @param pitchCor optional pitch (x-axis) correction in radians
  15317. * @param rollCor optional roll (z-axis) correction in radians
  15318. * @param space the choosen space of the target
  15319. * @returns the TransformNode.
  15320. */
  15321. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15322. /**
  15323. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15324. * This Vector3 is expressed in the World space.
  15325. * @param localAxis axis to rotate
  15326. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15327. */
  15328. getDirection(localAxis: Vector3): Vector3;
  15329. /**
  15330. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15331. * localAxis is expressed in the mesh local space.
  15332. * result is computed in the Wordl space from the mesh World matrix.
  15333. * @param localAxis axis to rotate
  15334. * @param result the resulting transformnode
  15335. * @returns this TransformNode.
  15336. */
  15337. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15338. /**
  15339. * Sets this transform node rotation to the given local axis.
  15340. * @param localAxis the axis in local space
  15341. * @param yawCor optional yaw (y-axis) correction in radians
  15342. * @param pitchCor optional pitch (x-axis) correction in radians
  15343. * @param rollCor optional roll (z-axis) correction in radians
  15344. * @returns this TransformNode
  15345. */
  15346. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15347. /**
  15348. * Sets a new pivot point to the current node
  15349. * @param point defines the new pivot point to use
  15350. * @param space defines if the point is in world or local space (local by default)
  15351. * @returns the current TransformNode
  15352. */
  15353. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15354. /**
  15355. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15356. * @returns the pivot point
  15357. */
  15358. getPivotPoint(): Vector3;
  15359. /**
  15360. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15361. * @param result the vector3 to store the result
  15362. * @returns this TransformNode.
  15363. */
  15364. getPivotPointToRef(result: Vector3): TransformNode;
  15365. /**
  15366. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15367. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15368. */
  15369. getAbsolutePivotPoint(): Vector3;
  15370. /**
  15371. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15372. * @param result vector3 to store the result
  15373. * @returns this TransformNode.
  15374. */
  15375. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15376. /**
  15377. * Defines the passed node as the parent of the current node.
  15378. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15379. * @see https://doc.babylonjs.com/how_to/parenting
  15380. * @param node the node ot set as the parent
  15381. * @returns this TransformNode.
  15382. */
  15383. setParent(node: Nullable<Node>): TransformNode;
  15384. private _nonUniformScaling;
  15385. /**
  15386. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15387. */
  15388. get nonUniformScaling(): boolean;
  15389. /** @hidden */
  15390. _updateNonUniformScalingState(value: boolean): boolean;
  15391. /**
  15392. * Attach the current TransformNode to another TransformNode associated with a bone
  15393. * @param bone Bone affecting the TransformNode
  15394. * @param affectedTransformNode TransformNode associated with the bone
  15395. * @returns this object
  15396. */
  15397. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15398. /**
  15399. * Detach the transform node if its associated with a bone
  15400. * @returns this object
  15401. */
  15402. detachFromBone(): TransformNode;
  15403. private static _rotationAxisCache;
  15404. /**
  15405. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15406. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15407. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15408. * The passed axis is also normalized.
  15409. * @param axis the axis to rotate around
  15410. * @param amount the amount to rotate in radians
  15411. * @param space Space to rotate in (Default: local)
  15412. * @returns the TransformNode.
  15413. */
  15414. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15415. /**
  15416. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15417. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15418. * The passed axis is also normalized. .
  15419. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15420. * @param point the point to rotate around
  15421. * @param axis the axis to rotate around
  15422. * @param amount the amount to rotate in radians
  15423. * @returns the TransformNode
  15424. */
  15425. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15426. /**
  15427. * Translates the mesh along the axis vector for the passed distance in the given space.
  15428. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15429. * @param axis the axis to translate in
  15430. * @param distance the distance to translate
  15431. * @param space Space to rotate in (Default: local)
  15432. * @returns the TransformNode.
  15433. */
  15434. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15435. /**
  15436. * Adds a rotation step to the mesh current rotation.
  15437. * x, y, z are Euler angles expressed in radians.
  15438. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15439. * This means this rotation is made in the mesh local space only.
  15440. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15441. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15442. * ```javascript
  15443. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15444. * ```
  15445. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15446. * 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.
  15447. * @param x Rotation to add
  15448. * @param y Rotation to add
  15449. * @param z Rotation to add
  15450. * @returns the TransformNode.
  15451. */
  15452. addRotation(x: number, y: number, z: number): TransformNode;
  15453. /**
  15454. * @hidden
  15455. */
  15456. protected _getEffectiveParent(): Nullable<Node>;
  15457. /**
  15458. * Computes the world matrix of the node
  15459. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15460. * @returns the world matrix
  15461. */
  15462. computeWorldMatrix(force?: boolean): Matrix;
  15463. /**
  15464. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15465. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15466. */
  15467. resetLocalMatrix(independentOfChildren?: boolean): void;
  15468. protected _afterComputeWorldMatrix(): void;
  15469. /**
  15470. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15471. * @param func callback function to add
  15472. *
  15473. * @returns the TransformNode.
  15474. */
  15475. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15476. /**
  15477. * Removes a registered callback function.
  15478. * @param func callback function to remove
  15479. * @returns the TransformNode.
  15480. */
  15481. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15482. /**
  15483. * Gets the position of the current mesh in camera space
  15484. * @param camera defines the camera to use
  15485. * @returns a position
  15486. */
  15487. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15488. /**
  15489. * Returns the distance from the mesh to the active camera
  15490. * @param camera defines the camera to use
  15491. * @returns the distance
  15492. */
  15493. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15494. /**
  15495. * Clone the current transform node
  15496. * @param name Name of the new clone
  15497. * @param newParent New parent for the clone
  15498. * @param doNotCloneChildren Do not clone children hierarchy
  15499. * @returns the new transform node
  15500. */
  15501. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15502. /**
  15503. * Serializes the objects information.
  15504. * @param currentSerializationObject defines the object to serialize in
  15505. * @returns the serialized object
  15506. */
  15507. serialize(currentSerializationObject?: any): any;
  15508. /**
  15509. * Returns a new TransformNode object parsed from the source provided.
  15510. * @param parsedTransformNode is the source.
  15511. * @param scene the scne the object belongs to
  15512. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15513. * @returns a new TransformNode object parsed from the source provided.
  15514. */
  15515. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15516. /**
  15517. * Get all child-transformNodes of this node
  15518. * @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
  15519. * @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
  15520. * @returns an array of TransformNode
  15521. */
  15522. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15523. /**
  15524. * Releases resources associated with this transform node.
  15525. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15526. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15527. */
  15528. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15529. /**
  15530. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15531. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15532. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15533. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15534. * @returns the current mesh
  15535. */
  15536. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15537. private _syncAbsoluteScalingAndRotation;
  15538. }
  15539. }
  15540. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15541. /**
  15542. * Class used to override all child animations of a given target
  15543. */
  15544. export class AnimationPropertiesOverride {
  15545. /**
  15546. * Gets or sets a value indicating if animation blending must be used
  15547. */
  15548. enableBlending: boolean;
  15549. /**
  15550. * Gets or sets the blending speed to use when enableBlending is true
  15551. */
  15552. blendingSpeed: number;
  15553. /**
  15554. * Gets or sets the default loop mode to use
  15555. */
  15556. loopMode: number;
  15557. }
  15558. }
  15559. declare module "babylonjs/Bones/bone" {
  15560. import { Skeleton } from "babylonjs/Bones/skeleton";
  15561. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15562. import { Nullable } from "babylonjs/types";
  15563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15564. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15565. import { Node } from "babylonjs/node";
  15566. import { Space } from "babylonjs/Maths/math.axis";
  15567. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15568. /**
  15569. * Class used to store bone information
  15570. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15571. */
  15572. export class Bone extends Node {
  15573. /**
  15574. * defines the bone name
  15575. */
  15576. name: string;
  15577. private static _tmpVecs;
  15578. private static _tmpQuat;
  15579. private static _tmpMats;
  15580. /**
  15581. * Gets the list of child bones
  15582. */
  15583. children: Bone[];
  15584. /** Gets the animations associated with this bone */
  15585. animations: import("babylonjs/Animations/animation").Animation[];
  15586. /**
  15587. * Gets or sets bone length
  15588. */
  15589. length: number;
  15590. /**
  15591. * @hidden Internal only
  15592. * Set this value to map this bone to a different index in the transform matrices
  15593. * Set this value to -1 to exclude the bone from the transform matrices
  15594. */
  15595. _index: Nullable<number>;
  15596. private _skeleton;
  15597. private _localMatrix;
  15598. private _restPose;
  15599. private _bindPose;
  15600. private _baseMatrix;
  15601. private _absoluteTransform;
  15602. private _invertedAbsoluteTransform;
  15603. private _parent;
  15604. private _scalingDeterminant;
  15605. private _worldTransform;
  15606. private _localScaling;
  15607. private _localRotation;
  15608. private _localPosition;
  15609. private _needToDecompose;
  15610. private _needToCompose;
  15611. /** @hidden */
  15612. _linkedTransformNode: Nullable<TransformNode>;
  15613. /** @hidden */
  15614. _waitingTransformNodeId: Nullable<string>;
  15615. /** @hidden */
  15616. get _matrix(): Matrix;
  15617. /** @hidden */
  15618. set _matrix(value: Matrix);
  15619. /**
  15620. * Create a new bone
  15621. * @param name defines the bone name
  15622. * @param skeleton defines the parent skeleton
  15623. * @param parentBone defines the parent (can be null if the bone is the root)
  15624. * @param localMatrix defines the local matrix
  15625. * @param restPose defines the rest pose matrix
  15626. * @param baseMatrix defines the base matrix
  15627. * @param index defines index of the bone in the hiearchy
  15628. */
  15629. constructor(
  15630. /**
  15631. * defines the bone name
  15632. */
  15633. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15634. /**
  15635. * Gets the current object class name.
  15636. * @return the class name
  15637. */
  15638. getClassName(): string;
  15639. /**
  15640. * Gets the parent skeleton
  15641. * @returns a skeleton
  15642. */
  15643. getSkeleton(): Skeleton;
  15644. /**
  15645. * Gets parent bone
  15646. * @returns a bone or null if the bone is the root of the bone hierarchy
  15647. */
  15648. getParent(): Nullable<Bone>;
  15649. /**
  15650. * Returns an array containing the root bones
  15651. * @returns an array containing the root bones
  15652. */
  15653. getChildren(): Array<Bone>;
  15654. /**
  15655. * Gets the node index in matrix array generated for rendering
  15656. * @returns the node index
  15657. */
  15658. getIndex(): number;
  15659. /**
  15660. * Sets the parent bone
  15661. * @param parent defines the parent (can be null if the bone is the root)
  15662. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15663. */
  15664. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15665. /**
  15666. * Gets the local matrix
  15667. * @returns a matrix
  15668. */
  15669. getLocalMatrix(): Matrix;
  15670. /**
  15671. * Gets the base matrix (initial matrix which remains unchanged)
  15672. * @returns a matrix
  15673. */
  15674. getBaseMatrix(): Matrix;
  15675. /**
  15676. * Gets the rest pose matrix
  15677. * @returns a matrix
  15678. */
  15679. getRestPose(): Matrix;
  15680. /**
  15681. * Sets the rest pose matrix
  15682. * @param matrix the local-space rest pose to set for this bone
  15683. */
  15684. setRestPose(matrix: Matrix): void;
  15685. /**
  15686. * Gets the bind pose matrix
  15687. * @returns the bind pose matrix
  15688. */
  15689. getBindPose(): Matrix;
  15690. /**
  15691. * Sets the bind pose matrix
  15692. * @param matrix the local-space bind pose to set for this bone
  15693. */
  15694. setBindPose(matrix: Matrix): void;
  15695. /**
  15696. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15697. */
  15698. getWorldMatrix(): Matrix;
  15699. /**
  15700. * Sets the local matrix to rest pose matrix
  15701. */
  15702. returnToRest(): void;
  15703. /**
  15704. * Gets the inverse of the absolute transform matrix.
  15705. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15706. * @returns a matrix
  15707. */
  15708. getInvertedAbsoluteTransform(): Matrix;
  15709. /**
  15710. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15711. * @returns a matrix
  15712. */
  15713. getAbsoluteTransform(): Matrix;
  15714. /**
  15715. * Links with the given transform node.
  15716. * The local matrix of this bone is copied from the transform node every frame.
  15717. * @param transformNode defines the transform node to link to
  15718. */
  15719. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15720. /**
  15721. * Gets the node used to drive the bone's transformation
  15722. * @returns a transform node or null
  15723. */
  15724. getTransformNode(): Nullable<TransformNode>;
  15725. /** Gets or sets current position (in local space) */
  15726. get position(): Vector3;
  15727. set position(newPosition: Vector3);
  15728. /** Gets or sets current rotation (in local space) */
  15729. get rotation(): Vector3;
  15730. set rotation(newRotation: Vector3);
  15731. /** Gets or sets current rotation quaternion (in local space) */
  15732. get rotationQuaternion(): Quaternion;
  15733. set rotationQuaternion(newRotation: Quaternion);
  15734. /** Gets or sets current scaling (in local space) */
  15735. get scaling(): Vector3;
  15736. set scaling(newScaling: Vector3);
  15737. /**
  15738. * Gets the animation properties override
  15739. */
  15740. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15741. private _decompose;
  15742. private _compose;
  15743. /**
  15744. * Update the base and local matrices
  15745. * @param matrix defines the new base or local matrix
  15746. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15747. * @param updateLocalMatrix defines if the local matrix should be updated
  15748. */
  15749. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15750. /** @hidden */
  15751. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15752. /**
  15753. * Flag the bone as dirty (Forcing it to update everything)
  15754. */
  15755. markAsDirty(): void;
  15756. /** @hidden */
  15757. _markAsDirtyAndCompose(): void;
  15758. private _markAsDirtyAndDecompose;
  15759. /**
  15760. * Translate the bone in local or world space
  15761. * @param vec The amount to translate the bone
  15762. * @param space The space that the translation is in
  15763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15764. */
  15765. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15766. /**
  15767. * Set the postion of the bone in local or world space
  15768. * @param position The position to set the bone
  15769. * @param space The space that the position is in
  15770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15771. */
  15772. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15773. /**
  15774. * Set the absolute position of the bone (world space)
  15775. * @param position The position to set the bone
  15776. * @param mesh The mesh that this bone is attached to
  15777. */
  15778. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15779. /**
  15780. * Scale the bone on the x, y and z axes (in local space)
  15781. * @param x The amount to scale the bone on the x axis
  15782. * @param y The amount to scale the bone on the y axis
  15783. * @param z The amount to scale the bone on the z axis
  15784. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15785. */
  15786. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15787. /**
  15788. * Set the bone scaling in local space
  15789. * @param scale defines the scaling vector
  15790. */
  15791. setScale(scale: Vector3): void;
  15792. /**
  15793. * Gets the current scaling in local space
  15794. * @returns the current scaling vector
  15795. */
  15796. getScale(): Vector3;
  15797. /**
  15798. * Gets the current scaling in local space and stores it in a target vector
  15799. * @param result defines the target vector
  15800. */
  15801. getScaleToRef(result: Vector3): void;
  15802. /**
  15803. * Set the yaw, pitch, and roll of the bone in local or world space
  15804. * @param yaw The rotation of the bone on the y axis
  15805. * @param pitch The rotation of the bone on the x axis
  15806. * @param roll The rotation of the bone on the z axis
  15807. * @param space The space that the axes of rotation are in
  15808. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15809. */
  15810. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15811. /**
  15812. * Add a rotation to the bone on an axis in local or world space
  15813. * @param axis The axis to rotate the bone on
  15814. * @param amount The amount to rotate the bone
  15815. * @param space The space that the axis is in
  15816. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15817. */
  15818. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15819. /**
  15820. * Set the rotation of the bone to a particular axis angle in local or world space
  15821. * @param axis The axis to rotate the bone on
  15822. * @param angle The angle that the bone should be rotated to
  15823. * @param space The space that the axis is in
  15824. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15825. */
  15826. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15827. /**
  15828. * Set the euler rotation of the bone in local or world space
  15829. * @param rotation The euler rotation that the bone should be set to
  15830. * @param space The space that the rotation is in
  15831. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15832. */
  15833. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15834. /**
  15835. * Set the quaternion rotation of the bone in local or world space
  15836. * @param quat The quaternion rotation that the bone should be set to
  15837. * @param space The space that the rotation is in
  15838. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15839. */
  15840. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15841. /**
  15842. * Set the rotation matrix of the bone in local or world space
  15843. * @param rotMat The rotation matrix that the bone should be set to
  15844. * @param space The space that the rotation is in
  15845. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15846. */
  15847. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15848. private _rotateWithMatrix;
  15849. private _getNegativeRotationToRef;
  15850. /**
  15851. * Get the position of the bone in local or world space
  15852. * @param space The space that the returned position is in
  15853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15854. * @returns The position of the bone
  15855. */
  15856. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15857. /**
  15858. * Copy the position of the bone to a vector3 in local or world space
  15859. * @param space The space that the returned position is in
  15860. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15861. * @param result The vector3 to copy the position to
  15862. */
  15863. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15864. /**
  15865. * Get the absolute position of the bone (world space)
  15866. * @param mesh The mesh that this bone is attached to
  15867. * @returns The absolute position of the bone
  15868. */
  15869. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15870. /**
  15871. * Copy the absolute position of the bone (world space) to the result param
  15872. * @param mesh The mesh that this bone is attached to
  15873. * @param result The vector3 to copy the absolute position to
  15874. */
  15875. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15876. /**
  15877. * Compute the absolute transforms of this bone and its children
  15878. */
  15879. computeAbsoluteTransforms(): void;
  15880. /**
  15881. * Get the world direction from an axis that is in the local space of the bone
  15882. * @param localAxis The local direction that is used to compute the world direction
  15883. * @param mesh The mesh that this bone is attached to
  15884. * @returns The world direction
  15885. */
  15886. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15887. /**
  15888. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15889. * @param localAxis The local direction that is used to compute the world direction
  15890. * @param mesh The mesh that this bone is attached to
  15891. * @param result The vector3 that the world direction will be copied to
  15892. */
  15893. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15894. /**
  15895. * Get the euler rotation of the bone in local or world space
  15896. * @param space The space that the rotation should be in
  15897. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15898. * @returns The euler rotation
  15899. */
  15900. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15901. /**
  15902. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15903. * @param space The space that the rotation should be in
  15904. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15905. * @param result The vector3 that the rotation should be copied to
  15906. */
  15907. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15908. /**
  15909. * Get the quaternion rotation of the bone in either local or world space
  15910. * @param space The space that the rotation should be in
  15911. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15912. * @returns The quaternion rotation
  15913. */
  15914. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15915. /**
  15916. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15917. * @param space The space that the rotation should be in
  15918. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15919. * @param result The quaternion that the rotation should be copied to
  15920. */
  15921. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15922. /**
  15923. * Get the rotation matrix of the bone in local or world space
  15924. * @param space The space that the rotation should be in
  15925. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15926. * @returns The rotation matrix
  15927. */
  15928. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15929. /**
  15930. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15931. * @param space The space that the rotation should be in
  15932. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15933. * @param result The quaternion that the rotation should be copied to
  15934. */
  15935. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15936. /**
  15937. * Get the world position of a point that is in the local space of the bone
  15938. * @param position The local position
  15939. * @param mesh The mesh that this bone is attached to
  15940. * @returns The world position
  15941. */
  15942. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15943. /**
  15944. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15945. * @param position The local position
  15946. * @param mesh The mesh that this bone is attached to
  15947. * @param result The vector3 that the world position should be copied to
  15948. */
  15949. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15950. /**
  15951. * Get the local position of a point that is in world space
  15952. * @param position The world position
  15953. * @param mesh The mesh that this bone is attached to
  15954. * @returns The local position
  15955. */
  15956. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15957. /**
  15958. * Get the local position of a point that is in world space and copy it to the result param
  15959. * @param position The world position
  15960. * @param mesh The mesh that this bone is attached to
  15961. * @param result The vector3 that the local position should be copied to
  15962. */
  15963. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15964. /**
  15965. * Set the current local matrix as the restPose for this bone.
  15966. */
  15967. setCurrentPoseAsRest(): void;
  15968. }
  15969. }
  15970. declare module "babylonjs/Animations/runtimeAnimation" {
  15971. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15972. import { Animatable } from "babylonjs/Animations/animatable";
  15973. import { Scene } from "babylonjs/scene";
  15974. /**
  15975. * Defines a runtime animation
  15976. */
  15977. export class RuntimeAnimation {
  15978. private _events;
  15979. /**
  15980. * The current frame of the runtime animation
  15981. */
  15982. private _currentFrame;
  15983. /**
  15984. * The animation used by the runtime animation
  15985. */
  15986. private _animation;
  15987. /**
  15988. * The target of the runtime animation
  15989. */
  15990. private _target;
  15991. /**
  15992. * The initiating animatable
  15993. */
  15994. private _host;
  15995. /**
  15996. * The original value of the runtime animation
  15997. */
  15998. private _originalValue;
  15999. /**
  16000. * The original blend value of the runtime animation
  16001. */
  16002. private _originalBlendValue;
  16003. /**
  16004. * The offsets cache of the runtime animation
  16005. */
  16006. private _offsetsCache;
  16007. /**
  16008. * The high limits cache of the runtime animation
  16009. */
  16010. private _highLimitsCache;
  16011. /**
  16012. * Specifies if the runtime animation has been stopped
  16013. */
  16014. private _stopped;
  16015. /**
  16016. * The blending factor of the runtime animation
  16017. */
  16018. private _blendingFactor;
  16019. /**
  16020. * The BabylonJS scene
  16021. */
  16022. private _scene;
  16023. /**
  16024. * The current value of the runtime animation
  16025. */
  16026. private _currentValue;
  16027. /** @hidden */
  16028. _animationState: _IAnimationState;
  16029. /**
  16030. * The active target of the runtime animation
  16031. */
  16032. private _activeTargets;
  16033. private _currentActiveTarget;
  16034. private _directTarget;
  16035. /**
  16036. * The target path of the runtime animation
  16037. */
  16038. private _targetPath;
  16039. /**
  16040. * The weight of the runtime animation
  16041. */
  16042. private _weight;
  16043. /**
  16044. * The ratio offset of the runtime animation
  16045. */
  16046. private _ratioOffset;
  16047. /**
  16048. * The previous delay of the runtime animation
  16049. */
  16050. private _previousDelay;
  16051. /**
  16052. * The previous ratio of the runtime animation
  16053. */
  16054. private _previousRatio;
  16055. private _enableBlending;
  16056. private _keys;
  16057. private _minFrame;
  16058. private _maxFrame;
  16059. private _minValue;
  16060. private _maxValue;
  16061. private _targetIsArray;
  16062. /**
  16063. * Gets the current frame of the runtime animation
  16064. */
  16065. get currentFrame(): number;
  16066. /**
  16067. * Gets the weight of the runtime animation
  16068. */
  16069. get weight(): number;
  16070. /**
  16071. * Gets the current value of the runtime animation
  16072. */
  16073. get currentValue(): any;
  16074. /**
  16075. * Gets the target path of the runtime animation
  16076. */
  16077. get targetPath(): string;
  16078. /**
  16079. * Gets the actual target of the runtime animation
  16080. */
  16081. get target(): any;
  16082. /**
  16083. * Gets the additive state of the runtime animation
  16084. */
  16085. get isAdditive(): boolean;
  16086. /** @hidden */
  16087. _onLoop: () => void;
  16088. /**
  16089. * Create a new RuntimeAnimation object
  16090. * @param target defines the target of the animation
  16091. * @param animation defines the source animation object
  16092. * @param scene defines the hosting scene
  16093. * @param host defines the initiating Animatable
  16094. */
  16095. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16096. private _preparePath;
  16097. /**
  16098. * Gets the animation from the runtime animation
  16099. */
  16100. get animation(): Animation;
  16101. /**
  16102. * Resets the runtime animation to the beginning
  16103. * @param restoreOriginal defines whether to restore the target property to the original value
  16104. */
  16105. reset(restoreOriginal?: boolean): void;
  16106. /**
  16107. * Specifies if the runtime animation is stopped
  16108. * @returns Boolean specifying if the runtime animation is stopped
  16109. */
  16110. isStopped(): boolean;
  16111. /**
  16112. * Disposes of the runtime animation
  16113. */
  16114. dispose(): void;
  16115. /**
  16116. * Apply the interpolated value to the target
  16117. * @param currentValue defines the value computed by the animation
  16118. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16119. */
  16120. setValue(currentValue: any, weight: number): void;
  16121. private _getOriginalValues;
  16122. private _setValue;
  16123. /**
  16124. * Gets the loop pmode of the runtime animation
  16125. * @returns Loop Mode
  16126. */
  16127. private _getCorrectLoopMode;
  16128. /**
  16129. * Move the current animation to a given frame
  16130. * @param frame defines the frame to move to
  16131. */
  16132. goToFrame(frame: number): void;
  16133. /**
  16134. * @hidden Internal use only
  16135. */
  16136. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16137. /**
  16138. * Execute the current animation
  16139. * @param delay defines the delay to add to the current frame
  16140. * @param from defines the lower bound of the animation range
  16141. * @param to defines the upper bound of the animation range
  16142. * @param loop defines if the current animation must loop
  16143. * @param speedRatio defines the current speed ratio
  16144. * @param weight defines the weight of the animation (default is -1 so no weight)
  16145. * @param onLoop optional callback called when animation loops
  16146. * @returns a boolean indicating if the animation is running
  16147. */
  16148. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16149. }
  16150. }
  16151. declare module "babylonjs/Animations/animatable" {
  16152. import { Animation } from "babylonjs/Animations/animation";
  16153. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16154. import { Nullable } from "babylonjs/types";
  16155. import { Observable } from "babylonjs/Misc/observable";
  16156. import { Scene } from "babylonjs/scene";
  16157. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16158. import { Node } from "babylonjs/node";
  16159. /**
  16160. * Class used to store an actual running animation
  16161. */
  16162. export class Animatable {
  16163. /** defines the target object */
  16164. target: any;
  16165. /** defines the starting frame number (default is 0) */
  16166. fromFrame: number;
  16167. /** defines the ending frame number (default is 100) */
  16168. toFrame: number;
  16169. /** defines if the animation must loop (default is false) */
  16170. loopAnimation: boolean;
  16171. /** defines a callback to call when animation ends if it is not looping */
  16172. onAnimationEnd?: (() => void) | null | undefined;
  16173. /** defines a callback to call when animation loops */
  16174. onAnimationLoop?: (() => void) | null | undefined;
  16175. /** defines whether the animation should be evaluated additively */
  16176. isAdditive: boolean;
  16177. private _localDelayOffset;
  16178. private _pausedDelay;
  16179. private _runtimeAnimations;
  16180. private _paused;
  16181. private _scene;
  16182. private _speedRatio;
  16183. private _weight;
  16184. private _syncRoot;
  16185. /**
  16186. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16187. * This will only apply for non looping animation (default is true)
  16188. */
  16189. disposeOnEnd: boolean;
  16190. /**
  16191. * Gets a boolean indicating if the animation has started
  16192. */
  16193. animationStarted: boolean;
  16194. /**
  16195. * Observer raised when the animation ends
  16196. */
  16197. onAnimationEndObservable: Observable<Animatable>;
  16198. /**
  16199. * Observer raised when the animation loops
  16200. */
  16201. onAnimationLoopObservable: Observable<Animatable>;
  16202. /**
  16203. * Gets the root Animatable used to synchronize and normalize animations
  16204. */
  16205. get syncRoot(): Nullable<Animatable>;
  16206. /**
  16207. * Gets the current frame of the first RuntimeAnimation
  16208. * Used to synchronize Animatables
  16209. */
  16210. get masterFrame(): number;
  16211. /**
  16212. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16213. */
  16214. get weight(): number;
  16215. set weight(value: number);
  16216. /**
  16217. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16218. */
  16219. get speedRatio(): number;
  16220. set speedRatio(value: number);
  16221. /**
  16222. * Creates a new Animatable
  16223. * @param scene defines the hosting scene
  16224. * @param target defines the target object
  16225. * @param fromFrame defines the starting frame number (default is 0)
  16226. * @param toFrame defines the ending frame number (default is 100)
  16227. * @param loopAnimation defines if the animation must loop (default is false)
  16228. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16229. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16230. * @param animations defines a group of animation to add to the new Animatable
  16231. * @param onAnimationLoop defines a callback to call when animation loops
  16232. * @param isAdditive defines whether the animation should be evaluated additively
  16233. */
  16234. constructor(scene: Scene,
  16235. /** defines the target object */
  16236. target: any,
  16237. /** defines the starting frame number (default is 0) */
  16238. fromFrame?: number,
  16239. /** defines the ending frame number (default is 100) */
  16240. toFrame?: number,
  16241. /** defines if the animation must loop (default is false) */
  16242. loopAnimation?: boolean, speedRatio?: number,
  16243. /** defines a callback to call when animation ends if it is not looping */
  16244. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16245. /** defines a callback to call when animation loops */
  16246. onAnimationLoop?: (() => void) | null | undefined,
  16247. /** defines whether the animation should be evaluated additively */
  16248. isAdditive?: boolean);
  16249. /**
  16250. * Synchronize and normalize current Animatable with a source Animatable
  16251. * This is useful when using animation weights and when animations are not of the same length
  16252. * @param root defines the root Animatable to synchronize with
  16253. * @returns the current Animatable
  16254. */
  16255. syncWith(root: Animatable): Animatable;
  16256. /**
  16257. * Gets the list of runtime animations
  16258. * @returns an array of RuntimeAnimation
  16259. */
  16260. getAnimations(): RuntimeAnimation[];
  16261. /**
  16262. * Adds more animations to the current animatable
  16263. * @param target defines the target of the animations
  16264. * @param animations defines the new animations to add
  16265. */
  16266. appendAnimations(target: any, animations: Animation[]): void;
  16267. /**
  16268. * Gets the source animation for a specific property
  16269. * @param property defines the propertyu to look for
  16270. * @returns null or the source animation for the given property
  16271. */
  16272. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16273. /**
  16274. * Gets the runtime animation for a specific property
  16275. * @param property defines the propertyu to look for
  16276. * @returns null or the runtime animation for the given property
  16277. */
  16278. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16279. /**
  16280. * Resets the animatable to its original state
  16281. */
  16282. reset(): void;
  16283. /**
  16284. * Allows the animatable to blend with current running animations
  16285. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16286. * @param blendingSpeed defines the blending speed to use
  16287. */
  16288. enableBlending(blendingSpeed: number): void;
  16289. /**
  16290. * Disable animation blending
  16291. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16292. */
  16293. disableBlending(): void;
  16294. /**
  16295. * Jump directly to a given frame
  16296. * @param frame defines the frame to jump to
  16297. */
  16298. goToFrame(frame: number): void;
  16299. /**
  16300. * Pause the animation
  16301. */
  16302. pause(): void;
  16303. /**
  16304. * Restart the animation
  16305. */
  16306. restart(): void;
  16307. private _raiseOnAnimationEnd;
  16308. /**
  16309. * Stop and delete the current animation
  16310. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16311. * @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)
  16312. */
  16313. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16314. /**
  16315. * Wait asynchronously for the animation to end
  16316. * @returns a promise which will be fullfilled when the animation ends
  16317. */
  16318. waitAsync(): Promise<Animatable>;
  16319. /** @hidden */
  16320. _animate(delay: number): boolean;
  16321. }
  16322. module "babylonjs/scene" {
  16323. interface Scene {
  16324. /** @hidden */
  16325. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16326. /** @hidden */
  16327. _processLateAnimationBindingsForMatrices(holder: {
  16328. totalWeight: number;
  16329. totalAdditiveWeight: number;
  16330. animations: RuntimeAnimation[];
  16331. additiveAnimations: RuntimeAnimation[];
  16332. originalValue: Matrix;
  16333. }): any;
  16334. /** @hidden */
  16335. _processLateAnimationBindingsForQuaternions(holder: {
  16336. totalWeight: number;
  16337. totalAdditiveWeight: number;
  16338. animations: RuntimeAnimation[];
  16339. additiveAnimations: RuntimeAnimation[];
  16340. originalValue: Quaternion;
  16341. }, refQuaternion: Quaternion): Quaternion;
  16342. /** @hidden */
  16343. _processLateAnimationBindings(): void;
  16344. /**
  16345. * Will start the animation sequence of a given target
  16346. * @param target defines the target
  16347. * @param from defines from which frame should animation start
  16348. * @param to defines until which frame should animation run.
  16349. * @param weight defines the weight to apply to the animation (1.0 by default)
  16350. * @param loop defines if the animation loops
  16351. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16352. * @param onAnimationEnd defines the function to be executed when the animation ends
  16353. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16354. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16355. * @param onAnimationLoop defines the callback to call when an animation loops
  16356. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16357. * @returns the animatable object created for this animation
  16358. */
  16359. 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;
  16360. /**
  16361. * Will start the animation sequence of a given target
  16362. * @param target defines the target
  16363. * @param from defines from which frame should animation start
  16364. * @param to defines until which frame should animation run.
  16365. * @param loop defines if the animation loops
  16366. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16367. * @param onAnimationEnd defines the function to be executed when the animation ends
  16368. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16369. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16370. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16371. * @param onAnimationLoop defines the callback to call when an animation loops
  16372. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16373. * @returns the animatable object created for this animation
  16374. */
  16375. 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;
  16376. /**
  16377. * Will start the animation sequence of a given target and its hierarchy
  16378. * @param target defines the target
  16379. * @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.
  16380. * @param from defines from which frame should animation start
  16381. * @param to defines until which frame should animation run.
  16382. * @param loop defines if the animation loops
  16383. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16384. * @param onAnimationEnd defines the function to be executed when the animation ends
  16385. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16386. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16387. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16388. * @param onAnimationLoop defines the callback to call when an animation loops
  16389. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16390. * @returns the list of created animatables
  16391. */
  16392. 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[];
  16393. /**
  16394. * Begin a new animation on a given node
  16395. * @param target defines the target where the animation will take place
  16396. * @param animations defines the list of animations to start
  16397. * @param from defines the initial value
  16398. * @param to defines the final value
  16399. * @param loop defines if you want animation to loop (off by default)
  16400. * @param speedRatio defines the speed ratio to apply to all animations
  16401. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16402. * @param onAnimationLoop defines the callback to call when an animation loops
  16403. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16404. * @returns the list of created animatables
  16405. */
  16406. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16407. /**
  16408. * Begin a new animation on a given node and its hierarchy
  16409. * @param target defines the root node where the animation will take place
  16410. * @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.
  16411. * @param animations defines the list of animations to start
  16412. * @param from defines the initial value
  16413. * @param to defines the final value
  16414. * @param loop defines if you want animation to loop (off by default)
  16415. * @param speedRatio defines the speed ratio to apply to all animations
  16416. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16417. * @param onAnimationLoop defines the callback to call when an animation loops
  16418. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16419. * @returns the list of animatables created for all nodes
  16420. */
  16421. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16422. /**
  16423. * Gets the animatable associated with a specific target
  16424. * @param target defines the target of the animatable
  16425. * @returns the required animatable if found
  16426. */
  16427. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16428. /**
  16429. * Gets all animatables associated with a given target
  16430. * @param target defines the target to look animatables for
  16431. * @returns an array of Animatables
  16432. */
  16433. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16434. /**
  16435. * Stops and removes all animations that have been applied to the scene
  16436. */
  16437. stopAllAnimations(): void;
  16438. /**
  16439. * Gets the current delta time used by animation engine
  16440. */
  16441. deltaTime: number;
  16442. }
  16443. }
  16444. module "babylonjs/Bones/bone" {
  16445. interface Bone {
  16446. /**
  16447. * Copy an animation range from another bone
  16448. * @param source defines the source bone
  16449. * @param rangeName defines the range name to copy
  16450. * @param frameOffset defines the frame offset
  16451. * @param rescaleAsRequired defines if rescaling must be applied if required
  16452. * @param skelDimensionsRatio defines the scaling ratio
  16453. * @returns true if operation was successful
  16454. */
  16455. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16456. }
  16457. }
  16458. }
  16459. declare module "babylonjs/Bones/skeleton" {
  16460. import { Bone } from "babylonjs/Bones/bone";
  16461. import { Observable } from "babylonjs/Misc/observable";
  16462. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16463. import { Scene } from "babylonjs/scene";
  16464. import { Nullable } from "babylonjs/types";
  16465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16466. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16467. import { Animatable } from "babylonjs/Animations/animatable";
  16468. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16469. import { Animation } from "babylonjs/Animations/animation";
  16470. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16471. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16472. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16473. /**
  16474. * Class used to handle skinning animations
  16475. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16476. */
  16477. export class Skeleton implements IAnimatable {
  16478. /** defines the skeleton name */
  16479. name: string;
  16480. /** defines the skeleton Id */
  16481. id: string;
  16482. /**
  16483. * Defines the list of child bones
  16484. */
  16485. bones: Bone[];
  16486. /**
  16487. * Defines an estimate of the dimension of the skeleton at rest
  16488. */
  16489. dimensionsAtRest: Vector3;
  16490. /**
  16491. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16492. */
  16493. needInitialSkinMatrix: boolean;
  16494. /**
  16495. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16496. */
  16497. overrideMesh: Nullable<AbstractMesh>;
  16498. /**
  16499. * Gets the list of animations attached to this skeleton
  16500. */
  16501. animations: Array<Animation>;
  16502. private _scene;
  16503. private _isDirty;
  16504. private _transformMatrices;
  16505. private _transformMatrixTexture;
  16506. private _meshesWithPoseMatrix;
  16507. private _animatables;
  16508. private _identity;
  16509. private _synchronizedWithMesh;
  16510. private _ranges;
  16511. private _lastAbsoluteTransformsUpdateId;
  16512. private _canUseTextureForBones;
  16513. private _uniqueId;
  16514. /** @hidden */
  16515. _numBonesWithLinkedTransformNode: number;
  16516. /** @hidden */
  16517. _hasWaitingData: Nullable<boolean>;
  16518. /** @hidden */
  16519. _waitingOverrideMeshId: Nullable<string>;
  16520. /**
  16521. * Specifies if the skeleton should be serialized
  16522. */
  16523. doNotSerialize: boolean;
  16524. private _useTextureToStoreBoneMatrices;
  16525. /**
  16526. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16527. * Please note that this option is not available if the hardware does not support it
  16528. */
  16529. get useTextureToStoreBoneMatrices(): boolean;
  16530. set useTextureToStoreBoneMatrices(value: boolean);
  16531. private _animationPropertiesOverride;
  16532. /**
  16533. * Gets or sets the animation properties override
  16534. */
  16535. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16536. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16537. /**
  16538. * List of inspectable custom properties (used by the Inspector)
  16539. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16540. */
  16541. inspectableCustomProperties: IInspectable[];
  16542. /**
  16543. * An observable triggered before computing the skeleton's matrices
  16544. */
  16545. onBeforeComputeObservable: Observable<Skeleton>;
  16546. /**
  16547. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16548. */
  16549. get isUsingTextureForMatrices(): boolean;
  16550. /**
  16551. * Gets the unique ID of this skeleton
  16552. */
  16553. get uniqueId(): number;
  16554. /**
  16555. * Creates a new skeleton
  16556. * @param name defines the skeleton name
  16557. * @param id defines the skeleton Id
  16558. * @param scene defines the hosting scene
  16559. */
  16560. constructor(
  16561. /** defines the skeleton name */
  16562. name: string,
  16563. /** defines the skeleton Id */
  16564. id: string, scene: Scene);
  16565. /**
  16566. * Gets the current object class name.
  16567. * @return the class name
  16568. */
  16569. getClassName(): string;
  16570. /**
  16571. * Returns an array containing the root bones
  16572. * @returns an array containing the root bones
  16573. */
  16574. getChildren(): Array<Bone>;
  16575. /**
  16576. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16577. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16578. * @returns a Float32Array containing matrices data
  16579. */
  16580. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16581. /**
  16582. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16583. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16584. * @returns a raw texture containing the data
  16585. */
  16586. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16587. /**
  16588. * Gets the current hosting scene
  16589. * @returns a scene object
  16590. */
  16591. getScene(): Scene;
  16592. /**
  16593. * Gets a string representing the current skeleton data
  16594. * @param fullDetails defines a boolean indicating if we want a verbose version
  16595. * @returns a string representing the current skeleton data
  16596. */
  16597. toString(fullDetails?: boolean): string;
  16598. /**
  16599. * Get bone's index searching by name
  16600. * @param name defines bone's name to search for
  16601. * @return the indice of the bone. Returns -1 if not found
  16602. */
  16603. getBoneIndexByName(name: string): number;
  16604. /**
  16605. * Creater a new animation range
  16606. * @param name defines the name of the range
  16607. * @param from defines the start key
  16608. * @param to defines the end key
  16609. */
  16610. createAnimationRange(name: string, from: number, to: number): void;
  16611. /**
  16612. * Delete a specific animation range
  16613. * @param name defines the name of the range
  16614. * @param deleteFrames defines if frames must be removed as well
  16615. */
  16616. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16617. /**
  16618. * Gets a specific animation range
  16619. * @param name defines the name of the range to look for
  16620. * @returns the requested animation range or null if not found
  16621. */
  16622. getAnimationRange(name: string): Nullable<AnimationRange>;
  16623. /**
  16624. * Gets the list of all animation ranges defined on this skeleton
  16625. * @returns an array
  16626. */
  16627. getAnimationRanges(): Nullable<AnimationRange>[];
  16628. /**
  16629. * Copy animation range from a source skeleton.
  16630. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16631. * @param source defines the source skeleton
  16632. * @param name defines the name of the range to copy
  16633. * @param rescaleAsRequired defines if rescaling must be applied if required
  16634. * @returns true if operation was successful
  16635. */
  16636. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16637. /**
  16638. * Forces the skeleton to go to rest pose
  16639. */
  16640. returnToRest(): void;
  16641. private _getHighestAnimationFrame;
  16642. /**
  16643. * Begin a specific animation range
  16644. * @param name defines the name of the range to start
  16645. * @param loop defines if looping must be turned on (false by default)
  16646. * @param speedRatio defines the speed ratio to apply (1 by default)
  16647. * @param onAnimationEnd defines a callback which will be called when animation will end
  16648. * @returns a new animatable
  16649. */
  16650. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16651. /**
  16652. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16653. * @param skeleton defines the Skeleton containing the animation range to convert
  16654. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16655. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16656. * @returns the original skeleton
  16657. */
  16658. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16659. /** @hidden */
  16660. _markAsDirty(): void;
  16661. /** @hidden */
  16662. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16663. /** @hidden */
  16664. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16665. private _computeTransformMatrices;
  16666. /**
  16667. * Build all resources required to render a skeleton
  16668. */
  16669. prepare(): void;
  16670. /**
  16671. * Gets the list of animatables currently running for this skeleton
  16672. * @returns an array of animatables
  16673. */
  16674. getAnimatables(): IAnimatable[];
  16675. /**
  16676. * Clone the current skeleton
  16677. * @param name defines the name of the new skeleton
  16678. * @param id defines the id of the new skeleton
  16679. * @returns the new skeleton
  16680. */
  16681. clone(name: string, id?: string): Skeleton;
  16682. /**
  16683. * Enable animation blending for this skeleton
  16684. * @param blendingSpeed defines the blending speed to apply
  16685. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16686. */
  16687. enableBlending(blendingSpeed?: number): void;
  16688. /**
  16689. * Releases all resources associated with the current skeleton
  16690. */
  16691. dispose(): void;
  16692. /**
  16693. * Serialize the skeleton in a JSON object
  16694. * @returns a JSON object
  16695. */
  16696. serialize(): any;
  16697. /**
  16698. * Creates a new skeleton from serialized data
  16699. * @param parsedSkeleton defines the serialized data
  16700. * @param scene defines the hosting scene
  16701. * @returns a new skeleton
  16702. */
  16703. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16704. /**
  16705. * Compute all node absolute transforms
  16706. * @param forceUpdate defines if computation must be done even if cache is up to date
  16707. */
  16708. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16709. /**
  16710. * Gets the root pose matrix
  16711. * @returns a matrix
  16712. */
  16713. getPoseMatrix(): Nullable<Matrix>;
  16714. /**
  16715. * Sorts bones per internal index
  16716. */
  16717. sortBones(): void;
  16718. private _sortBones;
  16719. /**
  16720. * Set the current local matrix as the restPose for all bones in the skeleton.
  16721. */
  16722. setCurrentPoseAsRest(): void;
  16723. }
  16724. }
  16725. declare module "babylonjs/Meshes/instancedMesh" {
  16726. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16727. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16728. import { Camera } from "babylonjs/Cameras/camera";
  16729. import { Node } from "babylonjs/node";
  16730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16731. import { Mesh } from "babylonjs/Meshes/mesh";
  16732. import { Material } from "babylonjs/Materials/material";
  16733. import { Skeleton } from "babylonjs/Bones/skeleton";
  16734. import { Light } from "babylonjs/Lights/light";
  16735. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16736. /**
  16737. * Creates an instance based on a source mesh.
  16738. */
  16739. export class InstancedMesh extends AbstractMesh {
  16740. private _sourceMesh;
  16741. private _currentLOD;
  16742. /** @hidden */
  16743. _indexInSourceMeshInstanceArray: number;
  16744. constructor(name: string, source: Mesh);
  16745. /**
  16746. * Returns the string "InstancedMesh".
  16747. */
  16748. getClassName(): string;
  16749. /** Gets the list of lights affecting that mesh */
  16750. get lightSources(): Light[];
  16751. _resyncLightSources(): void;
  16752. _resyncLightSource(light: Light): void;
  16753. _removeLightSource(light: Light, dispose: boolean): void;
  16754. /**
  16755. * If the source mesh receives shadows
  16756. */
  16757. get receiveShadows(): boolean;
  16758. /**
  16759. * The material of the source mesh
  16760. */
  16761. get material(): Nullable<Material>;
  16762. /**
  16763. * Visibility of the source mesh
  16764. */
  16765. get visibility(): number;
  16766. /**
  16767. * Skeleton of the source mesh
  16768. */
  16769. get skeleton(): Nullable<Skeleton>;
  16770. /**
  16771. * Rendering ground id of the source mesh
  16772. */
  16773. get renderingGroupId(): number;
  16774. set renderingGroupId(value: number);
  16775. /**
  16776. * Returns the total number of vertices (integer).
  16777. */
  16778. getTotalVertices(): number;
  16779. /**
  16780. * Returns a positive integer : the total number of indices in this mesh geometry.
  16781. * @returns the numner of indices or zero if the mesh has no geometry.
  16782. */
  16783. getTotalIndices(): number;
  16784. /**
  16785. * The source mesh of the instance
  16786. */
  16787. get sourceMesh(): Mesh;
  16788. /**
  16789. * Creates a new InstancedMesh object from the mesh model.
  16790. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16791. * @param name defines the name of the new instance
  16792. * @returns a new InstancedMesh
  16793. */
  16794. createInstance(name: string): InstancedMesh;
  16795. /**
  16796. * Is this node ready to be used/rendered
  16797. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16798. * @return {boolean} is it ready
  16799. */
  16800. isReady(completeCheck?: boolean): boolean;
  16801. /**
  16802. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16803. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16804. * @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.
  16805. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16806. */
  16807. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16808. /**
  16809. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16810. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16811. * The `data` are either a numeric array either a Float32Array.
  16812. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16813. * 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).
  16814. * Note that a new underlying VertexBuffer object is created each call.
  16815. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16816. *
  16817. * Possible `kind` values :
  16818. * - VertexBuffer.PositionKind
  16819. * - VertexBuffer.UVKind
  16820. * - VertexBuffer.UV2Kind
  16821. * - VertexBuffer.UV3Kind
  16822. * - VertexBuffer.UV4Kind
  16823. * - VertexBuffer.UV5Kind
  16824. * - VertexBuffer.UV6Kind
  16825. * - VertexBuffer.ColorKind
  16826. * - VertexBuffer.MatricesIndicesKind
  16827. * - VertexBuffer.MatricesIndicesExtraKind
  16828. * - VertexBuffer.MatricesWeightsKind
  16829. * - VertexBuffer.MatricesWeightsExtraKind
  16830. *
  16831. * Returns the Mesh.
  16832. */
  16833. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16834. /**
  16835. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16836. * If the mesh has no geometry, it is simply returned as it is.
  16837. * The `data` are either a numeric array either a Float32Array.
  16838. * No new underlying VertexBuffer object is created.
  16839. * 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.
  16840. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16841. *
  16842. * Possible `kind` values :
  16843. * - VertexBuffer.PositionKind
  16844. * - VertexBuffer.UVKind
  16845. * - VertexBuffer.UV2Kind
  16846. * - VertexBuffer.UV3Kind
  16847. * - VertexBuffer.UV4Kind
  16848. * - VertexBuffer.UV5Kind
  16849. * - VertexBuffer.UV6Kind
  16850. * - VertexBuffer.ColorKind
  16851. * - VertexBuffer.MatricesIndicesKind
  16852. * - VertexBuffer.MatricesIndicesExtraKind
  16853. * - VertexBuffer.MatricesWeightsKind
  16854. * - VertexBuffer.MatricesWeightsExtraKind
  16855. *
  16856. * Returns the Mesh.
  16857. */
  16858. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16859. /**
  16860. * Sets the mesh indices.
  16861. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16862. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16863. * This method creates a new index buffer each call.
  16864. * Returns the Mesh.
  16865. */
  16866. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16867. /**
  16868. * Boolean : True if the mesh owns the requested kind of data.
  16869. */
  16870. isVerticesDataPresent(kind: string): boolean;
  16871. /**
  16872. * Returns an array of indices (IndicesArray).
  16873. */
  16874. getIndices(): Nullable<IndicesArray>;
  16875. get _positions(): Nullable<Vector3[]>;
  16876. /**
  16877. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16878. * This means the mesh underlying bounding box and sphere are recomputed.
  16879. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16880. * @returns the current mesh
  16881. */
  16882. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16883. /** @hidden */
  16884. _preActivate(): InstancedMesh;
  16885. /** @hidden */
  16886. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16887. /** @hidden */
  16888. _postActivate(): void;
  16889. getWorldMatrix(): Matrix;
  16890. get isAnInstance(): boolean;
  16891. /**
  16892. * Returns the current associated LOD AbstractMesh.
  16893. */
  16894. getLOD(camera: Camera): AbstractMesh;
  16895. /** @hidden */
  16896. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16897. /** @hidden */
  16898. _syncSubMeshes(): InstancedMesh;
  16899. /** @hidden */
  16900. _generatePointsArray(): boolean;
  16901. /** @hidden */
  16902. _updateBoundingInfo(): AbstractMesh;
  16903. /**
  16904. * Creates a new InstancedMesh from the current mesh.
  16905. * - name (string) : the cloned mesh name
  16906. * - newParent (optional Node) : the optional Node to parent the clone to.
  16907. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16908. *
  16909. * Returns the clone.
  16910. */
  16911. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16912. /**
  16913. * Disposes the InstancedMesh.
  16914. * Returns nothing.
  16915. */
  16916. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16917. }
  16918. module "babylonjs/Meshes/mesh" {
  16919. interface Mesh {
  16920. /**
  16921. * Register a custom buffer that will be instanced
  16922. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16923. * @param kind defines the buffer kind
  16924. * @param stride defines the stride in floats
  16925. */
  16926. registerInstancedBuffer(kind: string, stride: number): void;
  16927. /**
  16928. * true to use the edge renderer for all instances of this mesh
  16929. */
  16930. edgesShareWithInstances: boolean;
  16931. /** @hidden */
  16932. _userInstancedBuffersStorage: {
  16933. data: {
  16934. [key: string]: Float32Array;
  16935. };
  16936. sizes: {
  16937. [key: string]: number;
  16938. };
  16939. vertexBuffers: {
  16940. [key: string]: Nullable<VertexBuffer>;
  16941. };
  16942. strides: {
  16943. [key: string]: number;
  16944. };
  16945. };
  16946. }
  16947. }
  16948. module "babylonjs/Meshes/abstractMesh" {
  16949. interface AbstractMesh {
  16950. /**
  16951. * Object used to store instanced buffers defined by user
  16952. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16953. */
  16954. instancedBuffers: {
  16955. [key: string]: any;
  16956. };
  16957. }
  16958. }
  16959. }
  16960. declare module "babylonjs/Materials/shaderMaterial" {
  16961. import { Nullable } from "babylonjs/types";
  16962. import { Scene } from "babylonjs/scene";
  16963. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16965. import { Mesh } from "babylonjs/Meshes/mesh";
  16966. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16967. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16968. import { Effect } from "babylonjs/Materials/effect";
  16969. import { Material } from "babylonjs/Materials/material";
  16970. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16971. /**
  16972. * Defines the options associated with the creation of a shader material.
  16973. */
  16974. export interface IShaderMaterialOptions {
  16975. /**
  16976. * Does the material work in alpha blend mode
  16977. */
  16978. needAlphaBlending: boolean;
  16979. /**
  16980. * Does the material work in alpha test mode
  16981. */
  16982. needAlphaTesting: boolean;
  16983. /**
  16984. * The list of attribute names used in the shader
  16985. */
  16986. attributes: string[];
  16987. /**
  16988. * The list of unifrom names used in the shader
  16989. */
  16990. uniforms: string[];
  16991. /**
  16992. * The list of UBO names used in the shader
  16993. */
  16994. uniformBuffers: string[];
  16995. /**
  16996. * The list of sampler names used in the shader
  16997. */
  16998. samplers: string[];
  16999. /**
  17000. * The list of defines used in the shader
  17001. */
  17002. defines: string[];
  17003. }
  17004. /**
  17005. * 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.
  17006. *
  17007. * This returned material effects how the mesh will look based on the code in the shaders.
  17008. *
  17009. * @see https://doc.babylonjs.com/how_to/shader_material
  17010. */
  17011. export class ShaderMaterial extends Material {
  17012. private _shaderPath;
  17013. private _options;
  17014. private _textures;
  17015. private _textureArrays;
  17016. private _floats;
  17017. private _ints;
  17018. private _floatsArrays;
  17019. private _colors3;
  17020. private _colors3Arrays;
  17021. private _colors4;
  17022. private _colors4Arrays;
  17023. private _vectors2;
  17024. private _vectors3;
  17025. private _vectors4;
  17026. private _matrices;
  17027. private _matrixArrays;
  17028. private _matrices3x3;
  17029. private _matrices2x2;
  17030. private _vectors2Arrays;
  17031. private _vectors3Arrays;
  17032. private _vectors4Arrays;
  17033. private _cachedWorldViewMatrix;
  17034. private _cachedWorldViewProjectionMatrix;
  17035. private _renderId;
  17036. private _multiview;
  17037. private _cachedDefines;
  17038. /** Define the Url to load snippets */
  17039. static SnippetUrl: string;
  17040. /** Snippet ID if the material was created from the snippet server */
  17041. snippetId: string;
  17042. /**
  17043. * Instantiate a new shader material.
  17044. * 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.
  17045. * This returned material effects how the mesh will look based on the code in the shaders.
  17046. * @see https://doc.babylonjs.com/how_to/shader_material
  17047. * @param name Define the name of the material in the scene
  17048. * @param scene Define the scene the material belongs to
  17049. * @param shaderPath Defines the route to the shader code in one of three ways:
  17050. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17051. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17052. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17053. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17054. * @param options Define the options used to create the shader
  17055. */
  17056. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17057. /**
  17058. * Gets the shader path used to define the shader code
  17059. * It can be modified to trigger a new compilation
  17060. */
  17061. get shaderPath(): any;
  17062. /**
  17063. * Sets the shader path used to define the shader code
  17064. * It can be modified to trigger a new compilation
  17065. */
  17066. set shaderPath(shaderPath: any);
  17067. /**
  17068. * Gets the options used to compile the shader.
  17069. * They can be modified to trigger a new compilation
  17070. */
  17071. get options(): IShaderMaterialOptions;
  17072. /**
  17073. * Gets the current class name of the material e.g. "ShaderMaterial"
  17074. * Mainly use in serialization.
  17075. * @returns the class name
  17076. */
  17077. getClassName(): string;
  17078. /**
  17079. * Specifies if the material will require alpha blending
  17080. * @returns a boolean specifying if alpha blending is needed
  17081. */
  17082. needAlphaBlending(): boolean;
  17083. /**
  17084. * Specifies if this material should be rendered in alpha test mode
  17085. * @returns a boolean specifying if an alpha test is needed.
  17086. */
  17087. needAlphaTesting(): boolean;
  17088. private _checkUniform;
  17089. /**
  17090. * Set a texture in the shader.
  17091. * @param name Define the name of the uniform samplers as defined in the shader
  17092. * @param texture Define the texture to bind to this sampler
  17093. * @return the material itself allowing "fluent" like uniform updates
  17094. */
  17095. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17096. /**
  17097. * Set a texture array in the shader.
  17098. * @param name Define the name of the uniform sampler array as defined in the shader
  17099. * @param textures Define the list of textures to bind to this sampler
  17100. * @return the material itself allowing "fluent" like uniform updates
  17101. */
  17102. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17103. /**
  17104. * Set a float in the shader.
  17105. * @param name Define the name of the uniform as defined in the shader
  17106. * @param value Define the value to give to the uniform
  17107. * @return the material itself allowing "fluent" like uniform updates
  17108. */
  17109. setFloat(name: string, value: number): ShaderMaterial;
  17110. /**
  17111. * Set a int in the shader.
  17112. * @param name Define the name of the uniform as defined in the shader
  17113. * @param value Define the value to give to the uniform
  17114. * @return the material itself allowing "fluent" like uniform updates
  17115. */
  17116. setInt(name: string, value: number): ShaderMaterial;
  17117. /**
  17118. * Set an array of floats in the shader.
  17119. * @param name Define the name of the uniform as defined in the shader
  17120. * @param value Define the value to give to the uniform
  17121. * @return the material itself allowing "fluent" like uniform updates
  17122. */
  17123. setFloats(name: string, value: number[]): ShaderMaterial;
  17124. /**
  17125. * Set a vec3 in the shader from a Color3.
  17126. * @param name Define the name of the uniform as defined in the shader
  17127. * @param value Define the value to give to the uniform
  17128. * @return the material itself allowing "fluent" like uniform updates
  17129. */
  17130. setColor3(name: string, value: Color3): ShaderMaterial;
  17131. /**
  17132. * Set a vec3 array in the shader from a Color3 array.
  17133. * @param name Define the name of the uniform as defined in the shader
  17134. * @param value Define the value to give to the uniform
  17135. * @return the material itself allowing "fluent" like uniform updates
  17136. */
  17137. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17138. /**
  17139. * Set a vec4 in the shader from a Color4.
  17140. * @param name Define the name of the uniform as defined in the shader
  17141. * @param value Define the value to give to the uniform
  17142. * @return the material itself allowing "fluent" like uniform updates
  17143. */
  17144. setColor4(name: string, value: Color4): ShaderMaterial;
  17145. /**
  17146. * Set a vec4 array in the shader from a Color4 array.
  17147. * @param name Define the name of the uniform as defined in the shader
  17148. * @param value Define the value to give to the uniform
  17149. * @return the material itself allowing "fluent" like uniform updates
  17150. */
  17151. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17152. /**
  17153. * Set a vec2 in the shader from a Vector2.
  17154. * @param name Define the name of the uniform as defined in the shader
  17155. * @param value Define the value to give to the uniform
  17156. * @return the material itself allowing "fluent" like uniform updates
  17157. */
  17158. setVector2(name: string, value: Vector2): ShaderMaterial;
  17159. /**
  17160. * Set a vec3 in the shader from a Vector3.
  17161. * @param name Define the name of the uniform as defined in the shader
  17162. * @param value Define the value to give to the uniform
  17163. * @return the material itself allowing "fluent" like uniform updates
  17164. */
  17165. setVector3(name: string, value: Vector3): ShaderMaterial;
  17166. /**
  17167. * Set a vec4 in the shader from a Vector4.
  17168. * @param name Define the name of the uniform as defined in the shader
  17169. * @param value Define the value to give to the uniform
  17170. * @return the material itself allowing "fluent" like uniform updates
  17171. */
  17172. setVector4(name: string, value: Vector4): ShaderMaterial;
  17173. /**
  17174. * Set a mat4 in the shader from a Matrix.
  17175. * @param name Define the name of the uniform as defined in the shader
  17176. * @param value Define the value to give to the uniform
  17177. * @return the material itself allowing "fluent" like uniform updates
  17178. */
  17179. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17180. /**
  17181. * Set a float32Array in the shader from a matrix array.
  17182. * @param name Define the name of the uniform as defined in the shader
  17183. * @param value Define the value to give to the uniform
  17184. * @return the material itself allowing "fluent" like uniform updates
  17185. */
  17186. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17187. /**
  17188. * Set a mat3 in the shader from a Float32Array.
  17189. * @param name Define the name of the uniform as defined in the shader
  17190. * @param value Define the value to give to the uniform
  17191. * @return the material itself allowing "fluent" like uniform updates
  17192. */
  17193. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17194. /**
  17195. * Set a mat2 in the shader from a Float32Array.
  17196. * @param name Define the name of the uniform as defined in the shader
  17197. * @param value Define the value to give to the uniform
  17198. * @return the material itself allowing "fluent" like uniform updates
  17199. */
  17200. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17201. /**
  17202. * Set a vec2 array in the shader from a number array.
  17203. * @param name Define the name of the uniform as defined in the shader
  17204. * @param value Define the value to give to the uniform
  17205. * @return the material itself allowing "fluent" like uniform updates
  17206. */
  17207. setArray2(name: string, value: number[]): ShaderMaterial;
  17208. /**
  17209. * Set a vec3 array in the shader from a number array.
  17210. * @param name Define the name of the uniform as defined in the shader
  17211. * @param value Define the value to give to the uniform
  17212. * @return the material itself allowing "fluent" like uniform updates
  17213. */
  17214. setArray3(name: string, value: number[]): ShaderMaterial;
  17215. /**
  17216. * Set a vec4 array in the shader from a number array.
  17217. * @param name Define the name of the uniform as defined in the shader
  17218. * @param value Define the value to give to the uniform
  17219. * @return the material itself allowing "fluent" like uniform updates
  17220. */
  17221. setArray4(name: string, value: number[]): ShaderMaterial;
  17222. private _checkCache;
  17223. /**
  17224. * Specifies that the submesh is ready to be used
  17225. * @param mesh defines the mesh to check
  17226. * @param subMesh defines which submesh to check
  17227. * @param useInstances specifies that instances should be used
  17228. * @returns a boolean indicating that the submesh is ready or not
  17229. */
  17230. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17231. /**
  17232. * Checks if the material is ready to render the requested mesh
  17233. * @param mesh Define the mesh to render
  17234. * @param useInstances Define whether or not the material is used with instances
  17235. * @returns true if ready, otherwise false
  17236. */
  17237. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17238. /**
  17239. * Binds the world matrix to the material
  17240. * @param world defines the world transformation matrix
  17241. * @param effectOverride - If provided, use this effect instead of internal effect
  17242. */
  17243. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17244. /**
  17245. * Binds the submesh to this material by preparing the effect and shader to draw
  17246. * @param world defines the world transformation matrix
  17247. * @param mesh defines the mesh containing the submesh
  17248. * @param subMesh defines the submesh to bind the material to
  17249. */
  17250. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17251. /**
  17252. * Binds the material to the mesh
  17253. * @param world defines the world transformation matrix
  17254. * @param mesh defines the mesh to bind the material to
  17255. * @param effectOverride - If provided, use this effect instead of internal effect
  17256. */
  17257. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17258. protected _afterBind(mesh?: Mesh): void;
  17259. /**
  17260. * Gets the active textures from the material
  17261. * @returns an array of textures
  17262. */
  17263. getActiveTextures(): BaseTexture[];
  17264. /**
  17265. * Specifies if the material uses a texture
  17266. * @param texture defines the texture to check against the material
  17267. * @returns a boolean specifying if the material uses the texture
  17268. */
  17269. hasTexture(texture: BaseTexture): boolean;
  17270. /**
  17271. * Makes a duplicate of the material, and gives it a new name
  17272. * @param name defines the new name for the duplicated material
  17273. * @returns the cloned material
  17274. */
  17275. clone(name: string): ShaderMaterial;
  17276. /**
  17277. * Disposes the material
  17278. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17279. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17280. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17281. */
  17282. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17283. /**
  17284. * Serializes this material in a JSON representation
  17285. * @returns the serialized material object
  17286. */
  17287. serialize(): any;
  17288. /**
  17289. * Creates a shader material from parsed shader material data
  17290. * @param source defines the JSON represnetation of the material
  17291. * @param scene defines the hosting scene
  17292. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17293. * @returns a new material
  17294. */
  17295. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17296. /**
  17297. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17298. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17299. * @param url defines the url to load from
  17300. * @param scene defines the hosting scene
  17301. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17302. * @returns a promise that will resolve to the new ShaderMaterial
  17303. */
  17304. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17305. /**
  17306. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17307. * @param snippetId defines the snippet to load
  17308. * @param scene defines the hosting scene
  17309. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17310. * @returns a promise that will resolve to the new ShaderMaterial
  17311. */
  17312. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17313. }
  17314. }
  17315. declare module "babylonjs/Shaders/color.fragment" {
  17316. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17317. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17318. /** @hidden */
  17319. export var colorPixelShader: {
  17320. name: string;
  17321. shader: string;
  17322. };
  17323. }
  17324. declare module "babylonjs/Shaders/color.vertex" {
  17325. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17326. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17327. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17328. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17329. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17330. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17331. /** @hidden */
  17332. export var colorVertexShader: {
  17333. name: string;
  17334. shader: string;
  17335. };
  17336. }
  17337. declare module "babylonjs/Meshes/linesMesh" {
  17338. import { Nullable } from "babylonjs/types";
  17339. import { Scene } from "babylonjs/scene";
  17340. import { Color3 } from "babylonjs/Maths/math.color";
  17341. import { Node } from "babylonjs/node";
  17342. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17343. import { Mesh } from "babylonjs/Meshes/mesh";
  17344. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17345. import { Effect } from "babylonjs/Materials/effect";
  17346. import { Material } from "babylonjs/Materials/material";
  17347. import "babylonjs/Shaders/color.fragment";
  17348. import "babylonjs/Shaders/color.vertex";
  17349. /**
  17350. * Line mesh
  17351. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17352. */
  17353. export class LinesMesh extends Mesh {
  17354. /**
  17355. * If vertex color should be applied to the mesh
  17356. */
  17357. readonly useVertexColor?: boolean | undefined;
  17358. /**
  17359. * If vertex alpha should be applied to the mesh
  17360. */
  17361. readonly useVertexAlpha?: boolean | undefined;
  17362. /**
  17363. * Color of the line (Default: White)
  17364. */
  17365. color: Color3;
  17366. /**
  17367. * Alpha of the line (Default: 1)
  17368. */
  17369. alpha: number;
  17370. /**
  17371. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17372. * This margin is expressed in world space coordinates, so its value may vary.
  17373. * Default value is 0.1
  17374. */
  17375. intersectionThreshold: number;
  17376. private _colorShader;
  17377. private color4;
  17378. /**
  17379. * Creates a new LinesMesh
  17380. * @param name defines the name
  17381. * @param scene defines the hosting scene
  17382. * @param parent defines the parent mesh if any
  17383. * @param source defines the optional source LinesMesh used to clone data from
  17384. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17385. * When false, achieved by calling a clone(), also passing False.
  17386. * This will make creation of children, recursive.
  17387. * @param useVertexColor defines if this LinesMesh supports vertex color
  17388. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17389. */
  17390. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17391. /**
  17392. * If vertex color should be applied to the mesh
  17393. */
  17394. useVertexColor?: boolean | undefined,
  17395. /**
  17396. * If vertex alpha should be applied to the mesh
  17397. */
  17398. useVertexAlpha?: boolean | undefined);
  17399. private _addClipPlaneDefine;
  17400. private _removeClipPlaneDefine;
  17401. isReady(): boolean;
  17402. /**
  17403. * Returns the string "LineMesh"
  17404. */
  17405. getClassName(): string;
  17406. /**
  17407. * @hidden
  17408. */
  17409. get material(): Material;
  17410. /**
  17411. * @hidden
  17412. */
  17413. set material(value: Material);
  17414. /**
  17415. * @hidden
  17416. */
  17417. get checkCollisions(): boolean;
  17418. /** @hidden */
  17419. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17420. /** @hidden */
  17421. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17422. /**
  17423. * Disposes of the line mesh
  17424. * @param doNotRecurse If children should be disposed
  17425. */
  17426. dispose(doNotRecurse?: boolean): void;
  17427. /**
  17428. * Returns a new LineMesh object cloned from the current one.
  17429. */
  17430. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17431. /**
  17432. * Creates a new InstancedLinesMesh object from the mesh model.
  17433. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17434. * @param name defines the name of the new instance
  17435. * @returns a new InstancedLinesMesh
  17436. */
  17437. createInstance(name: string): InstancedLinesMesh;
  17438. }
  17439. /**
  17440. * Creates an instance based on a source LinesMesh
  17441. */
  17442. export class InstancedLinesMesh extends InstancedMesh {
  17443. /**
  17444. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17445. * This margin is expressed in world space coordinates, so its value may vary.
  17446. * Initilized with the intersectionThreshold value of the source LinesMesh
  17447. */
  17448. intersectionThreshold: number;
  17449. constructor(name: string, source: LinesMesh);
  17450. /**
  17451. * Returns the string "InstancedLinesMesh".
  17452. */
  17453. getClassName(): string;
  17454. }
  17455. }
  17456. declare module "babylonjs/Shaders/line.fragment" {
  17457. /** @hidden */
  17458. export var linePixelShader: {
  17459. name: string;
  17460. shader: string;
  17461. };
  17462. }
  17463. declare module "babylonjs/Shaders/line.vertex" {
  17464. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17465. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17466. /** @hidden */
  17467. export var lineVertexShader: {
  17468. name: string;
  17469. shader: string;
  17470. };
  17471. }
  17472. declare module "babylonjs/Rendering/edgesRenderer" {
  17473. import { Nullable } from "babylonjs/types";
  17474. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17476. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17477. import { IDisposable } from "babylonjs/scene";
  17478. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17479. import "babylonjs/Shaders/line.fragment";
  17480. import "babylonjs/Shaders/line.vertex";
  17481. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17482. import { SmartArray } from "babylonjs/Misc/smartArray";
  17483. module "babylonjs/scene" {
  17484. interface Scene {
  17485. /** @hidden */
  17486. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17487. }
  17488. }
  17489. module "babylonjs/Meshes/abstractMesh" {
  17490. interface AbstractMesh {
  17491. /**
  17492. * Gets the edgesRenderer associated with the mesh
  17493. */
  17494. edgesRenderer: Nullable<EdgesRenderer>;
  17495. }
  17496. }
  17497. module "babylonjs/Meshes/linesMesh" {
  17498. interface LinesMesh {
  17499. /**
  17500. * Enables the edge rendering mode on the mesh.
  17501. * This mode makes the mesh edges visible
  17502. * @param epsilon defines the maximal distance between two angles to detect a face
  17503. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17504. * @returns the currentAbstractMesh
  17505. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17506. */
  17507. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17508. }
  17509. }
  17510. module "babylonjs/Meshes/linesMesh" {
  17511. interface InstancedLinesMesh {
  17512. /**
  17513. * Enables the edge rendering mode on the mesh.
  17514. * This mode makes the mesh edges visible
  17515. * @param epsilon defines the maximal distance between two angles to detect a face
  17516. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17517. * @returns the current InstancedLinesMesh
  17518. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17519. */
  17520. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17521. }
  17522. }
  17523. /**
  17524. * Defines the minimum contract an Edges renderer should follow.
  17525. */
  17526. export interface IEdgesRenderer extends IDisposable {
  17527. /**
  17528. * Gets or sets a boolean indicating if the edgesRenderer is active
  17529. */
  17530. isEnabled: boolean;
  17531. /**
  17532. * Renders the edges of the attached mesh,
  17533. */
  17534. render(): void;
  17535. /**
  17536. * Checks wether or not the edges renderer is ready to render.
  17537. * @return true if ready, otherwise false.
  17538. */
  17539. isReady(): boolean;
  17540. /**
  17541. * List of instances to render in case the source mesh has instances
  17542. */
  17543. customInstances: SmartArray<Matrix>;
  17544. }
  17545. /**
  17546. * Defines the additional options of the edges renderer
  17547. */
  17548. export interface IEdgesRendererOptions {
  17549. /**
  17550. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17551. * If not defined, the default value is true
  17552. */
  17553. useAlternateEdgeFinder?: boolean;
  17554. /**
  17555. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17556. * If not defined, the default value is true.
  17557. * 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)
  17558. * This option is used only if useAlternateEdgeFinder = true
  17559. */
  17560. useFastVertexMerger?: boolean;
  17561. /**
  17562. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17563. * The default value is 1e-6
  17564. * This option is used only if useAlternateEdgeFinder = true
  17565. */
  17566. epsilonVertexMerge?: number;
  17567. /**
  17568. * 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
  17569. * 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.
  17570. * This option is used only if useAlternateEdgeFinder = true
  17571. */
  17572. applyTessellation?: boolean;
  17573. /**
  17574. * 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
  17575. * The default value is 1e-6
  17576. * This option is used only if useAlternateEdgeFinder = true
  17577. */
  17578. epsilonVertexAligned?: number;
  17579. }
  17580. /**
  17581. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17582. */
  17583. export class EdgesRenderer implements IEdgesRenderer {
  17584. /**
  17585. * Define the size of the edges with an orthographic camera
  17586. */
  17587. edgesWidthScalerForOrthographic: number;
  17588. /**
  17589. * Define the size of the edges with a perspective camera
  17590. */
  17591. edgesWidthScalerForPerspective: number;
  17592. protected _source: AbstractMesh;
  17593. protected _linesPositions: number[];
  17594. protected _linesNormals: number[];
  17595. protected _linesIndices: number[];
  17596. protected _epsilon: number;
  17597. protected _indicesCount: number;
  17598. protected _lineShader: ShaderMaterial;
  17599. protected _ib: DataBuffer;
  17600. protected _buffers: {
  17601. [key: string]: Nullable<VertexBuffer>;
  17602. };
  17603. protected _buffersForInstances: {
  17604. [key: string]: Nullable<VertexBuffer>;
  17605. };
  17606. protected _checkVerticesInsteadOfIndices: boolean;
  17607. protected _options: Nullable<IEdgesRendererOptions>;
  17608. private _meshRebuildObserver;
  17609. private _meshDisposeObserver;
  17610. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17611. isEnabled: boolean;
  17612. /**
  17613. * List of instances to render in case the source mesh has instances
  17614. */
  17615. customInstances: SmartArray<Matrix>;
  17616. private static GetShader;
  17617. /**
  17618. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17619. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17620. * @param source Mesh used to create edges
  17621. * @param epsilon sum of angles in adjacency to check for edge
  17622. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17623. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17624. * @param options The options to apply when generating the edges
  17625. */
  17626. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17627. protected _prepareRessources(): void;
  17628. /** @hidden */
  17629. _rebuild(): void;
  17630. /**
  17631. * Releases the required resources for the edges renderer
  17632. */
  17633. dispose(): void;
  17634. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17635. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17636. /**
  17637. * Checks if the pair of p0 and p1 is en edge
  17638. * @param faceIndex
  17639. * @param edge
  17640. * @param faceNormals
  17641. * @param p0
  17642. * @param p1
  17643. * @private
  17644. */
  17645. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17646. /**
  17647. * push line into the position, normal and index buffer
  17648. * @protected
  17649. */
  17650. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17651. /**
  17652. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17653. */
  17654. private _tessellateTriangle;
  17655. private _generateEdgesLinesAlternate;
  17656. /**
  17657. * Generates lines edges from adjacencjes
  17658. * @private
  17659. */
  17660. _generateEdgesLines(): void;
  17661. /**
  17662. * Checks wether or not the edges renderer is ready to render.
  17663. * @return true if ready, otherwise false.
  17664. */
  17665. isReady(): boolean;
  17666. /**
  17667. * Renders the edges of the attached mesh,
  17668. */
  17669. render(): void;
  17670. }
  17671. /**
  17672. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17673. */
  17674. export class LineEdgesRenderer extends EdgesRenderer {
  17675. /**
  17676. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17677. * @param source LineMesh used to generate edges
  17678. * @param epsilon not important (specified angle for edge detection)
  17679. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17680. */
  17681. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17682. /**
  17683. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17684. */
  17685. _generateEdgesLines(): void;
  17686. }
  17687. }
  17688. declare module "babylonjs/Rendering/renderingGroup" {
  17689. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17690. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17692. import { Nullable } from "babylonjs/types";
  17693. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17694. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17695. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17696. import { Material } from "babylonjs/Materials/material";
  17697. import { Scene } from "babylonjs/scene";
  17698. /**
  17699. * This represents the object necessary to create a rendering group.
  17700. * This is exclusively used and created by the rendering manager.
  17701. * To modify the behavior, you use the available helpers in your scene or meshes.
  17702. * @hidden
  17703. */
  17704. export class RenderingGroup {
  17705. index: number;
  17706. private static _zeroVector;
  17707. private _scene;
  17708. private _opaqueSubMeshes;
  17709. private _transparentSubMeshes;
  17710. private _alphaTestSubMeshes;
  17711. private _depthOnlySubMeshes;
  17712. private _particleSystems;
  17713. private _spriteManagers;
  17714. private _opaqueSortCompareFn;
  17715. private _alphaTestSortCompareFn;
  17716. private _transparentSortCompareFn;
  17717. private _renderOpaque;
  17718. private _renderAlphaTest;
  17719. private _renderTransparent;
  17720. /** @hidden */
  17721. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17722. onBeforeTransparentRendering: () => void;
  17723. /**
  17724. * Set the opaque sort comparison function.
  17725. * If null the sub meshes will be render in the order they were created
  17726. */
  17727. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17728. /**
  17729. * Set the alpha test sort comparison function.
  17730. * If null the sub meshes will be render in the order they were created
  17731. */
  17732. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17733. /**
  17734. * Set the transparent sort comparison function.
  17735. * If null the sub meshes will be render in the order they were created
  17736. */
  17737. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17738. /**
  17739. * Creates a new rendering group.
  17740. * @param index The rendering group index
  17741. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17742. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17743. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17744. */
  17745. 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>);
  17746. /**
  17747. * Render all the sub meshes contained in the group.
  17748. * @param customRenderFunction Used to override the default render behaviour of the group.
  17749. * @returns true if rendered some submeshes.
  17750. */
  17751. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17752. /**
  17753. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17754. * @param subMeshes The submeshes to render
  17755. */
  17756. private renderOpaqueSorted;
  17757. /**
  17758. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17759. * @param subMeshes The submeshes to render
  17760. */
  17761. private renderAlphaTestSorted;
  17762. /**
  17763. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17764. * @param subMeshes The submeshes to render
  17765. */
  17766. private renderTransparentSorted;
  17767. /**
  17768. * Renders the submeshes in a specified order.
  17769. * @param subMeshes The submeshes to sort before render
  17770. * @param sortCompareFn The comparison function use to sort
  17771. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17772. * @param transparent Specifies to activate blending if true
  17773. */
  17774. private static renderSorted;
  17775. /**
  17776. * Renders the submeshes in the order they were dispatched (no sort applied).
  17777. * @param subMeshes The submeshes to render
  17778. */
  17779. private static renderUnsorted;
  17780. /**
  17781. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17782. * are rendered back to front if in the same alpha index.
  17783. *
  17784. * @param a The first submesh
  17785. * @param b The second submesh
  17786. * @returns The result of the comparison
  17787. */
  17788. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17789. /**
  17790. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17791. * are rendered back to front.
  17792. *
  17793. * @param a The first submesh
  17794. * @param b The second submesh
  17795. * @returns The result of the comparison
  17796. */
  17797. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17798. /**
  17799. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17800. * are rendered front to back (prevent overdraw).
  17801. *
  17802. * @param a The first submesh
  17803. * @param b The second submesh
  17804. * @returns The result of the comparison
  17805. */
  17806. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17807. /**
  17808. * Resets the different lists of submeshes to prepare a new frame.
  17809. */
  17810. prepare(): void;
  17811. dispose(): void;
  17812. /**
  17813. * Inserts the submesh in its correct queue depending on its material.
  17814. * @param subMesh The submesh to dispatch
  17815. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17816. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17817. */
  17818. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17819. dispatchSprites(spriteManager: ISpriteManager): void;
  17820. dispatchParticles(particleSystem: IParticleSystem): void;
  17821. private _renderParticles;
  17822. private _renderSprites;
  17823. }
  17824. }
  17825. declare module "babylonjs/Rendering/renderingManager" {
  17826. import { Nullable } from "babylonjs/types";
  17827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17828. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17829. import { SmartArray } from "babylonjs/Misc/smartArray";
  17830. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17831. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17832. import { Material } from "babylonjs/Materials/material";
  17833. import { Scene } from "babylonjs/scene";
  17834. import { Camera } from "babylonjs/Cameras/camera";
  17835. /**
  17836. * Interface describing the different options available in the rendering manager
  17837. * regarding Auto Clear between groups.
  17838. */
  17839. export interface IRenderingManagerAutoClearSetup {
  17840. /**
  17841. * Defines whether or not autoclear is enable.
  17842. */
  17843. autoClear: boolean;
  17844. /**
  17845. * Defines whether or not to autoclear the depth buffer.
  17846. */
  17847. depth: boolean;
  17848. /**
  17849. * Defines whether or not to autoclear the stencil buffer.
  17850. */
  17851. stencil: boolean;
  17852. }
  17853. /**
  17854. * This class is used by the onRenderingGroupObservable
  17855. */
  17856. export class RenderingGroupInfo {
  17857. /**
  17858. * The Scene that being rendered
  17859. */
  17860. scene: Scene;
  17861. /**
  17862. * The camera currently used for the rendering pass
  17863. */
  17864. camera: Nullable<Camera>;
  17865. /**
  17866. * The ID of the renderingGroup being processed
  17867. */
  17868. renderingGroupId: number;
  17869. }
  17870. /**
  17871. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17872. * It is enable to manage the different groups as well as the different necessary sort functions.
  17873. * This should not be used directly aside of the few static configurations
  17874. */
  17875. export class RenderingManager {
  17876. /**
  17877. * The max id used for rendering groups (not included)
  17878. */
  17879. static MAX_RENDERINGGROUPS: number;
  17880. /**
  17881. * The min id used for rendering groups (included)
  17882. */
  17883. static MIN_RENDERINGGROUPS: number;
  17884. /**
  17885. * Used to globally prevent autoclearing scenes.
  17886. */
  17887. static AUTOCLEAR: boolean;
  17888. /**
  17889. * @hidden
  17890. */
  17891. _useSceneAutoClearSetup: boolean;
  17892. private _scene;
  17893. private _renderingGroups;
  17894. private _depthStencilBufferAlreadyCleaned;
  17895. private _autoClearDepthStencil;
  17896. private _customOpaqueSortCompareFn;
  17897. private _customAlphaTestSortCompareFn;
  17898. private _customTransparentSortCompareFn;
  17899. private _renderingGroupInfo;
  17900. /**
  17901. * Instantiates a new rendering group for a particular scene
  17902. * @param scene Defines the scene the groups belongs to
  17903. */
  17904. constructor(scene: Scene);
  17905. private _clearDepthStencilBuffer;
  17906. /**
  17907. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17908. * @hidden
  17909. */
  17910. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17911. /**
  17912. * Resets the different information of the group to prepare a new frame
  17913. * @hidden
  17914. */
  17915. reset(): void;
  17916. /**
  17917. * Dispose and release the group and its associated resources.
  17918. * @hidden
  17919. */
  17920. dispose(): void;
  17921. /**
  17922. * Clear the info related to rendering groups preventing retention points during dispose.
  17923. */
  17924. freeRenderingGroups(): void;
  17925. private _prepareRenderingGroup;
  17926. /**
  17927. * Add a sprite manager to the rendering manager in order to render it this frame.
  17928. * @param spriteManager Define the sprite manager to render
  17929. */
  17930. dispatchSprites(spriteManager: ISpriteManager): void;
  17931. /**
  17932. * Add a particle system to the rendering manager in order to render it this frame.
  17933. * @param particleSystem Define the particle system to render
  17934. */
  17935. dispatchParticles(particleSystem: IParticleSystem): void;
  17936. /**
  17937. * Add a submesh to the manager in order to render it this frame
  17938. * @param subMesh The submesh to dispatch
  17939. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17940. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17941. */
  17942. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17943. /**
  17944. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17945. * This allowed control for front to back rendering or reversly depending of the special needs.
  17946. *
  17947. * @param renderingGroupId The rendering group id corresponding to its index
  17948. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17949. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17950. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17951. */
  17952. 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;
  17953. /**
  17954. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17955. *
  17956. * @param renderingGroupId The rendering group id corresponding to its index
  17957. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17958. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17959. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17960. */
  17961. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17962. /**
  17963. * Gets the current auto clear configuration for one rendering group of the rendering
  17964. * manager.
  17965. * @param index the rendering group index to get the information for
  17966. * @returns The auto clear setup for the requested rendering group
  17967. */
  17968. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17969. }
  17970. }
  17971. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17972. import { SmartArray } from "babylonjs/Misc/smartArray";
  17973. import { Nullable } from "babylonjs/types";
  17974. import { Scene } from "babylonjs/scene";
  17975. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17976. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17978. import { Mesh } from "babylonjs/Meshes/mesh";
  17979. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17980. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17981. import { Effect } from "babylonjs/Materials/effect";
  17982. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17983. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17984. import "babylonjs/Shaders/shadowMap.fragment";
  17985. import "babylonjs/Shaders/shadowMap.vertex";
  17986. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17987. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17988. import { Observable } from "babylonjs/Misc/observable";
  17989. /**
  17990. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17991. */
  17992. export interface ICustomShaderOptions {
  17993. /**
  17994. * Gets or sets the custom shader name to use
  17995. */
  17996. shaderName: string;
  17997. /**
  17998. * The list of attribute names used in the shader
  17999. */
  18000. attributes?: string[];
  18001. /**
  18002. * The list of unifrom names used in the shader
  18003. */
  18004. uniforms?: string[];
  18005. /**
  18006. * The list of sampler names used in the shader
  18007. */
  18008. samplers?: string[];
  18009. /**
  18010. * The list of defines used in the shader
  18011. */
  18012. defines?: string[];
  18013. }
  18014. /**
  18015. * Interface to implement to create a shadow generator compatible with BJS.
  18016. */
  18017. export interface IShadowGenerator {
  18018. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18019. id: string;
  18020. /**
  18021. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18022. * @returns The render target texture if present otherwise, null
  18023. */
  18024. getShadowMap(): Nullable<RenderTargetTexture>;
  18025. /**
  18026. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18027. * @param subMesh The submesh we want to render in the shadow map
  18028. * @param useInstances Defines wether will draw in the map using instances
  18029. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18030. * @returns true if ready otherwise, false
  18031. */
  18032. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18033. /**
  18034. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18035. * @param defines Defines of the material we want to update
  18036. * @param lightIndex Index of the light in the enabled light list of the material
  18037. */
  18038. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18039. /**
  18040. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18041. * defined in the generator but impacting the effect).
  18042. * It implies the unifroms available on the materials are the standard BJS ones.
  18043. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18044. * @param effect The effect we are binfing the information for
  18045. */
  18046. bindShadowLight(lightIndex: string, effect: Effect): void;
  18047. /**
  18048. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18049. * (eq to shadow prjection matrix * light transform matrix)
  18050. * @returns The transform matrix used to create the shadow map
  18051. */
  18052. getTransformMatrix(): Matrix;
  18053. /**
  18054. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18055. * Cube and 2D textures for instance.
  18056. */
  18057. recreateShadowMap(): void;
  18058. /**
  18059. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18060. * @param onCompiled Callback triggered at the and of the effects compilation
  18061. * @param options Sets of optional options forcing the compilation with different modes
  18062. */
  18063. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18064. useInstances: boolean;
  18065. }>): void;
  18066. /**
  18067. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18068. * @param options Sets of optional options forcing the compilation with different modes
  18069. * @returns A promise that resolves when the compilation completes
  18070. */
  18071. forceCompilationAsync(options?: Partial<{
  18072. useInstances: boolean;
  18073. }>): Promise<void>;
  18074. /**
  18075. * Serializes the shadow generator setup to a json object.
  18076. * @returns The serialized JSON object
  18077. */
  18078. serialize(): any;
  18079. /**
  18080. * Disposes the Shadow map and related Textures and effects.
  18081. */
  18082. dispose(): void;
  18083. }
  18084. /**
  18085. * Default implementation IShadowGenerator.
  18086. * This is the main object responsible of generating shadows in the framework.
  18087. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18088. */
  18089. export class ShadowGenerator implements IShadowGenerator {
  18090. /**
  18091. * Name of the shadow generator class
  18092. */
  18093. static CLASSNAME: string;
  18094. /**
  18095. * Shadow generator mode None: no filtering applied.
  18096. */
  18097. static readonly FILTER_NONE: number;
  18098. /**
  18099. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18100. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18101. */
  18102. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18103. /**
  18104. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18105. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18106. */
  18107. static readonly FILTER_POISSONSAMPLING: number;
  18108. /**
  18109. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18110. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18111. */
  18112. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18113. /**
  18114. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18115. * edge artifacts on steep falloff.
  18116. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18117. */
  18118. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18119. /**
  18120. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18121. * edge artifacts on steep falloff.
  18122. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18123. */
  18124. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18125. /**
  18126. * Shadow generator mode PCF: Percentage Closer Filtering
  18127. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18128. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18129. */
  18130. static readonly FILTER_PCF: number;
  18131. /**
  18132. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18133. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18134. * Contact Hardening
  18135. */
  18136. static readonly FILTER_PCSS: number;
  18137. /**
  18138. * Reserved for PCF and PCSS
  18139. * Highest Quality.
  18140. *
  18141. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18142. *
  18143. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18144. */
  18145. static readonly QUALITY_HIGH: number;
  18146. /**
  18147. * Reserved for PCF and PCSS
  18148. * Good tradeoff for quality/perf cross devices
  18149. *
  18150. * Execute PCF on a 3*3 kernel.
  18151. *
  18152. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18153. */
  18154. static readonly QUALITY_MEDIUM: number;
  18155. /**
  18156. * Reserved for PCF and PCSS
  18157. * The lowest quality but the fastest.
  18158. *
  18159. * Execute PCF on a 1*1 kernel.
  18160. *
  18161. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18162. */
  18163. static readonly QUALITY_LOW: number;
  18164. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18165. id: string;
  18166. /** Gets or sets the custom shader name to use */
  18167. customShaderOptions: ICustomShaderOptions;
  18168. /**
  18169. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18170. */
  18171. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18172. /**
  18173. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18174. */
  18175. onAfterShadowMapRenderObservable: Observable<Effect>;
  18176. /**
  18177. * Observable triggered before a mesh is rendered in the shadow map.
  18178. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18179. */
  18180. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18181. /**
  18182. * Observable triggered after a mesh is rendered in the shadow map.
  18183. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18184. */
  18185. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18186. protected _bias: number;
  18187. /**
  18188. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18189. */
  18190. get bias(): number;
  18191. /**
  18192. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18193. */
  18194. set bias(bias: number);
  18195. protected _normalBias: number;
  18196. /**
  18197. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18198. */
  18199. get normalBias(): number;
  18200. /**
  18201. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18202. */
  18203. set normalBias(normalBias: number);
  18204. protected _blurBoxOffset: number;
  18205. /**
  18206. * Gets the blur box offset: offset applied during the blur pass.
  18207. * Only useful if useKernelBlur = false
  18208. */
  18209. get blurBoxOffset(): number;
  18210. /**
  18211. * Sets the blur box offset: offset applied during the blur pass.
  18212. * Only useful if useKernelBlur = false
  18213. */
  18214. set blurBoxOffset(value: number);
  18215. protected _blurScale: number;
  18216. /**
  18217. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18218. * 2 means half of the size.
  18219. */
  18220. get blurScale(): number;
  18221. /**
  18222. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18223. * 2 means half of the size.
  18224. */
  18225. set blurScale(value: number);
  18226. protected _blurKernel: number;
  18227. /**
  18228. * Gets the blur kernel: kernel size of the blur pass.
  18229. * Only useful if useKernelBlur = true
  18230. */
  18231. get blurKernel(): number;
  18232. /**
  18233. * Sets the blur kernel: kernel size of the blur pass.
  18234. * Only useful if useKernelBlur = true
  18235. */
  18236. set blurKernel(value: number);
  18237. protected _useKernelBlur: boolean;
  18238. /**
  18239. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18240. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18241. */
  18242. get useKernelBlur(): boolean;
  18243. /**
  18244. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18245. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18246. */
  18247. set useKernelBlur(value: boolean);
  18248. protected _depthScale: number;
  18249. /**
  18250. * Gets the depth scale used in ESM mode.
  18251. */
  18252. get depthScale(): number;
  18253. /**
  18254. * Sets the depth scale used in ESM mode.
  18255. * This can override the scale stored on the light.
  18256. */
  18257. set depthScale(value: number);
  18258. protected _validateFilter(filter: number): number;
  18259. protected _filter: number;
  18260. /**
  18261. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18262. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18263. */
  18264. get filter(): number;
  18265. /**
  18266. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18267. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18268. */
  18269. set filter(value: number);
  18270. /**
  18271. * Gets if the current filter is set to Poisson Sampling.
  18272. */
  18273. get usePoissonSampling(): boolean;
  18274. /**
  18275. * Sets the current filter to Poisson Sampling.
  18276. */
  18277. set usePoissonSampling(value: boolean);
  18278. /**
  18279. * Gets if the current filter is set to ESM.
  18280. */
  18281. get useExponentialShadowMap(): boolean;
  18282. /**
  18283. * Sets the current filter is to ESM.
  18284. */
  18285. set useExponentialShadowMap(value: boolean);
  18286. /**
  18287. * Gets if the current filter is set to filtered ESM.
  18288. */
  18289. get useBlurExponentialShadowMap(): boolean;
  18290. /**
  18291. * Gets if the current filter is set to filtered ESM.
  18292. */
  18293. set useBlurExponentialShadowMap(value: boolean);
  18294. /**
  18295. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18296. * exponential to prevent steep falloff artifacts).
  18297. */
  18298. get useCloseExponentialShadowMap(): boolean;
  18299. /**
  18300. * Sets the current filter to "close ESM" (using the inverse of the
  18301. * exponential to prevent steep falloff artifacts).
  18302. */
  18303. set useCloseExponentialShadowMap(value: boolean);
  18304. /**
  18305. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18306. * exponential to prevent steep falloff artifacts).
  18307. */
  18308. get useBlurCloseExponentialShadowMap(): boolean;
  18309. /**
  18310. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18311. * exponential to prevent steep falloff artifacts).
  18312. */
  18313. set useBlurCloseExponentialShadowMap(value: boolean);
  18314. /**
  18315. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18316. */
  18317. get usePercentageCloserFiltering(): boolean;
  18318. /**
  18319. * Sets the current filter to "PCF" (percentage closer filtering).
  18320. */
  18321. set usePercentageCloserFiltering(value: boolean);
  18322. protected _filteringQuality: number;
  18323. /**
  18324. * Gets the PCF or PCSS Quality.
  18325. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18326. */
  18327. get filteringQuality(): number;
  18328. /**
  18329. * Sets the PCF or PCSS Quality.
  18330. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18331. */
  18332. set filteringQuality(filteringQuality: number);
  18333. /**
  18334. * Gets if the current filter is set to "PCSS" (contact hardening).
  18335. */
  18336. get useContactHardeningShadow(): boolean;
  18337. /**
  18338. * Sets the current filter to "PCSS" (contact hardening).
  18339. */
  18340. set useContactHardeningShadow(value: boolean);
  18341. protected _contactHardeningLightSizeUVRatio: number;
  18342. /**
  18343. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18344. * Using a ratio helps keeping shape stability independently of the map size.
  18345. *
  18346. * It does not account for the light projection as it was having too much
  18347. * instability during the light setup or during light position changes.
  18348. *
  18349. * Only valid if useContactHardeningShadow is true.
  18350. */
  18351. get contactHardeningLightSizeUVRatio(): number;
  18352. /**
  18353. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18354. * Using a ratio helps keeping shape stability independently of the map size.
  18355. *
  18356. * It does not account for the light projection as it was having too much
  18357. * instability during the light setup or during light position changes.
  18358. *
  18359. * Only valid if useContactHardeningShadow is true.
  18360. */
  18361. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18362. protected _darkness: number;
  18363. /** Gets or sets the actual darkness of a shadow */
  18364. get darkness(): number;
  18365. set darkness(value: number);
  18366. /**
  18367. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18368. * 0 means strongest and 1 would means no shadow.
  18369. * @returns the darkness.
  18370. */
  18371. getDarkness(): number;
  18372. /**
  18373. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18374. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18375. * @returns the shadow generator allowing fluent coding.
  18376. */
  18377. setDarkness(darkness: number): ShadowGenerator;
  18378. protected _transparencyShadow: boolean;
  18379. /** Gets or sets the ability to have transparent shadow */
  18380. get transparencyShadow(): boolean;
  18381. set transparencyShadow(value: boolean);
  18382. /**
  18383. * Sets the ability to have transparent shadow (boolean).
  18384. * @param transparent True if transparent else False
  18385. * @returns the shadow generator allowing fluent coding
  18386. */
  18387. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18388. /**
  18389. * Enables or disables shadows with varying strength based on the transparency
  18390. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18391. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18392. * mesh.visibility * alphaTexture.a
  18393. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18394. */
  18395. enableSoftTransparentShadow: boolean;
  18396. protected _shadowMap: Nullable<RenderTargetTexture>;
  18397. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18398. /**
  18399. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18400. * @returns The render target texture if present otherwise, null
  18401. */
  18402. getShadowMap(): Nullable<RenderTargetTexture>;
  18403. /**
  18404. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18405. * @returns The render target texture if the shadow map is present otherwise, null
  18406. */
  18407. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18408. /**
  18409. * Gets the class name of that object
  18410. * @returns "ShadowGenerator"
  18411. */
  18412. getClassName(): string;
  18413. /**
  18414. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18415. * @param mesh Mesh to add
  18416. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18417. * @returns the Shadow Generator itself
  18418. */
  18419. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18420. /**
  18421. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18422. * @param mesh Mesh to remove
  18423. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18424. * @returns the Shadow Generator itself
  18425. */
  18426. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18427. /**
  18428. * Controls the extent to which the shadows fade out at the edge of the frustum
  18429. */
  18430. frustumEdgeFalloff: number;
  18431. protected _light: IShadowLight;
  18432. /**
  18433. * Returns the associated light object.
  18434. * @returns the light generating the shadow
  18435. */
  18436. getLight(): IShadowLight;
  18437. /**
  18438. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18439. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18440. * It might on the other hand introduce peter panning.
  18441. */
  18442. forceBackFacesOnly: boolean;
  18443. protected _scene: Scene;
  18444. protected _lightDirection: Vector3;
  18445. protected _effect: Effect;
  18446. protected _viewMatrix: Matrix;
  18447. protected _projectionMatrix: Matrix;
  18448. protected _transformMatrix: Matrix;
  18449. protected _cachedPosition: Vector3;
  18450. protected _cachedDirection: Vector3;
  18451. protected _cachedDefines: string;
  18452. protected _currentRenderID: number;
  18453. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18454. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18455. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18456. protected _blurPostProcesses: PostProcess[];
  18457. protected _mapSize: number;
  18458. protected _currentFaceIndex: number;
  18459. protected _currentFaceIndexCache: number;
  18460. protected _textureType: number;
  18461. protected _defaultTextureMatrix: Matrix;
  18462. protected _storedUniqueId: Nullable<number>;
  18463. /** @hidden */
  18464. static _SceneComponentInitialization: (scene: Scene) => void;
  18465. /**
  18466. * Creates a ShadowGenerator object.
  18467. * A ShadowGenerator is the required tool to use the shadows.
  18468. * Each light casting shadows needs to use its own ShadowGenerator.
  18469. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18470. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18471. * @param light The light object generating the shadows.
  18472. * @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.
  18473. */
  18474. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18475. protected _initializeGenerator(): void;
  18476. protected _createTargetRenderTexture(): void;
  18477. protected _initializeShadowMap(): void;
  18478. protected _initializeBlurRTTAndPostProcesses(): void;
  18479. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18480. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18481. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18482. protected _applyFilterValues(): void;
  18483. /**
  18484. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18485. * @param onCompiled Callback triggered at the and of the effects compilation
  18486. * @param options Sets of optional options forcing the compilation with different modes
  18487. */
  18488. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18489. useInstances: boolean;
  18490. }>): void;
  18491. /**
  18492. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18493. * @param options Sets of optional options forcing the compilation with different modes
  18494. * @returns A promise that resolves when the compilation completes
  18495. */
  18496. forceCompilationAsync(options?: Partial<{
  18497. useInstances: boolean;
  18498. }>): Promise<void>;
  18499. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18500. private _prepareShadowDefines;
  18501. /**
  18502. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18503. * @param subMesh The submesh we want to render in the shadow map
  18504. * @param useInstances Defines wether will draw in the map using instances
  18505. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18506. * @returns true if ready otherwise, false
  18507. */
  18508. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18509. /**
  18510. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18511. * @param defines Defines of the material we want to update
  18512. * @param lightIndex Index of the light in the enabled light list of the material
  18513. */
  18514. prepareDefines(defines: any, lightIndex: number): void;
  18515. /**
  18516. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18517. * defined in the generator but impacting the effect).
  18518. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18519. * @param effect The effect we are binfing the information for
  18520. */
  18521. bindShadowLight(lightIndex: string, effect: Effect): void;
  18522. /**
  18523. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18524. * (eq to shadow prjection matrix * light transform matrix)
  18525. * @returns The transform matrix used to create the shadow map
  18526. */
  18527. getTransformMatrix(): Matrix;
  18528. /**
  18529. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18530. * Cube and 2D textures for instance.
  18531. */
  18532. recreateShadowMap(): void;
  18533. protected _disposeBlurPostProcesses(): void;
  18534. protected _disposeRTTandPostProcesses(): void;
  18535. /**
  18536. * Disposes the ShadowGenerator.
  18537. * Returns nothing.
  18538. */
  18539. dispose(): void;
  18540. /**
  18541. * Serializes the shadow generator setup to a json object.
  18542. * @returns The serialized JSON object
  18543. */
  18544. serialize(): any;
  18545. /**
  18546. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18547. * @param parsedShadowGenerator The JSON object to parse
  18548. * @param scene The scene to create the shadow map for
  18549. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18550. * @returns The parsed shadow generator
  18551. */
  18552. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18553. }
  18554. }
  18555. declare module "babylonjs/Lights/light" {
  18556. import { Nullable } from "babylonjs/types";
  18557. import { Scene } from "babylonjs/scene";
  18558. import { Vector3 } from "babylonjs/Maths/math.vector";
  18559. import { Color3 } from "babylonjs/Maths/math.color";
  18560. import { Node } from "babylonjs/node";
  18561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18562. import { Effect } from "babylonjs/Materials/effect";
  18563. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18564. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18565. /**
  18566. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18567. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18568. * 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.
  18569. */
  18570. export abstract class Light extends Node {
  18571. /**
  18572. * Falloff Default: light is falling off following the material specification:
  18573. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18574. */
  18575. static readonly FALLOFF_DEFAULT: number;
  18576. /**
  18577. * Falloff Physical: light is falling off following the inverse squared distance law.
  18578. */
  18579. static readonly FALLOFF_PHYSICAL: number;
  18580. /**
  18581. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18582. * to enhance interoperability with other engines.
  18583. */
  18584. static readonly FALLOFF_GLTF: number;
  18585. /**
  18586. * Falloff Standard: light is falling off like in the standard material
  18587. * to enhance interoperability with other materials.
  18588. */
  18589. static readonly FALLOFF_STANDARD: number;
  18590. /**
  18591. * If every light affecting the material is in this lightmapMode,
  18592. * material.lightmapTexture adds or multiplies
  18593. * (depends on material.useLightmapAsShadowmap)
  18594. * after every other light calculations.
  18595. */
  18596. static readonly LIGHTMAP_DEFAULT: number;
  18597. /**
  18598. * material.lightmapTexture as only diffuse lighting from this light
  18599. * adds only specular lighting from this light
  18600. * adds dynamic shadows
  18601. */
  18602. static readonly LIGHTMAP_SPECULAR: number;
  18603. /**
  18604. * material.lightmapTexture as only lighting
  18605. * no light calculation from this light
  18606. * only adds dynamic shadows from this light
  18607. */
  18608. static readonly LIGHTMAP_SHADOWSONLY: number;
  18609. /**
  18610. * Each light type uses the default quantity according to its type:
  18611. * point/spot lights use luminous intensity
  18612. * directional lights use illuminance
  18613. */
  18614. static readonly INTENSITYMODE_AUTOMATIC: number;
  18615. /**
  18616. * lumen (lm)
  18617. */
  18618. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18619. /**
  18620. * candela (lm/sr)
  18621. */
  18622. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18623. /**
  18624. * lux (lm/m^2)
  18625. */
  18626. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18627. /**
  18628. * nit (cd/m^2)
  18629. */
  18630. static readonly INTENSITYMODE_LUMINANCE: number;
  18631. /**
  18632. * Light type const id of the point light.
  18633. */
  18634. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18635. /**
  18636. * Light type const id of the directional light.
  18637. */
  18638. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18639. /**
  18640. * Light type const id of the spot light.
  18641. */
  18642. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18643. /**
  18644. * Light type const id of the hemispheric light.
  18645. */
  18646. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18647. /**
  18648. * Diffuse gives the basic color to an object.
  18649. */
  18650. diffuse: Color3;
  18651. /**
  18652. * Specular produces a highlight color on an object.
  18653. * Note: This is note affecting PBR materials.
  18654. */
  18655. specular: Color3;
  18656. /**
  18657. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18658. * falling off base on range or angle.
  18659. * This can be set to any values in Light.FALLOFF_x.
  18660. *
  18661. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18662. * other types of materials.
  18663. */
  18664. falloffType: number;
  18665. /**
  18666. * Strength of the light.
  18667. * Note: By default it is define in the framework own unit.
  18668. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18669. */
  18670. intensity: number;
  18671. private _range;
  18672. protected _inverseSquaredRange: number;
  18673. /**
  18674. * Defines how far from the source the light is impacting in scene units.
  18675. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18676. */
  18677. get range(): number;
  18678. /**
  18679. * Defines how far from the source the light is impacting in scene units.
  18680. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18681. */
  18682. set range(value: number);
  18683. /**
  18684. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18685. * of light.
  18686. */
  18687. private _photometricScale;
  18688. private _intensityMode;
  18689. /**
  18690. * Gets the photometric scale used to interpret the intensity.
  18691. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18692. */
  18693. get intensityMode(): number;
  18694. /**
  18695. * Sets the photometric scale used to interpret the intensity.
  18696. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18697. */
  18698. set intensityMode(value: number);
  18699. private _radius;
  18700. /**
  18701. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18702. */
  18703. get radius(): number;
  18704. /**
  18705. * sets the light radius used by PBR Materials to simulate soft area lights.
  18706. */
  18707. set radius(value: number);
  18708. private _renderPriority;
  18709. /**
  18710. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18711. * exceeding the number allowed of the materials.
  18712. */
  18713. renderPriority: number;
  18714. private _shadowEnabled;
  18715. /**
  18716. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18717. * the current shadow generator.
  18718. */
  18719. get shadowEnabled(): boolean;
  18720. /**
  18721. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18722. * the current shadow generator.
  18723. */
  18724. set shadowEnabled(value: boolean);
  18725. private _includedOnlyMeshes;
  18726. /**
  18727. * Gets the only meshes impacted by this light.
  18728. */
  18729. get includedOnlyMeshes(): AbstractMesh[];
  18730. /**
  18731. * Sets the only meshes impacted by this light.
  18732. */
  18733. set includedOnlyMeshes(value: AbstractMesh[]);
  18734. private _excludedMeshes;
  18735. /**
  18736. * Gets the meshes not impacted by this light.
  18737. */
  18738. get excludedMeshes(): AbstractMesh[];
  18739. /**
  18740. * Sets the meshes not impacted by this light.
  18741. */
  18742. set excludedMeshes(value: AbstractMesh[]);
  18743. private _excludeWithLayerMask;
  18744. /**
  18745. * Gets the layer id use to find what meshes are not impacted by the light.
  18746. * Inactive if 0
  18747. */
  18748. get excludeWithLayerMask(): number;
  18749. /**
  18750. * Sets the layer id use to find what meshes are not impacted by the light.
  18751. * Inactive if 0
  18752. */
  18753. set excludeWithLayerMask(value: number);
  18754. private _includeOnlyWithLayerMask;
  18755. /**
  18756. * Gets the layer id use to find what meshes are impacted by the light.
  18757. * Inactive if 0
  18758. */
  18759. get includeOnlyWithLayerMask(): number;
  18760. /**
  18761. * Sets the layer id use to find what meshes are impacted by the light.
  18762. * Inactive if 0
  18763. */
  18764. set includeOnlyWithLayerMask(value: number);
  18765. private _lightmapMode;
  18766. /**
  18767. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18768. */
  18769. get lightmapMode(): number;
  18770. /**
  18771. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18772. */
  18773. set lightmapMode(value: number);
  18774. /**
  18775. * Shadow generator associted to the light.
  18776. * @hidden Internal use only.
  18777. */
  18778. _shadowGenerator: Nullable<IShadowGenerator>;
  18779. /**
  18780. * @hidden Internal use only.
  18781. */
  18782. _excludedMeshesIds: string[];
  18783. /**
  18784. * @hidden Internal use only.
  18785. */
  18786. _includedOnlyMeshesIds: string[];
  18787. /**
  18788. * The current light unifom buffer.
  18789. * @hidden Internal use only.
  18790. */
  18791. _uniformBuffer: UniformBuffer;
  18792. /** @hidden */
  18793. _renderId: number;
  18794. /**
  18795. * Creates a Light object in the scene.
  18796. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18797. * @param name The firendly name of the light
  18798. * @param scene The scene the light belongs too
  18799. */
  18800. constructor(name: string, scene: Scene);
  18801. protected abstract _buildUniformLayout(): void;
  18802. /**
  18803. * Sets the passed Effect "effect" with the Light information.
  18804. * @param effect The effect to update
  18805. * @param lightIndex The index of the light in the effect to update
  18806. * @returns The light
  18807. */
  18808. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18809. /**
  18810. * Sets the passed Effect "effect" with the Light textures.
  18811. * @param effect The effect to update
  18812. * @param lightIndex The index of the light in the effect to update
  18813. * @returns The light
  18814. */
  18815. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18816. /**
  18817. * Binds the lights information from the scene to the effect for the given mesh.
  18818. * @param lightIndex Light index
  18819. * @param scene The scene where the light belongs to
  18820. * @param effect The effect we are binding the data to
  18821. * @param useSpecular Defines if specular is supported
  18822. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18823. */
  18824. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18825. /**
  18826. * Sets the passed Effect "effect" with the Light information.
  18827. * @param effect The effect to update
  18828. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18829. * @returns The light
  18830. */
  18831. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18832. /**
  18833. * Returns the string "Light".
  18834. * @returns the class name
  18835. */
  18836. getClassName(): string;
  18837. /** @hidden */
  18838. readonly _isLight: boolean;
  18839. /**
  18840. * Converts the light information to a readable string for debug purpose.
  18841. * @param fullDetails Supports for multiple levels of logging within scene loading
  18842. * @returns the human readable light info
  18843. */
  18844. toString(fullDetails?: boolean): string;
  18845. /** @hidden */
  18846. protected _syncParentEnabledState(): void;
  18847. /**
  18848. * Set the enabled state of this node.
  18849. * @param value - the new enabled state
  18850. */
  18851. setEnabled(value: boolean): void;
  18852. /**
  18853. * Returns the Light associated shadow generator if any.
  18854. * @return the associated shadow generator.
  18855. */
  18856. getShadowGenerator(): Nullable<IShadowGenerator>;
  18857. /**
  18858. * Returns a Vector3, the absolute light position in the World.
  18859. * @returns the world space position of the light
  18860. */
  18861. getAbsolutePosition(): Vector3;
  18862. /**
  18863. * Specifies if the light will affect the passed mesh.
  18864. * @param mesh The mesh to test against the light
  18865. * @return true the mesh is affected otherwise, false.
  18866. */
  18867. canAffectMesh(mesh: AbstractMesh): boolean;
  18868. /**
  18869. * Sort function to order lights for rendering.
  18870. * @param a First Light object to compare to second.
  18871. * @param b Second Light object to compare first.
  18872. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18873. */
  18874. static CompareLightsPriority(a: Light, b: Light): number;
  18875. /**
  18876. * Releases resources associated with this node.
  18877. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18878. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18879. */
  18880. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18881. /**
  18882. * Returns the light type ID (integer).
  18883. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18884. */
  18885. getTypeID(): number;
  18886. /**
  18887. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18888. * @returns the scaled intensity in intensity mode unit
  18889. */
  18890. getScaledIntensity(): number;
  18891. /**
  18892. * Returns a new Light object, named "name", from the current one.
  18893. * @param name The name of the cloned light
  18894. * @param newParent The parent of this light, if it has one
  18895. * @returns the new created light
  18896. */
  18897. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18898. /**
  18899. * Serializes the current light into a Serialization object.
  18900. * @returns the serialized object.
  18901. */
  18902. serialize(): any;
  18903. /**
  18904. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18905. * This new light is named "name" and added to the passed scene.
  18906. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18907. * @param name The friendly name of the light
  18908. * @param scene The scene the new light will belong to
  18909. * @returns the constructor function
  18910. */
  18911. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18912. /**
  18913. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18914. * @param parsedLight The JSON representation of the light
  18915. * @param scene The scene to create the parsed light in
  18916. * @returns the created light after parsing
  18917. */
  18918. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18919. private _hookArrayForExcluded;
  18920. private _hookArrayForIncludedOnly;
  18921. private _resyncMeshes;
  18922. /**
  18923. * Forces the meshes to update their light related information in their rendering used effects
  18924. * @hidden Internal Use Only
  18925. */
  18926. _markMeshesAsLightDirty(): void;
  18927. /**
  18928. * Recomputes the cached photometric scale if needed.
  18929. */
  18930. private _computePhotometricScale;
  18931. /**
  18932. * Returns the Photometric Scale according to the light type and intensity mode.
  18933. */
  18934. private _getPhotometricScale;
  18935. /**
  18936. * Reorder the light in the scene according to their defined priority.
  18937. * @hidden Internal Use Only
  18938. */
  18939. _reorderLightsInScene(): void;
  18940. /**
  18941. * Prepares the list of defines specific to the light type.
  18942. * @param defines the list of defines
  18943. * @param lightIndex defines the index of the light for the effect
  18944. */
  18945. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18946. }
  18947. }
  18948. declare module "babylonjs/Cameras/targetCamera" {
  18949. import { Nullable } from "babylonjs/types";
  18950. import { Camera } from "babylonjs/Cameras/camera";
  18951. import { Scene } from "babylonjs/scene";
  18952. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18953. /**
  18954. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18955. * This is the base of the follow, arc rotate cameras and Free camera
  18956. * @see https://doc.babylonjs.com/features/cameras
  18957. */
  18958. export class TargetCamera extends Camera {
  18959. private static _RigCamTransformMatrix;
  18960. private static _TargetTransformMatrix;
  18961. private static _TargetFocalPoint;
  18962. private _tmpUpVector;
  18963. private _tmpTargetVector;
  18964. /**
  18965. * Define the current direction the camera is moving to
  18966. */
  18967. cameraDirection: Vector3;
  18968. /**
  18969. * Define the current rotation the camera is rotating to
  18970. */
  18971. cameraRotation: Vector2;
  18972. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18973. ignoreParentScaling: boolean;
  18974. /**
  18975. * When set, the up vector of the camera will be updated by the rotation of the camera
  18976. */
  18977. updateUpVectorFromRotation: boolean;
  18978. private _tmpQuaternion;
  18979. /**
  18980. * Define the current rotation of the camera
  18981. */
  18982. rotation: Vector3;
  18983. /**
  18984. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18985. */
  18986. rotationQuaternion: Quaternion;
  18987. /**
  18988. * Define the current speed of the camera
  18989. */
  18990. speed: number;
  18991. /**
  18992. * Add constraint to the camera to prevent it to move freely in all directions and
  18993. * around all axis.
  18994. */
  18995. noRotationConstraint: boolean;
  18996. /**
  18997. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18998. * panning
  18999. */
  19000. invertRotation: boolean;
  19001. /**
  19002. * Speed multiplier for inverse camera panning
  19003. */
  19004. inverseRotationSpeed: number;
  19005. /**
  19006. * Define the current target of the camera as an object or a position.
  19007. */
  19008. lockedTarget: any;
  19009. /** @hidden */
  19010. _currentTarget: Vector3;
  19011. /** @hidden */
  19012. _initialFocalDistance: number;
  19013. /** @hidden */
  19014. _viewMatrix: Matrix;
  19015. /** @hidden */
  19016. _camMatrix: Matrix;
  19017. /** @hidden */
  19018. _cameraTransformMatrix: Matrix;
  19019. /** @hidden */
  19020. _cameraRotationMatrix: Matrix;
  19021. /** @hidden */
  19022. _referencePoint: Vector3;
  19023. /** @hidden */
  19024. _transformedReferencePoint: Vector3;
  19025. /** @hidden */
  19026. _reset: () => void;
  19027. private _defaultUp;
  19028. /**
  19029. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19030. * This is the base of the follow, arc rotate cameras and Free camera
  19031. * @see https://doc.babylonjs.com/features/cameras
  19032. * @param name Defines the name of the camera in the scene
  19033. * @param position Defines the start position of the camera in the scene
  19034. * @param scene Defines the scene the camera belongs to
  19035. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19036. */
  19037. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19038. /**
  19039. * Gets the position in front of the camera at a given distance.
  19040. * @param distance The distance from the camera we want the position to be
  19041. * @returns the position
  19042. */
  19043. getFrontPosition(distance: number): Vector3;
  19044. /** @hidden */
  19045. _getLockedTargetPosition(): Nullable<Vector3>;
  19046. private _storedPosition;
  19047. private _storedRotation;
  19048. private _storedRotationQuaternion;
  19049. /**
  19050. * Store current camera state of the camera (fov, position, rotation, etc..)
  19051. * @returns the camera
  19052. */
  19053. storeState(): Camera;
  19054. /**
  19055. * Restored camera state. You must call storeState() first
  19056. * @returns whether it was successful or not
  19057. * @hidden
  19058. */
  19059. _restoreStateValues(): boolean;
  19060. /** @hidden */
  19061. _initCache(): void;
  19062. /** @hidden */
  19063. _updateCache(ignoreParentClass?: boolean): void;
  19064. /** @hidden */
  19065. _isSynchronizedViewMatrix(): boolean;
  19066. /** @hidden */
  19067. _computeLocalCameraSpeed(): number;
  19068. /**
  19069. * Defines the target the camera should look at.
  19070. * @param target Defines the new target as a Vector or a mesh
  19071. */
  19072. setTarget(target: Vector3): void;
  19073. /**
  19074. * Defines the target point of the camera.
  19075. * The camera looks towards it form the radius distance.
  19076. */
  19077. get target(): Vector3;
  19078. set target(value: Vector3);
  19079. /**
  19080. * Return the current target position of the camera. This value is expressed in local space.
  19081. * @returns the target position
  19082. */
  19083. getTarget(): Vector3;
  19084. /** @hidden */
  19085. _decideIfNeedsToMove(): boolean;
  19086. /** @hidden */
  19087. _updatePosition(): void;
  19088. /** @hidden */
  19089. _checkInputs(): void;
  19090. protected _updateCameraRotationMatrix(): void;
  19091. /**
  19092. * 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)
  19093. * @returns the current camera
  19094. */
  19095. private _rotateUpVectorWithCameraRotationMatrix;
  19096. private _cachedRotationZ;
  19097. private _cachedQuaternionRotationZ;
  19098. /** @hidden */
  19099. _getViewMatrix(): Matrix;
  19100. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19101. /**
  19102. * @hidden
  19103. */
  19104. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19105. /**
  19106. * @hidden
  19107. */
  19108. _updateRigCameras(): void;
  19109. private _getRigCamPositionAndTarget;
  19110. /**
  19111. * Gets the current object class name.
  19112. * @return the class name
  19113. */
  19114. getClassName(): string;
  19115. }
  19116. }
  19117. declare module "babylonjs/Events/keyboardEvents" {
  19118. /**
  19119. * Gather the list of keyboard event types as constants.
  19120. */
  19121. export class KeyboardEventTypes {
  19122. /**
  19123. * The keydown event is fired when a key becomes active (pressed).
  19124. */
  19125. static readonly KEYDOWN: number;
  19126. /**
  19127. * The keyup event is fired when a key has been released.
  19128. */
  19129. static readonly KEYUP: number;
  19130. }
  19131. /**
  19132. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19133. */
  19134. export class KeyboardInfo {
  19135. /**
  19136. * Defines the type of event (KeyboardEventTypes)
  19137. */
  19138. type: number;
  19139. /**
  19140. * Defines the related dom event
  19141. */
  19142. event: KeyboardEvent;
  19143. /**
  19144. * Instantiates a new keyboard info.
  19145. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19146. * @param type Defines the type of event (KeyboardEventTypes)
  19147. * @param event Defines the related dom event
  19148. */
  19149. constructor(
  19150. /**
  19151. * Defines the type of event (KeyboardEventTypes)
  19152. */
  19153. type: number,
  19154. /**
  19155. * Defines the related dom event
  19156. */
  19157. event: KeyboardEvent);
  19158. }
  19159. /**
  19160. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19161. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19162. */
  19163. export class KeyboardInfoPre extends KeyboardInfo {
  19164. /**
  19165. * Defines the type of event (KeyboardEventTypes)
  19166. */
  19167. type: number;
  19168. /**
  19169. * Defines the related dom event
  19170. */
  19171. event: KeyboardEvent;
  19172. /**
  19173. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19174. */
  19175. skipOnPointerObservable: boolean;
  19176. /**
  19177. * Instantiates a new keyboard pre info.
  19178. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19179. * @param type Defines the type of event (KeyboardEventTypes)
  19180. * @param event Defines the related dom event
  19181. */
  19182. constructor(
  19183. /**
  19184. * Defines the type of event (KeyboardEventTypes)
  19185. */
  19186. type: number,
  19187. /**
  19188. * Defines the related dom event
  19189. */
  19190. event: KeyboardEvent);
  19191. }
  19192. }
  19193. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19194. import { Nullable } from "babylonjs/types";
  19195. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19196. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19197. /**
  19198. * Manage the keyboard inputs to control the movement of a free camera.
  19199. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19200. */
  19201. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19202. /**
  19203. * Defines the camera the input is attached to.
  19204. */
  19205. camera: FreeCamera;
  19206. /**
  19207. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19208. */
  19209. keysUp: number[];
  19210. /**
  19211. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19212. */
  19213. keysUpward: number[];
  19214. /**
  19215. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19216. */
  19217. keysDown: number[];
  19218. /**
  19219. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19220. */
  19221. keysDownward: number[];
  19222. /**
  19223. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19224. */
  19225. keysLeft: number[];
  19226. /**
  19227. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19228. */
  19229. keysRight: number[];
  19230. private _keys;
  19231. private _onCanvasBlurObserver;
  19232. private _onKeyboardObserver;
  19233. private _engine;
  19234. private _scene;
  19235. /**
  19236. * Attach the input controls to a specific dom element to get the input from.
  19237. * @param element Defines the element the controls should be listened from
  19238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19239. */
  19240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19241. /**
  19242. * Detach the current controls from the specified dom element.
  19243. * @param element Defines the element to stop listening the inputs from
  19244. */
  19245. detachControl(element: Nullable<HTMLElement>): void;
  19246. /**
  19247. * Update the current camera state depending on the inputs that have been used this frame.
  19248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19249. */
  19250. checkInputs(): void;
  19251. /**
  19252. * Gets the class name of the current intput.
  19253. * @returns the class name
  19254. */
  19255. getClassName(): string;
  19256. /** @hidden */
  19257. _onLostFocus(): void;
  19258. /**
  19259. * Get the friendly name associated with the input class.
  19260. * @returns the input friendly name
  19261. */
  19262. getSimpleName(): string;
  19263. }
  19264. }
  19265. declare module "babylonjs/Events/pointerEvents" {
  19266. import { Nullable } from "babylonjs/types";
  19267. import { Vector2 } from "babylonjs/Maths/math.vector";
  19268. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19269. import { Ray } from "babylonjs/Culling/ray";
  19270. /**
  19271. * Gather the list of pointer event types as constants.
  19272. */
  19273. export class PointerEventTypes {
  19274. /**
  19275. * 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.
  19276. */
  19277. static readonly POINTERDOWN: number;
  19278. /**
  19279. * The pointerup event is fired when a pointer is no longer active.
  19280. */
  19281. static readonly POINTERUP: number;
  19282. /**
  19283. * The pointermove event is fired when a pointer changes coordinates.
  19284. */
  19285. static readonly POINTERMOVE: number;
  19286. /**
  19287. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19288. */
  19289. static readonly POINTERWHEEL: number;
  19290. /**
  19291. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19292. */
  19293. static readonly POINTERPICK: number;
  19294. /**
  19295. * The pointertap event is fired when a the object has been touched and released without drag.
  19296. */
  19297. static readonly POINTERTAP: number;
  19298. /**
  19299. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19300. */
  19301. static readonly POINTERDOUBLETAP: number;
  19302. }
  19303. /**
  19304. * Base class of pointer info types.
  19305. */
  19306. export class PointerInfoBase {
  19307. /**
  19308. * Defines the type of event (PointerEventTypes)
  19309. */
  19310. type: number;
  19311. /**
  19312. * Defines the related dom event
  19313. */
  19314. event: PointerEvent | MouseWheelEvent;
  19315. /**
  19316. * Instantiates the base class of pointers info.
  19317. * @param type Defines the type of event (PointerEventTypes)
  19318. * @param event Defines the related dom event
  19319. */
  19320. constructor(
  19321. /**
  19322. * Defines the type of event (PointerEventTypes)
  19323. */
  19324. type: number,
  19325. /**
  19326. * Defines the related dom event
  19327. */
  19328. event: PointerEvent | MouseWheelEvent);
  19329. }
  19330. /**
  19331. * This class is used to store pointer related info for the onPrePointerObservable event.
  19332. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19333. */
  19334. export class PointerInfoPre extends PointerInfoBase {
  19335. /**
  19336. * Ray from a pointer if availible (eg. 6dof controller)
  19337. */
  19338. ray: Nullable<Ray>;
  19339. /**
  19340. * Defines the local position of the pointer on the canvas.
  19341. */
  19342. localPosition: Vector2;
  19343. /**
  19344. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19345. */
  19346. skipOnPointerObservable: boolean;
  19347. /**
  19348. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19349. * @param type Defines the type of event (PointerEventTypes)
  19350. * @param event Defines the related dom event
  19351. * @param localX Defines the local x coordinates of the pointer when the event occured
  19352. * @param localY Defines the local y coordinates of the pointer when the event occured
  19353. */
  19354. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19355. }
  19356. /**
  19357. * This type contains all the data related to a pointer event in Babylon.js.
  19358. * 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.
  19359. */
  19360. export class PointerInfo extends PointerInfoBase {
  19361. /**
  19362. * Defines the picking info associated to the info (if any)\
  19363. */
  19364. pickInfo: Nullable<PickingInfo>;
  19365. /**
  19366. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19367. * @param type Defines the type of event (PointerEventTypes)
  19368. * @param event Defines the related dom event
  19369. * @param pickInfo Defines the picking info associated to the info (if any)\
  19370. */
  19371. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19372. /**
  19373. * Defines the picking info associated to the info (if any)\
  19374. */
  19375. pickInfo: Nullable<PickingInfo>);
  19376. }
  19377. /**
  19378. * Data relating to a touch event on the screen.
  19379. */
  19380. export interface PointerTouch {
  19381. /**
  19382. * X coordinate of touch.
  19383. */
  19384. x: number;
  19385. /**
  19386. * Y coordinate of touch.
  19387. */
  19388. y: number;
  19389. /**
  19390. * Id of touch. Unique for each finger.
  19391. */
  19392. pointerId: number;
  19393. /**
  19394. * Event type passed from DOM.
  19395. */
  19396. type: any;
  19397. }
  19398. }
  19399. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19400. import { Observable } from "babylonjs/Misc/observable";
  19401. import { Nullable } from "babylonjs/types";
  19402. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19403. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19404. /**
  19405. * Manage the mouse inputs to control the movement of a free camera.
  19406. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19407. */
  19408. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19409. /**
  19410. * Define if touch is enabled in the mouse input
  19411. */
  19412. touchEnabled: boolean;
  19413. /**
  19414. * Defines the camera the input is attached to.
  19415. */
  19416. camera: FreeCamera;
  19417. /**
  19418. * Defines the buttons associated with the input to handle camera move.
  19419. */
  19420. buttons: number[];
  19421. /**
  19422. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19423. */
  19424. angularSensibility: number;
  19425. private _pointerInput;
  19426. private _onMouseMove;
  19427. private _observer;
  19428. private previousPosition;
  19429. /**
  19430. * Observable for when a pointer move event occurs containing the move offset
  19431. */
  19432. onPointerMovedObservable: Observable<{
  19433. offsetX: number;
  19434. offsetY: number;
  19435. }>;
  19436. /**
  19437. * @hidden
  19438. * If the camera should be rotated automatically based on pointer movement
  19439. */
  19440. _allowCameraRotation: boolean;
  19441. /**
  19442. * Manage the mouse inputs to control the movement of a free camera.
  19443. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19444. * @param touchEnabled Defines if touch is enabled or not
  19445. */
  19446. constructor(
  19447. /**
  19448. * Define if touch is enabled in the mouse input
  19449. */
  19450. touchEnabled?: boolean);
  19451. /**
  19452. * Attach the input controls to a specific dom element to get the input from.
  19453. * @param element Defines the element the controls should be listened from
  19454. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19455. */
  19456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19457. /**
  19458. * Called on JS contextmenu event.
  19459. * Override this method to provide functionality.
  19460. */
  19461. protected onContextMenu(evt: PointerEvent): void;
  19462. /**
  19463. * Detach the current controls from the specified dom element.
  19464. * @param element Defines the element to stop listening the inputs from
  19465. */
  19466. detachControl(element: Nullable<HTMLElement>): void;
  19467. /**
  19468. * Gets the class name of the current intput.
  19469. * @returns the class name
  19470. */
  19471. getClassName(): string;
  19472. /**
  19473. * Get the friendly name associated with the input class.
  19474. * @returns the input friendly name
  19475. */
  19476. getSimpleName(): string;
  19477. }
  19478. }
  19479. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19480. import { Nullable } from "babylonjs/types";
  19481. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19482. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19483. /**
  19484. * Manage the touch inputs to control the movement of a free camera.
  19485. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19486. */
  19487. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19488. /**
  19489. * Define if mouse events can be treated as touch events
  19490. */
  19491. allowMouse: boolean;
  19492. /**
  19493. * Defines the camera the input is attached to.
  19494. */
  19495. camera: FreeCamera;
  19496. /**
  19497. * Defines the touch sensibility for rotation.
  19498. * The higher the faster.
  19499. */
  19500. touchAngularSensibility: number;
  19501. /**
  19502. * Defines the touch sensibility for move.
  19503. * The higher the faster.
  19504. */
  19505. touchMoveSensibility: number;
  19506. private _offsetX;
  19507. private _offsetY;
  19508. private _pointerPressed;
  19509. private _pointerInput;
  19510. private _observer;
  19511. private _onLostFocus;
  19512. /**
  19513. * Manage the touch inputs to control the movement of a free camera.
  19514. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19515. * @param allowMouse Defines if mouse events can be treated as touch events
  19516. */
  19517. constructor(
  19518. /**
  19519. * Define if mouse events can be treated as touch events
  19520. */
  19521. allowMouse?: boolean);
  19522. /**
  19523. * Attach the input controls to a specific dom element to get the input from.
  19524. * @param element Defines the element the controls should be listened from
  19525. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19526. */
  19527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19528. /**
  19529. * Detach the current controls from the specified dom element.
  19530. * @param element Defines the element to stop listening the inputs from
  19531. */
  19532. detachControl(element: Nullable<HTMLElement>): void;
  19533. /**
  19534. * Update the current camera state depending on the inputs that have been used this frame.
  19535. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19536. */
  19537. checkInputs(): void;
  19538. /**
  19539. * Gets the class name of the current intput.
  19540. * @returns the class name
  19541. */
  19542. getClassName(): string;
  19543. /**
  19544. * Get the friendly name associated with the input class.
  19545. * @returns the input friendly name
  19546. */
  19547. getSimpleName(): string;
  19548. }
  19549. }
  19550. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19551. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19552. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19553. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19554. import { Nullable } from "babylonjs/types";
  19555. /**
  19556. * Default Inputs manager for the FreeCamera.
  19557. * It groups all the default supported inputs for ease of use.
  19558. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19559. */
  19560. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19561. /**
  19562. * @hidden
  19563. */
  19564. _mouseInput: Nullable<FreeCameraMouseInput>;
  19565. /**
  19566. * Instantiates a new FreeCameraInputsManager.
  19567. * @param camera Defines the camera the inputs belong to
  19568. */
  19569. constructor(camera: FreeCamera);
  19570. /**
  19571. * Add keyboard input support to the input manager.
  19572. * @returns the current input manager
  19573. */
  19574. addKeyboard(): FreeCameraInputsManager;
  19575. /**
  19576. * Add mouse input support to the input manager.
  19577. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19578. * @returns the current input manager
  19579. */
  19580. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19581. /**
  19582. * Removes the mouse input support from the manager
  19583. * @returns the current input manager
  19584. */
  19585. removeMouse(): FreeCameraInputsManager;
  19586. /**
  19587. * Add touch input support to the input manager.
  19588. * @returns the current input manager
  19589. */
  19590. addTouch(): FreeCameraInputsManager;
  19591. /**
  19592. * Remove all attached input methods from a camera
  19593. */
  19594. clear(): void;
  19595. }
  19596. }
  19597. declare module "babylonjs/Cameras/freeCamera" {
  19598. import { Vector3 } from "babylonjs/Maths/math.vector";
  19599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19600. import { Scene } from "babylonjs/scene";
  19601. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19602. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19603. /**
  19604. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19605. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19606. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19607. */
  19608. export class FreeCamera extends TargetCamera {
  19609. /**
  19610. * Define the collision ellipsoid of the camera.
  19611. * This is helpful to simulate a camera body like the player body around the camera
  19612. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19613. */
  19614. ellipsoid: Vector3;
  19615. /**
  19616. * Define an offset for the position of the ellipsoid around the camera.
  19617. * This can be helpful to determine the center of the body near the gravity center of the body
  19618. * instead of its head.
  19619. */
  19620. ellipsoidOffset: Vector3;
  19621. /**
  19622. * Enable or disable collisions of the camera with the rest of the scene objects.
  19623. */
  19624. checkCollisions: boolean;
  19625. /**
  19626. * Enable or disable gravity on the camera.
  19627. */
  19628. applyGravity: boolean;
  19629. /**
  19630. * Define the input manager associated to the camera.
  19631. */
  19632. inputs: FreeCameraInputsManager;
  19633. /**
  19634. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19635. * Higher values reduce sensitivity.
  19636. */
  19637. get angularSensibility(): number;
  19638. /**
  19639. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19640. * Higher values reduce sensitivity.
  19641. */
  19642. set angularSensibility(value: number);
  19643. /**
  19644. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19645. */
  19646. get keysUp(): number[];
  19647. set keysUp(value: number[]);
  19648. /**
  19649. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19650. */
  19651. get keysUpward(): number[];
  19652. set keysUpward(value: number[]);
  19653. /**
  19654. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19655. */
  19656. get keysDown(): number[];
  19657. set keysDown(value: number[]);
  19658. /**
  19659. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19660. */
  19661. get keysDownward(): number[];
  19662. set keysDownward(value: number[]);
  19663. /**
  19664. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19665. */
  19666. get keysLeft(): number[];
  19667. set keysLeft(value: number[]);
  19668. /**
  19669. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19670. */
  19671. get keysRight(): number[];
  19672. set keysRight(value: number[]);
  19673. /**
  19674. * Event raised when the camera collide with a mesh in the scene.
  19675. */
  19676. onCollide: (collidedMesh: AbstractMesh) => void;
  19677. private _collider;
  19678. private _needMoveForGravity;
  19679. private _oldPosition;
  19680. private _diffPosition;
  19681. private _newPosition;
  19682. /** @hidden */
  19683. _localDirection: Vector3;
  19684. /** @hidden */
  19685. _transformedDirection: Vector3;
  19686. /**
  19687. * Instantiates a Free Camera.
  19688. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19689. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19690. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19691. * @param name Define the name of the camera in the scene
  19692. * @param position Define the start position of the camera in the scene
  19693. * @param scene Define the scene the camera belongs to
  19694. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19695. */
  19696. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19697. /**
  19698. * Attached controls to the current camera.
  19699. * @param element Defines the element the controls should be listened from
  19700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19701. */
  19702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19703. /**
  19704. * Detach the current controls from the camera.
  19705. * The camera will stop reacting to inputs.
  19706. * @param element Defines the element to stop listening the inputs from
  19707. */
  19708. detachControl(element: HTMLElement): void;
  19709. private _collisionMask;
  19710. /**
  19711. * Define a collision mask to limit the list of object the camera can collide with
  19712. */
  19713. get collisionMask(): number;
  19714. set collisionMask(mask: number);
  19715. /** @hidden */
  19716. _collideWithWorld(displacement: Vector3): void;
  19717. private _onCollisionPositionChange;
  19718. /** @hidden */
  19719. _checkInputs(): void;
  19720. /** @hidden */
  19721. _decideIfNeedsToMove(): boolean;
  19722. /** @hidden */
  19723. _updatePosition(): void;
  19724. /**
  19725. * Destroy the camera and release the current resources hold by it.
  19726. */
  19727. dispose(): void;
  19728. /**
  19729. * Gets the current object class name.
  19730. * @return the class name
  19731. */
  19732. getClassName(): string;
  19733. }
  19734. }
  19735. declare module "babylonjs/Gamepads/gamepad" {
  19736. import { Observable } from "babylonjs/Misc/observable";
  19737. /**
  19738. * Represents a gamepad control stick position
  19739. */
  19740. export class StickValues {
  19741. /**
  19742. * The x component of the control stick
  19743. */
  19744. x: number;
  19745. /**
  19746. * The y component of the control stick
  19747. */
  19748. y: number;
  19749. /**
  19750. * Initializes the gamepad x and y control stick values
  19751. * @param x The x component of the gamepad control stick value
  19752. * @param y The y component of the gamepad control stick value
  19753. */
  19754. constructor(
  19755. /**
  19756. * The x component of the control stick
  19757. */
  19758. x: number,
  19759. /**
  19760. * The y component of the control stick
  19761. */
  19762. y: number);
  19763. }
  19764. /**
  19765. * An interface which manages callbacks for gamepad button changes
  19766. */
  19767. export interface GamepadButtonChanges {
  19768. /**
  19769. * Called when a gamepad has been changed
  19770. */
  19771. changed: boolean;
  19772. /**
  19773. * Called when a gamepad press event has been triggered
  19774. */
  19775. pressChanged: boolean;
  19776. /**
  19777. * Called when a touch event has been triggered
  19778. */
  19779. touchChanged: boolean;
  19780. /**
  19781. * Called when a value has changed
  19782. */
  19783. valueChanged: boolean;
  19784. }
  19785. /**
  19786. * Represents a gamepad
  19787. */
  19788. export class Gamepad {
  19789. /**
  19790. * The id of the gamepad
  19791. */
  19792. id: string;
  19793. /**
  19794. * The index of the gamepad
  19795. */
  19796. index: number;
  19797. /**
  19798. * The browser gamepad
  19799. */
  19800. browserGamepad: any;
  19801. /**
  19802. * Specifies what type of gamepad this represents
  19803. */
  19804. type: number;
  19805. private _leftStick;
  19806. private _rightStick;
  19807. /** @hidden */
  19808. _isConnected: boolean;
  19809. private _leftStickAxisX;
  19810. private _leftStickAxisY;
  19811. private _rightStickAxisX;
  19812. private _rightStickAxisY;
  19813. /**
  19814. * Triggered when the left control stick has been changed
  19815. */
  19816. private _onleftstickchanged;
  19817. /**
  19818. * Triggered when the right control stick has been changed
  19819. */
  19820. private _onrightstickchanged;
  19821. /**
  19822. * Represents a gamepad controller
  19823. */
  19824. static GAMEPAD: number;
  19825. /**
  19826. * Represents a generic controller
  19827. */
  19828. static GENERIC: number;
  19829. /**
  19830. * Represents an XBox controller
  19831. */
  19832. static XBOX: number;
  19833. /**
  19834. * Represents a pose-enabled controller
  19835. */
  19836. static POSE_ENABLED: number;
  19837. /**
  19838. * Represents an Dual Shock controller
  19839. */
  19840. static DUALSHOCK: number;
  19841. /**
  19842. * Specifies whether the left control stick should be Y-inverted
  19843. */
  19844. protected _invertLeftStickY: boolean;
  19845. /**
  19846. * Specifies if the gamepad has been connected
  19847. */
  19848. get isConnected(): boolean;
  19849. /**
  19850. * Initializes the gamepad
  19851. * @param id The id of the gamepad
  19852. * @param index The index of the gamepad
  19853. * @param browserGamepad The browser gamepad
  19854. * @param leftStickX The x component of the left joystick
  19855. * @param leftStickY The y component of the left joystick
  19856. * @param rightStickX The x component of the right joystick
  19857. * @param rightStickY The y component of the right joystick
  19858. */
  19859. constructor(
  19860. /**
  19861. * The id of the gamepad
  19862. */
  19863. id: string,
  19864. /**
  19865. * The index of the gamepad
  19866. */
  19867. index: number,
  19868. /**
  19869. * The browser gamepad
  19870. */
  19871. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19872. /**
  19873. * Callback triggered when the left joystick has changed
  19874. * @param callback
  19875. */
  19876. onleftstickchanged(callback: (values: StickValues) => void): void;
  19877. /**
  19878. * Callback triggered when the right joystick has changed
  19879. * @param callback
  19880. */
  19881. onrightstickchanged(callback: (values: StickValues) => void): void;
  19882. /**
  19883. * Gets the left joystick
  19884. */
  19885. get leftStick(): StickValues;
  19886. /**
  19887. * Sets the left joystick values
  19888. */
  19889. set leftStick(newValues: StickValues);
  19890. /**
  19891. * Gets the right joystick
  19892. */
  19893. get rightStick(): StickValues;
  19894. /**
  19895. * Sets the right joystick value
  19896. */
  19897. set rightStick(newValues: StickValues);
  19898. /**
  19899. * Updates the gamepad joystick positions
  19900. */
  19901. update(): void;
  19902. /**
  19903. * Disposes the gamepad
  19904. */
  19905. dispose(): void;
  19906. }
  19907. /**
  19908. * Represents a generic gamepad
  19909. */
  19910. export class GenericPad extends Gamepad {
  19911. private _buttons;
  19912. private _onbuttondown;
  19913. private _onbuttonup;
  19914. /**
  19915. * Observable triggered when a button has been pressed
  19916. */
  19917. onButtonDownObservable: Observable<number>;
  19918. /**
  19919. * Observable triggered when a button has been released
  19920. */
  19921. onButtonUpObservable: Observable<number>;
  19922. /**
  19923. * Callback triggered when a button has been pressed
  19924. * @param callback Called when a button has been pressed
  19925. */
  19926. onbuttondown(callback: (buttonPressed: number) => void): void;
  19927. /**
  19928. * Callback triggered when a button has been released
  19929. * @param callback Called when a button has been released
  19930. */
  19931. onbuttonup(callback: (buttonReleased: number) => void): void;
  19932. /**
  19933. * Initializes the generic gamepad
  19934. * @param id The id of the generic gamepad
  19935. * @param index The index of the generic gamepad
  19936. * @param browserGamepad The browser gamepad
  19937. */
  19938. constructor(id: string, index: number, browserGamepad: any);
  19939. private _setButtonValue;
  19940. /**
  19941. * Updates the generic gamepad
  19942. */
  19943. update(): void;
  19944. /**
  19945. * Disposes the generic gamepad
  19946. */
  19947. dispose(): void;
  19948. }
  19949. }
  19950. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19951. import { Observable } from "babylonjs/Misc/observable";
  19952. import { Nullable } from "babylonjs/types";
  19953. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19954. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19956. import { Ray } from "babylonjs/Culling/ray";
  19957. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19958. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19959. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19960. /**
  19961. * Defines the types of pose enabled controllers that are supported
  19962. */
  19963. export enum PoseEnabledControllerType {
  19964. /**
  19965. * HTC Vive
  19966. */
  19967. VIVE = 0,
  19968. /**
  19969. * Oculus Rift
  19970. */
  19971. OCULUS = 1,
  19972. /**
  19973. * Windows mixed reality
  19974. */
  19975. WINDOWS = 2,
  19976. /**
  19977. * Samsung gear VR
  19978. */
  19979. GEAR_VR = 3,
  19980. /**
  19981. * Google Daydream
  19982. */
  19983. DAYDREAM = 4,
  19984. /**
  19985. * Generic
  19986. */
  19987. GENERIC = 5
  19988. }
  19989. /**
  19990. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19991. */
  19992. export interface MutableGamepadButton {
  19993. /**
  19994. * Value of the button/trigger
  19995. */
  19996. value: number;
  19997. /**
  19998. * If the button/trigger is currently touched
  19999. */
  20000. touched: boolean;
  20001. /**
  20002. * If the button/trigger is currently pressed
  20003. */
  20004. pressed: boolean;
  20005. }
  20006. /**
  20007. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20008. * @hidden
  20009. */
  20010. export interface ExtendedGamepadButton extends GamepadButton {
  20011. /**
  20012. * If the button/trigger is currently pressed
  20013. */
  20014. readonly pressed: boolean;
  20015. /**
  20016. * If the button/trigger is currently touched
  20017. */
  20018. readonly touched: boolean;
  20019. /**
  20020. * Value of the button/trigger
  20021. */
  20022. readonly value: number;
  20023. }
  20024. /** @hidden */
  20025. export interface _GamePadFactory {
  20026. /**
  20027. * Returns whether or not the current gamepad can be created for this type of controller.
  20028. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20029. * @returns true if it can be created, otherwise false
  20030. */
  20031. canCreate(gamepadInfo: any): boolean;
  20032. /**
  20033. * Creates a new instance of the Gamepad.
  20034. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20035. * @returns the new gamepad instance
  20036. */
  20037. create(gamepadInfo: any): Gamepad;
  20038. }
  20039. /**
  20040. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20041. */
  20042. export class PoseEnabledControllerHelper {
  20043. /** @hidden */
  20044. static _ControllerFactories: _GamePadFactory[];
  20045. /** @hidden */
  20046. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20047. /**
  20048. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20049. * @param vrGamepad the gamepad to initialized
  20050. * @returns a vr controller of the type the gamepad identified as
  20051. */
  20052. static InitiateController(vrGamepad: any): Gamepad;
  20053. }
  20054. /**
  20055. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20056. */
  20057. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20058. /**
  20059. * If the controller is used in a webXR session
  20060. */
  20061. isXR: boolean;
  20062. private _deviceRoomPosition;
  20063. private _deviceRoomRotationQuaternion;
  20064. /**
  20065. * The device position in babylon space
  20066. */
  20067. devicePosition: Vector3;
  20068. /**
  20069. * The device rotation in babylon space
  20070. */
  20071. deviceRotationQuaternion: Quaternion;
  20072. /**
  20073. * The scale factor of the device in babylon space
  20074. */
  20075. deviceScaleFactor: number;
  20076. /**
  20077. * (Likely devicePosition should be used instead) The device position in its room space
  20078. */
  20079. position: Vector3;
  20080. /**
  20081. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20082. */
  20083. rotationQuaternion: Quaternion;
  20084. /**
  20085. * The type of controller (Eg. Windows mixed reality)
  20086. */
  20087. controllerType: PoseEnabledControllerType;
  20088. protected _calculatedPosition: Vector3;
  20089. private _calculatedRotation;
  20090. /**
  20091. * The raw pose from the device
  20092. */
  20093. rawPose: DevicePose;
  20094. private _trackPosition;
  20095. private _maxRotationDistFromHeadset;
  20096. private _draggedRoomRotation;
  20097. /**
  20098. * @hidden
  20099. */
  20100. _disableTrackPosition(fixedPosition: Vector3): void;
  20101. /**
  20102. * Internal, the mesh attached to the controller
  20103. * @hidden
  20104. */
  20105. _mesh: Nullable<AbstractMesh>;
  20106. private _poseControlledCamera;
  20107. private _leftHandSystemQuaternion;
  20108. /**
  20109. * Internal, matrix used to convert room space to babylon space
  20110. * @hidden
  20111. */
  20112. _deviceToWorld: Matrix;
  20113. /**
  20114. * Node to be used when casting a ray from the controller
  20115. * @hidden
  20116. */
  20117. _pointingPoseNode: Nullable<TransformNode>;
  20118. /**
  20119. * Name of the child mesh that can be used to cast a ray from the controller
  20120. */
  20121. static readonly POINTING_POSE: string;
  20122. /**
  20123. * Creates a new PoseEnabledController from a gamepad
  20124. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20125. */
  20126. constructor(browserGamepad: any);
  20127. private _workingMatrix;
  20128. /**
  20129. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20130. */
  20131. update(): void;
  20132. /**
  20133. * Updates only the pose device and mesh without doing any button event checking
  20134. */
  20135. protected _updatePoseAndMesh(): void;
  20136. /**
  20137. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20138. * @param poseData raw pose fromthe device
  20139. */
  20140. updateFromDevice(poseData: DevicePose): void;
  20141. /**
  20142. * @hidden
  20143. */
  20144. _meshAttachedObservable: Observable<AbstractMesh>;
  20145. /**
  20146. * Attaches a mesh to the controller
  20147. * @param mesh the mesh to be attached
  20148. */
  20149. attachToMesh(mesh: AbstractMesh): void;
  20150. /**
  20151. * Attaches the controllers mesh to a camera
  20152. * @param camera the camera the mesh should be attached to
  20153. */
  20154. attachToPoseControlledCamera(camera: TargetCamera): void;
  20155. /**
  20156. * Disposes of the controller
  20157. */
  20158. dispose(): void;
  20159. /**
  20160. * The mesh that is attached to the controller
  20161. */
  20162. get mesh(): Nullable<AbstractMesh>;
  20163. /**
  20164. * Gets the ray of the controller in the direction the controller is pointing
  20165. * @param length the length the resulting ray should be
  20166. * @returns a ray in the direction the controller is pointing
  20167. */
  20168. getForwardRay(length?: number): Ray;
  20169. }
  20170. }
  20171. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20172. import { Observable } from "babylonjs/Misc/observable";
  20173. import { Scene } from "babylonjs/scene";
  20174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20175. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20176. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20177. import { Nullable } from "babylonjs/types";
  20178. /**
  20179. * Defines the WebVRController object that represents controllers tracked in 3D space
  20180. */
  20181. export abstract class WebVRController extends PoseEnabledController {
  20182. /**
  20183. * Internal, the default controller model for the controller
  20184. */
  20185. protected _defaultModel: Nullable<AbstractMesh>;
  20186. /**
  20187. * Fired when the trigger state has changed
  20188. */
  20189. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20190. /**
  20191. * Fired when the main button state has changed
  20192. */
  20193. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20194. /**
  20195. * Fired when the secondary button state has changed
  20196. */
  20197. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20198. /**
  20199. * Fired when the pad state has changed
  20200. */
  20201. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20202. /**
  20203. * Fired when controllers stick values have changed
  20204. */
  20205. onPadValuesChangedObservable: Observable<StickValues>;
  20206. /**
  20207. * Array of button availible on the controller
  20208. */
  20209. protected _buttons: Array<MutableGamepadButton>;
  20210. private _onButtonStateChange;
  20211. /**
  20212. * Fired when a controller button's state has changed
  20213. * @param callback the callback containing the button that was modified
  20214. */
  20215. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20216. /**
  20217. * X and Y axis corresponding to the controllers joystick
  20218. */
  20219. pad: StickValues;
  20220. /**
  20221. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20222. */
  20223. hand: string;
  20224. /**
  20225. * The default controller model for the controller
  20226. */
  20227. get defaultModel(): Nullable<AbstractMesh>;
  20228. /**
  20229. * Creates a new WebVRController from a gamepad
  20230. * @param vrGamepad the gamepad that the WebVRController should be created from
  20231. */
  20232. constructor(vrGamepad: any);
  20233. /**
  20234. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20235. */
  20236. update(): void;
  20237. /**
  20238. * Function to be called when a button is modified
  20239. */
  20240. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20241. /**
  20242. * Loads a mesh and attaches it to the controller
  20243. * @param scene the scene the mesh should be added to
  20244. * @param meshLoaded callback for when the mesh has been loaded
  20245. */
  20246. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20247. private _setButtonValue;
  20248. private _changes;
  20249. private _checkChanges;
  20250. /**
  20251. * Disposes of th webVRCOntroller
  20252. */
  20253. dispose(): void;
  20254. }
  20255. }
  20256. declare module "babylonjs/Lights/hemisphericLight" {
  20257. import { Nullable } from "babylonjs/types";
  20258. import { Scene } from "babylonjs/scene";
  20259. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20260. import { Color3 } from "babylonjs/Maths/math.color";
  20261. import { Effect } from "babylonjs/Materials/effect";
  20262. import { Light } from "babylonjs/Lights/light";
  20263. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20264. /**
  20265. * The HemisphericLight simulates the ambient environment light,
  20266. * so the passed direction is the light reflection direction, not the incoming direction.
  20267. */
  20268. export class HemisphericLight extends Light {
  20269. /**
  20270. * The groundColor is the light in the opposite direction to the one specified during creation.
  20271. * 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.
  20272. */
  20273. groundColor: Color3;
  20274. /**
  20275. * The light reflection direction, not the incoming direction.
  20276. */
  20277. direction: Vector3;
  20278. /**
  20279. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20280. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20281. * The HemisphericLight can't cast shadows.
  20282. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20283. * @param name The friendly name of the light
  20284. * @param direction The direction of the light reflection
  20285. * @param scene The scene the light belongs to
  20286. */
  20287. constructor(name: string, direction: Vector3, scene: Scene);
  20288. protected _buildUniformLayout(): void;
  20289. /**
  20290. * Returns the string "HemisphericLight".
  20291. * @return The class name
  20292. */
  20293. getClassName(): string;
  20294. /**
  20295. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20296. * Returns the updated direction.
  20297. * @param target The target the direction should point to
  20298. * @return The computed direction
  20299. */
  20300. setDirectionToTarget(target: Vector3): Vector3;
  20301. /**
  20302. * Returns the shadow generator associated to the light.
  20303. * @returns Always null for hemispheric lights because it does not support shadows.
  20304. */
  20305. getShadowGenerator(): Nullable<IShadowGenerator>;
  20306. /**
  20307. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20308. * @param effect The effect to update
  20309. * @param lightIndex The index of the light in the effect to update
  20310. * @returns The hemispheric light
  20311. */
  20312. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20313. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20314. /**
  20315. * Computes the world matrix of the node
  20316. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20317. * @param useWasUpdatedFlag defines a reserved property
  20318. * @returns the world matrix
  20319. */
  20320. computeWorldMatrix(): Matrix;
  20321. /**
  20322. * Returns the integer 3.
  20323. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20324. */
  20325. getTypeID(): number;
  20326. /**
  20327. * Prepares the list of defines specific to the light type.
  20328. * @param defines the list of defines
  20329. * @param lightIndex defines the index of the light for the effect
  20330. */
  20331. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20332. }
  20333. }
  20334. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20335. /** @hidden */
  20336. export var vrMultiviewToSingleviewPixelShader: {
  20337. name: string;
  20338. shader: string;
  20339. };
  20340. }
  20341. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20342. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20343. import { Scene } from "babylonjs/scene";
  20344. /**
  20345. * Renders to multiple views with a single draw call
  20346. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20347. */
  20348. export class MultiviewRenderTarget extends RenderTargetTexture {
  20349. /**
  20350. * Creates a multiview render target
  20351. * @param scene scene used with the render target
  20352. * @param size the size of the render target (used for each view)
  20353. */
  20354. constructor(scene: Scene, size?: number | {
  20355. width: number;
  20356. height: number;
  20357. } | {
  20358. ratio: number;
  20359. });
  20360. /**
  20361. * @hidden
  20362. * @param faceIndex the face index, if its a cube texture
  20363. */
  20364. _bindFrameBuffer(faceIndex?: number): void;
  20365. /**
  20366. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20367. * @returns the view count
  20368. */
  20369. getViewCount(): number;
  20370. }
  20371. }
  20372. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20373. import { Camera } from "babylonjs/Cameras/camera";
  20374. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20375. import { Nullable } from "babylonjs/types";
  20376. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20377. import { Matrix } from "babylonjs/Maths/math.vector";
  20378. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20379. module "babylonjs/Engines/engine" {
  20380. interface Engine {
  20381. /**
  20382. * Creates a new multiview render target
  20383. * @param width defines the width of the texture
  20384. * @param height defines the height of the texture
  20385. * @returns the created multiview texture
  20386. */
  20387. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20388. /**
  20389. * Binds a multiview framebuffer to be drawn to
  20390. * @param multiviewTexture texture to bind
  20391. */
  20392. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20393. }
  20394. }
  20395. module "babylonjs/Cameras/camera" {
  20396. interface Camera {
  20397. /**
  20398. * @hidden
  20399. * 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)
  20400. */
  20401. _useMultiviewToSingleView: boolean;
  20402. /**
  20403. * @hidden
  20404. * 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)
  20405. */
  20406. _multiviewTexture: Nullable<RenderTargetTexture>;
  20407. /**
  20408. * @hidden
  20409. * ensures the multiview texture of the camera exists and has the specified width/height
  20410. * @param width height to set on the multiview texture
  20411. * @param height width to set on the multiview texture
  20412. */
  20413. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20414. }
  20415. }
  20416. module "babylonjs/scene" {
  20417. interface Scene {
  20418. /** @hidden */
  20419. _transformMatrixR: Matrix;
  20420. /** @hidden */
  20421. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20422. /** @hidden */
  20423. _createMultiviewUbo(): void;
  20424. /** @hidden */
  20425. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20426. /** @hidden */
  20427. _renderMultiviewToSingleView(camera: Camera): void;
  20428. }
  20429. }
  20430. }
  20431. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20432. import { Camera } from "babylonjs/Cameras/camera";
  20433. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20434. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20435. import "babylonjs/Engines/Extensions/engine.multiview";
  20436. /**
  20437. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20438. * This will not be used for webXR as it supports displaying texture arrays directly
  20439. */
  20440. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20441. /**
  20442. * Gets a string identifying the name of the class
  20443. * @returns "VRMultiviewToSingleviewPostProcess" string
  20444. */
  20445. getClassName(): string;
  20446. /**
  20447. * Initializes a VRMultiviewToSingleview
  20448. * @param name name of the post process
  20449. * @param camera camera to be applied to
  20450. * @param scaleFactor scaling factor to the size of the output texture
  20451. */
  20452. constructor(name: string, camera: Camera, scaleFactor: number);
  20453. }
  20454. }
  20455. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20456. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20457. import { Nullable } from "babylonjs/types";
  20458. import { Size } from "babylonjs/Maths/math.size";
  20459. import { Observable } from "babylonjs/Misc/observable";
  20460. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20461. /**
  20462. * Interface used to define additional presentation attributes
  20463. */
  20464. export interface IVRPresentationAttributes {
  20465. /**
  20466. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20467. */
  20468. highRefreshRate: boolean;
  20469. /**
  20470. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20471. */
  20472. foveationLevel: number;
  20473. }
  20474. module "babylonjs/Engines/engine" {
  20475. interface Engine {
  20476. /** @hidden */
  20477. _vrDisplay: any;
  20478. /** @hidden */
  20479. _vrSupported: boolean;
  20480. /** @hidden */
  20481. _oldSize: Size;
  20482. /** @hidden */
  20483. _oldHardwareScaleFactor: number;
  20484. /** @hidden */
  20485. _vrExclusivePointerMode: boolean;
  20486. /** @hidden */
  20487. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20488. /** @hidden */
  20489. _onVRDisplayPointerRestricted: () => void;
  20490. /** @hidden */
  20491. _onVRDisplayPointerUnrestricted: () => void;
  20492. /** @hidden */
  20493. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20494. /** @hidden */
  20495. _onVrDisplayDisconnect: Nullable<() => void>;
  20496. /** @hidden */
  20497. _onVrDisplayPresentChange: Nullable<() => void>;
  20498. /**
  20499. * Observable signaled when VR display mode changes
  20500. */
  20501. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20502. /**
  20503. * Observable signaled when VR request present is complete
  20504. */
  20505. onVRRequestPresentComplete: Observable<boolean>;
  20506. /**
  20507. * Observable signaled when VR request present starts
  20508. */
  20509. onVRRequestPresentStart: Observable<Engine>;
  20510. /**
  20511. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20512. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20513. */
  20514. isInVRExclusivePointerMode: boolean;
  20515. /**
  20516. * Gets a boolean indicating if a webVR device was detected
  20517. * @returns true if a webVR device was detected
  20518. */
  20519. isVRDevicePresent(): boolean;
  20520. /**
  20521. * Gets the current webVR device
  20522. * @returns the current webVR device (or null)
  20523. */
  20524. getVRDevice(): any;
  20525. /**
  20526. * Initializes a webVR display and starts listening to display change events
  20527. * The onVRDisplayChangedObservable will be notified upon these changes
  20528. * @returns A promise containing a VRDisplay and if vr is supported
  20529. */
  20530. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20531. /** @hidden */
  20532. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20533. /**
  20534. * Gets or sets the presentation attributes used to configure VR rendering
  20535. */
  20536. vrPresentationAttributes?: IVRPresentationAttributes;
  20537. /**
  20538. * Call this function to switch to webVR mode
  20539. * Will do nothing if webVR is not supported or if there is no webVR device
  20540. * @param options the webvr options provided to the camera. mainly used for multiview
  20541. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20542. */
  20543. enableVR(options: WebVROptions): void;
  20544. /** @hidden */
  20545. _onVRFullScreenTriggered(): void;
  20546. }
  20547. }
  20548. }
  20549. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20550. import { Nullable } from "babylonjs/types";
  20551. import { Observable } from "babylonjs/Misc/observable";
  20552. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20553. import { Scene } from "babylonjs/scene";
  20554. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20555. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20556. import { Node } from "babylonjs/node";
  20557. import { Ray } from "babylonjs/Culling/ray";
  20558. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20559. import "babylonjs/Engines/Extensions/engine.webVR";
  20560. /**
  20561. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20562. * IMPORTANT!! The data is right-hand data.
  20563. * @export
  20564. * @interface DevicePose
  20565. */
  20566. export interface DevicePose {
  20567. /**
  20568. * The position of the device, values in array are [x,y,z].
  20569. */
  20570. readonly position: Nullable<Float32Array>;
  20571. /**
  20572. * The linearVelocity of the device, values in array are [x,y,z].
  20573. */
  20574. readonly linearVelocity: Nullable<Float32Array>;
  20575. /**
  20576. * The linearAcceleration of the device, values in array are [x,y,z].
  20577. */
  20578. readonly linearAcceleration: Nullable<Float32Array>;
  20579. /**
  20580. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20581. */
  20582. readonly orientation: Nullable<Float32Array>;
  20583. /**
  20584. * The angularVelocity of the device, values in array are [x,y,z].
  20585. */
  20586. readonly angularVelocity: Nullable<Float32Array>;
  20587. /**
  20588. * The angularAcceleration of the device, values in array are [x,y,z].
  20589. */
  20590. readonly angularAcceleration: Nullable<Float32Array>;
  20591. }
  20592. /**
  20593. * Interface representing a pose controlled object in Babylon.
  20594. * A pose controlled object has both regular pose values as well as pose values
  20595. * from an external device such as a VR head mounted display
  20596. */
  20597. export interface PoseControlled {
  20598. /**
  20599. * The position of the object in babylon space.
  20600. */
  20601. position: Vector3;
  20602. /**
  20603. * The rotation quaternion of the object in babylon space.
  20604. */
  20605. rotationQuaternion: Quaternion;
  20606. /**
  20607. * The position of the device in babylon space.
  20608. */
  20609. devicePosition?: Vector3;
  20610. /**
  20611. * The rotation quaternion of the device in babylon space.
  20612. */
  20613. deviceRotationQuaternion: Quaternion;
  20614. /**
  20615. * The raw pose coming from the device.
  20616. */
  20617. rawPose: Nullable<DevicePose>;
  20618. /**
  20619. * The scale of the device to be used when translating from device space to babylon space.
  20620. */
  20621. deviceScaleFactor: number;
  20622. /**
  20623. * Updates the poseControlled values based on the input device pose.
  20624. * @param poseData the pose data to update the object with
  20625. */
  20626. updateFromDevice(poseData: DevicePose): void;
  20627. }
  20628. /**
  20629. * Set of options to customize the webVRCamera
  20630. */
  20631. export interface WebVROptions {
  20632. /**
  20633. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20634. */
  20635. trackPosition?: boolean;
  20636. /**
  20637. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20638. */
  20639. positionScale?: number;
  20640. /**
  20641. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20642. */
  20643. displayName?: string;
  20644. /**
  20645. * Should the native controller meshes be initialized. (default: true)
  20646. */
  20647. controllerMeshes?: boolean;
  20648. /**
  20649. * Creating a default HemiLight only on controllers. (default: true)
  20650. */
  20651. defaultLightingOnControllers?: boolean;
  20652. /**
  20653. * If you don't want to use the default VR button of the helper. (default: false)
  20654. */
  20655. useCustomVRButton?: boolean;
  20656. /**
  20657. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20658. */
  20659. customVRButton?: HTMLButtonElement;
  20660. /**
  20661. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20662. */
  20663. rayLength?: number;
  20664. /**
  20665. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20666. */
  20667. defaultHeight?: number;
  20668. /**
  20669. * If multiview should be used if availible (default: false)
  20670. */
  20671. useMultiview?: boolean;
  20672. }
  20673. /**
  20674. * This represents a WebVR camera.
  20675. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20676. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20677. */
  20678. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20679. private webVROptions;
  20680. /**
  20681. * @hidden
  20682. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20683. */
  20684. _vrDevice: any;
  20685. /**
  20686. * The rawPose of the vrDevice.
  20687. */
  20688. rawPose: Nullable<DevicePose>;
  20689. private _onVREnabled;
  20690. private _specsVersion;
  20691. private _attached;
  20692. private _frameData;
  20693. protected _descendants: Array<Node>;
  20694. private _deviceRoomPosition;
  20695. /** @hidden */
  20696. _deviceRoomRotationQuaternion: Quaternion;
  20697. private _standingMatrix;
  20698. /**
  20699. * Represents device position in babylon space.
  20700. */
  20701. devicePosition: Vector3;
  20702. /**
  20703. * Represents device rotation in babylon space.
  20704. */
  20705. deviceRotationQuaternion: Quaternion;
  20706. /**
  20707. * The scale of the device to be used when translating from device space to babylon space.
  20708. */
  20709. deviceScaleFactor: number;
  20710. private _deviceToWorld;
  20711. private _worldToDevice;
  20712. /**
  20713. * References to the webVR controllers for the vrDevice.
  20714. */
  20715. controllers: Array<WebVRController>;
  20716. /**
  20717. * Emits an event when a controller is attached.
  20718. */
  20719. onControllersAttachedObservable: Observable<WebVRController[]>;
  20720. /**
  20721. * Emits an event when a controller's mesh has been loaded;
  20722. */
  20723. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20724. /**
  20725. * Emits an event when the HMD's pose has been updated.
  20726. */
  20727. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20728. private _poseSet;
  20729. /**
  20730. * If the rig cameras be used as parent instead of this camera.
  20731. */
  20732. rigParenting: boolean;
  20733. private _lightOnControllers;
  20734. private _defaultHeight?;
  20735. /**
  20736. * Instantiates a WebVRFreeCamera.
  20737. * @param name The name of the WebVRFreeCamera
  20738. * @param position The starting anchor position for the camera
  20739. * @param scene The scene the camera belongs to
  20740. * @param webVROptions a set of customizable options for the webVRCamera
  20741. */
  20742. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20743. /**
  20744. * Gets the device distance from the ground in meters.
  20745. * @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.
  20746. */
  20747. deviceDistanceToRoomGround(): number;
  20748. /**
  20749. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20750. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20751. */
  20752. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20753. /**
  20754. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20755. * @returns A promise with a boolean set to if the standing matrix is supported.
  20756. */
  20757. useStandingMatrixAsync(): Promise<boolean>;
  20758. /**
  20759. * Disposes the camera
  20760. */
  20761. dispose(): void;
  20762. /**
  20763. * Gets a vrController by name.
  20764. * @param name The name of the controller to retreive
  20765. * @returns the controller matching the name specified or null if not found
  20766. */
  20767. getControllerByName(name: string): Nullable<WebVRController>;
  20768. private _leftController;
  20769. /**
  20770. * The controller corresponding to the users left hand.
  20771. */
  20772. get leftController(): Nullable<WebVRController>;
  20773. private _rightController;
  20774. /**
  20775. * The controller corresponding to the users right hand.
  20776. */
  20777. get rightController(): Nullable<WebVRController>;
  20778. /**
  20779. * Casts a ray forward from the vrCamera's gaze.
  20780. * @param length Length of the ray (default: 100)
  20781. * @returns the ray corresponding to the gaze
  20782. */
  20783. getForwardRay(length?: number): Ray;
  20784. /**
  20785. * @hidden
  20786. * Updates the camera based on device's frame data
  20787. */
  20788. _checkInputs(): void;
  20789. /**
  20790. * Updates the poseControlled values based on the input device pose.
  20791. * @param poseData Pose coming from the device
  20792. */
  20793. updateFromDevice(poseData: DevicePose): void;
  20794. private _htmlElementAttached;
  20795. private _detachIfAttached;
  20796. /**
  20797. * WebVR's attach control will start broadcasting frames to the device.
  20798. * Note that in certain browsers (chrome for example) this function must be called
  20799. * within a user-interaction callback. Example:
  20800. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20801. *
  20802. * @param element html element to attach the vrDevice to
  20803. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20804. */
  20805. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20806. /**
  20807. * Detaches the camera from the html element and disables VR
  20808. *
  20809. * @param element html element to detach from
  20810. */
  20811. detachControl(element: HTMLElement): void;
  20812. /**
  20813. * @returns the name of this class
  20814. */
  20815. getClassName(): string;
  20816. /**
  20817. * Calls resetPose on the vrDisplay
  20818. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20819. */
  20820. resetToCurrentRotation(): void;
  20821. /**
  20822. * @hidden
  20823. * Updates the rig cameras (left and right eye)
  20824. */
  20825. _updateRigCameras(): void;
  20826. private _workingVector;
  20827. private _oneVector;
  20828. private _workingMatrix;
  20829. private updateCacheCalled;
  20830. private _correctPositionIfNotTrackPosition;
  20831. /**
  20832. * @hidden
  20833. * Updates the cached values of the camera
  20834. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20835. */
  20836. _updateCache(ignoreParentClass?: boolean): void;
  20837. /**
  20838. * @hidden
  20839. * Get current device position in babylon world
  20840. */
  20841. _computeDevicePosition(): void;
  20842. /**
  20843. * Updates the current device position and rotation in the babylon world
  20844. */
  20845. update(): void;
  20846. /**
  20847. * @hidden
  20848. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20849. * @returns an identity matrix
  20850. */
  20851. _getViewMatrix(): Matrix;
  20852. private _tmpMatrix;
  20853. /**
  20854. * This function is called by the two RIG cameras.
  20855. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20856. * @hidden
  20857. */
  20858. _getWebVRViewMatrix(): Matrix;
  20859. /** @hidden */
  20860. _getWebVRProjectionMatrix(): Matrix;
  20861. private _onGamepadConnectedObserver;
  20862. private _onGamepadDisconnectedObserver;
  20863. private _updateCacheWhenTrackingDisabledObserver;
  20864. /**
  20865. * Initializes the controllers and their meshes
  20866. */
  20867. initControllers(): void;
  20868. }
  20869. }
  20870. declare module "babylonjs/Materials/materialHelper" {
  20871. import { Nullable } from "babylonjs/types";
  20872. import { Scene } from "babylonjs/scene";
  20873. import { Engine } from "babylonjs/Engines/engine";
  20874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20875. import { Light } from "babylonjs/Lights/light";
  20876. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20877. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20878. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20879. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20880. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20881. /**
  20882. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20883. *
  20884. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20885. *
  20886. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20887. */
  20888. export class MaterialHelper {
  20889. /**
  20890. * Bind the current view position to an effect.
  20891. * @param effect The effect to be bound
  20892. * @param scene The scene the eyes position is used from
  20893. * @param variableName name of the shader variable that will hold the eye position
  20894. */
  20895. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20896. /**
  20897. * Helps preparing the defines values about the UVs in used in the effect.
  20898. * UVs are shared as much as we can accross channels in the shaders.
  20899. * @param texture The texture we are preparing the UVs for
  20900. * @param defines The defines to update
  20901. * @param key The channel key "diffuse", "specular"... used in the shader
  20902. */
  20903. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20904. /**
  20905. * Binds a texture matrix value to its corrsponding uniform
  20906. * @param texture The texture to bind the matrix for
  20907. * @param uniformBuffer The uniform buffer receivin the data
  20908. * @param key The channel key "diffuse", "specular"... used in the shader
  20909. */
  20910. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20911. /**
  20912. * Gets the current status of the fog (should it be enabled?)
  20913. * @param mesh defines the mesh to evaluate for fog support
  20914. * @param scene defines the hosting scene
  20915. * @returns true if fog must be enabled
  20916. */
  20917. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20918. /**
  20919. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20920. * @param mesh defines the current mesh
  20921. * @param scene defines the current scene
  20922. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20923. * @param pointsCloud defines if point cloud rendering has to be turned on
  20924. * @param fogEnabled defines if fog has to be turned on
  20925. * @param alphaTest defines if alpha testing has to be turned on
  20926. * @param defines defines the current list of defines
  20927. */
  20928. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20929. /**
  20930. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20931. * @param scene defines the current scene
  20932. * @param engine defines the current engine
  20933. * @param defines specifies the list of active defines
  20934. * @param useInstances defines if instances have to be turned on
  20935. * @param useClipPlane defines if clip plane have to be turned on
  20936. * @param useInstances defines if instances have to be turned on
  20937. * @param useThinInstances defines if thin instances have to be turned on
  20938. */
  20939. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20940. /**
  20941. * Prepares the defines for bones
  20942. * @param mesh The mesh containing the geometry data we will draw
  20943. * @param defines The defines to update
  20944. */
  20945. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20946. /**
  20947. * Prepares the defines for morph targets
  20948. * @param mesh The mesh containing the geometry data we will draw
  20949. * @param defines The defines to update
  20950. */
  20951. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20952. /**
  20953. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20954. * @param mesh The mesh containing the geometry data we will draw
  20955. * @param defines The defines to update
  20956. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20957. * @param useBones Precise whether bones should be used or not (override mesh info)
  20958. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20959. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20960. * @returns false if defines are considered not dirty and have not been checked
  20961. */
  20962. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20963. /**
  20964. * Prepares the defines related to multiview
  20965. * @param scene The scene we are intending to draw
  20966. * @param defines The defines to update
  20967. */
  20968. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20969. /**
  20970. * Prepares the defines related to the prepass
  20971. * @param scene The scene we are intending to draw
  20972. * @param defines The defines to update
  20973. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20974. */
  20975. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20976. /**
  20977. * Prepares the defines related to the light information passed in parameter
  20978. * @param scene The scene we are intending to draw
  20979. * @param mesh The mesh the effect is compiling for
  20980. * @param light The light the effect is compiling for
  20981. * @param lightIndex The index of the light
  20982. * @param defines The defines to update
  20983. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20984. * @param state Defines the current state regarding what is needed (normals, etc...)
  20985. */
  20986. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20987. needNormals: boolean;
  20988. needRebuild: boolean;
  20989. shadowEnabled: boolean;
  20990. specularEnabled: boolean;
  20991. lightmapMode: boolean;
  20992. }): void;
  20993. /**
  20994. * Prepares the defines related to the light information passed in parameter
  20995. * @param scene The scene we are intending to draw
  20996. * @param mesh The mesh the effect is compiling for
  20997. * @param defines The defines to update
  20998. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20999. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21000. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21001. * @returns true if normals will be required for the rest of the effect
  21002. */
  21003. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21004. /**
  21005. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21006. * @param lightIndex defines the light index
  21007. * @param uniformsList The uniform list
  21008. * @param samplersList The sampler list
  21009. * @param projectedLightTexture defines if projected texture must be used
  21010. * @param uniformBuffersList defines an optional list of uniform buffers
  21011. */
  21012. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21013. /**
  21014. * Prepares the uniforms and samplers list to be used in the effect
  21015. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21016. * @param samplersList The sampler list
  21017. * @param defines The defines helping in the list generation
  21018. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21019. */
  21020. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21021. /**
  21022. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21023. * @param defines The defines to update while falling back
  21024. * @param fallbacks The authorized effect fallbacks
  21025. * @param maxSimultaneousLights The maximum number of lights allowed
  21026. * @param rank the current rank of the Effect
  21027. * @returns The newly affected rank
  21028. */
  21029. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21030. private static _TmpMorphInfluencers;
  21031. /**
  21032. * Prepares the list of attributes required for morph targets according to the effect defines.
  21033. * @param attribs The current list of supported attribs
  21034. * @param mesh The mesh to prepare the morph targets attributes for
  21035. * @param influencers The number of influencers
  21036. */
  21037. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21038. /**
  21039. * Prepares the list of attributes required for morph targets according to the effect defines.
  21040. * @param attribs The current list of supported attribs
  21041. * @param mesh The mesh to prepare the morph targets attributes for
  21042. * @param defines The current Defines of the effect
  21043. */
  21044. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21045. /**
  21046. * Prepares the list of attributes required for bones according to the effect defines.
  21047. * @param attribs The current list of supported attribs
  21048. * @param mesh The mesh to prepare the bones attributes for
  21049. * @param defines The current Defines of the effect
  21050. * @param fallbacks The current efffect fallback strategy
  21051. */
  21052. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21053. /**
  21054. * Check and prepare the list of attributes required for instances according to the effect defines.
  21055. * @param attribs The current list of supported attribs
  21056. * @param defines The current MaterialDefines of the effect
  21057. */
  21058. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21059. /**
  21060. * Add the list of attributes required for instances to the attribs array.
  21061. * @param attribs The current list of supported attribs
  21062. */
  21063. static PushAttributesForInstances(attribs: string[]): void;
  21064. /**
  21065. * Binds the light information to the effect.
  21066. * @param light The light containing the generator
  21067. * @param effect The effect we are binding the data to
  21068. * @param lightIndex The light index in the effect used to render
  21069. */
  21070. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21071. /**
  21072. * Binds the lights information from the scene to the effect for the given mesh.
  21073. * @param light Light to bind
  21074. * @param lightIndex Light index
  21075. * @param scene The scene where the light belongs to
  21076. * @param effect The effect we are binding the data to
  21077. * @param useSpecular Defines if specular is supported
  21078. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21079. */
  21080. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21081. /**
  21082. * Binds the lights information from the scene to the effect for the given mesh.
  21083. * @param scene The scene the lights belongs to
  21084. * @param mesh The mesh we are binding the information to render
  21085. * @param effect The effect we are binding the data to
  21086. * @param defines The generated defines for the effect
  21087. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21088. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21089. */
  21090. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21091. private static _tempFogColor;
  21092. /**
  21093. * Binds the fog information from the scene to the effect for the given mesh.
  21094. * @param scene The scene the lights belongs to
  21095. * @param mesh The mesh we are binding the information to render
  21096. * @param effect The effect we are binding the data to
  21097. * @param linearSpace Defines if the fog effect is applied in linear space
  21098. */
  21099. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21100. /**
  21101. * Binds the bones information from the mesh to the effect.
  21102. * @param mesh The mesh we are binding the information to render
  21103. * @param effect The effect we are binding the data to
  21104. */
  21105. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  21106. /**
  21107. * Binds the morph targets information from the mesh to the effect.
  21108. * @param abstractMesh The mesh we are binding the information to render
  21109. * @param effect The effect we are binding the data to
  21110. */
  21111. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21112. /**
  21113. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21114. * @param defines The generated defines used in the effect
  21115. * @param effect The effect we are binding the data to
  21116. * @param scene The scene we are willing to render with logarithmic scale for
  21117. */
  21118. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21119. /**
  21120. * Binds the clip plane information from the scene to the effect.
  21121. * @param scene The scene the clip plane information are extracted from
  21122. * @param effect The effect we are binding the data to
  21123. */
  21124. static BindClipPlane(effect: Effect, scene: Scene): void;
  21125. }
  21126. }
  21127. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21129. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21130. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21131. import { Nullable } from "babylonjs/types";
  21132. import { Effect } from "babylonjs/Materials/effect";
  21133. import { Matrix } from "babylonjs/Maths/math.vector";
  21134. import { Scene } from "babylonjs/scene";
  21135. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21136. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21137. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21138. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21139. import { Observable } from "babylonjs/Misc/observable";
  21140. /**
  21141. * Block used to expose an input value
  21142. */
  21143. export class InputBlock extends NodeMaterialBlock {
  21144. private _mode;
  21145. private _associatedVariableName;
  21146. private _storedValue;
  21147. private _valueCallback;
  21148. private _type;
  21149. private _animationType;
  21150. /** Gets or set a value used to limit the range of float values */
  21151. min: number;
  21152. /** Gets or set a value used to limit the range of float values */
  21153. max: number;
  21154. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21155. isBoolean: boolean;
  21156. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21157. matrixMode: number;
  21158. /** @hidden */
  21159. _systemValue: Nullable<NodeMaterialSystemValues>;
  21160. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21161. isConstant: boolean;
  21162. /** Gets or sets the group to use to display this block in the Inspector */
  21163. groupInInspector: string;
  21164. /** Gets an observable raised when the value is changed */
  21165. onValueChangedObservable: Observable<InputBlock>;
  21166. /**
  21167. * Gets or sets the connection point type (default is float)
  21168. */
  21169. get type(): NodeMaterialBlockConnectionPointTypes;
  21170. /**
  21171. * Creates a new InputBlock
  21172. * @param name defines the block name
  21173. * @param target defines the target of that block (Vertex by default)
  21174. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21175. */
  21176. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21177. /**
  21178. * Validates if a name is a reserve word.
  21179. * @param newName the new name to be given to the node.
  21180. * @returns false if the name is a reserve word, else true.
  21181. */
  21182. validateBlockName(newName: string): boolean;
  21183. /**
  21184. * Gets the output component
  21185. */
  21186. get output(): NodeMaterialConnectionPoint;
  21187. /**
  21188. * Set the source of this connection point to a vertex attribute
  21189. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21190. * @returns the current connection point
  21191. */
  21192. setAsAttribute(attributeName?: string): InputBlock;
  21193. /**
  21194. * Set the source of this connection point to a system value
  21195. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21196. * @returns the current connection point
  21197. */
  21198. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21199. /**
  21200. * Gets or sets the value of that point.
  21201. * Please note that this value will be ignored if valueCallback is defined
  21202. */
  21203. get value(): any;
  21204. set value(value: any);
  21205. /**
  21206. * Gets or sets a callback used to get the value of that point.
  21207. * Please note that setting this value will force the connection point to ignore the value property
  21208. */
  21209. get valueCallback(): () => any;
  21210. set valueCallback(value: () => any);
  21211. /**
  21212. * Gets or sets the associated variable name in the shader
  21213. */
  21214. get associatedVariableName(): string;
  21215. set associatedVariableName(value: string);
  21216. /** Gets or sets the type of animation applied to the input */
  21217. get animationType(): AnimatedInputBlockTypes;
  21218. set animationType(value: AnimatedInputBlockTypes);
  21219. /**
  21220. * Gets a boolean indicating that this connection point not defined yet
  21221. */
  21222. get isUndefined(): boolean;
  21223. /**
  21224. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21225. * In this case the connection point name must be the name of the uniform to use.
  21226. * Can only be set on inputs
  21227. */
  21228. get isUniform(): boolean;
  21229. set isUniform(value: boolean);
  21230. /**
  21231. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21232. * In this case the connection point name must be the name of the attribute to use
  21233. * Can only be set on inputs
  21234. */
  21235. get isAttribute(): boolean;
  21236. set isAttribute(value: boolean);
  21237. /**
  21238. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21239. * Can only be set on exit points
  21240. */
  21241. get isVarying(): boolean;
  21242. set isVarying(value: boolean);
  21243. /**
  21244. * Gets a boolean indicating that the current connection point is a system value
  21245. */
  21246. get isSystemValue(): boolean;
  21247. /**
  21248. * Gets or sets the current well known value or null if not defined as a system value
  21249. */
  21250. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21251. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21252. /**
  21253. * Gets the current class name
  21254. * @returns the class name
  21255. */
  21256. getClassName(): string;
  21257. /**
  21258. * Animate the input if animationType !== None
  21259. * @param scene defines the rendering scene
  21260. */
  21261. animate(scene: Scene): void;
  21262. private _emitDefine;
  21263. initialize(state: NodeMaterialBuildState): void;
  21264. /**
  21265. * Set the input block to its default value (based on its type)
  21266. */
  21267. setDefaultValue(): void;
  21268. private _emitConstant;
  21269. /** @hidden */
  21270. get _noContextSwitch(): boolean;
  21271. private _emit;
  21272. /** @hidden */
  21273. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21274. /** @hidden */
  21275. _transmit(effect: Effect, scene: Scene): void;
  21276. protected _buildBlock(state: NodeMaterialBuildState): void;
  21277. protected _dumpPropertiesCode(): string;
  21278. dispose(): void;
  21279. serialize(): any;
  21280. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21281. }
  21282. }
  21283. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21284. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21285. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21286. import { Nullable } from "babylonjs/types";
  21287. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21288. import { Observable } from "babylonjs/Misc/observable";
  21289. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21290. /**
  21291. * Enum used to define the compatibility state between two connection points
  21292. */
  21293. export enum NodeMaterialConnectionPointCompatibilityStates {
  21294. /** Points are compatibles */
  21295. Compatible = 0,
  21296. /** Points are incompatible because of their types */
  21297. TypeIncompatible = 1,
  21298. /** Points are incompatible because of their targets (vertex vs fragment) */
  21299. TargetIncompatible = 2
  21300. }
  21301. /**
  21302. * Defines the direction of a connection point
  21303. */
  21304. export enum NodeMaterialConnectionPointDirection {
  21305. /** Input */
  21306. Input = 0,
  21307. /** Output */
  21308. Output = 1
  21309. }
  21310. /**
  21311. * Defines a connection point for a block
  21312. */
  21313. export class NodeMaterialConnectionPoint {
  21314. /** @hidden */
  21315. _ownerBlock: NodeMaterialBlock;
  21316. /** @hidden */
  21317. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21318. private _endpoints;
  21319. private _associatedVariableName;
  21320. private _direction;
  21321. /** @hidden */
  21322. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21323. /** @hidden */
  21324. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21325. private _type;
  21326. /** @hidden */
  21327. _enforceAssociatedVariableName: boolean;
  21328. /** Gets the direction of the point */
  21329. get direction(): NodeMaterialConnectionPointDirection;
  21330. /** Indicates that this connection point needs dual validation before being connected to another point */
  21331. needDualDirectionValidation: boolean;
  21332. /**
  21333. * Gets or sets the additional types supported by this connection point
  21334. */
  21335. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21336. /**
  21337. * Gets or sets the additional types excluded by this connection point
  21338. */
  21339. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21340. /**
  21341. * Observable triggered when this point is connected
  21342. */
  21343. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21344. /**
  21345. * Gets or sets the associated variable name in the shader
  21346. */
  21347. get associatedVariableName(): string;
  21348. set associatedVariableName(value: string);
  21349. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21350. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21351. /**
  21352. * Gets or sets the connection point type (default is float)
  21353. */
  21354. get type(): NodeMaterialBlockConnectionPointTypes;
  21355. set type(value: NodeMaterialBlockConnectionPointTypes);
  21356. /**
  21357. * Gets or sets the connection point name
  21358. */
  21359. name: string;
  21360. /**
  21361. * Gets or sets the connection point name
  21362. */
  21363. displayName: string;
  21364. /**
  21365. * Gets or sets a boolean indicating that this connection point can be omitted
  21366. */
  21367. isOptional: boolean;
  21368. /**
  21369. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21370. */
  21371. isExposedOnFrame: boolean;
  21372. /**
  21373. * Gets or sets number indicating the position that the port is exposed to on a frame
  21374. */
  21375. exposedPortPosition: number;
  21376. /**
  21377. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21378. */
  21379. define: string;
  21380. /** @hidden */
  21381. _prioritizeVertex: boolean;
  21382. private _target;
  21383. /** Gets or sets the target of that connection point */
  21384. get target(): NodeMaterialBlockTargets;
  21385. set target(value: NodeMaterialBlockTargets);
  21386. /**
  21387. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21388. */
  21389. get isConnected(): boolean;
  21390. /**
  21391. * Gets a boolean indicating that the current point is connected to an input block
  21392. */
  21393. get isConnectedToInputBlock(): boolean;
  21394. /**
  21395. * Gets a the connected input block (if any)
  21396. */
  21397. get connectInputBlock(): Nullable<InputBlock>;
  21398. /** Get the other side of the connection (if any) */
  21399. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21400. /** Get the block that owns this connection point */
  21401. get ownerBlock(): NodeMaterialBlock;
  21402. /** Get the block connected on the other side of this connection (if any) */
  21403. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21404. /** Get the block connected on the endpoints of this connection (if any) */
  21405. get connectedBlocks(): Array<NodeMaterialBlock>;
  21406. /** Gets the list of connected endpoints */
  21407. get endpoints(): NodeMaterialConnectionPoint[];
  21408. /** Gets a boolean indicating if that output point is connected to at least one input */
  21409. get hasEndpoints(): boolean;
  21410. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21411. get isConnectedInVertexShader(): boolean;
  21412. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21413. get isConnectedInFragmentShader(): boolean;
  21414. /**
  21415. * Creates a block suitable to be used as an input for this input point.
  21416. * If null is returned, a block based on the point type will be created.
  21417. * @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
  21418. */
  21419. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21420. /**
  21421. * Creates a new connection point
  21422. * @param name defines the connection point name
  21423. * @param ownerBlock defines the block hosting this connection point
  21424. * @param direction defines the direction of the connection point
  21425. */
  21426. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21427. /**
  21428. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21429. * @returns the class name
  21430. */
  21431. getClassName(): string;
  21432. /**
  21433. * Gets a boolean indicating if the current point can be connected to another point
  21434. * @param connectionPoint defines the other connection point
  21435. * @returns a boolean
  21436. */
  21437. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21438. /**
  21439. * Gets a number indicating if the current point can be connected to another point
  21440. * @param connectionPoint defines the other connection point
  21441. * @returns a number defining the compatibility state
  21442. */
  21443. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21444. /**
  21445. * Connect this point to another connection point
  21446. * @param connectionPoint defines the other connection point
  21447. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21448. * @returns the current connection point
  21449. */
  21450. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21451. /**
  21452. * Disconnect this point from one of his endpoint
  21453. * @param endpoint defines the other connection point
  21454. * @returns the current connection point
  21455. */
  21456. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21457. /**
  21458. * Serializes this point in a JSON representation
  21459. * @param isInput defines if the connection point is an input (default is true)
  21460. * @returns the serialized point object
  21461. */
  21462. serialize(isInput?: boolean): any;
  21463. /**
  21464. * Release resources
  21465. */
  21466. dispose(): void;
  21467. }
  21468. }
  21469. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21470. /**
  21471. * Enum used to define the material modes
  21472. */
  21473. export enum NodeMaterialModes {
  21474. /** Regular material */
  21475. Material = 0,
  21476. /** For post process */
  21477. PostProcess = 1,
  21478. /** For particle system */
  21479. Particle = 2,
  21480. /** For procedural texture */
  21481. ProceduralTexture = 3
  21482. }
  21483. }
  21484. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21485. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21486. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21487. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21488. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21490. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21491. import { Effect } from "babylonjs/Materials/effect";
  21492. import { Mesh } from "babylonjs/Meshes/mesh";
  21493. import { Nullable } from "babylonjs/types";
  21494. import { Texture } from "babylonjs/Materials/Textures/texture";
  21495. import { Scene } from "babylonjs/scene";
  21496. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21497. /**
  21498. * Block used to read a texture from a sampler
  21499. */
  21500. export class TextureBlock extends NodeMaterialBlock {
  21501. private _defineName;
  21502. private _linearDefineName;
  21503. private _gammaDefineName;
  21504. private _tempTextureRead;
  21505. private _samplerName;
  21506. private _transformedUVName;
  21507. private _textureTransformName;
  21508. private _textureInfoName;
  21509. private _mainUVName;
  21510. private _mainUVDefineName;
  21511. private _fragmentOnly;
  21512. /**
  21513. * Gets or sets the texture associated with the node
  21514. */
  21515. texture: Nullable<Texture>;
  21516. /**
  21517. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21518. */
  21519. convertToGammaSpace: boolean;
  21520. /**
  21521. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21522. */
  21523. convertToLinearSpace: boolean;
  21524. /**
  21525. * Create a new TextureBlock
  21526. * @param name defines the block name
  21527. */
  21528. constructor(name: string, fragmentOnly?: boolean);
  21529. /**
  21530. * Gets the current class name
  21531. * @returns the class name
  21532. */
  21533. getClassName(): string;
  21534. /**
  21535. * Gets the uv input component
  21536. */
  21537. get uv(): NodeMaterialConnectionPoint;
  21538. /**
  21539. * Gets the rgba output component
  21540. */
  21541. get rgba(): NodeMaterialConnectionPoint;
  21542. /**
  21543. * Gets the rgb output component
  21544. */
  21545. get rgb(): NodeMaterialConnectionPoint;
  21546. /**
  21547. * Gets the r output component
  21548. */
  21549. get r(): NodeMaterialConnectionPoint;
  21550. /**
  21551. * Gets the g output component
  21552. */
  21553. get g(): NodeMaterialConnectionPoint;
  21554. /**
  21555. * Gets the b output component
  21556. */
  21557. get b(): NodeMaterialConnectionPoint;
  21558. /**
  21559. * Gets the a output component
  21560. */
  21561. get a(): NodeMaterialConnectionPoint;
  21562. get target(): NodeMaterialBlockTargets;
  21563. autoConfigure(material: NodeMaterial): void;
  21564. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21565. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21566. isReady(): boolean;
  21567. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21568. private get _isMixed();
  21569. private _injectVertexCode;
  21570. private _writeTextureRead;
  21571. private _writeOutput;
  21572. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21573. protected _dumpPropertiesCode(): string;
  21574. serialize(): any;
  21575. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21576. }
  21577. }
  21578. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21579. /** @hidden */
  21580. export var reflectionFunction: {
  21581. name: string;
  21582. shader: string;
  21583. };
  21584. }
  21585. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21586. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21587. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21588. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21589. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21591. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21592. import { Effect } from "babylonjs/Materials/effect";
  21593. import { Mesh } from "babylonjs/Meshes/mesh";
  21594. import { Nullable } from "babylonjs/types";
  21595. import { Scene } from "babylonjs/scene";
  21596. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21597. /**
  21598. * Base block used to read a reflection texture from a sampler
  21599. */
  21600. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21601. /** @hidden */
  21602. _define3DName: string;
  21603. /** @hidden */
  21604. _defineCubicName: string;
  21605. /** @hidden */
  21606. _defineExplicitName: string;
  21607. /** @hidden */
  21608. _defineProjectionName: string;
  21609. /** @hidden */
  21610. _defineLocalCubicName: string;
  21611. /** @hidden */
  21612. _defineSphericalName: string;
  21613. /** @hidden */
  21614. _definePlanarName: string;
  21615. /** @hidden */
  21616. _defineEquirectangularName: string;
  21617. /** @hidden */
  21618. _defineMirroredEquirectangularFixedName: string;
  21619. /** @hidden */
  21620. _defineEquirectangularFixedName: string;
  21621. /** @hidden */
  21622. _defineSkyboxName: string;
  21623. /** @hidden */
  21624. _defineOppositeZ: string;
  21625. /** @hidden */
  21626. _cubeSamplerName: string;
  21627. /** @hidden */
  21628. _2DSamplerName: string;
  21629. protected _positionUVWName: string;
  21630. protected _directionWName: string;
  21631. protected _reflectionVectorName: string;
  21632. /** @hidden */
  21633. _reflectionCoordsName: string;
  21634. /** @hidden */
  21635. _reflectionMatrixName: string;
  21636. protected _reflectionColorName: string;
  21637. /**
  21638. * Gets or sets the texture associated with the node
  21639. */
  21640. texture: Nullable<BaseTexture>;
  21641. /**
  21642. * Create a new ReflectionTextureBaseBlock
  21643. * @param name defines the block name
  21644. */
  21645. constructor(name: string);
  21646. /**
  21647. * Gets the current class name
  21648. * @returns the class name
  21649. */
  21650. getClassName(): string;
  21651. /**
  21652. * Gets the world position input component
  21653. */
  21654. abstract get position(): NodeMaterialConnectionPoint;
  21655. /**
  21656. * Gets the world position input component
  21657. */
  21658. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21659. /**
  21660. * Gets the world normal input component
  21661. */
  21662. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21663. /**
  21664. * Gets the world input component
  21665. */
  21666. abstract get world(): NodeMaterialConnectionPoint;
  21667. /**
  21668. * Gets the camera (or eye) position component
  21669. */
  21670. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21671. /**
  21672. * Gets the view input component
  21673. */
  21674. abstract get view(): NodeMaterialConnectionPoint;
  21675. protected _getTexture(): Nullable<BaseTexture>;
  21676. autoConfigure(material: NodeMaterial): void;
  21677. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21678. isReady(): boolean;
  21679. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21680. /**
  21681. * Gets the code to inject in the vertex shader
  21682. * @param state current state of the node material building
  21683. * @returns the shader code
  21684. */
  21685. handleVertexSide(state: NodeMaterialBuildState): string;
  21686. /**
  21687. * Handles the inits for the fragment code path
  21688. * @param state node material build state
  21689. */
  21690. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21691. /**
  21692. * Generates the reflection coords code for the fragment code path
  21693. * @param worldNormalVarName name of the world normal variable
  21694. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21695. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21696. * @returns the shader code
  21697. */
  21698. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21699. /**
  21700. * Generates the reflection color code for the fragment code path
  21701. * @param lodVarName name of the lod variable
  21702. * @param swizzleLookupTexture swizzle to use for the final color variable
  21703. * @returns the shader code
  21704. */
  21705. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21706. /**
  21707. * Generates the code corresponding to the connected output points
  21708. * @param state node material build state
  21709. * @param varName name of the variable to output
  21710. * @returns the shader code
  21711. */
  21712. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21713. protected _buildBlock(state: NodeMaterialBuildState): this;
  21714. protected _dumpPropertiesCode(): string;
  21715. serialize(): any;
  21716. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21717. }
  21718. }
  21719. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21720. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21721. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21722. import { Nullable } from "babylonjs/types";
  21723. /**
  21724. * Defines a connection point to be used for points with a custom object type
  21725. */
  21726. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21727. private _blockType;
  21728. private _blockName;
  21729. private _nameForCheking?;
  21730. /**
  21731. * Creates a new connection point
  21732. * @param name defines the connection point name
  21733. * @param ownerBlock defines the block hosting this connection point
  21734. * @param direction defines the direction of the connection point
  21735. */
  21736. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21737. /**
  21738. * Gets a number indicating if the current point can be connected to another point
  21739. * @param connectionPoint defines the other connection point
  21740. * @returns a number defining the compatibility state
  21741. */
  21742. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21743. /**
  21744. * Creates a block suitable to be used as an input for this input point.
  21745. * If null is returned, a block based on the point type will be created.
  21746. * @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
  21747. */
  21748. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21749. }
  21750. }
  21751. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21752. /**
  21753. * Enum defining the type of properties that can be edited in the property pages in the NME
  21754. */
  21755. export enum PropertyTypeForEdition {
  21756. /** property is a boolean */
  21757. Boolean = 0,
  21758. /** property is a float */
  21759. Float = 1,
  21760. /** property is a Vector2 */
  21761. Vector2 = 2,
  21762. /** property is a list of values */
  21763. List = 3
  21764. }
  21765. /**
  21766. * Interface that defines an option in a variable of type list
  21767. */
  21768. export interface IEditablePropertyListOption {
  21769. /** label of the option */
  21770. "label": string;
  21771. /** value of the option */
  21772. "value": number;
  21773. }
  21774. /**
  21775. * Interface that defines the options available for an editable property
  21776. */
  21777. export interface IEditablePropertyOption {
  21778. /** min value */
  21779. "min"?: number;
  21780. /** max value */
  21781. "max"?: number;
  21782. /** notifiers: indicates which actions to take when the property is changed */
  21783. "notifiers"?: {
  21784. /** the material should be rebuilt */
  21785. "rebuild"?: boolean;
  21786. /** the preview should be updated */
  21787. "update"?: boolean;
  21788. };
  21789. /** list of the options for a variable of type list */
  21790. "options"?: IEditablePropertyListOption[];
  21791. }
  21792. /**
  21793. * Interface that describes an editable property
  21794. */
  21795. export interface IPropertyDescriptionForEdition {
  21796. /** name of the property */
  21797. "propertyName": string;
  21798. /** display name of the property */
  21799. "displayName": string;
  21800. /** type of the property */
  21801. "type": PropertyTypeForEdition;
  21802. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21803. "groupName": string;
  21804. /** options for the property */
  21805. "options": IEditablePropertyOption;
  21806. }
  21807. /**
  21808. * Decorator that flags a property in a node material block as being editable
  21809. */
  21810. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21811. }
  21812. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21813. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21814. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21815. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21817. import { Nullable } from "babylonjs/types";
  21818. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21819. import { Mesh } from "babylonjs/Meshes/mesh";
  21820. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21821. import { Effect } from "babylonjs/Materials/effect";
  21822. import { Scene } from "babylonjs/scene";
  21823. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21824. /**
  21825. * Block used to implement the refraction part of the sub surface module of the PBR material
  21826. */
  21827. export class RefractionBlock extends NodeMaterialBlock {
  21828. /** @hidden */
  21829. _define3DName: string;
  21830. /** @hidden */
  21831. _refractionMatrixName: string;
  21832. /** @hidden */
  21833. _defineLODRefractionAlpha: string;
  21834. /** @hidden */
  21835. _defineLinearSpecularRefraction: string;
  21836. /** @hidden */
  21837. _defineOppositeZ: string;
  21838. /** @hidden */
  21839. _cubeSamplerName: string;
  21840. /** @hidden */
  21841. _2DSamplerName: string;
  21842. /** @hidden */
  21843. _vRefractionMicrosurfaceInfosName: string;
  21844. /** @hidden */
  21845. _vRefractionInfosName: string;
  21846. private _scene;
  21847. /**
  21848. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21849. * Materials half opaque for instance using refraction could benefit from this control.
  21850. */
  21851. linkRefractionWithTransparency: boolean;
  21852. /**
  21853. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21854. */
  21855. invertRefractionY: boolean;
  21856. /**
  21857. * Gets or sets the texture associated with the node
  21858. */
  21859. texture: Nullable<BaseTexture>;
  21860. /**
  21861. * Create a new RefractionBlock
  21862. * @param name defines the block name
  21863. */
  21864. constructor(name: string);
  21865. /**
  21866. * Gets the current class name
  21867. * @returns the class name
  21868. */
  21869. getClassName(): string;
  21870. /**
  21871. * Gets the intensity input component
  21872. */
  21873. get intensity(): NodeMaterialConnectionPoint;
  21874. /**
  21875. * Gets the index of refraction input component
  21876. */
  21877. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21878. /**
  21879. * Gets the tint at distance input component
  21880. */
  21881. get tintAtDistance(): NodeMaterialConnectionPoint;
  21882. /**
  21883. * Gets the view input component
  21884. */
  21885. get view(): NodeMaterialConnectionPoint;
  21886. /**
  21887. * Gets the refraction object output component
  21888. */
  21889. get refraction(): NodeMaterialConnectionPoint;
  21890. /**
  21891. * Returns true if the block has a texture
  21892. */
  21893. get hasTexture(): boolean;
  21894. protected _getTexture(): Nullable<BaseTexture>;
  21895. autoConfigure(material: NodeMaterial): void;
  21896. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21897. isReady(): boolean;
  21898. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21899. /**
  21900. * Gets the main code of the block (fragment side)
  21901. * @param state current state of the node material building
  21902. * @returns the shader code
  21903. */
  21904. getCode(state: NodeMaterialBuildState): string;
  21905. protected _buildBlock(state: NodeMaterialBuildState): this;
  21906. protected _dumpPropertiesCode(): string;
  21907. serialize(): any;
  21908. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21909. }
  21910. }
  21911. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21912. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21913. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21914. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21915. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21917. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21918. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21919. import { Nullable } from "babylonjs/types";
  21920. import { Scene } from "babylonjs/scene";
  21921. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21922. /**
  21923. * Base block used as input for post process
  21924. */
  21925. export class CurrentScreenBlock extends NodeMaterialBlock {
  21926. private _samplerName;
  21927. private _linearDefineName;
  21928. private _gammaDefineName;
  21929. private _mainUVName;
  21930. private _tempTextureRead;
  21931. /**
  21932. * Gets or sets the texture associated with the node
  21933. */
  21934. texture: Nullable<BaseTexture>;
  21935. /**
  21936. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21937. */
  21938. convertToGammaSpace: boolean;
  21939. /**
  21940. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21941. */
  21942. convertToLinearSpace: boolean;
  21943. /**
  21944. * Create a new CurrentScreenBlock
  21945. * @param name defines the block name
  21946. */
  21947. constructor(name: string);
  21948. /**
  21949. * Gets the current class name
  21950. * @returns the class name
  21951. */
  21952. getClassName(): string;
  21953. /**
  21954. * Gets the uv input component
  21955. */
  21956. get uv(): NodeMaterialConnectionPoint;
  21957. /**
  21958. * Gets the rgba output component
  21959. */
  21960. get rgba(): NodeMaterialConnectionPoint;
  21961. /**
  21962. * Gets the rgb output component
  21963. */
  21964. get rgb(): NodeMaterialConnectionPoint;
  21965. /**
  21966. * Gets the r output component
  21967. */
  21968. get r(): NodeMaterialConnectionPoint;
  21969. /**
  21970. * Gets the g output component
  21971. */
  21972. get g(): NodeMaterialConnectionPoint;
  21973. /**
  21974. * Gets the b output component
  21975. */
  21976. get b(): NodeMaterialConnectionPoint;
  21977. /**
  21978. * Gets the a output component
  21979. */
  21980. get a(): NodeMaterialConnectionPoint;
  21981. /**
  21982. * Initialize the block and prepare the context for build
  21983. * @param state defines the state that will be used for the build
  21984. */
  21985. initialize(state: NodeMaterialBuildState): void;
  21986. get target(): NodeMaterialBlockTargets;
  21987. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21988. isReady(): boolean;
  21989. private _injectVertexCode;
  21990. private _writeTextureRead;
  21991. private _writeOutput;
  21992. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21993. serialize(): any;
  21994. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21995. }
  21996. }
  21997. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21999. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22000. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22002. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22003. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22004. import { Nullable } from "babylonjs/types";
  22005. import { Scene } from "babylonjs/scene";
  22006. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22007. /**
  22008. * Base block used for the particle texture
  22009. */
  22010. export class ParticleTextureBlock extends NodeMaterialBlock {
  22011. private _samplerName;
  22012. private _linearDefineName;
  22013. private _gammaDefineName;
  22014. private _tempTextureRead;
  22015. /**
  22016. * Gets or sets the texture associated with the node
  22017. */
  22018. texture: Nullable<BaseTexture>;
  22019. /**
  22020. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22021. */
  22022. convertToGammaSpace: boolean;
  22023. /**
  22024. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22025. */
  22026. convertToLinearSpace: boolean;
  22027. /**
  22028. * Create a new ParticleTextureBlock
  22029. * @param name defines the block name
  22030. */
  22031. constructor(name: string);
  22032. /**
  22033. * Gets the current class name
  22034. * @returns the class name
  22035. */
  22036. getClassName(): string;
  22037. /**
  22038. * Gets the uv input component
  22039. */
  22040. get uv(): NodeMaterialConnectionPoint;
  22041. /**
  22042. * Gets the rgba output component
  22043. */
  22044. get rgba(): NodeMaterialConnectionPoint;
  22045. /**
  22046. * Gets the rgb output component
  22047. */
  22048. get rgb(): NodeMaterialConnectionPoint;
  22049. /**
  22050. * Gets the r output component
  22051. */
  22052. get r(): NodeMaterialConnectionPoint;
  22053. /**
  22054. * Gets the g output component
  22055. */
  22056. get g(): NodeMaterialConnectionPoint;
  22057. /**
  22058. * Gets the b output component
  22059. */
  22060. get b(): NodeMaterialConnectionPoint;
  22061. /**
  22062. * Gets the a output component
  22063. */
  22064. get a(): NodeMaterialConnectionPoint;
  22065. /**
  22066. * Initialize the block and prepare the context for build
  22067. * @param state defines the state that will be used for the build
  22068. */
  22069. initialize(state: NodeMaterialBuildState): void;
  22070. autoConfigure(material: NodeMaterial): void;
  22071. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22072. isReady(): boolean;
  22073. private _writeOutput;
  22074. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22075. serialize(): any;
  22076. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22077. }
  22078. }
  22079. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22080. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22081. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22082. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22083. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22084. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22085. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22086. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22087. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22088. import { Scene } from "babylonjs/scene";
  22089. /**
  22090. * Class used to store shared data between 2 NodeMaterialBuildState
  22091. */
  22092. export class NodeMaterialBuildStateSharedData {
  22093. /**
  22094. * Gets the list of emitted varyings
  22095. */
  22096. temps: string[];
  22097. /**
  22098. * Gets the list of emitted varyings
  22099. */
  22100. varyings: string[];
  22101. /**
  22102. * Gets the varying declaration string
  22103. */
  22104. varyingDeclaration: string;
  22105. /**
  22106. * Input blocks
  22107. */
  22108. inputBlocks: InputBlock[];
  22109. /**
  22110. * Input blocks
  22111. */
  22112. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22113. /**
  22114. * Bindable blocks (Blocks that need to set data to the effect)
  22115. */
  22116. bindableBlocks: NodeMaterialBlock[];
  22117. /**
  22118. * List of blocks that can provide a compilation fallback
  22119. */
  22120. blocksWithFallbacks: NodeMaterialBlock[];
  22121. /**
  22122. * List of blocks that can provide a define update
  22123. */
  22124. blocksWithDefines: NodeMaterialBlock[];
  22125. /**
  22126. * List of blocks that can provide a repeatable content
  22127. */
  22128. repeatableContentBlocks: NodeMaterialBlock[];
  22129. /**
  22130. * List of blocks that can provide a dynamic list of uniforms
  22131. */
  22132. dynamicUniformBlocks: NodeMaterialBlock[];
  22133. /**
  22134. * List of blocks that can block the isReady function for the material
  22135. */
  22136. blockingBlocks: NodeMaterialBlock[];
  22137. /**
  22138. * Gets the list of animated inputs
  22139. */
  22140. animatedInputs: InputBlock[];
  22141. /**
  22142. * Build Id used to avoid multiple recompilations
  22143. */
  22144. buildId: number;
  22145. /** List of emitted variables */
  22146. variableNames: {
  22147. [key: string]: number;
  22148. };
  22149. /** List of emitted defines */
  22150. defineNames: {
  22151. [key: string]: number;
  22152. };
  22153. /** Should emit comments? */
  22154. emitComments: boolean;
  22155. /** Emit build activity */
  22156. verbose: boolean;
  22157. /** Gets or sets the hosting scene */
  22158. scene: Scene;
  22159. /**
  22160. * Gets the compilation hints emitted at compilation time
  22161. */
  22162. hints: {
  22163. needWorldViewMatrix: boolean;
  22164. needWorldViewProjectionMatrix: boolean;
  22165. needAlphaBlending: boolean;
  22166. needAlphaTesting: boolean;
  22167. };
  22168. /**
  22169. * List of compilation checks
  22170. */
  22171. checks: {
  22172. emitVertex: boolean;
  22173. emitFragment: boolean;
  22174. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22175. };
  22176. /**
  22177. * Is vertex program allowed to be empty?
  22178. */
  22179. allowEmptyVertexProgram: boolean;
  22180. /** Creates a new shared data */
  22181. constructor();
  22182. /**
  22183. * Emits console errors and exceptions if there is a failing check
  22184. */
  22185. emitErrors(): void;
  22186. }
  22187. }
  22188. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22189. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22190. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22191. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22192. /**
  22193. * Class used to store node based material build state
  22194. */
  22195. export class NodeMaterialBuildState {
  22196. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22197. supportUniformBuffers: boolean;
  22198. /**
  22199. * Gets the list of emitted attributes
  22200. */
  22201. attributes: string[];
  22202. /**
  22203. * Gets the list of emitted uniforms
  22204. */
  22205. uniforms: string[];
  22206. /**
  22207. * Gets the list of emitted constants
  22208. */
  22209. constants: string[];
  22210. /**
  22211. * Gets the list of emitted samplers
  22212. */
  22213. samplers: string[];
  22214. /**
  22215. * Gets the list of emitted functions
  22216. */
  22217. functions: {
  22218. [key: string]: string;
  22219. };
  22220. /**
  22221. * Gets the list of emitted extensions
  22222. */
  22223. extensions: {
  22224. [key: string]: string;
  22225. };
  22226. /**
  22227. * Gets the target of the compilation state
  22228. */
  22229. target: NodeMaterialBlockTargets;
  22230. /**
  22231. * Gets the list of emitted counters
  22232. */
  22233. counters: {
  22234. [key: string]: number;
  22235. };
  22236. /**
  22237. * Shared data between multiple NodeMaterialBuildState instances
  22238. */
  22239. sharedData: NodeMaterialBuildStateSharedData;
  22240. /** @hidden */
  22241. _vertexState: NodeMaterialBuildState;
  22242. /** @hidden */
  22243. _attributeDeclaration: string;
  22244. /** @hidden */
  22245. _uniformDeclaration: string;
  22246. /** @hidden */
  22247. _constantDeclaration: string;
  22248. /** @hidden */
  22249. _samplerDeclaration: string;
  22250. /** @hidden */
  22251. _varyingTransfer: string;
  22252. /** @hidden */
  22253. _injectAtEnd: string;
  22254. private _repeatableContentAnchorIndex;
  22255. /** @hidden */
  22256. _builtCompilationString: string;
  22257. /**
  22258. * Gets the emitted compilation strings
  22259. */
  22260. compilationString: string;
  22261. /**
  22262. * Finalize the compilation strings
  22263. * @param state defines the current compilation state
  22264. */
  22265. finalize(state: NodeMaterialBuildState): void;
  22266. /** @hidden */
  22267. get _repeatableContentAnchor(): string;
  22268. /** @hidden */
  22269. _getFreeVariableName(prefix: string): string;
  22270. /** @hidden */
  22271. _getFreeDefineName(prefix: string): string;
  22272. /** @hidden */
  22273. _excludeVariableName(name: string): void;
  22274. /** @hidden */
  22275. _emit2DSampler(name: string): void;
  22276. /** @hidden */
  22277. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22278. /** @hidden */
  22279. _emitExtension(name: string, extension: string, define?: string): void;
  22280. /** @hidden */
  22281. _emitFunction(name: string, code: string, comments: string): void;
  22282. /** @hidden */
  22283. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22284. replaceStrings?: {
  22285. search: RegExp;
  22286. replace: string;
  22287. }[];
  22288. repeatKey?: string;
  22289. }): string;
  22290. /** @hidden */
  22291. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22292. repeatKey?: string;
  22293. removeAttributes?: boolean;
  22294. removeUniforms?: boolean;
  22295. removeVaryings?: boolean;
  22296. removeIfDef?: boolean;
  22297. replaceStrings?: {
  22298. search: RegExp;
  22299. replace: string;
  22300. }[];
  22301. }, storeKey?: string): void;
  22302. /** @hidden */
  22303. _registerTempVariable(name: string): boolean;
  22304. /** @hidden */
  22305. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22306. /** @hidden */
  22307. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22308. /** @hidden */
  22309. _emitFloat(value: number): string;
  22310. }
  22311. }
  22312. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22313. /**
  22314. * Helper class used to generate session unique ID
  22315. */
  22316. export class UniqueIdGenerator {
  22317. private static _UniqueIdCounter;
  22318. /**
  22319. * Gets an unique (relatively to the current scene) Id
  22320. */
  22321. static get UniqueId(): number;
  22322. }
  22323. }
  22324. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22325. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22326. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22327. import { Nullable } from "babylonjs/types";
  22328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22329. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22330. import { Effect } from "babylonjs/Materials/effect";
  22331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22332. import { Mesh } from "babylonjs/Meshes/mesh";
  22333. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22334. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22335. import { Scene } from "babylonjs/scene";
  22336. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22337. /**
  22338. * Defines a block that can be used inside a node based material
  22339. */
  22340. export class NodeMaterialBlock {
  22341. private _buildId;
  22342. private _buildTarget;
  22343. private _target;
  22344. private _isFinalMerger;
  22345. private _isInput;
  22346. private _name;
  22347. protected _isUnique: boolean;
  22348. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22349. inputsAreExclusive: boolean;
  22350. /** @hidden */
  22351. _codeVariableName: string;
  22352. /** @hidden */
  22353. _inputs: NodeMaterialConnectionPoint[];
  22354. /** @hidden */
  22355. _outputs: NodeMaterialConnectionPoint[];
  22356. /** @hidden */
  22357. _preparationId: number;
  22358. /**
  22359. * Gets the name of the block
  22360. */
  22361. get name(): string;
  22362. /**
  22363. * Sets the name of the block. Will check if the name is valid.
  22364. */
  22365. set name(newName: string);
  22366. /**
  22367. * Gets or sets the unique id of the node
  22368. */
  22369. uniqueId: number;
  22370. /**
  22371. * Gets or sets the comments associated with this block
  22372. */
  22373. comments: string;
  22374. /**
  22375. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22376. */
  22377. get isUnique(): boolean;
  22378. /**
  22379. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22380. */
  22381. get isFinalMerger(): boolean;
  22382. /**
  22383. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22384. */
  22385. get isInput(): boolean;
  22386. /**
  22387. * Gets or sets the build Id
  22388. */
  22389. get buildId(): number;
  22390. set buildId(value: number);
  22391. /**
  22392. * Gets or sets the target of the block
  22393. */
  22394. get target(): NodeMaterialBlockTargets;
  22395. set target(value: NodeMaterialBlockTargets);
  22396. /**
  22397. * Gets the list of input points
  22398. */
  22399. get inputs(): NodeMaterialConnectionPoint[];
  22400. /** Gets the list of output points */
  22401. get outputs(): NodeMaterialConnectionPoint[];
  22402. /**
  22403. * Find an input by its name
  22404. * @param name defines the name of the input to look for
  22405. * @returns the input or null if not found
  22406. */
  22407. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22408. /**
  22409. * Find an output by its name
  22410. * @param name defines the name of the outputto look for
  22411. * @returns the output or null if not found
  22412. */
  22413. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22414. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22415. visibleInInspector: boolean;
  22416. /**
  22417. * Creates a new NodeMaterialBlock
  22418. * @param name defines the block name
  22419. * @param target defines the target of that block (Vertex by default)
  22420. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22421. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22422. */
  22423. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22424. /**
  22425. * Initialize the block and prepare the context for build
  22426. * @param state defines the state that will be used for the build
  22427. */
  22428. initialize(state: NodeMaterialBuildState): void;
  22429. /**
  22430. * Bind data to effect. Will only be called for blocks with isBindable === true
  22431. * @param effect defines the effect to bind data to
  22432. * @param nodeMaterial defines the hosting NodeMaterial
  22433. * @param mesh defines the mesh that will be rendered
  22434. * @param subMesh defines the submesh that will be rendered
  22435. */
  22436. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22437. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22438. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22439. protected _writeFloat(value: number): string;
  22440. /**
  22441. * Gets the current class name e.g. "NodeMaterialBlock"
  22442. * @returns the class name
  22443. */
  22444. getClassName(): string;
  22445. /**
  22446. * Register a new input. Must be called inside a block constructor
  22447. * @param name defines the connection point name
  22448. * @param type defines the connection point type
  22449. * @param isOptional defines a boolean indicating that this input can be omitted
  22450. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22451. * @param point an already created connection point. If not provided, create a new one
  22452. * @returns the current block
  22453. */
  22454. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22455. /**
  22456. * Register a new output. Must be called inside a block constructor
  22457. * @param name defines the connection point name
  22458. * @param type defines the connection point type
  22459. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22460. * @param point an already created connection point. If not provided, create a new one
  22461. * @returns the current block
  22462. */
  22463. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22464. /**
  22465. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22466. * @param forOutput defines an optional connection point to check compatibility with
  22467. * @returns the first available input or null
  22468. */
  22469. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22470. /**
  22471. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22472. * @param forBlock defines an optional block to check compatibility with
  22473. * @returns the first available input or null
  22474. */
  22475. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22476. /**
  22477. * Gets the sibling of the given output
  22478. * @param current defines the current output
  22479. * @returns the next output in the list or null
  22480. */
  22481. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22482. /**
  22483. * Connect current block with another block
  22484. * @param other defines the block to connect with
  22485. * @param options define the various options to help pick the right connections
  22486. * @returns the current block
  22487. */
  22488. connectTo(other: NodeMaterialBlock, options?: {
  22489. input?: string;
  22490. output?: string;
  22491. outputSwizzle?: string;
  22492. }): this | undefined;
  22493. protected _buildBlock(state: NodeMaterialBuildState): void;
  22494. /**
  22495. * Add uniforms, samplers and uniform buffers at compilation time
  22496. * @param state defines the state to update
  22497. * @param nodeMaterial defines the node material requesting the update
  22498. * @param defines defines the material defines to update
  22499. * @param uniformBuffers defines the list of uniform buffer names
  22500. */
  22501. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22502. /**
  22503. * Add potential fallbacks if shader compilation fails
  22504. * @param mesh defines the mesh to be rendered
  22505. * @param fallbacks defines the current prioritized list of fallbacks
  22506. */
  22507. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22508. /**
  22509. * Initialize defines for shader compilation
  22510. * @param mesh defines the mesh to be rendered
  22511. * @param nodeMaterial defines the node material requesting the update
  22512. * @param defines defines the material defines to update
  22513. * @param useInstances specifies that instances should be used
  22514. */
  22515. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22516. /**
  22517. * Update defines for shader compilation
  22518. * @param mesh defines the mesh to be rendered
  22519. * @param nodeMaterial defines the node material requesting the update
  22520. * @param defines defines the material defines to update
  22521. * @param useInstances specifies that instances should be used
  22522. * @param subMesh defines which submesh to render
  22523. */
  22524. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22525. /**
  22526. * Lets the block try to connect some inputs automatically
  22527. * @param material defines the hosting NodeMaterial
  22528. */
  22529. autoConfigure(material: NodeMaterial): void;
  22530. /**
  22531. * Function called when a block is declared as repeatable content generator
  22532. * @param vertexShaderState defines the current compilation state for the vertex shader
  22533. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22534. * @param mesh defines the mesh to be rendered
  22535. * @param defines defines the material defines to update
  22536. */
  22537. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22538. /**
  22539. * Checks if the block is ready
  22540. * @param mesh defines the mesh to be rendered
  22541. * @param nodeMaterial defines the node material requesting the update
  22542. * @param defines defines the material defines to update
  22543. * @param useInstances specifies that instances should be used
  22544. * @returns true if the block is ready
  22545. */
  22546. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22547. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22548. private _processBuild;
  22549. /**
  22550. * Validates the new name for the block node.
  22551. * @param newName the new name to be given to the node.
  22552. * @returns false if the name is a reserve word, else true.
  22553. */
  22554. validateBlockName(newName: string): boolean;
  22555. /**
  22556. * Compile the current node and generate the shader code
  22557. * @param state defines the current compilation state (uniforms, samplers, current string)
  22558. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22559. * @returns true if already built
  22560. */
  22561. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22562. protected _inputRename(name: string): string;
  22563. protected _outputRename(name: string): string;
  22564. protected _dumpPropertiesCode(): string;
  22565. /** @hidden */
  22566. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22567. /** @hidden */
  22568. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22569. /**
  22570. * Clone the current block to a new identical block
  22571. * @param scene defines the hosting scene
  22572. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22573. * @returns a copy of the current block
  22574. */
  22575. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22576. /**
  22577. * Serializes this block in a JSON representation
  22578. * @returns the serialized block object
  22579. */
  22580. serialize(): any;
  22581. /** @hidden */
  22582. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22583. private _deserializePortDisplayNamesAndExposedOnFrame;
  22584. /**
  22585. * Release resources
  22586. */
  22587. dispose(): void;
  22588. }
  22589. }
  22590. declare module "babylonjs/Materials/pushMaterial" {
  22591. import { Nullable } from "babylonjs/types";
  22592. import { Scene } from "babylonjs/scene";
  22593. import { Matrix } from "babylonjs/Maths/math.vector";
  22594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22595. import { Mesh } from "babylonjs/Meshes/mesh";
  22596. import { Material } from "babylonjs/Materials/material";
  22597. import { Effect } from "babylonjs/Materials/effect";
  22598. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22599. /**
  22600. * Base class of materials working in push mode in babylon JS
  22601. * @hidden
  22602. */
  22603. export class PushMaterial extends Material {
  22604. protected _activeEffect: Effect;
  22605. protected _normalMatrix: Matrix;
  22606. constructor(name: string, scene: Scene);
  22607. getEffect(): Effect;
  22608. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22609. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22610. /**
  22611. * Binds the given world matrix to the active effect
  22612. *
  22613. * @param world the matrix to bind
  22614. */
  22615. bindOnlyWorldMatrix(world: Matrix): void;
  22616. /**
  22617. * Binds the given normal matrix to the active effect
  22618. *
  22619. * @param normalMatrix the matrix to bind
  22620. */
  22621. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22622. bind(world: Matrix, mesh?: Mesh): void;
  22623. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22624. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22625. }
  22626. }
  22627. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22628. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22629. /**
  22630. * Root class for all node material optimizers
  22631. */
  22632. export class NodeMaterialOptimizer {
  22633. /**
  22634. * Function used to optimize a NodeMaterial graph
  22635. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22636. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22637. */
  22638. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22639. }
  22640. }
  22641. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22642. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22643. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22644. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22645. import { Scene } from "babylonjs/scene";
  22646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22647. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22648. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22649. /**
  22650. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22651. */
  22652. export class TransformBlock extends NodeMaterialBlock {
  22653. /**
  22654. * Defines the value to use to complement W value to transform it to a Vector4
  22655. */
  22656. complementW: number;
  22657. /**
  22658. * Defines the value to use to complement z value to transform it to a Vector4
  22659. */
  22660. complementZ: number;
  22661. /**
  22662. * Creates a new TransformBlock
  22663. * @param name defines the block name
  22664. */
  22665. constructor(name: string);
  22666. /**
  22667. * Gets the current class name
  22668. * @returns the class name
  22669. */
  22670. getClassName(): string;
  22671. /**
  22672. * Gets the vector input
  22673. */
  22674. get vector(): NodeMaterialConnectionPoint;
  22675. /**
  22676. * Gets the output component
  22677. */
  22678. get output(): NodeMaterialConnectionPoint;
  22679. /**
  22680. * Gets the xyz output component
  22681. */
  22682. get xyz(): NodeMaterialConnectionPoint;
  22683. /**
  22684. * Gets the matrix transform input
  22685. */
  22686. get transform(): NodeMaterialConnectionPoint;
  22687. protected _buildBlock(state: NodeMaterialBuildState): this;
  22688. /**
  22689. * Update defines for shader compilation
  22690. * @param mesh defines the mesh to be rendered
  22691. * @param nodeMaterial defines the node material requesting the update
  22692. * @param defines defines the material defines to update
  22693. * @param useInstances specifies that instances should be used
  22694. * @param subMesh defines which submesh to render
  22695. */
  22696. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22697. serialize(): any;
  22698. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22699. protected _dumpPropertiesCode(): string;
  22700. }
  22701. }
  22702. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22703. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22704. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22705. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22706. /**
  22707. * Block used to output the vertex position
  22708. */
  22709. export class VertexOutputBlock extends NodeMaterialBlock {
  22710. /**
  22711. * Creates a new VertexOutputBlock
  22712. * @param name defines the block name
  22713. */
  22714. constructor(name: string);
  22715. /**
  22716. * Gets the current class name
  22717. * @returns the class name
  22718. */
  22719. getClassName(): string;
  22720. /**
  22721. * Gets the vector input component
  22722. */
  22723. get vector(): NodeMaterialConnectionPoint;
  22724. protected _buildBlock(state: NodeMaterialBuildState): this;
  22725. }
  22726. }
  22727. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22728. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22729. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22730. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22731. /**
  22732. * Block used to output the final color
  22733. */
  22734. export class FragmentOutputBlock extends NodeMaterialBlock {
  22735. /**
  22736. * Create a new FragmentOutputBlock
  22737. * @param name defines the block name
  22738. */
  22739. constructor(name: string);
  22740. /**
  22741. * Gets the current class name
  22742. * @returns the class name
  22743. */
  22744. getClassName(): string;
  22745. /**
  22746. * Gets the rgba input component
  22747. */
  22748. get rgba(): NodeMaterialConnectionPoint;
  22749. /**
  22750. * Gets the rgb input component
  22751. */
  22752. get rgb(): NodeMaterialConnectionPoint;
  22753. /**
  22754. * Gets the a input component
  22755. */
  22756. get a(): NodeMaterialConnectionPoint;
  22757. protected _buildBlock(state: NodeMaterialBuildState): this;
  22758. }
  22759. }
  22760. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22761. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22762. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22763. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22764. /**
  22765. * Block used for the particle ramp gradient section
  22766. */
  22767. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22768. /**
  22769. * Create a new ParticleRampGradientBlock
  22770. * @param name defines the block name
  22771. */
  22772. constructor(name: string);
  22773. /**
  22774. * Gets the current class name
  22775. * @returns the class name
  22776. */
  22777. getClassName(): string;
  22778. /**
  22779. * Gets the color input component
  22780. */
  22781. get color(): NodeMaterialConnectionPoint;
  22782. /**
  22783. * Gets the rampColor output component
  22784. */
  22785. get rampColor(): NodeMaterialConnectionPoint;
  22786. /**
  22787. * Initialize the block and prepare the context for build
  22788. * @param state defines the state that will be used for the build
  22789. */
  22790. initialize(state: NodeMaterialBuildState): void;
  22791. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22792. }
  22793. }
  22794. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22795. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22796. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22797. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22798. /**
  22799. * Block used for the particle blend multiply section
  22800. */
  22801. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22802. /**
  22803. * Create a new ParticleBlendMultiplyBlock
  22804. * @param name defines the block name
  22805. */
  22806. constructor(name: string);
  22807. /**
  22808. * Gets the current class name
  22809. * @returns the class name
  22810. */
  22811. getClassName(): string;
  22812. /**
  22813. * Gets the color input component
  22814. */
  22815. get color(): NodeMaterialConnectionPoint;
  22816. /**
  22817. * Gets the alphaTexture input component
  22818. */
  22819. get alphaTexture(): NodeMaterialConnectionPoint;
  22820. /**
  22821. * Gets the alphaColor input component
  22822. */
  22823. get alphaColor(): NodeMaterialConnectionPoint;
  22824. /**
  22825. * Gets the blendColor output component
  22826. */
  22827. get blendColor(): NodeMaterialConnectionPoint;
  22828. /**
  22829. * Initialize the block and prepare the context for build
  22830. * @param state defines the state that will be used for the build
  22831. */
  22832. initialize(state: NodeMaterialBuildState): void;
  22833. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22834. }
  22835. }
  22836. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22837. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22838. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22839. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22840. /**
  22841. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22842. */
  22843. export class VectorMergerBlock extends NodeMaterialBlock {
  22844. /**
  22845. * Create a new VectorMergerBlock
  22846. * @param name defines the block name
  22847. */
  22848. constructor(name: string);
  22849. /**
  22850. * Gets the current class name
  22851. * @returns the class name
  22852. */
  22853. getClassName(): string;
  22854. /**
  22855. * Gets the xyz component (input)
  22856. */
  22857. get xyzIn(): NodeMaterialConnectionPoint;
  22858. /**
  22859. * Gets the xy component (input)
  22860. */
  22861. get xyIn(): NodeMaterialConnectionPoint;
  22862. /**
  22863. * Gets the x component (input)
  22864. */
  22865. get x(): NodeMaterialConnectionPoint;
  22866. /**
  22867. * Gets the y component (input)
  22868. */
  22869. get y(): NodeMaterialConnectionPoint;
  22870. /**
  22871. * Gets the z component (input)
  22872. */
  22873. get z(): NodeMaterialConnectionPoint;
  22874. /**
  22875. * Gets the w component (input)
  22876. */
  22877. get w(): NodeMaterialConnectionPoint;
  22878. /**
  22879. * Gets the xyzw component (output)
  22880. */
  22881. get xyzw(): NodeMaterialConnectionPoint;
  22882. /**
  22883. * Gets the xyz component (output)
  22884. */
  22885. get xyzOut(): NodeMaterialConnectionPoint;
  22886. /**
  22887. * Gets the xy component (output)
  22888. */
  22889. get xyOut(): NodeMaterialConnectionPoint;
  22890. /**
  22891. * Gets the xy component (output)
  22892. * @deprecated Please use xyOut instead.
  22893. */
  22894. get xy(): NodeMaterialConnectionPoint;
  22895. /**
  22896. * Gets the xyz component (output)
  22897. * @deprecated Please use xyzOut instead.
  22898. */
  22899. get xyz(): NodeMaterialConnectionPoint;
  22900. protected _buildBlock(state: NodeMaterialBuildState): this;
  22901. }
  22902. }
  22903. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22904. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22905. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22906. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22907. import { Vector2 } from "babylonjs/Maths/math.vector";
  22908. import { Scene } from "babylonjs/scene";
  22909. /**
  22910. * Block used to remap a float from a range to a new one
  22911. */
  22912. export class RemapBlock extends NodeMaterialBlock {
  22913. /**
  22914. * Gets or sets the source range
  22915. */
  22916. sourceRange: Vector2;
  22917. /**
  22918. * Gets or sets the target range
  22919. */
  22920. targetRange: Vector2;
  22921. /**
  22922. * Creates a new RemapBlock
  22923. * @param name defines the block name
  22924. */
  22925. constructor(name: string);
  22926. /**
  22927. * Gets the current class name
  22928. * @returns the class name
  22929. */
  22930. getClassName(): string;
  22931. /**
  22932. * Gets the input component
  22933. */
  22934. get input(): NodeMaterialConnectionPoint;
  22935. /**
  22936. * Gets the source min input component
  22937. */
  22938. get sourceMin(): NodeMaterialConnectionPoint;
  22939. /**
  22940. * Gets the source max input component
  22941. */
  22942. get sourceMax(): NodeMaterialConnectionPoint;
  22943. /**
  22944. * Gets the target min input component
  22945. */
  22946. get targetMin(): NodeMaterialConnectionPoint;
  22947. /**
  22948. * Gets the target max input component
  22949. */
  22950. get targetMax(): NodeMaterialConnectionPoint;
  22951. /**
  22952. * Gets the output component
  22953. */
  22954. get output(): NodeMaterialConnectionPoint;
  22955. protected _buildBlock(state: NodeMaterialBuildState): this;
  22956. protected _dumpPropertiesCode(): string;
  22957. serialize(): any;
  22958. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22959. }
  22960. }
  22961. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22962. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22963. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22964. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22965. /**
  22966. * Block used to multiply 2 values
  22967. */
  22968. export class MultiplyBlock extends NodeMaterialBlock {
  22969. /**
  22970. * Creates a new MultiplyBlock
  22971. * @param name defines the block name
  22972. */
  22973. constructor(name: string);
  22974. /**
  22975. * Gets the current class name
  22976. * @returns the class name
  22977. */
  22978. getClassName(): string;
  22979. /**
  22980. * Gets the left operand input component
  22981. */
  22982. get left(): NodeMaterialConnectionPoint;
  22983. /**
  22984. * Gets the right operand input component
  22985. */
  22986. get right(): NodeMaterialConnectionPoint;
  22987. /**
  22988. * Gets the output component
  22989. */
  22990. get output(): NodeMaterialConnectionPoint;
  22991. protected _buildBlock(state: NodeMaterialBuildState): this;
  22992. }
  22993. }
  22994. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22995. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22996. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22997. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22998. /**
  22999. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  23000. */
  23001. export class ColorSplitterBlock extends NodeMaterialBlock {
  23002. /**
  23003. * Create a new ColorSplitterBlock
  23004. * @param name defines the block name
  23005. */
  23006. constructor(name: string);
  23007. /**
  23008. * Gets the current class name
  23009. * @returns the class name
  23010. */
  23011. getClassName(): string;
  23012. /**
  23013. * Gets the rgba component (input)
  23014. */
  23015. get rgba(): NodeMaterialConnectionPoint;
  23016. /**
  23017. * Gets the rgb component (input)
  23018. */
  23019. get rgbIn(): NodeMaterialConnectionPoint;
  23020. /**
  23021. * Gets the rgb component (output)
  23022. */
  23023. get rgbOut(): NodeMaterialConnectionPoint;
  23024. /**
  23025. * Gets the r component (output)
  23026. */
  23027. get r(): NodeMaterialConnectionPoint;
  23028. /**
  23029. * Gets the g component (output)
  23030. */
  23031. get g(): NodeMaterialConnectionPoint;
  23032. /**
  23033. * Gets the b component (output)
  23034. */
  23035. get b(): NodeMaterialConnectionPoint;
  23036. /**
  23037. * Gets the a component (output)
  23038. */
  23039. get a(): NodeMaterialConnectionPoint;
  23040. protected _inputRename(name: string): string;
  23041. protected _outputRename(name: string): string;
  23042. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23043. }
  23044. }
  23045. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23046. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23047. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23048. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23049. import { Scene } from "babylonjs/scene";
  23050. /**
  23051. * Operations supported by the Trigonometry block
  23052. */
  23053. export enum TrigonometryBlockOperations {
  23054. /** Cos */
  23055. Cos = 0,
  23056. /** Sin */
  23057. Sin = 1,
  23058. /** Abs */
  23059. Abs = 2,
  23060. /** Exp */
  23061. Exp = 3,
  23062. /** Exp2 */
  23063. Exp2 = 4,
  23064. /** Round */
  23065. Round = 5,
  23066. /** Floor */
  23067. Floor = 6,
  23068. /** Ceiling */
  23069. Ceiling = 7,
  23070. /** Square root */
  23071. Sqrt = 8,
  23072. /** Log */
  23073. Log = 9,
  23074. /** Tangent */
  23075. Tan = 10,
  23076. /** Arc tangent */
  23077. ArcTan = 11,
  23078. /** Arc cosinus */
  23079. ArcCos = 12,
  23080. /** Arc sinus */
  23081. ArcSin = 13,
  23082. /** Fraction */
  23083. Fract = 14,
  23084. /** Sign */
  23085. Sign = 15,
  23086. /** To radians (from degrees) */
  23087. Radians = 16,
  23088. /** To degrees (from radians) */
  23089. Degrees = 17
  23090. }
  23091. /**
  23092. * Block used to apply trigonometry operation to floats
  23093. */
  23094. export class TrigonometryBlock extends NodeMaterialBlock {
  23095. /**
  23096. * Gets or sets the operation applied by the block
  23097. */
  23098. operation: TrigonometryBlockOperations;
  23099. /**
  23100. * Creates a new TrigonometryBlock
  23101. * @param name defines the block name
  23102. */
  23103. constructor(name: string);
  23104. /**
  23105. * Gets the current class name
  23106. * @returns the class name
  23107. */
  23108. getClassName(): string;
  23109. /**
  23110. * Gets the input component
  23111. */
  23112. get input(): NodeMaterialConnectionPoint;
  23113. /**
  23114. * Gets the output component
  23115. */
  23116. get output(): NodeMaterialConnectionPoint;
  23117. protected _buildBlock(state: NodeMaterialBuildState): this;
  23118. serialize(): any;
  23119. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23120. protected _dumpPropertiesCode(): string;
  23121. }
  23122. }
  23123. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23124. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23125. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23126. import { Scene } from "babylonjs/scene";
  23127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23128. import { Matrix } from "babylonjs/Maths/math.vector";
  23129. import { Mesh } from "babylonjs/Meshes/mesh";
  23130. import { Engine } from "babylonjs/Engines/engine";
  23131. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23132. import { Observable } from "babylonjs/Misc/observable";
  23133. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23134. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23135. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23136. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23137. import { Nullable } from "babylonjs/types";
  23138. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23139. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23140. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23141. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23142. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23143. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23144. import { Effect } from "babylonjs/Materials/effect";
  23145. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23146. import { Camera } from "babylonjs/Cameras/camera";
  23147. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23148. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23149. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23150. /**
  23151. * Interface used to configure the node material editor
  23152. */
  23153. export interface INodeMaterialEditorOptions {
  23154. /** Define the URl to load node editor script */
  23155. editorURL?: string;
  23156. }
  23157. /** @hidden */
  23158. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23159. NORMAL: boolean;
  23160. TANGENT: boolean;
  23161. UV1: boolean;
  23162. /** BONES */
  23163. NUM_BONE_INFLUENCERS: number;
  23164. BonesPerMesh: number;
  23165. BONETEXTURE: boolean;
  23166. /** MORPH TARGETS */
  23167. MORPHTARGETS: boolean;
  23168. MORPHTARGETS_NORMAL: boolean;
  23169. MORPHTARGETS_TANGENT: boolean;
  23170. MORPHTARGETS_UV: boolean;
  23171. NUM_MORPH_INFLUENCERS: number;
  23172. /** IMAGE PROCESSING */
  23173. IMAGEPROCESSING: boolean;
  23174. VIGNETTE: boolean;
  23175. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23176. VIGNETTEBLENDMODEOPAQUE: boolean;
  23177. TONEMAPPING: boolean;
  23178. TONEMAPPING_ACES: boolean;
  23179. CONTRAST: boolean;
  23180. EXPOSURE: boolean;
  23181. COLORCURVES: boolean;
  23182. COLORGRADING: boolean;
  23183. COLORGRADING3D: boolean;
  23184. SAMPLER3DGREENDEPTH: boolean;
  23185. SAMPLER3DBGRMAP: boolean;
  23186. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23187. /** MISC. */
  23188. BUMPDIRECTUV: number;
  23189. constructor();
  23190. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23191. }
  23192. /**
  23193. * Class used to configure NodeMaterial
  23194. */
  23195. export interface INodeMaterialOptions {
  23196. /**
  23197. * Defines if blocks should emit comments
  23198. */
  23199. emitComments: boolean;
  23200. }
  23201. /**
  23202. * Class used to create a node based material built by assembling shader blocks
  23203. */
  23204. export class NodeMaterial extends PushMaterial {
  23205. private static _BuildIdGenerator;
  23206. private _options;
  23207. private _vertexCompilationState;
  23208. private _fragmentCompilationState;
  23209. private _sharedData;
  23210. private _buildId;
  23211. private _buildWasSuccessful;
  23212. private _cachedWorldViewMatrix;
  23213. private _cachedWorldViewProjectionMatrix;
  23214. private _optimizers;
  23215. private _animationFrame;
  23216. /** Define the Url to load node editor script */
  23217. static EditorURL: string;
  23218. /** Define the Url to load snippets */
  23219. static SnippetUrl: string;
  23220. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23221. static IgnoreTexturesAtLoadTime: boolean;
  23222. private BJSNODEMATERIALEDITOR;
  23223. /** Get the inspector from bundle or global */
  23224. private _getGlobalNodeMaterialEditor;
  23225. /**
  23226. * Snippet ID if the material was created from the snippet server
  23227. */
  23228. snippetId: string;
  23229. /**
  23230. * Gets or sets data used by visual editor
  23231. * @see https://nme.babylonjs.com
  23232. */
  23233. editorData: any;
  23234. /**
  23235. * 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)
  23236. */
  23237. ignoreAlpha: boolean;
  23238. /**
  23239. * Defines the maximum number of lights that can be used in the material
  23240. */
  23241. maxSimultaneousLights: number;
  23242. /**
  23243. * Observable raised when the material is built
  23244. */
  23245. onBuildObservable: Observable<NodeMaterial>;
  23246. /**
  23247. * Gets or sets the root nodes of the material vertex shader
  23248. */
  23249. _vertexOutputNodes: NodeMaterialBlock[];
  23250. /**
  23251. * Gets or sets the root nodes of the material fragment (pixel) shader
  23252. */
  23253. _fragmentOutputNodes: NodeMaterialBlock[];
  23254. /** Gets or sets options to control the node material overall behavior */
  23255. get options(): INodeMaterialOptions;
  23256. set options(options: INodeMaterialOptions);
  23257. /**
  23258. * Default configuration related to image processing available in the standard Material.
  23259. */
  23260. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23261. /**
  23262. * Gets the image processing configuration used either in this material.
  23263. */
  23264. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23265. /**
  23266. * Sets the Default image processing configuration used either in the this material.
  23267. *
  23268. * If sets to null, the scene one is in use.
  23269. */
  23270. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23271. /**
  23272. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23273. */
  23274. attachedBlocks: NodeMaterialBlock[];
  23275. /**
  23276. * Specifies the mode of the node material
  23277. * @hidden
  23278. */
  23279. _mode: NodeMaterialModes;
  23280. /**
  23281. * Gets the mode property
  23282. */
  23283. get mode(): NodeMaterialModes;
  23284. /**
  23285. * Create a new node based material
  23286. * @param name defines the material name
  23287. * @param scene defines the hosting scene
  23288. * @param options defines creation option
  23289. */
  23290. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23291. /**
  23292. * Gets the current class name of the material e.g. "NodeMaterial"
  23293. * @returns the class name
  23294. */
  23295. getClassName(): string;
  23296. /**
  23297. * Keep track of the image processing observer to allow dispose and replace.
  23298. */
  23299. private _imageProcessingObserver;
  23300. /**
  23301. * Attaches a new image processing configuration to the Standard Material.
  23302. * @param configuration
  23303. */
  23304. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23305. /**
  23306. * Get a block by its name
  23307. * @param name defines the name of the block to retrieve
  23308. * @returns the required block or null if not found
  23309. */
  23310. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23311. /**
  23312. * Get a block by its name
  23313. * @param predicate defines the predicate used to find the good candidate
  23314. * @returns the required block or null if not found
  23315. */
  23316. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23317. /**
  23318. * Get an input block by its name
  23319. * @param predicate defines the predicate used to find the good candidate
  23320. * @returns the required input block or null if not found
  23321. */
  23322. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23323. /**
  23324. * Gets the list of input blocks attached to this material
  23325. * @returns an array of InputBlocks
  23326. */
  23327. getInputBlocks(): InputBlock[];
  23328. /**
  23329. * Adds a new optimizer to the list of optimizers
  23330. * @param optimizer defines the optimizers to add
  23331. * @returns the current material
  23332. */
  23333. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23334. /**
  23335. * Remove an optimizer from the list of optimizers
  23336. * @param optimizer defines the optimizers to remove
  23337. * @returns the current material
  23338. */
  23339. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23340. /**
  23341. * Add a new block to the list of output nodes
  23342. * @param node defines the node to add
  23343. * @returns the current material
  23344. */
  23345. addOutputNode(node: NodeMaterialBlock): this;
  23346. /**
  23347. * Remove a block from the list of root nodes
  23348. * @param node defines the node to remove
  23349. * @returns the current material
  23350. */
  23351. removeOutputNode(node: NodeMaterialBlock): this;
  23352. private _addVertexOutputNode;
  23353. private _removeVertexOutputNode;
  23354. private _addFragmentOutputNode;
  23355. private _removeFragmentOutputNode;
  23356. /**
  23357. * Specifies if the material will require alpha blending
  23358. * @returns a boolean specifying if alpha blending is needed
  23359. */
  23360. needAlphaBlending(): boolean;
  23361. /**
  23362. * Specifies if this material should be rendered in alpha test mode
  23363. * @returns a boolean specifying if an alpha test is needed.
  23364. */
  23365. needAlphaTesting(): boolean;
  23366. private _initializeBlock;
  23367. private _resetDualBlocks;
  23368. /**
  23369. * Remove a block from the current node material
  23370. * @param block defines the block to remove
  23371. */
  23372. removeBlock(block: NodeMaterialBlock): void;
  23373. /**
  23374. * Build the material and generates the inner effect
  23375. * @param verbose defines if the build should log activity
  23376. */
  23377. build(verbose?: boolean): void;
  23378. /**
  23379. * Runs an otpimization phase to try to improve the shader code
  23380. */
  23381. optimize(): void;
  23382. private _prepareDefinesForAttributes;
  23383. /**
  23384. * Create a post process from the material
  23385. * @param camera The camera to apply the render pass to.
  23386. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23387. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23388. * @param engine The engine which the post process will be applied. (default: current engine)
  23389. * @param reusable If the post process can be reused on the same frame. (default: false)
  23390. * @param textureType Type of textures used when performing the post process. (default: 0)
  23391. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23392. * @returns the post process created
  23393. */
  23394. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23395. /**
  23396. * Create the post process effect from the material
  23397. * @param postProcess The post process to create the effect for
  23398. */
  23399. createEffectForPostProcess(postProcess: PostProcess): void;
  23400. private _createEffectForPostProcess;
  23401. /**
  23402. * Create a new procedural texture based on this node material
  23403. * @param size defines the size of the texture
  23404. * @param scene defines the hosting scene
  23405. * @returns the new procedural texture attached to this node material
  23406. */
  23407. createProceduralTexture(size: number | {
  23408. width: number;
  23409. height: number;
  23410. layers?: number;
  23411. }, scene: Scene): Nullable<ProceduralTexture>;
  23412. private _createEffectForParticles;
  23413. private _checkInternals;
  23414. /**
  23415. * Create the effect to be used as the custom effect for a particle system
  23416. * @param particleSystem Particle system to create the effect for
  23417. * @param onCompiled defines a function to call when the effect creation is successful
  23418. * @param onError defines a function to call when the effect creation has failed
  23419. */
  23420. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23421. private _processDefines;
  23422. /**
  23423. * Get if the submesh is ready to be used and all its information available.
  23424. * Child classes can use it to update shaders
  23425. * @param mesh defines the mesh to check
  23426. * @param subMesh defines which submesh to check
  23427. * @param useInstances specifies that instances should be used
  23428. * @returns a boolean indicating that the submesh is ready or not
  23429. */
  23430. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23431. /**
  23432. * Get a string representing the shaders built by the current node graph
  23433. */
  23434. get compiledShaders(): string;
  23435. /**
  23436. * Binds the world matrix to the material
  23437. * @param world defines the world transformation matrix
  23438. */
  23439. bindOnlyWorldMatrix(world: Matrix): void;
  23440. /**
  23441. * Binds the submesh to this material by preparing the effect and shader to draw
  23442. * @param world defines the world transformation matrix
  23443. * @param mesh defines the mesh containing the submesh
  23444. * @param subMesh defines the submesh to bind the material to
  23445. */
  23446. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23447. /**
  23448. * Gets the active textures from the material
  23449. * @returns an array of textures
  23450. */
  23451. getActiveTextures(): BaseTexture[];
  23452. /**
  23453. * Gets the list of texture blocks
  23454. * @returns an array of texture blocks
  23455. */
  23456. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23457. /**
  23458. * Specifies if the material uses a texture
  23459. * @param texture defines the texture to check against the material
  23460. * @returns a boolean specifying if the material uses the texture
  23461. */
  23462. hasTexture(texture: BaseTexture): boolean;
  23463. /**
  23464. * Disposes the material
  23465. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23466. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23467. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23468. */
  23469. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23470. /** Creates the node editor window. */
  23471. private _createNodeEditor;
  23472. /**
  23473. * Launch the node material editor
  23474. * @param config Define the configuration of the editor
  23475. * @return a promise fulfilled when the node editor is visible
  23476. */
  23477. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23478. /**
  23479. * Clear the current material
  23480. */
  23481. clear(): void;
  23482. /**
  23483. * Clear the current material and set it to a default state
  23484. */
  23485. setToDefault(): void;
  23486. /**
  23487. * Clear the current material and set it to a default state for post process
  23488. */
  23489. setToDefaultPostProcess(): void;
  23490. /**
  23491. * Clear the current material and set it to a default state for procedural texture
  23492. */
  23493. setToDefaultProceduralTexture(): void;
  23494. /**
  23495. * Clear the current material and set it to a default state for particle
  23496. */
  23497. setToDefaultParticle(): void;
  23498. /**
  23499. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23500. * @param url defines the url to load from
  23501. * @returns a promise that will fullfil when the material is fully loaded
  23502. */
  23503. loadAsync(url: string): Promise<void>;
  23504. private _gatherBlocks;
  23505. /**
  23506. * Generate a string containing the code declaration required to create an equivalent of this material
  23507. * @returns a string
  23508. */
  23509. generateCode(): string;
  23510. /**
  23511. * Serializes this material in a JSON representation
  23512. * @returns the serialized material object
  23513. */
  23514. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23515. private _restoreConnections;
  23516. /**
  23517. * Clear the current graph and load a new one from a serialization object
  23518. * @param source defines the JSON representation of the material
  23519. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23520. * @param merge defines whether or not the source must be merged or replace the current content
  23521. */
  23522. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23523. /**
  23524. * Makes a duplicate of the current material.
  23525. * @param name - name to use for the new material.
  23526. */
  23527. clone(name: string): NodeMaterial;
  23528. /**
  23529. * Creates a node material from parsed material data
  23530. * @param source defines the JSON representation of the material
  23531. * @param scene defines the hosting scene
  23532. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23533. * @returns a new node material
  23534. */
  23535. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23536. /**
  23537. * Creates a node material from a snippet saved in a remote file
  23538. * @param name defines the name of the material to create
  23539. * @param url defines the url to load from
  23540. * @param scene defines the hosting scene
  23541. * @returns a promise that will resolve to the new node material
  23542. */
  23543. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23544. /**
  23545. * Creates a node material from a snippet saved by the node material editor
  23546. * @param snippetId defines the snippet to load
  23547. * @param scene defines the hosting scene
  23548. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23549. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23550. * @returns a promise that will resolve to the new node material
  23551. */
  23552. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23553. /**
  23554. * Creates a new node material set to default basic configuration
  23555. * @param name defines the name of the material
  23556. * @param scene defines the hosting scene
  23557. * @returns a new NodeMaterial
  23558. */
  23559. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23560. }
  23561. }
  23562. declare module "babylonjs/PostProcesses/postProcess" {
  23563. import { Nullable } from "babylonjs/types";
  23564. import { SmartArray } from "babylonjs/Misc/smartArray";
  23565. import { Observable } from "babylonjs/Misc/observable";
  23566. import { Vector2 } from "babylonjs/Maths/math.vector";
  23567. import { Camera } from "babylonjs/Cameras/camera";
  23568. import { Effect } from "babylonjs/Materials/effect";
  23569. import "babylonjs/Shaders/postprocess.vertex";
  23570. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23571. import { Engine } from "babylonjs/Engines/engine";
  23572. import { Color4 } from "babylonjs/Maths/math.color";
  23573. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23574. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23575. import { Scene } from "babylonjs/scene";
  23576. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23577. /**
  23578. * Size options for a post process
  23579. */
  23580. export type PostProcessOptions = {
  23581. width: number;
  23582. height: number;
  23583. };
  23584. /**
  23585. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23586. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23587. */
  23588. export class PostProcess {
  23589. /**
  23590. * Gets or sets the unique id of the post process
  23591. */
  23592. uniqueId: number;
  23593. /** Name of the PostProcess. */
  23594. name: string;
  23595. /**
  23596. * Width of the texture to apply the post process on
  23597. */
  23598. width: number;
  23599. /**
  23600. * Height of the texture to apply the post process on
  23601. */
  23602. height: number;
  23603. /**
  23604. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23605. */
  23606. nodeMaterialSource: Nullable<NodeMaterial>;
  23607. /**
  23608. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23609. * @hidden
  23610. */
  23611. _outputTexture: Nullable<InternalTexture>;
  23612. /**
  23613. * Sampling mode used by the shader
  23614. * See https://doc.babylonjs.com/classes/3.1/texture
  23615. */
  23616. renderTargetSamplingMode: number;
  23617. /**
  23618. * Clear color to use when screen clearing
  23619. */
  23620. clearColor: Color4;
  23621. /**
  23622. * If the buffer needs to be cleared before applying the post process. (default: true)
  23623. * Should be set to false if shader will overwrite all previous pixels.
  23624. */
  23625. autoClear: boolean;
  23626. /**
  23627. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23628. */
  23629. alphaMode: number;
  23630. /**
  23631. * Sets the setAlphaBlendConstants of the babylon engine
  23632. */
  23633. alphaConstants: Color4;
  23634. /**
  23635. * Animations to be used for the post processing
  23636. */
  23637. animations: import("babylonjs/Animations/animation").Animation[];
  23638. /**
  23639. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23640. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23641. */
  23642. enablePixelPerfectMode: boolean;
  23643. /**
  23644. * Force the postprocess to be applied without taking in account viewport
  23645. */
  23646. forceFullscreenViewport: boolean;
  23647. /**
  23648. * List of inspectable custom properties (used by the Inspector)
  23649. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23650. */
  23651. inspectableCustomProperties: IInspectable[];
  23652. /**
  23653. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23654. *
  23655. * | Value | Type | Description |
  23656. * | ----- | ----------------------------------- | ----------- |
  23657. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23658. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23659. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23660. *
  23661. */
  23662. scaleMode: number;
  23663. /**
  23664. * Force textures to be a power of two (default: false)
  23665. */
  23666. alwaysForcePOT: boolean;
  23667. private _samples;
  23668. /**
  23669. * Number of sample textures (default: 1)
  23670. */
  23671. get samples(): number;
  23672. set samples(n: number);
  23673. /**
  23674. * Modify the scale of the post process to be the same as the viewport (default: false)
  23675. */
  23676. adaptScaleToCurrentViewport: boolean;
  23677. private _camera;
  23678. protected _scene: Scene;
  23679. private _engine;
  23680. private _options;
  23681. private _reusable;
  23682. private _textureType;
  23683. private _textureFormat;
  23684. /**
  23685. * Smart array of input and output textures for the post process.
  23686. * @hidden
  23687. */
  23688. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23689. /**
  23690. * The index in _textures that corresponds to the output texture.
  23691. * @hidden
  23692. */
  23693. _currentRenderTextureInd: number;
  23694. private _effect;
  23695. private _samplers;
  23696. private _fragmentUrl;
  23697. private _vertexUrl;
  23698. private _parameters;
  23699. private _scaleRatio;
  23700. protected _indexParameters: any;
  23701. private _shareOutputWithPostProcess;
  23702. private _texelSize;
  23703. private _forcedOutputTexture;
  23704. /**
  23705. * Returns the fragment url or shader name used in the post process.
  23706. * @returns the fragment url or name in the shader store.
  23707. */
  23708. getEffectName(): string;
  23709. /**
  23710. * An event triggered when the postprocess is activated.
  23711. */
  23712. onActivateObservable: Observable<Camera>;
  23713. private _onActivateObserver;
  23714. /**
  23715. * A function that is added to the onActivateObservable
  23716. */
  23717. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23718. /**
  23719. * An event triggered when the postprocess changes its size.
  23720. */
  23721. onSizeChangedObservable: Observable<PostProcess>;
  23722. private _onSizeChangedObserver;
  23723. /**
  23724. * A function that is added to the onSizeChangedObservable
  23725. */
  23726. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23727. /**
  23728. * An event triggered when the postprocess applies its effect.
  23729. */
  23730. onApplyObservable: Observable<Effect>;
  23731. private _onApplyObserver;
  23732. /**
  23733. * A function that is added to the onApplyObservable
  23734. */
  23735. set onApply(callback: (effect: Effect) => void);
  23736. /**
  23737. * An event triggered before rendering the postprocess
  23738. */
  23739. onBeforeRenderObservable: Observable<Effect>;
  23740. private _onBeforeRenderObserver;
  23741. /**
  23742. * A function that is added to the onBeforeRenderObservable
  23743. */
  23744. set onBeforeRender(callback: (effect: Effect) => void);
  23745. /**
  23746. * An event triggered after rendering the postprocess
  23747. */
  23748. onAfterRenderObservable: Observable<Effect>;
  23749. private _onAfterRenderObserver;
  23750. /**
  23751. * A function that is added to the onAfterRenderObservable
  23752. */
  23753. set onAfterRender(callback: (efect: Effect) => void);
  23754. /**
  23755. * 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
  23756. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23757. */
  23758. get inputTexture(): InternalTexture;
  23759. set inputTexture(value: InternalTexture);
  23760. /**
  23761. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23762. * the only way to unset it is to use this function to restore its internal state
  23763. */
  23764. restoreDefaultInputTexture(): void;
  23765. /**
  23766. * Gets the camera which post process is applied to.
  23767. * @returns The camera the post process is applied to.
  23768. */
  23769. getCamera(): Camera;
  23770. /**
  23771. * Gets the texel size of the postprocess.
  23772. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23773. */
  23774. get texelSize(): Vector2;
  23775. /**
  23776. * Creates a new instance PostProcess
  23777. * @param name The name of the PostProcess.
  23778. * @param fragmentUrl The url of the fragment shader to be used.
  23779. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23780. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23781. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23782. * @param camera The camera to apply the render pass to.
  23783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23784. * @param engine The engine which the post process will be applied. (default: current engine)
  23785. * @param reusable If the post process can be reused on the same frame. (default: false)
  23786. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23787. * @param textureType Type of textures used when performing the post process. (default: 0)
  23788. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23789. * @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
  23790. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23791. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23792. */
  23793. constructor(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);
  23794. /**
  23795. * Gets a string identifying the name of the class
  23796. * @returns "PostProcess" string
  23797. */
  23798. getClassName(): string;
  23799. /**
  23800. * Gets the engine which this post process belongs to.
  23801. * @returns The engine the post process was enabled with.
  23802. */
  23803. getEngine(): Engine;
  23804. /**
  23805. * The effect that is created when initializing the post process.
  23806. * @returns The created effect corresponding the the postprocess.
  23807. */
  23808. getEffect(): Effect;
  23809. /**
  23810. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23811. * @param postProcess The post process to share the output with.
  23812. * @returns This post process.
  23813. */
  23814. shareOutputWith(postProcess: PostProcess): PostProcess;
  23815. /**
  23816. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23817. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23818. */
  23819. useOwnOutput(): void;
  23820. /**
  23821. * Updates the effect with the current post process compile time values and recompiles the shader.
  23822. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23823. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23824. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23825. * @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
  23826. * @param onCompiled Called when the shader has been compiled.
  23827. * @param onError Called if there is an error when compiling a shader.
  23828. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23829. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23830. */
  23831. 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;
  23832. /**
  23833. * The post process is reusable if it can be used multiple times within one frame.
  23834. * @returns If the post process is reusable
  23835. */
  23836. isReusable(): boolean;
  23837. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23838. markTextureDirty(): void;
  23839. /**
  23840. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23841. * 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.
  23842. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23843. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23844. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23845. * @returns The target texture that was bound to be written to.
  23846. */
  23847. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23848. /**
  23849. * If the post process is supported.
  23850. */
  23851. get isSupported(): boolean;
  23852. /**
  23853. * The aspect ratio of the output texture.
  23854. */
  23855. get aspectRatio(): number;
  23856. /**
  23857. * Get a value indicating if the post-process is ready to be used
  23858. * @returns true if the post-process is ready (shader is compiled)
  23859. */
  23860. isReady(): boolean;
  23861. /**
  23862. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23863. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23864. */
  23865. apply(): Nullable<Effect>;
  23866. private _disposeTextures;
  23867. /**
  23868. * Disposes the post process.
  23869. * @param camera The camera to dispose the post process on.
  23870. */
  23871. dispose(camera?: Camera): void;
  23872. /**
  23873. * Serializes the particle system to a JSON object
  23874. * @returns the JSON object
  23875. */
  23876. serialize(): any;
  23877. /**
  23878. * Creates a material from parsed material data
  23879. * @param parsedPostProcess defines parsed post process data
  23880. * @param scene defines the hosting scene
  23881. * @param rootUrl defines the root URL to use to load textures
  23882. * @returns a new post process
  23883. */
  23884. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23885. }
  23886. }
  23887. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23888. /** @hidden */
  23889. export var kernelBlurVaryingDeclaration: {
  23890. name: string;
  23891. shader: string;
  23892. };
  23893. }
  23894. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23895. /** @hidden */
  23896. export var kernelBlurFragment: {
  23897. name: string;
  23898. shader: string;
  23899. };
  23900. }
  23901. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23902. /** @hidden */
  23903. export var kernelBlurFragment2: {
  23904. name: string;
  23905. shader: string;
  23906. };
  23907. }
  23908. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23909. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23910. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23911. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23912. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23913. /** @hidden */
  23914. export var kernelBlurPixelShader: {
  23915. name: string;
  23916. shader: string;
  23917. };
  23918. }
  23919. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23920. /** @hidden */
  23921. export var kernelBlurVertex: {
  23922. name: string;
  23923. shader: string;
  23924. };
  23925. }
  23926. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23927. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23928. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23929. /** @hidden */
  23930. export var kernelBlurVertexShader: {
  23931. name: string;
  23932. shader: string;
  23933. };
  23934. }
  23935. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23936. import { Vector2 } from "babylonjs/Maths/math.vector";
  23937. import { Nullable } from "babylonjs/types";
  23938. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23939. import { Camera } from "babylonjs/Cameras/camera";
  23940. import { Effect } from "babylonjs/Materials/effect";
  23941. import { Engine } from "babylonjs/Engines/engine";
  23942. import "babylonjs/Shaders/kernelBlur.fragment";
  23943. import "babylonjs/Shaders/kernelBlur.vertex";
  23944. import { Scene } from "babylonjs/scene";
  23945. /**
  23946. * The Blur Post Process which blurs an image based on a kernel and direction.
  23947. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23948. */
  23949. export class BlurPostProcess extends PostProcess {
  23950. private blockCompilation;
  23951. protected _kernel: number;
  23952. protected _idealKernel: number;
  23953. protected _packedFloat: boolean;
  23954. private _staticDefines;
  23955. /** The direction in which to blur the image. */
  23956. direction: Vector2;
  23957. /**
  23958. * Sets the length in pixels of the blur sample region
  23959. */
  23960. set kernel(v: number);
  23961. /**
  23962. * Gets the length in pixels of the blur sample region
  23963. */
  23964. get kernel(): number;
  23965. /**
  23966. * Sets wether or not the blur needs to unpack/repack floats
  23967. */
  23968. set packedFloat(v: boolean);
  23969. /**
  23970. * Gets wether or not the blur is unpacking/repacking floats
  23971. */
  23972. get packedFloat(): boolean;
  23973. /**
  23974. * Gets a string identifying the name of the class
  23975. * @returns "BlurPostProcess" string
  23976. */
  23977. getClassName(): string;
  23978. /**
  23979. * Creates a new instance BlurPostProcess
  23980. * @param name The name of the effect.
  23981. * @param direction The direction in which to blur the image.
  23982. * @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.
  23983. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23984. * @param camera The camera to apply the render pass to.
  23985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23986. * @param engine The engine which the post process will be applied. (default: current engine)
  23987. * @param reusable If the post process can be reused on the same frame. (default: false)
  23988. * @param textureType Type of textures used when performing the post process. (default: 0)
  23989. * @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)
  23990. */
  23991. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23992. /**
  23993. * Updates the effect with the current post process compile time values and recompiles the shader.
  23994. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23995. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23996. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23997. * @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
  23998. * @param onCompiled Called when the shader has been compiled.
  23999. * @param onError Called if there is an error when compiling a shader.
  24000. */
  24001. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24002. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24003. /**
  24004. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  24005. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  24006. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  24007. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  24008. * The gaps between physical kernels are compensated for in the weighting of the samples
  24009. * @param idealKernel Ideal blur kernel.
  24010. * @return Nearest best kernel.
  24011. */
  24012. protected _nearestBestKernel(idealKernel: number): number;
  24013. /**
  24014. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  24015. * @param x The point on the Gaussian distribution to sample.
  24016. * @return the value of the Gaussian function at x.
  24017. */
  24018. protected _gaussianWeight(x: number): number;
  24019. /**
  24020. * Generates a string that can be used as a floating point number in GLSL.
  24021. * @param x Value to print.
  24022. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24023. * @return GLSL float string.
  24024. */
  24025. protected _glslFloat(x: number, decimalFigures?: number): string;
  24026. /** @hidden */
  24027. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  24028. }
  24029. }
  24030. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  24031. import { Scene } from "babylonjs/scene";
  24032. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24033. import { Plane } from "babylonjs/Maths/math.plane";
  24034. /**
  24035. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24036. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24037. * You can then easily use it as a reflectionTexture on a flat surface.
  24038. * In case the surface is not a plane, please consider relying on reflection probes.
  24039. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24040. */
  24041. export class MirrorTexture extends RenderTargetTexture {
  24042. private scene;
  24043. /**
  24044. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  24045. * 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.
  24046. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24047. */
  24048. mirrorPlane: Plane;
  24049. /**
  24050. * Define the blur ratio used to blur the reflection if needed.
  24051. */
  24052. set blurRatio(value: number);
  24053. get blurRatio(): number;
  24054. /**
  24055. * Define the adaptive blur kernel used to blur the reflection if needed.
  24056. * This will autocompute the closest best match for the `blurKernel`
  24057. */
  24058. set adaptiveBlurKernel(value: number);
  24059. /**
  24060. * Define the blur kernel used to blur the reflection if needed.
  24061. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24062. */
  24063. set blurKernel(value: number);
  24064. /**
  24065. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  24066. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24067. */
  24068. set blurKernelX(value: number);
  24069. get blurKernelX(): number;
  24070. /**
  24071. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  24072. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24073. */
  24074. set blurKernelY(value: number);
  24075. get blurKernelY(): number;
  24076. private _autoComputeBlurKernel;
  24077. protected _onRatioRescale(): void;
  24078. private _updateGammaSpace;
  24079. private _imageProcessingConfigChangeObserver;
  24080. private _transformMatrix;
  24081. private _mirrorMatrix;
  24082. private _savedViewMatrix;
  24083. private _blurX;
  24084. private _blurY;
  24085. private _adaptiveBlurKernel;
  24086. private _blurKernelX;
  24087. private _blurKernelY;
  24088. private _blurRatio;
  24089. /**
  24090. * Instantiates a Mirror Texture.
  24091. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24092. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24093. * You can then easily use it as a reflectionTexture on a flat surface.
  24094. * In case the surface is not a plane, please consider relying on reflection probes.
  24095. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24096. * @param name
  24097. * @param size
  24098. * @param scene
  24099. * @param generateMipMaps
  24100. * @param type
  24101. * @param samplingMode
  24102. * @param generateDepthBuffer
  24103. */
  24104. constructor(name: string, size: number | {
  24105. width: number;
  24106. height: number;
  24107. } | {
  24108. ratio: number;
  24109. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  24110. private _preparePostProcesses;
  24111. /**
  24112. * Clone the mirror texture.
  24113. * @returns the cloned texture
  24114. */
  24115. clone(): MirrorTexture;
  24116. /**
  24117. * Serialize the texture to a JSON representation you could use in Parse later on
  24118. * @returns the serialized JSON representation
  24119. */
  24120. serialize(): any;
  24121. /**
  24122. * Dispose the texture and release its associated resources.
  24123. */
  24124. dispose(): void;
  24125. }
  24126. }
  24127. declare module "babylonjs/Materials/Textures/texture" {
  24128. import { Observable } from "babylonjs/Misc/observable";
  24129. import { Nullable } from "babylonjs/types";
  24130. import { Matrix } from "babylonjs/Maths/math.vector";
  24131. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24132. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24133. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24134. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  24135. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  24136. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24137. import { Scene } from "babylonjs/scene";
  24138. /**
  24139. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24140. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24141. */
  24142. export class Texture extends BaseTexture {
  24143. /**
  24144. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  24145. */
  24146. static SerializeBuffers: boolean;
  24147. /** @hidden */
  24148. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  24149. /** @hidden */
  24150. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  24151. /** @hidden */
  24152. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  24153. /** nearest is mag = nearest and min = nearest and mip = linear */
  24154. static readonly NEAREST_SAMPLINGMODE: number;
  24155. /** nearest is mag = nearest and min = nearest and mip = linear */
  24156. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  24157. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24158. static readonly BILINEAR_SAMPLINGMODE: number;
  24159. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24160. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  24161. /** Trilinear is mag = linear and min = linear and mip = linear */
  24162. static readonly TRILINEAR_SAMPLINGMODE: number;
  24163. /** Trilinear is mag = linear and min = linear and mip = linear */
  24164. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  24165. /** mag = nearest and min = nearest and mip = nearest */
  24166. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  24167. /** mag = nearest and min = linear and mip = nearest */
  24168. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  24169. /** mag = nearest and min = linear and mip = linear */
  24170. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  24171. /** mag = nearest and min = linear and mip = none */
  24172. static readonly NEAREST_LINEAR: number;
  24173. /** mag = nearest and min = nearest and mip = none */
  24174. static readonly NEAREST_NEAREST: number;
  24175. /** mag = linear and min = nearest and mip = nearest */
  24176. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24177. /** mag = linear and min = nearest and mip = linear */
  24178. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24179. /** mag = linear and min = linear and mip = none */
  24180. static readonly LINEAR_LINEAR: number;
  24181. /** mag = linear and min = nearest and mip = none */
  24182. static readonly LINEAR_NEAREST: number;
  24183. /** Explicit coordinates mode */
  24184. static readonly EXPLICIT_MODE: number;
  24185. /** Spherical coordinates mode */
  24186. static readonly SPHERICAL_MODE: number;
  24187. /** Planar coordinates mode */
  24188. static readonly PLANAR_MODE: number;
  24189. /** Cubic coordinates mode */
  24190. static readonly CUBIC_MODE: number;
  24191. /** Projection coordinates mode */
  24192. static readonly PROJECTION_MODE: number;
  24193. /** Inverse Cubic coordinates mode */
  24194. static readonly SKYBOX_MODE: number;
  24195. /** Inverse Cubic coordinates mode */
  24196. static readonly INVCUBIC_MODE: number;
  24197. /** Equirectangular coordinates mode */
  24198. static readonly EQUIRECTANGULAR_MODE: number;
  24199. /** Equirectangular Fixed coordinates mode */
  24200. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24201. /** Equirectangular Fixed Mirrored coordinates mode */
  24202. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24203. /** Texture is not repeating outside of 0..1 UVs */
  24204. static readonly CLAMP_ADDRESSMODE: number;
  24205. /** Texture is repeating outside of 0..1 UVs */
  24206. static readonly WRAP_ADDRESSMODE: number;
  24207. /** Texture is repeating and mirrored */
  24208. static readonly MIRROR_ADDRESSMODE: number;
  24209. /**
  24210. * 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
  24211. */
  24212. static UseSerializedUrlIfAny: boolean;
  24213. /**
  24214. * Define the url of the texture.
  24215. */
  24216. url: Nullable<string>;
  24217. /**
  24218. * Define an offset on the texture to offset the u coordinates of the UVs
  24219. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24220. */
  24221. uOffset: number;
  24222. /**
  24223. * Define an offset on the texture to offset the v coordinates of the UVs
  24224. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24225. */
  24226. vOffset: number;
  24227. /**
  24228. * Define an offset on the texture to scale the u coordinates of the UVs
  24229. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24230. */
  24231. uScale: number;
  24232. /**
  24233. * Define an offset on the texture to scale the v coordinates of the UVs
  24234. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24235. */
  24236. vScale: number;
  24237. /**
  24238. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24239. * @see https://doc.babylonjs.com/how_to/more_materials
  24240. */
  24241. uAng: number;
  24242. /**
  24243. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24244. * @see https://doc.babylonjs.com/how_to/more_materials
  24245. */
  24246. vAng: number;
  24247. /**
  24248. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24249. * @see https://doc.babylonjs.com/how_to/more_materials
  24250. */
  24251. wAng: number;
  24252. /**
  24253. * Defines the center of rotation (U)
  24254. */
  24255. uRotationCenter: number;
  24256. /**
  24257. * Defines the center of rotation (V)
  24258. */
  24259. vRotationCenter: number;
  24260. /**
  24261. * Defines the center of rotation (W)
  24262. */
  24263. wRotationCenter: number;
  24264. /**
  24265. * Are mip maps generated for this texture or not.
  24266. */
  24267. get noMipmap(): boolean;
  24268. /**
  24269. * List of inspectable custom properties (used by the Inspector)
  24270. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24271. */
  24272. inspectableCustomProperties: Nullable<IInspectable[]>;
  24273. private _noMipmap;
  24274. /** @hidden */
  24275. _invertY: boolean;
  24276. private _rowGenerationMatrix;
  24277. private _cachedTextureMatrix;
  24278. private _projectionModeMatrix;
  24279. private _t0;
  24280. private _t1;
  24281. private _t2;
  24282. private _cachedUOffset;
  24283. private _cachedVOffset;
  24284. private _cachedUScale;
  24285. private _cachedVScale;
  24286. private _cachedUAng;
  24287. private _cachedVAng;
  24288. private _cachedWAng;
  24289. private _cachedProjectionMatrixId;
  24290. private _cachedCoordinatesMode;
  24291. /** @hidden */
  24292. protected _initialSamplingMode: number;
  24293. /** @hidden */
  24294. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24295. private _deleteBuffer;
  24296. protected _format: Nullable<number>;
  24297. private _delayedOnLoad;
  24298. private _delayedOnError;
  24299. private _mimeType?;
  24300. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24301. get mimeType(): string | undefined;
  24302. /**
  24303. * Observable triggered once the texture has been loaded.
  24304. */
  24305. onLoadObservable: Observable<Texture>;
  24306. protected _isBlocking: boolean;
  24307. /**
  24308. * Is the texture preventing material to render while loading.
  24309. * If false, a default texture will be used instead of the loading one during the preparation step.
  24310. */
  24311. set isBlocking(value: boolean);
  24312. get isBlocking(): boolean;
  24313. /**
  24314. * Get the current sampling mode associated with the texture.
  24315. */
  24316. get samplingMode(): number;
  24317. /**
  24318. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24319. */
  24320. get invertY(): boolean;
  24321. /**
  24322. * Instantiates a new texture.
  24323. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24324. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24325. * @param url defines the url of the picture to load as a texture
  24326. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24327. * @param noMipmap defines if the texture will require mip maps or not
  24328. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24329. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24330. * @param onLoad defines a callback triggered when the texture has been loaded
  24331. * @param onError defines a callback triggered when an error occurred during the loading session
  24332. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24333. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24334. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24335. * @param mimeType defines an optional mime type information
  24336. */
  24337. 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);
  24338. /**
  24339. * Update the url (and optional buffer) of this texture if url was null during construction.
  24340. * @param url the url of the texture
  24341. * @param buffer the buffer of the texture (defaults to null)
  24342. * @param onLoad callback called when the texture is loaded (defaults to null)
  24343. */
  24344. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24345. /**
  24346. * Finish the loading sequence of a texture flagged as delayed load.
  24347. * @hidden
  24348. */
  24349. delayLoad(): void;
  24350. private _prepareRowForTextureGeneration;
  24351. /**
  24352. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24353. * @returns the transform matrix of the texture.
  24354. */
  24355. getTextureMatrix(uBase?: number): Matrix;
  24356. /**
  24357. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24358. * @returns The reflection texture transform
  24359. */
  24360. getReflectionTextureMatrix(): Matrix;
  24361. /**
  24362. * Clones the texture.
  24363. * @returns the cloned texture
  24364. */
  24365. clone(): Texture;
  24366. /**
  24367. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24368. * @returns The JSON representation of the texture
  24369. */
  24370. serialize(): any;
  24371. /**
  24372. * Get the current class name of the texture useful for serialization or dynamic coding.
  24373. * @returns "Texture"
  24374. */
  24375. getClassName(): string;
  24376. /**
  24377. * Dispose the texture and release its associated resources.
  24378. */
  24379. dispose(): void;
  24380. /**
  24381. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24382. * @param parsedTexture Define the JSON representation of the texture
  24383. * @param scene Define the scene the parsed texture should be instantiated in
  24384. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24385. * @returns The parsed texture if successful
  24386. */
  24387. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24388. /**
  24389. * Creates a texture from its base 64 representation.
  24390. * @param data Define the base64 payload without the data: prefix
  24391. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24392. * @param scene Define the scene the texture should belong to
  24393. * @param noMipmap Forces the texture to not create mip map information if true
  24394. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24395. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24396. * @param onLoad define a callback triggered when the texture has been loaded
  24397. * @param onError define a callback triggered when an error occurred during the loading session
  24398. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24399. * @returns the created texture
  24400. */
  24401. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24402. /**
  24403. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24404. * @param data Define the base64 payload without the data: prefix
  24405. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24406. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24407. * @param scene Define the scene the texture should belong to
  24408. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24409. * @param noMipmap Forces the texture to not create mip map information if true
  24410. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24411. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24412. * @param onLoad define a callback triggered when the texture has been loaded
  24413. * @param onError define a callback triggered when an error occurred during the loading session
  24414. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24415. * @returns the created texture
  24416. */
  24417. 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;
  24418. }
  24419. }
  24420. declare module "babylonjs/PostProcesses/postProcessManager" {
  24421. import { Nullable } from "babylonjs/types";
  24422. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24423. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24424. import { Scene } from "babylonjs/scene";
  24425. /**
  24426. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24427. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24428. */
  24429. export class PostProcessManager {
  24430. private _scene;
  24431. private _indexBuffer;
  24432. private _vertexBuffers;
  24433. /**
  24434. * Creates a new instance PostProcess
  24435. * @param scene The scene that the post process is associated with.
  24436. */
  24437. constructor(scene: Scene);
  24438. private _prepareBuffers;
  24439. private _buildIndexBuffer;
  24440. /**
  24441. * Rebuilds the vertex buffers of the manager.
  24442. * @hidden
  24443. */
  24444. _rebuild(): void;
  24445. /**
  24446. * Prepares a frame to be run through a post process.
  24447. * @param sourceTexture The input texture to the post procesess. (default: null)
  24448. * @param postProcesses An array of post processes to be run. (default: null)
  24449. * @returns True if the post processes were able to be run.
  24450. * @hidden
  24451. */
  24452. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24453. /**
  24454. * Manually render a set of post processes to a texture.
  24455. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24456. * @param postProcesses An array of post processes to be run.
  24457. * @param targetTexture The target texture to render to.
  24458. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24459. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24460. * @param lodLevel defines which lod of the texture to render to
  24461. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24462. */
  24463. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24464. /**
  24465. * Finalize the result of the output of the postprocesses.
  24466. * @param doNotPresent If true the result will not be displayed to the screen.
  24467. * @param targetTexture The target texture to render to.
  24468. * @param faceIndex The index of the face to bind the target texture to.
  24469. * @param postProcesses The array of post processes to render.
  24470. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24471. * @hidden
  24472. */
  24473. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24474. /**
  24475. * Disposes of the post process manager.
  24476. */
  24477. dispose(): void;
  24478. }
  24479. }
  24480. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24481. import { Observable } from "babylonjs/Misc/observable";
  24482. import { SmartArray } from "babylonjs/Misc/smartArray";
  24483. import { Nullable, Immutable } from "babylonjs/types";
  24484. import { Camera } from "babylonjs/Cameras/camera";
  24485. import { Scene } from "babylonjs/scene";
  24486. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24487. import { Color4 } from "babylonjs/Maths/math.color";
  24488. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24490. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24491. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24492. import { Texture } from "babylonjs/Materials/Textures/texture";
  24493. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24494. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24495. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24496. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24497. import { Engine } from "babylonjs/Engines/engine";
  24498. /**
  24499. * This Helps creating a texture that will be created from a camera in your scene.
  24500. * It is basically a dynamic texture that could be used to create special effects for instance.
  24501. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24502. */
  24503. export class RenderTargetTexture extends Texture {
  24504. /**
  24505. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24506. */
  24507. static readonly REFRESHRATE_RENDER_ONCE: number;
  24508. /**
  24509. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24510. */
  24511. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24512. /**
  24513. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24514. * the central point of your effect and can save a lot of performances.
  24515. */
  24516. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24517. /**
  24518. * Use this predicate to dynamically define the list of mesh you want to render.
  24519. * If set, the renderList property will be overwritten.
  24520. */
  24521. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24522. private _renderList;
  24523. /**
  24524. * Use this list to define the list of mesh you want to render.
  24525. */
  24526. get renderList(): Nullable<Array<AbstractMesh>>;
  24527. set renderList(value: Nullable<Array<AbstractMesh>>);
  24528. /**
  24529. * Use this function to overload the renderList array at rendering time.
  24530. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24531. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24532. * the cube (if the RTT is a cube, else layerOrFace=0).
  24533. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24534. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24535. * hold dummy elements!
  24536. */
  24537. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24538. private _hookArray;
  24539. /**
  24540. * Define if particles should be rendered in your texture.
  24541. */
  24542. renderParticles: boolean;
  24543. /**
  24544. * Define if sprites should be rendered in your texture.
  24545. */
  24546. renderSprites: boolean;
  24547. /**
  24548. * Define the camera used to render the texture.
  24549. */
  24550. activeCamera: Nullable<Camera>;
  24551. /**
  24552. * Override the mesh isReady function with your own one.
  24553. */
  24554. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24555. /**
  24556. * Override the render function of the texture with your own one.
  24557. */
  24558. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24559. /**
  24560. * Define if camera post processes should be use while rendering the texture.
  24561. */
  24562. useCameraPostProcesses: boolean;
  24563. /**
  24564. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24565. */
  24566. ignoreCameraViewport: boolean;
  24567. private _postProcessManager;
  24568. private _postProcesses;
  24569. private _resizeObserver;
  24570. /**
  24571. * An event triggered when the texture is unbind.
  24572. */
  24573. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24574. /**
  24575. * An event triggered when the texture is unbind.
  24576. */
  24577. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24578. private _onAfterUnbindObserver;
  24579. /**
  24580. * Set a after unbind callback in the texture.
  24581. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24582. */
  24583. set onAfterUnbind(callback: () => void);
  24584. /**
  24585. * An event triggered before rendering the texture
  24586. */
  24587. onBeforeRenderObservable: Observable<number>;
  24588. private _onBeforeRenderObserver;
  24589. /**
  24590. * Set a before render callback in the texture.
  24591. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24592. */
  24593. set onBeforeRender(callback: (faceIndex: number) => void);
  24594. /**
  24595. * An event triggered after rendering the texture
  24596. */
  24597. onAfterRenderObservable: Observable<number>;
  24598. private _onAfterRenderObserver;
  24599. /**
  24600. * Set a after render callback in the texture.
  24601. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24602. */
  24603. set onAfterRender(callback: (faceIndex: number) => void);
  24604. /**
  24605. * An event triggered after the texture clear
  24606. */
  24607. onClearObservable: Observable<Engine>;
  24608. private _onClearObserver;
  24609. /**
  24610. * Set a clear callback in the texture.
  24611. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24612. */
  24613. set onClear(callback: (Engine: Engine) => void);
  24614. /**
  24615. * An event triggered when the texture is resized.
  24616. */
  24617. onResizeObservable: Observable<RenderTargetTexture>;
  24618. /**
  24619. * Define the clear color of the Render Target if it should be different from the scene.
  24620. */
  24621. clearColor: Color4;
  24622. protected _size: number | {
  24623. width: number;
  24624. height: number;
  24625. layers?: number;
  24626. };
  24627. protected _initialSizeParameter: number | {
  24628. width: number;
  24629. height: number;
  24630. } | {
  24631. ratio: number;
  24632. };
  24633. protected _sizeRatio: Nullable<number>;
  24634. /** @hidden */
  24635. _generateMipMaps: boolean;
  24636. protected _renderingManager: RenderingManager;
  24637. /** @hidden */
  24638. _waitingRenderList?: string[];
  24639. protected _doNotChangeAspectRatio: boolean;
  24640. protected _currentRefreshId: number;
  24641. protected _refreshRate: number;
  24642. protected _textureMatrix: Matrix;
  24643. protected _samples: number;
  24644. protected _renderTargetOptions: RenderTargetCreationOptions;
  24645. /**
  24646. * Gets render target creation options that were used.
  24647. */
  24648. get renderTargetOptions(): RenderTargetCreationOptions;
  24649. protected _onRatioRescale(): void;
  24650. /**
  24651. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24652. * It must define where the camera used to render the texture is set
  24653. */
  24654. boundingBoxPosition: Vector3;
  24655. private _boundingBoxSize;
  24656. /**
  24657. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24658. * When defined, the cubemap will switch to local mode
  24659. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24660. * @example https://www.babylonjs-playground.com/#RNASML
  24661. */
  24662. set boundingBoxSize(value: Vector3);
  24663. get boundingBoxSize(): Vector3;
  24664. /**
  24665. * In case the RTT has been created with a depth texture, get the associated
  24666. * depth texture.
  24667. * Otherwise, return null.
  24668. */
  24669. get depthStencilTexture(): Nullable<InternalTexture>;
  24670. /**
  24671. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24672. * or used a shadow, depth texture...
  24673. * @param name The friendly name of the texture
  24674. * @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)
  24675. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24676. * @param generateMipMaps True if mip maps need to be generated after render.
  24677. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24678. * @param type The type of the buffer in the RTT (int, half float, float...)
  24679. * @param isCube True if a cube texture needs to be created
  24680. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24681. * @param generateDepthBuffer True to generate a depth buffer
  24682. * @param generateStencilBuffer True to generate a stencil buffer
  24683. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24684. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24685. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24686. */
  24687. constructor(name: string, size: number | {
  24688. width: number;
  24689. height: number;
  24690. layers?: number;
  24691. } | {
  24692. ratio: number;
  24693. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24694. /**
  24695. * Creates a depth stencil texture.
  24696. * This is only available in WebGL 2 or with the depth texture extension available.
  24697. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24698. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24699. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24700. */
  24701. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24702. private _processSizeParameter;
  24703. /**
  24704. * Define the number of samples to use in case of MSAA.
  24705. * It defaults to one meaning no MSAA has been enabled.
  24706. */
  24707. get samples(): number;
  24708. set samples(value: number);
  24709. /**
  24710. * Resets the refresh counter of the texture and start bak from scratch.
  24711. * Could be useful to regenerate the texture if it is setup to render only once.
  24712. */
  24713. resetRefreshCounter(): void;
  24714. /**
  24715. * Define the refresh rate of the texture or the rendering frequency.
  24716. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24717. */
  24718. get refreshRate(): number;
  24719. set refreshRate(value: number);
  24720. /**
  24721. * Adds a post process to the render target rendering passes.
  24722. * @param postProcess define the post process to add
  24723. */
  24724. addPostProcess(postProcess: PostProcess): void;
  24725. /**
  24726. * Clear all the post processes attached to the render target
  24727. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24728. */
  24729. clearPostProcesses(dispose?: boolean): void;
  24730. /**
  24731. * Remove one of the post process from the list of attached post processes to the texture
  24732. * @param postProcess define the post process to remove from the list
  24733. */
  24734. removePostProcess(postProcess: PostProcess): void;
  24735. /** @hidden */
  24736. _shouldRender(): boolean;
  24737. /**
  24738. * Gets the actual render size of the texture.
  24739. * @returns the width of the render size
  24740. */
  24741. getRenderSize(): number;
  24742. /**
  24743. * Gets the actual render width of the texture.
  24744. * @returns the width of the render size
  24745. */
  24746. getRenderWidth(): number;
  24747. /**
  24748. * Gets the actual render height of the texture.
  24749. * @returns the height of the render size
  24750. */
  24751. getRenderHeight(): number;
  24752. /**
  24753. * Gets the actual number of layers of the texture.
  24754. * @returns the number of layers
  24755. */
  24756. getRenderLayers(): number;
  24757. /**
  24758. * Get if the texture can be rescaled or not.
  24759. */
  24760. get canRescale(): boolean;
  24761. /**
  24762. * Resize the texture using a ratio.
  24763. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24764. */
  24765. scale(ratio: number): void;
  24766. /**
  24767. * Get the texture reflection matrix used to rotate/transform the reflection.
  24768. * @returns the reflection matrix
  24769. */
  24770. getReflectionTextureMatrix(): Matrix;
  24771. /**
  24772. * Resize the texture to a new desired size.
  24773. * Be carrefull as it will recreate all the data in the new texture.
  24774. * @param size Define the new size. It can be:
  24775. * - a number for squared texture,
  24776. * - an object containing { width: number, height: number }
  24777. * - or an object containing a ratio { ratio: number }
  24778. */
  24779. resize(size: number | {
  24780. width: number;
  24781. height: number;
  24782. } | {
  24783. ratio: number;
  24784. }): void;
  24785. private _defaultRenderListPrepared;
  24786. /**
  24787. * Renders all the objects from the render list into the texture.
  24788. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24789. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24790. */
  24791. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24792. private _bestReflectionRenderTargetDimension;
  24793. private _prepareRenderingManager;
  24794. /**
  24795. * @hidden
  24796. * @param faceIndex face index to bind to if this is a cubetexture
  24797. * @param layer defines the index of the texture to bind in the array
  24798. */
  24799. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24800. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24801. private renderToTarget;
  24802. /**
  24803. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24804. * This allowed control for front to back rendering or reversly depending of the special needs.
  24805. *
  24806. * @param renderingGroupId The rendering group id corresponding to its index
  24807. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24808. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24809. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24810. */
  24811. 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;
  24812. /**
  24813. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24814. *
  24815. * @param renderingGroupId The rendering group id corresponding to its index
  24816. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24817. */
  24818. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24819. /**
  24820. * Clones the texture.
  24821. * @returns the cloned texture
  24822. */
  24823. clone(): RenderTargetTexture;
  24824. /**
  24825. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24826. * @returns The JSON representation of the texture
  24827. */
  24828. serialize(): any;
  24829. /**
  24830. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24831. */
  24832. disposeFramebufferObjects(): void;
  24833. /**
  24834. * Dispose the texture and release its associated resources.
  24835. */
  24836. dispose(): void;
  24837. /** @hidden */
  24838. _rebuild(): void;
  24839. /**
  24840. * Clear the info related to rendering groups preventing retention point in material dispose.
  24841. */
  24842. freeRenderingGroups(): void;
  24843. /**
  24844. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24845. * @returns the view count
  24846. */
  24847. getViewCount(): number;
  24848. }
  24849. }
  24850. declare module "babylonjs/Misc/guid" {
  24851. /**
  24852. * Class used to manipulate GUIDs
  24853. */
  24854. export class GUID {
  24855. /**
  24856. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24857. * Be aware Math.random() could cause collisions, but:
  24858. * "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"
  24859. * @returns a pseudo random id
  24860. */
  24861. static RandomId(): string;
  24862. }
  24863. }
  24864. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24865. import { Nullable } from "babylonjs/types";
  24866. import { Scene } from "babylonjs/scene";
  24867. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24868. import { Material } from "babylonjs/Materials/material";
  24869. import { Effect } from "babylonjs/Materials/effect";
  24870. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24871. /**
  24872. * Options to be used when creating a shadow depth material
  24873. */
  24874. export interface IIOptionShadowDepthMaterial {
  24875. /** Variables in the vertex shader code that need to have their names remapped.
  24876. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24877. * "var_name" should be either: worldPos or vNormalW
  24878. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24879. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24880. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24881. */
  24882. remappedVariables?: string[];
  24883. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24884. standalone?: boolean;
  24885. }
  24886. /**
  24887. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24888. */
  24889. export class ShadowDepthWrapper {
  24890. private _scene;
  24891. private _options?;
  24892. private _baseMaterial;
  24893. private _onEffectCreatedObserver;
  24894. private _subMeshToEffect;
  24895. private _subMeshToDepthEffect;
  24896. private _meshes;
  24897. /** @hidden */
  24898. _matriceNames: any;
  24899. /** Gets the standalone status of the wrapper */
  24900. get standalone(): boolean;
  24901. /** Gets the base material the wrapper is built upon */
  24902. get baseMaterial(): Material;
  24903. /**
  24904. * Instantiate a new shadow depth wrapper.
  24905. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24906. * generate the shadow depth map. For more information, please refer to the documentation:
  24907. * https://doc.babylonjs.com/babylon101/shadows
  24908. * @param baseMaterial Material to wrap
  24909. * @param scene Define the scene the material belongs to
  24910. * @param options Options used to create the wrapper
  24911. */
  24912. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24913. /**
  24914. * Gets the effect to use to generate the depth map
  24915. * @param subMesh subMesh to get the effect for
  24916. * @param shadowGenerator shadow generator to get the effect for
  24917. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24918. */
  24919. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24920. /**
  24921. * Specifies that the submesh is ready to be used for depth rendering
  24922. * @param subMesh submesh to check
  24923. * @param defines the list of defines to take into account when checking the effect
  24924. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24925. * @param useInstances specifies that instances should be used
  24926. * @returns a boolean indicating that the submesh is ready or not
  24927. */
  24928. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24929. /**
  24930. * Disposes the resources
  24931. */
  24932. dispose(): void;
  24933. private _makeEffect;
  24934. }
  24935. }
  24936. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24937. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24938. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24939. import { Nullable } from "babylonjs/types";
  24940. module "babylonjs/Engines/thinEngine" {
  24941. interface ThinEngine {
  24942. /**
  24943. * Unbind a list of render target textures from the webGL context
  24944. * This is used only when drawBuffer extension or webGL2 are active
  24945. * @param textures defines the render target textures to unbind
  24946. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24947. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24948. */
  24949. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24950. /**
  24951. * Create a multi render target texture
  24952. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24953. * @param size defines the size of the texture
  24954. * @param options defines the creation options
  24955. * @returns the cube texture as an InternalTexture
  24956. */
  24957. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24958. /**
  24959. * Update the sample count for a given multiple render target texture
  24960. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24961. * @param textures defines the textures to update
  24962. * @param samples defines the sample count to set
  24963. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24964. */
  24965. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24966. /**
  24967. * Select a subsets of attachments to draw to.
  24968. * @param attachments gl attachments
  24969. */
  24970. bindAttachments(attachments: number[]): void;
  24971. }
  24972. }
  24973. }
  24974. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24975. import { Scene } from "babylonjs/scene";
  24976. import { Engine } from "babylonjs/Engines/engine";
  24977. import { Texture } from "babylonjs/Materials/Textures/texture";
  24978. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24979. import "babylonjs/Engines/Extensions/engine.multiRender";
  24980. /**
  24981. * Creation options of the multi render target texture.
  24982. */
  24983. export interface IMultiRenderTargetOptions {
  24984. /**
  24985. * Define if the texture needs to create mip maps after render.
  24986. */
  24987. generateMipMaps?: boolean;
  24988. /**
  24989. * Define the types of all the draw buffers we want to create
  24990. */
  24991. types?: number[];
  24992. /**
  24993. * Define the sampling modes of all the draw buffers we want to create
  24994. */
  24995. samplingModes?: number[];
  24996. /**
  24997. * Define if a depth buffer is required
  24998. */
  24999. generateDepthBuffer?: boolean;
  25000. /**
  25001. * Define if a stencil buffer is required
  25002. */
  25003. generateStencilBuffer?: boolean;
  25004. /**
  25005. * Define if a depth texture is required instead of a depth buffer
  25006. */
  25007. generateDepthTexture?: boolean;
  25008. /**
  25009. * Define the number of desired draw buffers
  25010. */
  25011. textureCount?: number;
  25012. /**
  25013. * Define if aspect ratio should be adapted to the texture or stay the scene one
  25014. */
  25015. doNotChangeAspectRatio?: boolean;
  25016. /**
  25017. * Define the default type of the buffers we are creating
  25018. */
  25019. defaultType?: number;
  25020. }
  25021. /**
  25022. * A multi render target, like a render target provides the ability to render to a texture.
  25023. * Unlike the render target, it can render to several draw buffers in one draw.
  25024. * This is specially interesting in deferred rendering or for any effects requiring more than
  25025. * just one color from a single pass.
  25026. */
  25027. export class MultiRenderTarget extends RenderTargetTexture {
  25028. private _internalTextures;
  25029. private _textures;
  25030. private _multiRenderTargetOptions;
  25031. private _count;
  25032. /**
  25033. * Get if draw buffers are currently supported by the used hardware and browser.
  25034. */
  25035. get isSupported(): boolean;
  25036. /**
  25037. * Get the list of textures generated by the multi render target.
  25038. */
  25039. get textures(): Texture[];
  25040. /**
  25041. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  25042. */
  25043. get count(): number;
  25044. /**
  25045. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25046. */
  25047. get depthTexture(): Texture;
  25048. /**
  25049. * Set the wrapping mode on U of all the textures we are rendering to.
  25050. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25051. */
  25052. set wrapU(wrap: number);
  25053. /**
  25054. * Set the wrapping mode on V of all the textures we are rendering to.
  25055. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25056. */
  25057. set wrapV(wrap: number);
  25058. /**
  25059. * Instantiate a new multi render target texture.
  25060. * A multi render target, like a render target provides the ability to render to a texture.
  25061. * Unlike the render target, it can render to several draw buffers in one draw.
  25062. * This is specially interesting in deferred rendering or for any effects requiring more than
  25063. * just one color from a single pass.
  25064. * @param name Define the name of the texture
  25065. * @param size Define the size of the buffers to render to
  25066. * @param count Define the number of target we are rendering into
  25067. * @param scene Define the scene the texture belongs to
  25068. * @param options Define the options used to create the multi render target
  25069. */
  25070. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25071. private _initTypes;
  25072. /** @hidden */
  25073. _rebuild(forceFullRebuild?: boolean): void;
  25074. private _createInternalTextures;
  25075. private _createTextures;
  25076. /**
  25077. * Define the number of samples used if MSAA is enabled.
  25078. */
  25079. get samples(): number;
  25080. set samples(value: number);
  25081. /**
  25082. * Resize all the textures in the multi render target.
  25083. * Be careful as it will recreate all the data in the new texture.
  25084. * @param size Define the new size
  25085. */
  25086. resize(size: any): void;
  25087. /**
  25088. * Changes the number of render targets in this MRT
  25089. * Be careful as it will recreate all the data in the new texture.
  25090. * @param count new texture count
  25091. * @param options Specifies texture types and sampling modes for new textures
  25092. */
  25093. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  25094. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25095. /**
  25096. * Dispose the render targets and their associated resources
  25097. */
  25098. dispose(): void;
  25099. /**
  25100. * Release all the underlying texture used as draw buffers.
  25101. */
  25102. releaseInternalTextures(): void;
  25103. }
  25104. }
  25105. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  25106. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  25107. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25108. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  25109. /** @hidden */
  25110. export var imageProcessingPixelShader: {
  25111. name: string;
  25112. shader: string;
  25113. };
  25114. }
  25115. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  25116. import { Nullable } from "babylonjs/types";
  25117. import { Color4 } from "babylonjs/Maths/math.color";
  25118. import { Camera } from "babylonjs/Cameras/camera";
  25119. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25120. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  25121. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  25122. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  25123. import { Engine } from "babylonjs/Engines/engine";
  25124. import "babylonjs/Shaders/imageProcessing.fragment";
  25125. import "babylonjs/Shaders/postprocess.vertex";
  25126. /**
  25127. * ImageProcessingPostProcess
  25128. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  25129. */
  25130. export class ImageProcessingPostProcess extends PostProcess {
  25131. /**
  25132. * Default configuration related to image processing available in the PBR Material.
  25133. */
  25134. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25135. /**
  25136. * Gets the image processing configuration used either in this material.
  25137. */
  25138. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25139. /**
  25140. * Sets the Default image processing configuration used either in the this material.
  25141. *
  25142. * If sets to null, the scene one is in use.
  25143. */
  25144. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25145. /**
  25146. * Keep track of the image processing observer to allow dispose and replace.
  25147. */
  25148. private _imageProcessingObserver;
  25149. /**
  25150. * Attaches a new image processing configuration to the PBR Material.
  25151. * @param configuration
  25152. */
  25153. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  25154. /**
  25155. * If the post process is supported.
  25156. */
  25157. get isSupported(): boolean;
  25158. /**
  25159. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25160. */
  25161. get colorCurves(): Nullable<ColorCurves>;
  25162. /**
  25163. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25164. */
  25165. set colorCurves(value: Nullable<ColorCurves>);
  25166. /**
  25167. * Gets wether the color curves effect is enabled.
  25168. */
  25169. get colorCurvesEnabled(): boolean;
  25170. /**
  25171. * Sets wether the color curves effect is enabled.
  25172. */
  25173. set colorCurvesEnabled(value: boolean);
  25174. /**
  25175. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25176. */
  25177. get colorGradingTexture(): Nullable<BaseTexture>;
  25178. /**
  25179. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25180. */
  25181. set colorGradingTexture(value: Nullable<BaseTexture>);
  25182. /**
  25183. * Gets wether the color grading effect is enabled.
  25184. */
  25185. get colorGradingEnabled(): boolean;
  25186. /**
  25187. * Gets wether the color grading effect is enabled.
  25188. */
  25189. set colorGradingEnabled(value: boolean);
  25190. /**
  25191. * Gets exposure used in the effect.
  25192. */
  25193. get exposure(): number;
  25194. /**
  25195. * Sets exposure used in the effect.
  25196. */
  25197. set exposure(value: number);
  25198. /**
  25199. * Gets wether tonemapping is enabled or not.
  25200. */
  25201. get toneMappingEnabled(): boolean;
  25202. /**
  25203. * Sets wether tonemapping is enabled or not
  25204. */
  25205. set toneMappingEnabled(value: boolean);
  25206. /**
  25207. * Gets the type of tone mapping effect.
  25208. */
  25209. get toneMappingType(): number;
  25210. /**
  25211. * Sets the type of tone mapping effect.
  25212. */
  25213. set toneMappingType(value: number);
  25214. /**
  25215. * Gets contrast used in the effect.
  25216. */
  25217. get contrast(): number;
  25218. /**
  25219. * Sets contrast used in the effect.
  25220. */
  25221. set contrast(value: number);
  25222. /**
  25223. * Gets Vignette stretch size.
  25224. */
  25225. get vignetteStretch(): number;
  25226. /**
  25227. * Sets Vignette stretch size.
  25228. */
  25229. set vignetteStretch(value: number);
  25230. /**
  25231. * Gets Vignette centre X Offset.
  25232. */
  25233. get vignetteCentreX(): number;
  25234. /**
  25235. * Sets Vignette centre X Offset.
  25236. */
  25237. set vignetteCentreX(value: number);
  25238. /**
  25239. * Gets Vignette centre Y Offset.
  25240. */
  25241. get vignetteCentreY(): number;
  25242. /**
  25243. * Sets Vignette centre Y Offset.
  25244. */
  25245. set vignetteCentreY(value: number);
  25246. /**
  25247. * Gets Vignette weight or intensity of the vignette effect.
  25248. */
  25249. get vignetteWeight(): number;
  25250. /**
  25251. * Sets Vignette weight or intensity of the vignette effect.
  25252. */
  25253. set vignetteWeight(value: number);
  25254. /**
  25255. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25256. * if vignetteEnabled is set to true.
  25257. */
  25258. get vignetteColor(): Color4;
  25259. /**
  25260. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25261. * if vignetteEnabled is set to true.
  25262. */
  25263. set vignetteColor(value: Color4);
  25264. /**
  25265. * Gets Camera field of view used by the Vignette effect.
  25266. */
  25267. get vignetteCameraFov(): number;
  25268. /**
  25269. * Sets Camera field of view used by the Vignette effect.
  25270. */
  25271. set vignetteCameraFov(value: number);
  25272. /**
  25273. * Gets the vignette blend mode allowing different kind of effect.
  25274. */
  25275. get vignetteBlendMode(): number;
  25276. /**
  25277. * Sets the vignette blend mode allowing different kind of effect.
  25278. */
  25279. set vignetteBlendMode(value: number);
  25280. /**
  25281. * Gets wether the vignette effect is enabled.
  25282. */
  25283. get vignetteEnabled(): boolean;
  25284. /**
  25285. * Sets wether the vignette effect is enabled.
  25286. */
  25287. set vignetteEnabled(value: boolean);
  25288. private _fromLinearSpace;
  25289. /**
  25290. * Gets wether the input of the processing is in Gamma or Linear Space.
  25291. */
  25292. get fromLinearSpace(): boolean;
  25293. /**
  25294. * Sets wether the input of the processing is in Gamma or Linear Space.
  25295. */
  25296. set fromLinearSpace(value: boolean);
  25297. /**
  25298. * Defines cache preventing GC.
  25299. */
  25300. private _defines;
  25301. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25302. /**
  25303. * "ImageProcessingPostProcess"
  25304. * @returns "ImageProcessingPostProcess"
  25305. */
  25306. getClassName(): string;
  25307. /**
  25308. * @hidden
  25309. */
  25310. _updateParameters(): void;
  25311. dispose(camera?: Camera): void;
  25312. }
  25313. }
  25314. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  25315. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25316. /**
  25317. * Interface for defining prepass effects in the prepass post-process pipeline
  25318. */
  25319. export interface PrePassEffectConfiguration {
  25320. /**
  25321. * Name of the effect
  25322. */
  25323. name: string;
  25324. /**
  25325. * Post process to attach for this effect
  25326. */
  25327. postProcess?: PostProcess;
  25328. /**
  25329. * Textures required in the MRT
  25330. */
  25331. texturesRequired: number[];
  25332. /**
  25333. * Is the effect enabled
  25334. */
  25335. enabled: boolean;
  25336. /**
  25337. * Disposes the effect configuration
  25338. */
  25339. dispose(): void;
  25340. /**
  25341. * Creates the associated post process
  25342. */
  25343. createPostProcess?: () => PostProcess;
  25344. }
  25345. }
  25346. declare module "babylonjs/Rendering/prePassRenderer" {
  25347. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25348. import { Scene } from "babylonjs/scene";
  25349. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25350. import { Effect } from "babylonjs/Materials/effect";
  25351. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25352. /**
  25353. * Renders a pre pass of the scene
  25354. * This means every mesh in the scene will be rendered to a render target texture
  25355. * And then this texture will be composited to the rendering canvas with post processes
  25356. * It is necessary for effects like subsurface scattering or deferred shading
  25357. */
  25358. export class PrePassRenderer {
  25359. /** @hidden */
  25360. static _SceneComponentInitialization: (scene: Scene) => void;
  25361. private _textureFormats;
  25362. private _textureIndices;
  25363. private _scene;
  25364. private _engine;
  25365. private _isDirty;
  25366. /**
  25367. * Number of textures in the multi render target texture where the scene is directly rendered
  25368. */
  25369. mrtCount: number;
  25370. /**
  25371. * The render target where the scene is directly rendered
  25372. */
  25373. prePassRT: MultiRenderTarget;
  25374. private _multiRenderAttachments;
  25375. private _defaultAttachments;
  25376. private _clearAttachments;
  25377. private _postProcesses;
  25378. private readonly _clearColor;
  25379. /**
  25380. * Image processing post process for composition
  25381. */
  25382. imageProcessingPostProcess: ImageProcessingPostProcess;
  25383. /**
  25384. * Configuration for prepass effects
  25385. */
  25386. private _effectConfigurations;
  25387. /**
  25388. * Should materials render their geometry on the MRT
  25389. */
  25390. materialsShouldRenderGeometry: boolean;
  25391. /**
  25392. * Should materials render the irradiance information on the MRT
  25393. */
  25394. materialsShouldRenderIrradiance: boolean;
  25395. private _mrtFormats;
  25396. private _mrtLayout;
  25397. private _enabled;
  25398. /**
  25399. * Indicates if the prepass is enabled
  25400. */
  25401. get enabled(): boolean;
  25402. /**
  25403. * How many samples are used for MSAA of the scene render target
  25404. */
  25405. get samples(): number;
  25406. set samples(n: number);
  25407. /**
  25408. * Instanciates a prepass renderer
  25409. * @param scene The scene
  25410. */
  25411. constructor(scene: Scene);
  25412. private _initializeAttachments;
  25413. private _createCompositionEffect;
  25414. /**
  25415. * Indicates if rendering a prepass is supported
  25416. */
  25417. get isSupported(): boolean;
  25418. /**
  25419. * Sets the proper output textures to draw in the engine.
  25420. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25421. */
  25422. bindAttachmentsForEffect(effect: Effect): void;
  25423. /**
  25424. * @hidden
  25425. */
  25426. _beforeCameraDraw(): void;
  25427. /**
  25428. * @hidden
  25429. */
  25430. _afterCameraDraw(): void;
  25431. private _checkRTSize;
  25432. private _bindFrameBuffer;
  25433. /**
  25434. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25435. */
  25436. clear(): void;
  25437. private _setState;
  25438. private _checkTextureType;
  25439. /**
  25440. * Adds an effect configuration to the prepass.
  25441. * If an effect has already been added, it won't add it twice and will return the configuration
  25442. * already present.
  25443. * @param cfg the effect configuration
  25444. * @return the effect configuration now used by the prepass
  25445. */
  25446. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  25447. /**
  25448. * Returns the index of a texture in the multi render target texture array.
  25449. * @param type Texture type
  25450. * @return The index
  25451. */
  25452. getIndex(type: number): number;
  25453. private _enable;
  25454. private _disable;
  25455. private _resetLayout;
  25456. private _resetPostProcessChain;
  25457. private _bindPostProcessChain;
  25458. /**
  25459. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25460. */
  25461. markAsDirty(): void;
  25462. /**
  25463. * Enables a texture on the MultiRenderTarget for prepass
  25464. */
  25465. private _enableTextures;
  25466. private _update;
  25467. /**
  25468. * Disposes the prepass renderer.
  25469. */
  25470. dispose(): void;
  25471. }
  25472. }
  25473. declare module "babylonjs/Materials/material" {
  25474. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25475. import { SmartArray } from "babylonjs/Misc/smartArray";
  25476. import { Observable } from "babylonjs/Misc/observable";
  25477. import { Nullable } from "babylonjs/types";
  25478. import { Scene } from "babylonjs/scene";
  25479. import { Matrix } from "babylonjs/Maths/math.vector";
  25480. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25482. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25483. import { Effect } from "babylonjs/Materials/effect";
  25484. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25485. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25486. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25487. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25488. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25489. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25490. import { Mesh } from "babylonjs/Meshes/mesh";
  25491. import { Animation } from "babylonjs/Animations/animation";
  25492. /**
  25493. * Options for compiling materials.
  25494. */
  25495. export interface IMaterialCompilationOptions {
  25496. /**
  25497. * Defines whether clip planes are enabled.
  25498. */
  25499. clipPlane: boolean;
  25500. /**
  25501. * Defines whether instances are enabled.
  25502. */
  25503. useInstances: boolean;
  25504. }
  25505. /**
  25506. * Options passed when calling customShaderNameResolve
  25507. */
  25508. export interface ICustomShaderNameResolveOptions {
  25509. /**
  25510. * 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
  25511. */
  25512. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25513. }
  25514. /**
  25515. * Base class for the main features of a material in Babylon.js
  25516. */
  25517. export class Material implements IAnimatable {
  25518. /**
  25519. * Returns the triangle fill mode
  25520. */
  25521. static readonly TriangleFillMode: number;
  25522. /**
  25523. * Returns the wireframe mode
  25524. */
  25525. static readonly WireFrameFillMode: number;
  25526. /**
  25527. * Returns the point fill mode
  25528. */
  25529. static readonly PointFillMode: number;
  25530. /**
  25531. * Returns the point list draw mode
  25532. */
  25533. static readonly PointListDrawMode: number;
  25534. /**
  25535. * Returns the line list draw mode
  25536. */
  25537. static readonly LineListDrawMode: number;
  25538. /**
  25539. * Returns the line loop draw mode
  25540. */
  25541. static readonly LineLoopDrawMode: number;
  25542. /**
  25543. * Returns the line strip draw mode
  25544. */
  25545. static readonly LineStripDrawMode: number;
  25546. /**
  25547. * Returns the triangle strip draw mode
  25548. */
  25549. static readonly TriangleStripDrawMode: number;
  25550. /**
  25551. * Returns the triangle fan draw mode
  25552. */
  25553. static readonly TriangleFanDrawMode: number;
  25554. /**
  25555. * Stores the clock-wise side orientation
  25556. */
  25557. static readonly ClockWiseSideOrientation: number;
  25558. /**
  25559. * Stores the counter clock-wise side orientation
  25560. */
  25561. static readonly CounterClockWiseSideOrientation: number;
  25562. /**
  25563. * The dirty texture flag value
  25564. */
  25565. static readonly TextureDirtyFlag: number;
  25566. /**
  25567. * The dirty light flag value
  25568. */
  25569. static readonly LightDirtyFlag: number;
  25570. /**
  25571. * The dirty fresnel flag value
  25572. */
  25573. static readonly FresnelDirtyFlag: number;
  25574. /**
  25575. * The dirty attribute flag value
  25576. */
  25577. static readonly AttributesDirtyFlag: number;
  25578. /**
  25579. * The dirty misc flag value
  25580. */
  25581. static readonly MiscDirtyFlag: number;
  25582. /**
  25583. * The all dirty flag value
  25584. */
  25585. static readonly AllDirtyFlag: number;
  25586. /**
  25587. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25588. */
  25589. static readonly MATERIAL_OPAQUE: number;
  25590. /**
  25591. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25592. */
  25593. static readonly MATERIAL_ALPHATEST: number;
  25594. /**
  25595. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25596. */
  25597. static readonly MATERIAL_ALPHABLEND: number;
  25598. /**
  25599. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25600. * They are also discarded below the alpha cutoff threshold to improve performances.
  25601. */
  25602. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25603. /**
  25604. * The Whiteout method is used to blend normals.
  25605. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25606. */
  25607. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25608. /**
  25609. * The Reoriented Normal Mapping method is used to blend normals.
  25610. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25611. */
  25612. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25613. /**
  25614. * Custom callback helping to override the default shader used in the material.
  25615. */
  25616. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25617. /**
  25618. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25619. */
  25620. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25621. /**
  25622. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25623. * This means that the material can keep using a previous shader while a new one is being compiled.
  25624. * This is mostly used when shader parallel compilation is supported (true by default)
  25625. */
  25626. allowShaderHotSwapping: boolean;
  25627. /**
  25628. * The ID of the material
  25629. */
  25630. id: string;
  25631. /**
  25632. * Gets or sets the unique id of the material
  25633. */
  25634. uniqueId: number;
  25635. /**
  25636. * The name of the material
  25637. */
  25638. name: string;
  25639. /**
  25640. * Gets or sets user defined metadata
  25641. */
  25642. metadata: any;
  25643. /**
  25644. * For internal use only. Please do not use.
  25645. */
  25646. reservedDataStore: any;
  25647. /**
  25648. * Specifies if the ready state should be checked on each call
  25649. */
  25650. checkReadyOnEveryCall: boolean;
  25651. /**
  25652. * Specifies if the ready state should be checked once
  25653. */
  25654. checkReadyOnlyOnce: boolean;
  25655. /**
  25656. * The state of the material
  25657. */
  25658. state: string;
  25659. /**
  25660. * If the material can be rendered to several textures with MRT extension
  25661. */
  25662. get canRenderToMRT(): boolean;
  25663. /**
  25664. * The alpha value of the material
  25665. */
  25666. protected _alpha: number;
  25667. /**
  25668. * List of inspectable custom properties (used by the Inspector)
  25669. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25670. */
  25671. inspectableCustomProperties: IInspectable[];
  25672. /**
  25673. * Sets the alpha value of the material
  25674. */
  25675. set alpha(value: number);
  25676. /**
  25677. * Gets the alpha value of the material
  25678. */
  25679. get alpha(): number;
  25680. /**
  25681. * Specifies if back face culling is enabled
  25682. */
  25683. protected _backFaceCulling: boolean;
  25684. /**
  25685. * Sets the back-face culling state
  25686. */
  25687. set backFaceCulling(value: boolean);
  25688. /**
  25689. * Gets the back-face culling state
  25690. */
  25691. get backFaceCulling(): boolean;
  25692. /**
  25693. * Stores the value for side orientation
  25694. */
  25695. sideOrientation: number;
  25696. /**
  25697. * Callback triggered when the material is compiled
  25698. */
  25699. onCompiled: Nullable<(effect: Effect) => void>;
  25700. /**
  25701. * Callback triggered when an error occurs
  25702. */
  25703. onError: Nullable<(effect: Effect, errors: string) => void>;
  25704. /**
  25705. * Callback triggered to get the render target textures
  25706. */
  25707. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25708. /**
  25709. * Gets a boolean indicating that current material needs to register RTT
  25710. */
  25711. get hasRenderTargetTextures(): boolean;
  25712. /**
  25713. * Specifies if the material should be serialized
  25714. */
  25715. doNotSerialize: boolean;
  25716. /**
  25717. * @hidden
  25718. */
  25719. _storeEffectOnSubMeshes: boolean;
  25720. /**
  25721. * Stores the animations for the material
  25722. */
  25723. animations: Nullable<Array<Animation>>;
  25724. /**
  25725. * An event triggered when the material is disposed
  25726. */
  25727. onDisposeObservable: Observable<Material>;
  25728. /**
  25729. * An observer which watches for dispose events
  25730. */
  25731. private _onDisposeObserver;
  25732. private _onUnBindObservable;
  25733. /**
  25734. * Called during a dispose event
  25735. */
  25736. set onDispose(callback: () => void);
  25737. private _onBindObservable;
  25738. /**
  25739. * An event triggered when the material is bound
  25740. */
  25741. get onBindObservable(): Observable<AbstractMesh>;
  25742. /**
  25743. * An observer which watches for bind events
  25744. */
  25745. private _onBindObserver;
  25746. /**
  25747. * Called during a bind event
  25748. */
  25749. set onBind(callback: (Mesh: AbstractMesh) => void);
  25750. /**
  25751. * An event triggered when the material is unbound
  25752. */
  25753. get onUnBindObservable(): Observable<Material>;
  25754. protected _onEffectCreatedObservable: Nullable<Observable<{
  25755. effect: Effect;
  25756. subMesh: Nullable<SubMesh>;
  25757. }>>;
  25758. /**
  25759. * An event triggered when the effect is (re)created
  25760. */
  25761. get onEffectCreatedObservable(): Observable<{
  25762. effect: Effect;
  25763. subMesh: Nullable<SubMesh>;
  25764. }>;
  25765. /**
  25766. * Stores the value of the alpha mode
  25767. */
  25768. private _alphaMode;
  25769. /**
  25770. * Sets the value of the alpha mode.
  25771. *
  25772. * | Value | Type | Description |
  25773. * | --- | --- | --- |
  25774. * | 0 | ALPHA_DISABLE | |
  25775. * | 1 | ALPHA_ADD | |
  25776. * | 2 | ALPHA_COMBINE | |
  25777. * | 3 | ALPHA_SUBTRACT | |
  25778. * | 4 | ALPHA_MULTIPLY | |
  25779. * | 5 | ALPHA_MAXIMIZED | |
  25780. * | 6 | ALPHA_ONEONE | |
  25781. * | 7 | ALPHA_PREMULTIPLIED | |
  25782. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25783. * | 9 | ALPHA_INTERPOLATE | |
  25784. * | 10 | ALPHA_SCREENMODE | |
  25785. *
  25786. */
  25787. set alphaMode(value: number);
  25788. /**
  25789. * Gets the value of the alpha mode
  25790. */
  25791. get alphaMode(): number;
  25792. /**
  25793. * Stores the state of the need depth pre-pass value
  25794. */
  25795. private _needDepthPrePass;
  25796. /**
  25797. * Sets the need depth pre-pass value
  25798. */
  25799. set needDepthPrePass(value: boolean);
  25800. /**
  25801. * Gets the depth pre-pass value
  25802. */
  25803. get needDepthPrePass(): boolean;
  25804. /**
  25805. * Specifies if depth writing should be disabled
  25806. */
  25807. disableDepthWrite: boolean;
  25808. /**
  25809. * Specifies if color writing should be disabled
  25810. */
  25811. disableColorWrite: boolean;
  25812. /**
  25813. * Specifies if depth writing should be forced
  25814. */
  25815. forceDepthWrite: boolean;
  25816. /**
  25817. * Specifies the depth function that should be used. 0 means the default engine function
  25818. */
  25819. depthFunction: number;
  25820. /**
  25821. * Specifies if there should be a separate pass for culling
  25822. */
  25823. separateCullingPass: boolean;
  25824. /**
  25825. * Stores the state specifing if fog should be enabled
  25826. */
  25827. private _fogEnabled;
  25828. /**
  25829. * Sets the state for enabling fog
  25830. */
  25831. set fogEnabled(value: boolean);
  25832. /**
  25833. * Gets the value of the fog enabled state
  25834. */
  25835. get fogEnabled(): boolean;
  25836. /**
  25837. * Stores the size of points
  25838. */
  25839. pointSize: number;
  25840. /**
  25841. * Stores the z offset value
  25842. */
  25843. zOffset: number;
  25844. get wireframe(): boolean;
  25845. /**
  25846. * Sets the state of wireframe mode
  25847. */
  25848. set wireframe(value: boolean);
  25849. /**
  25850. * Gets the value specifying if point clouds are enabled
  25851. */
  25852. get pointsCloud(): boolean;
  25853. /**
  25854. * Sets the state of point cloud mode
  25855. */
  25856. set pointsCloud(value: boolean);
  25857. /**
  25858. * Gets the material fill mode
  25859. */
  25860. get fillMode(): number;
  25861. /**
  25862. * Sets the material fill mode
  25863. */
  25864. set fillMode(value: number);
  25865. /**
  25866. * @hidden
  25867. * Stores the effects for the material
  25868. */
  25869. _effect: Nullable<Effect>;
  25870. /**
  25871. * Specifies if uniform buffers should be used
  25872. */
  25873. private _useUBO;
  25874. /**
  25875. * Stores a reference to the scene
  25876. */
  25877. private _scene;
  25878. /**
  25879. * Stores the fill mode state
  25880. */
  25881. private _fillMode;
  25882. /**
  25883. * Specifies if the depth write state should be cached
  25884. */
  25885. private _cachedDepthWriteState;
  25886. /**
  25887. * Specifies if the color write state should be cached
  25888. */
  25889. private _cachedColorWriteState;
  25890. /**
  25891. * Specifies if the depth function state should be cached
  25892. */
  25893. private _cachedDepthFunctionState;
  25894. /**
  25895. * Stores the uniform buffer
  25896. */
  25897. protected _uniformBuffer: UniformBuffer;
  25898. /** @hidden */
  25899. _indexInSceneMaterialArray: number;
  25900. /** @hidden */
  25901. meshMap: Nullable<{
  25902. [id: string]: AbstractMesh | undefined;
  25903. }>;
  25904. /**
  25905. * Creates a material instance
  25906. * @param name defines the name of the material
  25907. * @param scene defines the scene to reference
  25908. * @param doNotAdd specifies if the material should be added to the scene
  25909. */
  25910. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25911. /**
  25912. * Returns a string representation of the current material
  25913. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25914. * @returns a string with material information
  25915. */
  25916. toString(fullDetails?: boolean): string;
  25917. /**
  25918. * Gets the class name of the material
  25919. * @returns a string with the class name of the material
  25920. */
  25921. getClassName(): string;
  25922. /**
  25923. * Specifies if updates for the material been locked
  25924. */
  25925. get isFrozen(): boolean;
  25926. /**
  25927. * Locks updates for the material
  25928. */
  25929. freeze(): void;
  25930. /**
  25931. * Unlocks updates for the material
  25932. */
  25933. unfreeze(): void;
  25934. /**
  25935. * Specifies if the material is ready to be used
  25936. * @param mesh defines the mesh to check
  25937. * @param useInstances specifies if instances should be used
  25938. * @returns a boolean indicating if the material is ready to be used
  25939. */
  25940. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25941. /**
  25942. * Specifies that the submesh is ready to be used
  25943. * @param mesh defines the mesh to check
  25944. * @param subMesh defines which submesh to check
  25945. * @param useInstances specifies that instances should be used
  25946. * @returns a boolean indicating that the submesh is ready or not
  25947. */
  25948. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25949. /**
  25950. * Returns the material effect
  25951. * @returns the effect associated with the material
  25952. */
  25953. getEffect(): Nullable<Effect>;
  25954. /**
  25955. * Returns the current scene
  25956. * @returns a Scene
  25957. */
  25958. getScene(): Scene;
  25959. /**
  25960. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25961. */
  25962. protected _forceAlphaTest: boolean;
  25963. /**
  25964. * The transparency mode of the material.
  25965. */
  25966. protected _transparencyMode: Nullable<number>;
  25967. /**
  25968. * Gets the current transparency mode.
  25969. */
  25970. get transparencyMode(): Nullable<number>;
  25971. /**
  25972. * Sets the transparency mode of the material.
  25973. *
  25974. * | Value | Type | Description |
  25975. * | ----- | ----------------------------------- | ----------- |
  25976. * | 0 | OPAQUE | |
  25977. * | 1 | ALPHATEST | |
  25978. * | 2 | ALPHABLEND | |
  25979. * | 3 | ALPHATESTANDBLEND | |
  25980. *
  25981. */
  25982. set transparencyMode(value: Nullable<number>);
  25983. /**
  25984. * Returns true if alpha blending should be disabled.
  25985. */
  25986. protected get _disableAlphaBlending(): boolean;
  25987. /**
  25988. * Specifies whether or not this material should be rendered in alpha blend mode.
  25989. * @returns a boolean specifying if alpha blending is needed
  25990. */
  25991. needAlphaBlending(): boolean;
  25992. /**
  25993. * Specifies if the mesh will require alpha blending
  25994. * @param mesh defines the mesh to check
  25995. * @returns a boolean specifying if alpha blending is needed for the mesh
  25996. */
  25997. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25998. /**
  25999. * Specifies whether or not this material should be rendered in alpha test mode.
  26000. * @returns a boolean specifying if an alpha test is needed.
  26001. */
  26002. needAlphaTesting(): boolean;
  26003. /**
  26004. * Specifies if material alpha testing should be turned on for the mesh
  26005. * @param mesh defines the mesh to check
  26006. */
  26007. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  26008. /**
  26009. * Gets the texture used for the alpha test
  26010. * @returns the texture to use for alpha testing
  26011. */
  26012. getAlphaTestTexture(): Nullable<BaseTexture>;
  26013. /**
  26014. * Marks the material to indicate that it needs to be re-calculated
  26015. */
  26016. markDirty(): void;
  26017. /** @hidden */
  26018. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  26019. /**
  26020. * Binds the material to the mesh
  26021. * @param world defines the world transformation matrix
  26022. * @param mesh defines the mesh to bind the material to
  26023. */
  26024. bind(world: Matrix, mesh?: Mesh): void;
  26025. /**
  26026. * Binds the submesh to the material
  26027. * @param world defines the world transformation matrix
  26028. * @param mesh defines the mesh containing the submesh
  26029. * @param subMesh defines the submesh to bind the material to
  26030. */
  26031. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26032. /**
  26033. * Binds the world matrix to the material
  26034. * @param world defines the world transformation matrix
  26035. */
  26036. bindOnlyWorldMatrix(world: Matrix): void;
  26037. /**
  26038. * Binds the scene's uniform buffer to the effect.
  26039. * @param effect defines the effect to bind to the scene uniform buffer
  26040. * @param sceneUbo defines the uniform buffer storing scene data
  26041. */
  26042. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  26043. /**
  26044. * Binds the view matrix to the effect
  26045. * @param effect defines the effect to bind the view matrix to
  26046. */
  26047. bindView(effect: Effect): void;
  26048. /**
  26049. * Binds the view projection matrix to the effect
  26050. * @param effect defines the effect to bind the view projection matrix to
  26051. */
  26052. bindViewProjection(effect: Effect): void;
  26053. /**
  26054. * Processes to execute after binding the material to a mesh
  26055. * @param mesh defines the rendered mesh
  26056. */
  26057. protected _afterBind(mesh?: Mesh): void;
  26058. /**
  26059. * Unbinds the material from the mesh
  26060. */
  26061. unbind(): void;
  26062. /**
  26063. * Gets the active textures from the material
  26064. * @returns an array of textures
  26065. */
  26066. getActiveTextures(): BaseTexture[];
  26067. /**
  26068. * Specifies if the material uses a texture
  26069. * @param texture defines the texture to check against the material
  26070. * @returns a boolean specifying if the material uses the texture
  26071. */
  26072. hasTexture(texture: BaseTexture): boolean;
  26073. /**
  26074. * Makes a duplicate of the material, and gives it a new name
  26075. * @param name defines the new name for the duplicated material
  26076. * @returns the cloned material
  26077. */
  26078. clone(name: string): Nullable<Material>;
  26079. /**
  26080. * Gets the meshes bound to the material
  26081. * @returns an array of meshes bound to the material
  26082. */
  26083. getBindedMeshes(): AbstractMesh[];
  26084. /**
  26085. * Force shader compilation
  26086. * @param mesh defines the mesh associated with this material
  26087. * @param onCompiled defines a function to execute once the material is compiled
  26088. * @param options defines the options to configure the compilation
  26089. * @param onError defines a function to execute if the material fails compiling
  26090. */
  26091. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  26092. /**
  26093. * Force shader compilation
  26094. * @param mesh defines the mesh that will use this material
  26095. * @param options defines additional options for compiling the shaders
  26096. * @returns a promise that resolves when the compilation completes
  26097. */
  26098. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  26099. private static readonly _AllDirtyCallBack;
  26100. private static readonly _ImageProcessingDirtyCallBack;
  26101. private static readonly _TextureDirtyCallBack;
  26102. private static readonly _FresnelDirtyCallBack;
  26103. private static readonly _MiscDirtyCallBack;
  26104. private static readonly _LightsDirtyCallBack;
  26105. private static readonly _AttributeDirtyCallBack;
  26106. private static _FresnelAndMiscDirtyCallBack;
  26107. private static _TextureAndMiscDirtyCallBack;
  26108. private static readonly _DirtyCallbackArray;
  26109. private static readonly _RunDirtyCallBacks;
  26110. /**
  26111. * Marks a define in the material to indicate that it needs to be re-computed
  26112. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  26113. */
  26114. markAsDirty(flag: number): void;
  26115. /**
  26116. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  26117. * @param func defines a function which checks material defines against the submeshes
  26118. */
  26119. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  26120. /**
  26121. * Indicates that the scene should check if the rendering now needs a prepass
  26122. */
  26123. protected _markScenePrePassDirty(): void;
  26124. /**
  26125. * Indicates that we need to re-calculated for all submeshes
  26126. */
  26127. protected _markAllSubMeshesAsAllDirty(): void;
  26128. /**
  26129. * Indicates that image processing needs to be re-calculated for all submeshes
  26130. */
  26131. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  26132. /**
  26133. * Indicates that textures need to be re-calculated for all submeshes
  26134. */
  26135. protected _markAllSubMeshesAsTexturesDirty(): void;
  26136. /**
  26137. * Indicates that fresnel needs to be re-calculated for all submeshes
  26138. */
  26139. protected _markAllSubMeshesAsFresnelDirty(): void;
  26140. /**
  26141. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  26142. */
  26143. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  26144. /**
  26145. * Indicates that lights need to be re-calculated for all submeshes
  26146. */
  26147. protected _markAllSubMeshesAsLightsDirty(): void;
  26148. /**
  26149. * Indicates that attributes need to be re-calculated for all submeshes
  26150. */
  26151. protected _markAllSubMeshesAsAttributesDirty(): void;
  26152. /**
  26153. * Indicates that misc needs to be re-calculated for all submeshes
  26154. */
  26155. protected _markAllSubMeshesAsMiscDirty(): void;
  26156. /**
  26157. * Indicates that textures and misc need to be re-calculated for all submeshes
  26158. */
  26159. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  26160. /**
  26161. * Sets the required values to the prepass renderer.
  26162. * @param prePassRenderer defines the prepass renderer to setup.
  26163. * @returns true if the pre pass is needed.
  26164. */
  26165. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26166. /**
  26167. * Disposes the material
  26168. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26169. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26170. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  26171. */
  26172. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  26173. /** @hidden */
  26174. private releaseVertexArrayObject;
  26175. /**
  26176. * Serializes this material
  26177. * @returns the serialized material object
  26178. */
  26179. serialize(): any;
  26180. /**
  26181. * Creates a material from parsed material data
  26182. * @param parsedMaterial defines parsed material data
  26183. * @param scene defines the hosting scene
  26184. * @param rootUrl defines the root URL to use to load textures
  26185. * @returns a new material
  26186. */
  26187. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  26188. }
  26189. }
  26190. declare module "babylonjs/Materials/multiMaterial" {
  26191. import { Nullable } from "babylonjs/types";
  26192. import { Scene } from "babylonjs/scene";
  26193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26194. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26195. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26196. import { Material } from "babylonjs/Materials/material";
  26197. /**
  26198. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26199. * separate meshes. This can be use to improve performances.
  26200. * @see https://doc.babylonjs.com/how_to/multi_materials
  26201. */
  26202. export class MultiMaterial extends Material {
  26203. private _subMaterials;
  26204. /**
  26205. * Gets or Sets the list of Materials used within the multi material.
  26206. * They need to be ordered according to the submeshes order in the associated mesh
  26207. */
  26208. get subMaterials(): Nullable<Material>[];
  26209. set subMaterials(value: Nullable<Material>[]);
  26210. /**
  26211. * Function used to align with Node.getChildren()
  26212. * @returns the list of Materials used within the multi material
  26213. */
  26214. getChildren(): Nullable<Material>[];
  26215. /**
  26216. * Instantiates a new Multi Material
  26217. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26218. * separate meshes. This can be use to improve performances.
  26219. * @see https://doc.babylonjs.com/how_to/multi_materials
  26220. * @param name Define the name in the scene
  26221. * @param scene Define the scene the material belongs to
  26222. */
  26223. constructor(name: string, scene: Scene);
  26224. private _hookArray;
  26225. /**
  26226. * Get one of the submaterial by its index in the submaterials array
  26227. * @param index The index to look the sub material at
  26228. * @returns The Material if the index has been defined
  26229. */
  26230. getSubMaterial(index: number): Nullable<Material>;
  26231. /**
  26232. * Get the list of active textures for the whole sub materials list.
  26233. * @returns All the textures that will be used during the rendering
  26234. */
  26235. getActiveTextures(): BaseTexture[];
  26236. /**
  26237. * Gets the current class name of the material e.g. "MultiMaterial"
  26238. * Mainly use in serialization.
  26239. * @returns the class name
  26240. */
  26241. getClassName(): string;
  26242. /**
  26243. * Checks if the material is ready to render the requested sub mesh
  26244. * @param mesh Define the mesh the submesh belongs to
  26245. * @param subMesh Define the sub mesh to look readyness for
  26246. * @param useInstances Define whether or not the material is used with instances
  26247. * @returns true if ready, otherwise false
  26248. */
  26249. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26250. /**
  26251. * Clones the current material and its related sub materials
  26252. * @param name Define the name of the newly cloned material
  26253. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26254. * @returns the cloned material
  26255. */
  26256. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26257. /**
  26258. * Serializes the materials into a JSON representation.
  26259. * @returns the JSON representation
  26260. */
  26261. serialize(): any;
  26262. /**
  26263. * Dispose the material and release its associated resources
  26264. * @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)
  26265. * @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)
  26266. * @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)
  26267. */
  26268. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26269. /**
  26270. * Creates a MultiMaterial from parsed MultiMaterial data.
  26271. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26272. * @param scene defines the hosting scene
  26273. * @returns a new MultiMaterial
  26274. */
  26275. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26276. }
  26277. }
  26278. declare module "babylonjs/Meshes/subMesh" {
  26279. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26280. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26281. import { Engine } from "babylonjs/Engines/engine";
  26282. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26283. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26284. import { Effect } from "babylonjs/Materials/effect";
  26285. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26286. import { Plane } from "babylonjs/Maths/math.plane";
  26287. import { Collider } from "babylonjs/Collisions/collider";
  26288. import { Material } from "babylonjs/Materials/material";
  26289. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26291. import { Mesh } from "babylonjs/Meshes/mesh";
  26292. import { Ray } from "babylonjs/Culling/ray";
  26293. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26294. /**
  26295. * Defines a subdivision inside a mesh
  26296. */
  26297. export class SubMesh implements ICullable {
  26298. /** the material index to use */
  26299. materialIndex: number;
  26300. /** vertex index start */
  26301. verticesStart: number;
  26302. /** vertices count */
  26303. verticesCount: number;
  26304. /** index start */
  26305. indexStart: number;
  26306. /** indices count */
  26307. indexCount: number;
  26308. /** @hidden */
  26309. _materialDefines: Nullable<MaterialDefines>;
  26310. /** @hidden */
  26311. _materialEffect: Nullable<Effect>;
  26312. /** @hidden */
  26313. _effectOverride: Nullable<Effect>;
  26314. /**
  26315. * Gets material defines used by the effect associated to the sub mesh
  26316. */
  26317. get materialDefines(): Nullable<MaterialDefines>;
  26318. /**
  26319. * Sets material defines used by the effect associated to the sub mesh
  26320. */
  26321. set materialDefines(defines: Nullable<MaterialDefines>);
  26322. /**
  26323. * Gets associated effect
  26324. */
  26325. get effect(): Nullable<Effect>;
  26326. /**
  26327. * Sets associated effect (effect used to render this submesh)
  26328. * @param effect defines the effect to associate with
  26329. * @param defines defines the set of defines used to compile this effect
  26330. */
  26331. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26332. /** @hidden */
  26333. _linesIndexCount: number;
  26334. private _mesh;
  26335. private _renderingMesh;
  26336. private _boundingInfo;
  26337. private _linesIndexBuffer;
  26338. /** @hidden */
  26339. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26340. /** @hidden */
  26341. _trianglePlanes: Plane[];
  26342. /** @hidden */
  26343. _lastColliderTransformMatrix: Nullable<Matrix>;
  26344. /** @hidden */
  26345. _renderId: number;
  26346. /** @hidden */
  26347. _alphaIndex: number;
  26348. /** @hidden */
  26349. _distanceToCamera: number;
  26350. /** @hidden */
  26351. _id: number;
  26352. private _currentMaterial;
  26353. /**
  26354. * Add a new submesh to a mesh
  26355. * @param materialIndex defines the material index to use
  26356. * @param verticesStart defines vertex index start
  26357. * @param verticesCount defines vertices count
  26358. * @param indexStart defines index start
  26359. * @param indexCount defines indices count
  26360. * @param mesh defines the parent mesh
  26361. * @param renderingMesh defines an optional rendering mesh
  26362. * @param createBoundingBox defines if bounding box should be created for this submesh
  26363. * @returns the new submesh
  26364. */
  26365. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26366. /**
  26367. * Creates a new submesh
  26368. * @param materialIndex defines the material index to use
  26369. * @param verticesStart defines vertex index start
  26370. * @param verticesCount defines vertices count
  26371. * @param indexStart defines index start
  26372. * @param indexCount defines indices count
  26373. * @param mesh defines the parent mesh
  26374. * @param renderingMesh defines an optional rendering mesh
  26375. * @param createBoundingBox defines if bounding box should be created for this submesh
  26376. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26377. */
  26378. constructor(
  26379. /** the material index to use */
  26380. materialIndex: number,
  26381. /** vertex index start */
  26382. verticesStart: number,
  26383. /** vertices count */
  26384. verticesCount: number,
  26385. /** index start */
  26386. indexStart: number,
  26387. /** indices count */
  26388. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26389. /**
  26390. * Returns true if this submesh covers the entire parent mesh
  26391. * @ignorenaming
  26392. */
  26393. get IsGlobal(): boolean;
  26394. /**
  26395. * Returns the submesh BoudingInfo object
  26396. * @returns current bounding info (or mesh's one if the submesh is global)
  26397. */
  26398. getBoundingInfo(): BoundingInfo;
  26399. /**
  26400. * Sets the submesh BoundingInfo
  26401. * @param boundingInfo defines the new bounding info to use
  26402. * @returns the SubMesh
  26403. */
  26404. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26405. /**
  26406. * Returns the mesh of the current submesh
  26407. * @return the parent mesh
  26408. */
  26409. getMesh(): AbstractMesh;
  26410. /**
  26411. * Returns the rendering mesh of the submesh
  26412. * @returns the rendering mesh (could be different from parent mesh)
  26413. */
  26414. getRenderingMesh(): Mesh;
  26415. /**
  26416. * Returns the replacement mesh of the submesh
  26417. * @returns the replacement mesh (could be different from parent mesh)
  26418. */
  26419. getReplacementMesh(): Nullable<AbstractMesh>;
  26420. /**
  26421. * Returns the effective mesh of the submesh
  26422. * @returns the effective mesh (could be different from parent mesh)
  26423. */
  26424. getEffectiveMesh(): AbstractMesh;
  26425. /**
  26426. * Returns the submesh material
  26427. * @returns null or the current material
  26428. */
  26429. getMaterial(): Nullable<Material>;
  26430. private _IsMultiMaterial;
  26431. /**
  26432. * Sets a new updated BoundingInfo object to the submesh
  26433. * @param data defines an optional position array to use to determine the bounding info
  26434. * @returns the SubMesh
  26435. */
  26436. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26437. /** @hidden */
  26438. _checkCollision(collider: Collider): boolean;
  26439. /**
  26440. * Updates the submesh BoundingInfo
  26441. * @param world defines the world matrix to use to update the bounding info
  26442. * @returns the submesh
  26443. */
  26444. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26445. /**
  26446. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26447. * @param frustumPlanes defines the frustum planes
  26448. * @returns true if the submesh is intersecting with the frustum
  26449. */
  26450. isInFrustum(frustumPlanes: Plane[]): boolean;
  26451. /**
  26452. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26453. * @param frustumPlanes defines the frustum planes
  26454. * @returns true if the submesh is inside the frustum
  26455. */
  26456. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26457. /**
  26458. * Renders the submesh
  26459. * @param enableAlphaMode defines if alpha needs to be used
  26460. * @returns the submesh
  26461. */
  26462. render(enableAlphaMode: boolean): SubMesh;
  26463. /**
  26464. * @hidden
  26465. */
  26466. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26467. /**
  26468. * Checks if the submesh intersects with a ray
  26469. * @param ray defines the ray to test
  26470. * @returns true is the passed ray intersects the submesh bounding box
  26471. */
  26472. canIntersects(ray: Ray): boolean;
  26473. /**
  26474. * Intersects current submesh with a ray
  26475. * @param ray defines the ray to test
  26476. * @param positions defines mesh's positions array
  26477. * @param indices defines mesh's indices array
  26478. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26479. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26480. * @returns intersection info or null if no intersection
  26481. */
  26482. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26483. /** @hidden */
  26484. private _intersectLines;
  26485. /** @hidden */
  26486. private _intersectUnIndexedLines;
  26487. /** @hidden */
  26488. private _intersectTriangles;
  26489. /** @hidden */
  26490. private _intersectUnIndexedTriangles;
  26491. /** @hidden */
  26492. _rebuild(): void;
  26493. /**
  26494. * Creates a new submesh from the passed mesh
  26495. * @param newMesh defines the new hosting mesh
  26496. * @param newRenderingMesh defines an optional rendering mesh
  26497. * @returns the new submesh
  26498. */
  26499. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26500. /**
  26501. * Release associated resources
  26502. */
  26503. dispose(): void;
  26504. /**
  26505. * Gets the class name
  26506. * @returns the string "SubMesh".
  26507. */
  26508. getClassName(): string;
  26509. /**
  26510. * Creates a new submesh from indices data
  26511. * @param materialIndex the index of the main mesh material
  26512. * @param startIndex the index where to start the copy in the mesh indices array
  26513. * @param indexCount the number of indices to copy then from the startIndex
  26514. * @param mesh the main mesh to create the submesh from
  26515. * @param renderingMesh the optional rendering mesh
  26516. * @returns a new submesh
  26517. */
  26518. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26519. }
  26520. }
  26521. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26522. /**
  26523. * Class used to represent data loading progression
  26524. */
  26525. export class SceneLoaderFlags {
  26526. private static _ForceFullSceneLoadingForIncremental;
  26527. private static _ShowLoadingScreen;
  26528. private static _CleanBoneMatrixWeights;
  26529. private static _loggingLevel;
  26530. /**
  26531. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26532. */
  26533. static get ForceFullSceneLoadingForIncremental(): boolean;
  26534. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26535. /**
  26536. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26537. */
  26538. static get ShowLoadingScreen(): boolean;
  26539. static set ShowLoadingScreen(value: boolean);
  26540. /**
  26541. * Defines the current logging level (while loading the scene)
  26542. * @ignorenaming
  26543. */
  26544. static get loggingLevel(): number;
  26545. static set loggingLevel(value: number);
  26546. /**
  26547. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26548. */
  26549. static get CleanBoneMatrixWeights(): boolean;
  26550. static set CleanBoneMatrixWeights(value: boolean);
  26551. }
  26552. }
  26553. declare module "babylonjs/Meshes/geometry" {
  26554. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26555. import { Scene } from "babylonjs/scene";
  26556. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26557. import { Engine } from "babylonjs/Engines/engine";
  26558. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26559. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26560. import { Effect } from "babylonjs/Materials/effect";
  26561. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26562. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26563. import { Mesh } from "babylonjs/Meshes/mesh";
  26564. /**
  26565. * Class used to store geometry data (vertex buffers + index buffer)
  26566. */
  26567. export class Geometry implements IGetSetVerticesData {
  26568. /**
  26569. * Gets or sets the ID of the geometry
  26570. */
  26571. id: string;
  26572. /**
  26573. * Gets or sets the unique ID of the geometry
  26574. */
  26575. uniqueId: number;
  26576. /**
  26577. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26578. */
  26579. delayLoadState: number;
  26580. /**
  26581. * Gets the file containing the data to load when running in delay load state
  26582. */
  26583. delayLoadingFile: Nullable<string>;
  26584. /**
  26585. * Callback called when the geometry is updated
  26586. */
  26587. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26588. private _scene;
  26589. private _engine;
  26590. private _meshes;
  26591. private _totalVertices;
  26592. /** @hidden */
  26593. _indices: IndicesArray;
  26594. /** @hidden */
  26595. _vertexBuffers: {
  26596. [key: string]: VertexBuffer;
  26597. };
  26598. private _isDisposed;
  26599. private _extend;
  26600. private _boundingBias;
  26601. /** @hidden */
  26602. _delayInfo: Array<string>;
  26603. private _indexBuffer;
  26604. private _indexBufferIsUpdatable;
  26605. /** @hidden */
  26606. _boundingInfo: Nullable<BoundingInfo>;
  26607. /** @hidden */
  26608. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26609. /** @hidden */
  26610. _softwareSkinningFrameId: number;
  26611. private _vertexArrayObjects;
  26612. private _updatable;
  26613. /** @hidden */
  26614. _positions: Nullable<Vector3[]>;
  26615. /**
  26616. * 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
  26617. */
  26618. get boundingBias(): Vector2;
  26619. /**
  26620. * 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
  26621. */
  26622. set boundingBias(value: Vector2);
  26623. /**
  26624. * Static function used to attach a new empty geometry to a mesh
  26625. * @param mesh defines the mesh to attach the geometry to
  26626. * @returns the new Geometry
  26627. */
  26628. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26629. /** Get the list of meshes using this geometry */
  26630. get meshes(): Mesh[];
  26631. /**
  26632. * 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
  26633. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26634. */
  26635. useBoundingInfoFromGeometry: boolean;
  26636. /**
  26637. * Creates a new geometry
  26638. * @param id defines the unique ID
  26639. * @param scene defines the hosting scene
  26640. * @param vertexData defines the VertexData used to get geometry data
  26641. * @param updatable defines if geometry must be updatable (false by default)
  26642. * @param mesh defines the mesh that will be associated with the geometry
  26643. */
  26644. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26645. /**
  26646. * Gets the current extend of the geometry
  26647. */
  26648. get extend(): {
  26649. minimum: Vector3;
  26650. maximum: Vector3;
  26651. };
  26652. /**
  26653. * Gets the hosting scene
  26654. * @returns the hosting Scene
  26655. */
  26656. getScene(): Scene;
  26657. /**
  26658. * Gets the hosting engine
  26659. * @returns the hosting Engine
  26660. */
  26661. getEngine(): Engine;
  26662. /**
  26663. * Defines if the geometry is ready to use
  26664. * @returns true if the geometry is ready to be used
  26665. */
  26666. isReady(): boolean;
  26667. /**
  26668. * Gets a value indicating that the geometry should not be serialized
  26669. */
  26670. get doNotSerialize(): boolean;
  26671. /** @hidden */
  26672. _rebuild(): void;
  26673. /**
  26674. * Affects all geometry data in one call
  26675. * @param vertexData defines the geometry data
  26676. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26677. */
  26678. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26679. /**
  26680. * Set specific vertex data
  26681. * @param kind defines the data kind (Position, normal, etc...)
  26682. * @param data defines the vertex data to use
  26683. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26684. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26685. */
  26686. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26687. /**
  26688. * Removes a specific vertex data
  26689. * @param kind defines the data kind (Position, normal, etc...)
  26690. */
  26691. removeVerticesData(kind: string): void;
  26692. /**
  26693. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26694. * @param buffer defines the vertex buffer to use
  26695. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26696. */
  26697. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26698. /**
  26699. * Update a specific vertex buffer
  26700. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26701. * It will do nothing if the buffer is not updatable
  26702. * @param kind defines the data kind (Position, normal, etc...)
  26703. * @param data defines the data to use
  26704. * @param offset defines the offset in the target buffer where to store the data
  26705. * @param useBytes set to true if the offset is in bytes
  26706. */
  26707. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26708. /**
  26709. * Update a specific vertex buffer
  26710. * This function will create a new buffer if the current one is not updatable
  26711. * @param kind defines the data kind (Position, normal, etc...)
  26712. * @param data defines the data to use
  26713. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26714. */
  26715. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26716. private _updateBoundingInfo;
  26717. /** @hidden */
  26718. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26719. /**
  26720. * Gets total number of vertices
  26721. * @returns the total number of vertices
  26722. */
  26723. getTotalVertices(): number;
  26724. /**
  26725. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26726. * @param kind defines the data kind (Position, normal, etc...)
  26727. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26728. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26729. * @returns a float array containing vertex data
  26730. */
  26731. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26732. /**
  26733. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26734. * @param kind defines the data kind (Position, normal, etc...)
  26735. * @returns true if the vertex buffer with the specified kind is updatable
  26736. */
  26737. isVertexBufferUpdatable(kind: string): boolean;
  26738. /**
  26739. * Gets a specific vertex buffer
  26740. * @param kind defines the data kind (Position, normal, etc...)
  26741. * @returns a VertexBuffer
  26742. */
  26743. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26744. /**
  26745. * Returns all vertex buffers
  26746. * @return an object holding all vertex buffers indexed by kind
  26747. */
  26748. getVertexBuffers(): Nullable<{
  26749. [key: string]: VertexBuffer;
  26750. }>;
  26751. /**
  26752. * Gets a boolean indicating if specific vertex buffer is present
  26753. * @param kind defines the data kind (Position, normal, etc...)
  26754. * @returns true if data is present
  26755. */
  26756. isVerticesDataPresent(kind: string): boolean;
  26757. /**
  26758. * Gets a list of all attached data kinds (Position, normal, etc...)
  26759. * @returns a list of string containing all kinds
  26760. */
  26761. getVerticesDataKinds(): string[];
  26762. /**
  26763. * Update index buffer
  26764. * @param indices defines the indices to store in the index buffer
  26765. * @param offset defines the offset in the target buffer where to store the data
  26766. * @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)
  26767. */
  26768. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26769. /**
  26770. * Creates a new index buffer
  26771. * @param indices defines the indices to store in the index buffer
  26772. * @param totalVertices defines the total number of vertices (could be null)
  26773. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26774. */
  26775. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26776. /**
  26777. * Return the total number of indices
  26778. * @returns the total number of indices
  26779. */
  26780. getTotalIndices(): number;
  26781. /**
  26782. * Gets the index buffer array
  26783. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26784. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26785. * @returns the index buffer array
  26786. */
  26787. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26788. /**
  26789. * Gets the index buffer
  26790. * @return the index buffer
  26791. */
  26792. getIndexBuffer(): Nullable<DataBuffer>;
  26793. /** @hidden */
  26794. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26795. /**
  26796. * Release the associated resources for a specific mesh
  26797. * @param mesh defines the source mesh
  26798. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26799. */
  26800. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26801. /**
  26802. * Apply current geometry to a given mesh
  26803. * @param mesh defines the mesh to apply geometry to
  26804. */
  26805. applyToMesh(mesh: Mesh): void;
  26806. private _updateExtend;
  26807. private _applyToMesh;
  26808. private notifyUpdate;
  26809. /**
  26810. * Load the geometry if it was flagged as delay loaded
  26811. * @param scene defines the hosting scene
  26812. * @param onLoaded defines a callback called when the geometry is loaded
  26813. */
  26814. load(scene: Scene, onLoaded?: () => void): void;
  26815. private _queueLoad;
  26816. /**
  26817. * Invert the geometry to move from a right handed system to a left handed one.
  26818. */
  26819. toLeftHanded(): void;
  26820. /** @hidden */
  26821. _resetPointsArrayCache(): void;
  26822. /** @hidden */
  26823. _generatePointsArray(): boolean;
  26824. /**
  26825. * Gets a value indicating if the geometry is disposed
  26826. * @returns true if the geometry was disposed
  26827. */
  26828. isDisposed(): boolean;
  26829. private _disposeVertexArrayObjects;
  26830. /**
  26831. * Free all associated resources
  26832. */
  26833. dispose(): void;
  26834. /**
  26835. * Clone the current geometry into a new geometry
  26836. * @param id defines the unique ID of the new geometry
  26837. * @returns a new geometry object
  26838. */
  26839. copy(id: string): Geometry;
  26840. /**
  26841. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26842. * @return a JSON representation of the current geometry data (without the vertices data)
  26843. */
  26844. serialize(): any;
  26845. private toNumberArray;
  26846. /**
  26847. * Serialize all vertices data into a JSON oject
  26848. * @returns a JSON representation of the current geometry data
  26849. */
  26850. serializeVerticeData(): any;
  26851. /**
  26852. * Extracts a clone of a mesh geometry
  26853. * @param mesh defines the source mesh
  26854. * @param id defines the unique ID of the new geometry object
  26855. * @returns the new geometry object
  26856. */
  26857. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26858. /**
  26859. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26860. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26861. * Be aware Math.random() could cause collisions, but:
  26862. * "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"
  26863. * @returns a string containing a new GUID
  26864. */
  26865. static RandomId(): string;
  26866. /** @hidden */
  26867. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26868. private static _CleanMatricesWeights;
  26869. /**
  26870. * Create a new geometry from persisted data (Using .babylon file format)
  26871. * @param parsedVertexData defines the persisted data
  26872. * @param scene defines the hosting scene
  26873. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26874. * @returns the new geometry object
  26875. */
  26876. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26877. }
  26878. }
  26879. declare module "babylonjs/Meshes/mesh.vertexData" {
  26880. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26881. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26882. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26883. import { Geometry } from "babylonjs/Meshes/geometry";
  26884. import { Mesh } from "babylonjs/Meshes/mesh";
  26885. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  26886. /**
  26887. * Define an interface for all classes that will get and set the data on vertices
  26888. */
  26889. export interface IGetSetVerticesData {
  26890. /**
  26891. * Gets a boolean indicating if specific vertex data is present
  26892. * @param kind defines the vertex data kind to use
  26893. * @returns true is data kind is present
  26894. */
  26895. isVerticesDataPresent(kind: string): boolean;
  26896. /**
  26897. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26898. * @param kind defines the data kind (Position, normal, etc...)
  26899. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26900. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26901. * @returns a float array containing vertex data
  26902. */
  26903. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26904. /**
  26905. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26906. * @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.
  26907. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26908. * @returns the indices array or an empty array if the mesh has no geometry
  26909. */
  26910. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26911. /**
  26912. * Set specific vertex data
  26913. * @param kind defines the data kind (Position, normal, etc...)
  26914. * @param data defines the vertex data to use
  26915. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26916. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26917. */
  26918. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26919. /**
  26920. * Update a specific associated vertex buffer
  26921. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26922. * - VertexBuffer.PositionKind
  26923. * - VertexBuffer.UVKind
  26924. * - VertexBuffer.UV2Kind
  26925. * - VertexBuffer.UV3Kind
  26926. * - VertexBuffer.UV4Kind
  26927. * - VertexBuffer.UV5Kind
  26928. * - VertexBuffer.UV6Kind
  26929. * - VertexBuffer.ColorKind
  26930. * - VertexBuffer.MatricesIndicesKind
  26931. * - VertexBuffer.MatricesIndicesExtraKind
  26932. * - VertexBuffer.MatricesWeightsKind
  26933. * - VertexBuffer.MatricesWeightsExtraKind
  26934. * @param data defines the data source
  26935. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26936. * @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)
  26937. */
  26938. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26939. /**
  26940. * Creates a new index buffer
  26941. * @param indices defines the indices to store in the index buffer
  26942. * @param totalVertices defines the total number of vertices (could be null)
  26943. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26944. */
  26945. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26946. }
  26947. /**
  26948. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26949. */
  26950. export class VertexData {
  26951. /**
  26952. * Mesh side orientation : usually the external or front surface
  26953. */
  26954. static readonly FRONTSIDE: number;
  26955. /**
  26956. * Mesh side orientation : usually the internal or back surface
  26957. */
  26958. static readonly BACKSIDE: number;
  26959. /**
  26960. * Mesh side orientation : both internal and external or front and back surfaces
  26961. */
  26962. static readonly DOUBLESIDE: number;
  26963. /**
  26964. * Mesh side orientation : by default, `FRONTSIDE`
  26965. */
  26966. static readonly DEFAULTSIDE: number;
  26967. /**
  26968. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26969. */
  26970. positions: Nullable<FloatArray>;
  26971. /**
  26972. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26973. */
  26974. normals: Nullable<FloatArray>;
  26975. /**
  26976. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26977. */
  26978. tangents: Nullable<FloatArray>;
  26979. /**
  26980. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26981. */
  26982. uvs: Nullable<FloatArray>;
  26983. /**
  26984. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26985. */
  26986. uvs2: Nullable<FloatArray>;
  26987. /**
  26988. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26989. */
  26990. uvs3: Nullable<FloatArray>;
  26991. /**
  26992. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26993. */
  26994. uvs4: Nullable<FloatArray>;
  26995. /**
  26996. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26997. */
  26998. uvs5: Nullable<FloatArray>;
  26999. /**
  27000. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27001. */
  27002. uvs6: Nullable<FloatArray>;
  27003. /**
  27004. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27005. */
  27006. colors: Nullable<FloatArray>;
  27007. /**
  27008. * 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).
  27009. */
  27010. matricesIndices: Nullable<FloatArray>;
  27011. /**
  27012. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27013. */
  27014. matricesWeights: Nullable<FloatArray>;
  27015. /**
  27016. * An array extending the number of possible indices
  27017. */
  27018. matricesIndicesExtra: Nullable<FloatArray>;
  27019. /**
  27020. * An array extending the number of possible weights when the number of indices is extended
  27021. */
  27022. matricesWeightsExtra: Nullable<FloatArray>;
  27023. /**
  27024. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27025. */
  27026. indices: Nullable<IndicesArray>;
  27027. /**
  27028. * Uses the passed data array to set the set the values for the specified kind of data
  27029. * @param data a linear array of floating numbers
  27030. * @param kind the type of data that is being set, eg positions, colors etc
  27031. */
  27032. set(data: FloatArray, kind: string): void;
  27033. /**
  27034. * Associates the vertexData to the passed Mesh.
  27035. * Sets it as updatable or not (default `false`)
  27036. * @param mesh the mesh the vertexData is applied to
  27037. * @param updatable when used and having the value true allows new data to update the vertexData
  27038. * @returns the VertexData
  27039. */
  27040. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27041. /**
  27042. * Associates the vertexData to the passed Geometry.
  27043. * Sets it as updatable or not (default `false`)
  27044. * @param geometry the geometry the vertexData is applied to
  27045. * @param updatable when used and having the value true allows new data to update the vertexData
  27046. * @returns VertexData
  27047. */
  27048. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27049. /**
  27050. * Updates the associated mesh
  27051. * @param mesh the mesh to be updated
  27052. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27053. * @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
  27054. * @returns VertexData
  27055. */
  27056. updateMesh(mesh: Mesh): VertexData;
  27057. /**
  27058. * Updates the associated geometry
  27059. * @param geometry the geometry to be updated
  27060. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27061. * @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
  27062. * @returns VertexData.
  27063. */
  27064. updateGeometry(geometry: Geometry): VertexData;
  27065. private _applyTo;
  27066. private _update;
  27067. /**
  27068. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27069. * @param matrix the transforming matrix
  27070. * @returns the VertexData
  27071. */
  27072. transform(matrix: Matrix): VertexData;
  27073. /**
  27074. * Merges the passed VertexData into the current one
  27075. * @param other the VertexData to be merged into the current one
  27076. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27077. * @returns the modified VertexData
  27078. */
  27079. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27080. private _mergeElement;
  27081. private _validate;
  27082. /**
  27083. * Serializes the VertexData
  27084. * @returns a serialized object
  27085. */
  27086. serialize(): any;
  27087. /**
  27088. * Extracts the vertexData from a mesh
  27089. * @param mesh the mesh from which to extract the VertexData
  27090. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27091. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27092. * @returns the object VertexData associated to the passed mesh
  27093. */
  27094. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27095. /**
  27096. * Extracts the vertexData from the geometry
  27097. * @param geometry the geometry from which to extract the VertexData
  27098. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27099. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27100. * @returns the object VertexData associated to the passed mesh
  27101. */
  27102. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27103. private static _ExtractFrom;
  27104. /**
  27105. * Creates the VertexData for a Ribbon
  27106. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27107. * * pathArray array of paths, each of which an array of successive Vector3
  27108. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27109. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27110. * * 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
  27111. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27112. * * 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)
  27113. * * 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)
  27114. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27115. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27116. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27117. * @returns the VertexData of the ribbon
  27118. */
  27119. static CreateRibbon(options: {
  27120. pathArray: Vector3[][];
  27121. closeArray?: boolean;
  27122. closePath?: boolean;
  27123. offset?: number;
  27124. sideOrientation?: number;
  27125. frontUVs?: Vector4;
  27126. backUVs?: Vector4;
  27127. invertUV?: boolean;
  27128. uvs?: Vector2[];
  27129. colors?: Color4[];
  27130. }): VertexData;
  27131. /**
  27132. * Creates the VertexData for a box
  27133. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27134. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27135. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27136. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27137. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27138. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27139. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27140. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27141. * * 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)
  27142. * * 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)
  27143. * @returns the VertexData of the box
  27144. */
  27145. static CreateBox(options: {
  27146. size?: number;
  27147. width?: number;
  27148. height?: number;
  27149. depth?: number;
  27150. faceUV?: Vector4[];
  27151. faceColors?: Color4[];
  27152. sideOrientation?: number;
  27153. frontUVs?: Vector4;
  27154. backUVs?: Vector4;
  27155. }): VertexData;
  27156. /**
  27157. * Creates the VertexData for a tiled box
  27158. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27159. * * faceTiles sets the pattern, tile size and number of tiles for a face
  27160. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27161. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27162. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27163. * @returns the VertexData of the box
  27164. */
  27165. static CreateTiledBox(options: {
  27166. pattern?: number;
  27167. width?: number;
  27168. height?: number;
  27169. depth?: number;
  27170. tileSize?: number;
  27171. tileWidth?: number;
  27172. tileHeight?: number;
  27173. alignHorizontal?: number;
  27174. alignVertical?: number;
  27175. faceUV?: Vector4[];
  27176. faceColors?: Color4[];
  27177. sideOrientation?: number;
  27178. }): VertexData;
  27179. /**
  27180. * Creates the VertexData for a tiled plane
  27181. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27182. * * pattern a limited pattern arrangement depending on the number
  27183. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  27184. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  27185. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  27186. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27187. * * 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)
  27188. * * 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)
  27189. * @returns the VertexData of the tiled plane
  27190. */
  27191. static CreateTiledPlane(options: {
  27192. pattern?: number;
  27193. tileSize?: number;
  27194. tileWidth?: number;
  27195. tileHeight?: number;
  27196. size?: number;
  27197. width?: number;
  27198. height?: number;
  27199. alignHorizontal?: number;
  27200. alignVertical?: number;
  27201. sideOrientation?: number;
  27202. frontUVs?: Vector4;
  27203. backUVs?: Vector4;
  27204. }): VertexData;
  27205. /**
  27206. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27207. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27208. * * segments sets the number of horizontal strips optional, default 32
  27209. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27210. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27211. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27212. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27213. * * 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
  27214. * * 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
  27215. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27216. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27217. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27218. * @returns the VertexData of the ellipsoid
  27219. */
  27220. static CreateSphere(options: {
  27221. segments?: number;
  27222. diameter?: number;
  27223. diameterX?: number;
  27224. diameterY?: number;
  27225. diameterZ?: number;
  27226. arc?: number;
  27227. slice?: number;
  27228. sideOrientation?: number;
  27229. frontUVs?: Vector4;
  27230. backUVs?: Vector4;
  27231. }): VertexData;
  27232. /**
  27233. * Creates the VertexData for a cylinder, cone or prism
  27234. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27235. * * height sets the height (y direction) of the cylinder, optional, default 2
  27236. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27237. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27238. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27239. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27240. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27241. * * 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
  27242. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27243. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27244. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27245. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27246. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27247. * * 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)
  27248. * * 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)
  27249. * @returns the VertexData of the cylinder, cone or prism
  27250. */
  27251. static CreateCylinder(options: {
  27252. height?: number;
  27253. diameterTop?: number;
  27254. diameterBottom?: number;
  27255. diameter?: number;
  27256. tessellation?: number;
  27257. subdivisions?: number;
  27258. arc?: number;
  27259. faceColors?: Color4[];
  27260. faceUV?: Vector4[];
  27261. hasRings?: boolean;
  27262. enclose?: boolean;
  27263. sideOrientation?: number;
  27264. frontUVs?: Vector4;
  27265. backUVs?: Vector4;
  27266. }): VertexData;
  27267. /**
  27268. * Creates the VertexData for a torus
  27269. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27270. * * diameter the diameter of the torus, optional default 1
  27271. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27272. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27273. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27274. * * 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)
  27275. * * 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)
  27276. * @returns the VertexData of the torus
  27277. */
  27278. static CreateTorus(options: {
  27279. diameter?: number;
  27280. thickness?: number;
  27281. tessellation?: number;
  27282. sideOrientation?: number;
  27283. frontUVs?: Vector4;
  27284. backUVs?: Vector4;
  27285. }): VertexData;
  27286. /**
  27287. * Creates the VertexData of the LineSystem
  27288. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27289. * - lines an array of lines, each line being an array of successive Vector3
  27290. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27291. * @returns the VertexData of the LineSystem
  27292. */
  27293. static CreateLineSystem(options: {
  27294. lines: Vector3[][];
  27295. colors?: Nullable<Color4[][]>;
  27296. }): VertexData;
  27297. /**
  27298. * Create the VertexData for a DashedLines
  27299. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27300. * - points an array successive Vector3
  27301. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27302. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27303. * - dashNb the intended total number of dashes, optional, default 200
  27304. * @returns the VertexData for the DashedLines
  27305. */
  27306. static CreateDashedLines(options: {
  27307. points: Vector3[];
  27308. dashSize?: number;
  27309. gapSize?: number;
  27310. dashNb?: number;
  27311. }): VertexData;
  27312. /**
  27313. * Creates the VertexData for a Ground
  27314. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27315. * - width the width (x direction) of the ground, optional, default 1
  27316. * - height the height (z direction) of the ground, optional, default 1
  27317. * - subdivisions the number of subdivisions per side, optional, default 1
  27318. * @returns the VertexData of the Ground
  27319. */
  27320. static CreateGround(options: {
  27321. width?: number;
  27322. height?: number;
  27323. subdivisions?: number;
  27324. subdivisionsX?: number;
  27325. subdivisionsY?: number;
  27326. }): VertexData;
  27327. /**
  27328. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27329. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27330. * * xmin the ground minimum X coordinate, optional, default -1
  27331. * * zmin the ground minimum Z coordinate, optional, default -1
  27332. * * xmax the ground maximum X coordinate, optional, default 1
  27333. * * zmax the ground maximum Z coordinate, optional, default 1
  27334. * * 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}
  27335. * * 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}
  27336. * @returns the VertexData of the TiledGround
  27337. */
  27338. static CreateTiledGround(options: {
  27339. xmin: number;
  27340. zmin: number;
  27341. xmax: number;
  27342. zmax: number;
  27343. subdivisions?: {
  27344. w: number;
  27345. h: number;
  27346. };
  27347. precision?: {
  27348. w: number;
  27349. h: number;
  27350. };
  27351. }): VertexData;
  27352. /**
  27353. * Creates the VertexData of the Ground designed from a heightmap
  27354. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27355. * * width the width (x direction) of the ground
  27356. * * height the height (z direction) of the ground
  27357. * * subdivisions the number of subdivisions per side
  27358. * * minHeight the minimum altitude on the ground, optional, default 0
  27359. * * maxHeight the maximum altitude on the ground, optional default 1
  27360. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27361. * * buffer the array holding the image color data
  27362. * * bufferWidth the width of image
  27363. * * bufferHeight the height of image
  27364. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27365. * @returns the VertexData of the Ground designed from a heightmap
  27366. */
  27367. static CreateGroundFromHeightMap(options: {
  27368. width: number;
  27369. height: number;
  27370. subdivisions: number;
  27371. minHeight: number;
  27372. maxHeight: number;
  27373. colorFilter: Color3;
  27374. buffer: Uint8Array;
  27375. bufferWidth: number;
  27376. bufferHeight: number;
  27377. alphaFilter: number;
  27378. }): VertexData;
  27379. /**
  27380. * Creates the VertexData for a Plane
  27381. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27382. * * size sets the width and height of the plane to the value of size, optional default 1
  27383. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27384. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27385. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27386. * * 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)
  27387. * * 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)
  27388. * @returns the VertexData of the box
  27389. */
  27390. static CreatePlane(options: {
  27391. size?: number;
  27392. width?: number;
  27393. height?: number;
  27394. sideOrientation?: number;
  27395. frontUVs?: Vector4;
  27396. backUVs?: Vector4;
  27397. }): VertexData;
  27398. /**
  27399. * Creates the VertexData of the Disc or regular Polygon
  27400. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27401. * * radius the radius of the disc, optional default 0.5
  27402. * * tessellation the number of polygon sides, optional, default 64
  27403. * * 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
  27404. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27405. * * 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)
  27406. * * 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)
  27407. * @returns the VertexData of the box
  27408. */
  27409. static CreateDisc(options: {
  27410. radius?: number;
  27411. tessellation?: number;
  27412. arc?: number;
  27413. sideOrientation?: number;
  27414. frontUVs?: Vector4;
  27415. backUVs?: Vector4;
  27416. }): VertexData;
  27417. /**
  27418. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27419. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27420. * @param polygon a mesh built from polygonTriangulation.build()
  27421. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27422. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27423. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27424. * @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)
  27425. * @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)
  27426. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27427. * @returns the VertexData of the Polygon
  27428. */
  27429. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27430. /**
  27431. * Creates the VertexData of the IcoSphere
  27432. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27433. * * radius the radius of the IcoSphere, optional default 1
  27434. * * radiusX allows stretching in the x direction, optional, default radius
  27435. * * radiusY allows stretching in the y direction, optional, default radius
  27436. * * radiusZ allows stretching in the z direction, optional, default radius
  27437. * * flat when true creates a flat shaded mesh, optional, default true
  27438. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27439. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27440. * * 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)
  27441. * * 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)
  27442. * @returns the VertexData of the IcoSphere
  27443. */
  27444. static CreateIcoSphere(options: {
  27445. radius?: number;
  27446. radiusX?: number;
  27447. radiusY?: number;
  27448. radiusZ?: number;
  27449. flat?: boolean;
  27450. subdivisions?: number;
  27451. sideOrientation?: number;
  27452. frontUVs?: Vector4;
  27453. backUVs?: Vector4;
  27454. }): VertexData;
  27455. /**
  27456. * Creates the VertexData for a Polyhedron
  27457. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27458. * * type provided types are:
  27459. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27460. * * 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)
  27461. * * size the size of the IcoSphere, optional default 1
  27462. * * sizeX allows stretching in the x direction, optional, default size
  27463. * * sizeY allows stretching in the y direction, optional, default size
  27464. * * sizeZ allows stretching in the z direction, optional, default size
  27465. * * 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
  27466. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27467. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27468. * * flat when true creates a flat shaded mesh, optional, default true
  27469. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27470. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27471. * * 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)
  27472. * * 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)
  27473. * @returns the VertexData of the Polyhedron
  27474. */
  27475. static CreatePolyhedron(options: {
  27476. type?: number;
  27477. size?: number;
  27478. sizeX?: number;
  27479. sizeY?: number;
  27480. sizeZ?: number;
  27481. custom?: any;
  27482. faceUV?: Vector4[];
  27483. faceColors?: Color4[];
  27484. flat?: boolean;
  27485. sideOrientation?: number;
  27486. frontUVs?: Vector4;
  27487. backUVs?: Vector4;
  27488. }): VertexData;
  27489. /**
  27490. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  27491. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  27492. * @returns the VertexData of the Capsule
  27493. */
  27494. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  27495. /**
  27496. * Creates the VertexData for a TorusKnot
  27497. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27498. * * radius the radius of the torus knot, optional, default 2
  27499. * * tube the thickness of the tube, optional, default 0.5
  27500. * * radialSegments the number of sides on each tube segments, optional, default 32
  27501. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27502. * * p the number of windings around the z axis, optional, default 2
  27503. * * q the number of windings around the x axis, optional, default 3
  27504. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27505. * * 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)
  27506. * * 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)
  27507. * @returns the VertexData of the Torus Knot
  27508. */
  27509. static CreateTorusKnot(options: {
  27510. radius?: number;
  27511. tube?: number;
  27512. radialSegments?: number;
  27513. tubularSegments?: number;
  27514. p?: number;
  27515. q?: number;
  27516. sideOrientation?: number;
  27517. frontUVs?: Vector4;
  27518. backUVs?: Vector4;
  27519. }): VertexData;
  27520. /**
  27521. * Compute normals for given positions and indices
  27522. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27523. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27524. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27525. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27526. * * facetNormals : optional array of facet normals (vector3)
  27527. * * facetPositions : optional array of facet positions (vector3)
  27528. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27529. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27530. * * bInfo : optional bounding info, required for facetPartitioning computation
  27531. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27532. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27533. * * useRightHandedSystem: optional boolean to for right handed system computation
  27534. * * depthSort : optional boolean to enable the facet depth sort computation
  27535. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27536. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27537. */
  27538. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27539. facetNormals?: any;
  27540. facetPositions?: any;
  27541. facetPartitioning?: any;
  27542. ratio?: number;
  27543. bInfo?: any;
  27544. bbSize?: Vector3;
  27545. subDiv?: any;
  27546. useRightHandedSystem?: boolean;
  27547. depthSort?: boolean;
  27548. distanceTo?: Vector3;
  27549. depthSortedFacets?: any;
  27550. }): void;
  27551. /** @hidden */
  27552. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27553. /**
  27554. * Applies VertexData created from the imported parameters to the geometry
  27555. * @param parsedVertexData the parsed data from an imported file
  27556. * @param geometry the geometry to apply the VertexData to
  27557. */
  27558. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27559. }
  27560. }
  27561. declare module "babylonjs/Morph/morphTarget" {
  27562. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27563. import { Observable } from "babylonjs/Misc/observable";
  27564. import { Nullable, FloatArray } from "babylonjs/types";
  27565. import { Scene } from "babylonjs/scene";
  27566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27567. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27568. /**
  27569. * Defines a target to use with MorphTargetManager
  27570. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27571. */
  27572. export class MorphTarget implements IAnimatable {
  27573. /** defines the name of the target */
  27574. name: string;
  27575. /**
  27576. * Gets or sets the list of animations
  27577. */
  27578. animations: import("babylonjs/Animations/animation").Animation[];
  27579. private _scene;
  27580. private _positions;
  27581. private _normals;
  27582. private _tangents;
  27583. private _uvs;
  27584. private _influence;
  27585. private _uniqueId;
  27586. /**
  27587. * Observable raised when the influence changes
  27588. */
  27589. onInfluenceChanged: Observable<boolean>;
  27590. /** @hidden */
  27591. _onDataLayoutChanged: Observable<void>;
  27592. /**
  27593. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27594. */
  27595. get influence(): number;
  27596. set influence(influence: number);
  27597. /**
  27598. * Gets or sets the id of the morph Target
  27599. */
  27600. id: string;
  27601. private _animationPropertiesOverride;
  27602. /**
  27603. * Gets or sets the animation properties override
  27604. */
  27605. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27606. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27607. /**
  27608. * Creates a new MorphTarget
  27609. * @param name defines the name of the target
  27610. * @param influence defines the influence to use
  27611. * @param scene defines the scene the morphtarget belongs to
  27612. */
  27613. constructor(
  27614. /** defines the name of the target */
  27615. name: string, influence?: number, scene?: Nullable<Scene>);
  27616. /**
  27617. * Gets the unique ID of this manager
  27618. */
  27619. get uniqueId(): number;
  27620. /**
  27621. * Gets a boolean defining if the target contains position data
  27622. */
  27623. get hasPositions(): boolean;
  27624. /**
  27625. * Gets a boolean defining if the target contains normal data
  27626. */
  27627. get hasNormals(): boolean;
  27628. /**
  27629. * Gets a boolean defining if the target contains tangent data
  27630. */
  27631. get hasTangents(): boolean;
  27632. /**
  27633. * Gets a boolean defining if the target contains texture coordinates data
  27634. */
  27635. get hasUVs(): boolean;
  27636. /**
  27637. * Affects position data to this target
  27638. * @param data defines the position data to use
  27639. */
  27640. setPositions(data: Nullable<FloatArray>): void;
  27641. /**
  27642. * Gets the position data stored in this target
  27643. * @returns a FloatArray containing the position data (or null if not present)
  27644. */
  27645. getPositions(): Nullable<FloatArray>;
  27646. /**
  27647. * Affects normal data to this target
  27648. * @param data defines the normal data to use
  27649. */
  27650. setNormals(data: Nullable<FloatArray>): void;
  27651. /**
  27652. * Gets the normal data stored in this target
  27653. * @returns a FloatArray containing the normal data (or null if not present)
  27654. */
  27655. getNormals(): Nullable<FloatArray>;
  27656. /**
  27657. * Affects tangent data to this target
  27658. * @param data defines the tangent data to use
  27659. */
  27660. setTangents(data: Nullable<FloatArray>): void;
  27661. /**
  27662. * Gets the tangent data stored in this target
  27663. * @returns a FloatArray containing the tangent data (or null if not present)
  27664. */
  27665. getTangents(): Nullable<FloatArray>;
  27666. /**
  27667. * Affects texture coordinates data to this target
  27668. * @param data defines the texture coordinates data to use
  27669. */
  27670. setUVs(data: Nullable<FloatArray>): void;
  27671. /**
  27672. * Gets the texture coordinates data stored in this target
  27673. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27674. */
  27675. getUVs(): Nullable<FloatArray>;
  27676. /**
  27677. * Clone the current target
  27678. * @returns a new MorphTarget
  27679. */
  27680. clone(): MorphTarget;
  27681. /**
  27682. * Serializes the current target into a Serialization object
  27683. * @returns the serialized object
  27684. */
  27685. serialize(): any;
  27686. /**
  27687. * Returns the string "MorphTarget"
  27688. * @returns "MorphTarget"
  27689. */
  27690. getClassName(): string;
  27691. /**
  27692. * Creates a new target from serialized data
  27693. * @param serializationObject defines the serialized data to use
  27694. * @returns a new MorphTarget
  27695. */
  27696. static Parse(serializationObject: any): MorphTarget;
  27697. /**
  27698. * Creates a MorphTarget from mesh data
  27699. * @param mesh defines the source mesh
  27700. * @param name defines the name to use for the new target
  27701. * @param influence defines the influence to attach to the target
  27702. * @returns a new MorphTarget
  27703. */
  27704. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27705. }
  27706. }
  27707. declare module "babylonjs/Morph/morphTargetManager" {
  27708. import { Nullable } from "babylonjs/types";
  27709. import { Scene } from "babylonjs/scene";
  27710. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27711. /**
  27712. * This class is used to deform meshes using morphing between different targets
  27713. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27714. */
  27715. export class MorphTargetManager {
  27716. private _targets;
  27717. private _targetInfluenceChangedObservers;
  27718. private _targetDataLayoutChangedObservers;
  27719. private _activeTargets;
  27720. private _scene;
  27721. private _influences;
  27722. private _supportsNormals;
  27723. private _supportsTangents;
  27724. private _supportsUVs;
  27725. private _vertexCount;
  27726. private _uniqueId;
  27727. private _tempInfluences;
  27728. /**
  27729. * Gets or sets a boolean indicating if normals must be morphed
  27730. */
  27731. enableNormalMorphing: boolean;
  27732. /**
  27733. * Gets or sets a boolean indicating if tangents must be morphed
  27734. */
  27735. enableTangentMorphing: boolean;
  27736. /**
  27737. * Gets or sets a boolean indicating if UV must be morphed
  27738. */
  27739. enableUVMorphing: boolean;
  27740. /**
  27741. * Creates a new MorphTargetManager
  27742. * @param scene defines the current scene
  27743. */
  27744. constructor(scene?: Nullable<Scene>);
  27745. /**
  27746. * Gets the unique ID of this manager
  27747. */
  27748. get uniqueId(): number;
  27749. /**
  27750. * Gets the number of vertices handled by this manager
  27751. */
  27752. get vertexCount(): number;
  27753. /**
  27754. * Gets a boolean indicating if this manager supports morphing of normals
  27755. */
  27756. get supportsNormals(): boolean;
  27757. /**
  27758. * Gets a boolean indicating if this manager supports morphing of tangents
  27759. */
  27760. get supportsTangents(): boolean;
  27761. /**
  27762. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27763. */
  27764. get supportsUVs(): boolean;
  27765. /**
  27766. * Gets the number of targets stored in this manager
  27767. */
  27768. get numTargets(): number;
  27769. /**
  27770. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27771. */
  27772. get numInfluencers(): number;
  27773. /**
  27774. * Gets the list of influences (one per target)
  27775. */
  27776. get influences(): Float32Array;
  27777. /**
  27778. * Gets the active target at specified index. An active target is a target with an influence > 0
  27779. * @param index defines the index to check
  27780. * @returns the requested target
  27781. */
  27782. getActiveTarget(index: number): MorphTarget;
  27783. /**
  27784. * Gets the target at specified index
  27785. * @param index defines the index to check
  27786. * @returns the requested target
  27787. */
  27788. getTarget(index: number): MorphTarget;
  27789. /**
  27790. * Add a new target to this manager
  27791. * @param target defines the target to add
  27792. */
  27793. addTarget(target: MorphTarget): void;
  27794. /**
  27795. * Removes a target from the manager
  27796. * @param target defines the target to remove
  27797. */
  27798. removeTarget(target: MorphTarget): void;
  27799. /**
  27800. * Clone the current manager
  27801. * @returns a new MorphTargetManager
  27802. */
  27803. clone(): MorphTargetManager;
  27804. /**
  27805. * Serializes the current manager into a Serialization object
  27806. * @returns the serialized object
  27807. */
  27808. serialize(): any;
  27809. private _syncActiveTargets;
  27810. /**
  27811. * Syncrhonize the targets with all the meshes using this morph target manager
  27812. */
  27813. synchronize(): void;
  27814. /**
  27815. * Creates a new MorphTargetManager from serialized data
  27816. * @param serializationObject defines the serialized data
  27817. * @param scene defines the hosting scene
  27818. * @returns the new MorphTargetManager
  27819. */
  27820. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27821. }
  27822. }
  27823. declare module "babylonjs/Meshes/meshLODLevel" {
  27824. import { Mesh } from "babylonjs/Meshes/mesh";
  27825. import { Nullable } from "babylonjs/types";
  27826. /**
  27827. * Class used to represent a specific level of detail of a mesh
  27828. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27829. */
  27830. export class MeshLODLevel {
  27831. /** Defines the distance where this level should start being displayed */
  27832. distance: number;
  27833. /** Defines the mesh to use to render this level */
  27834. mesh: Nullable<Mesh>;
  27835. /**
  27836. * Creates a new LOD level
  27837. * @param distance defines the distance where this level should star being displayed
  27838. * @param mesh defines the mesh to use to render this level
  27839. */
  27840. constructor(
  27841. /** Defines the distance where this level should start being displayed */
  27842. distance: number,
  27843. /** Defines the mesh to use to render this level */
  27844. mesh: Nullable<Mesh>);
  27845. }
  27846. }
  27847. declare module "babylonjs/Misc/canvasGenerator" {
  27848. /**
  27849. * Helper class used to generate a canvas to manipulate images
  27850. */
  27851. export class CanvasGenerator {
  27852. /**
  27853. * Create a new canvas (or offscreen canvas depending on the context)
  27854. * @param width defines the expected width
  27855. * @param height defines the expected height
  27856. * @return a new canvas or offscreen canvas
  27857. */
  27858. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27859. }
  27860. }
  27861. declare module "babylonjs/Meshes/groundMesh" {
  27862. import { Scene } from "babylonjs/scene";
  27863. import { Vector3 } from "babylonjs/Maths/math.vector";
  27864. import { Mesh } from "babylonjs/Meshes/mesh";
  27865. /**
  27866. * Mesh representing the gorund
  27867. */
  27868. export class GroundMesh extends Mesh {
  27869. /** If octree should be generated */
  27870. generateOctree: boolean;
  27871. private _heightQuads;
  27872. /** @hidden */
  27873. _subdivisionsX: number;
  27874. /** @hidden */
  27875. _subdivisionsY: number;
  27876. /** @hidden */
  27877. _width: number;
  27878. /** @hidden */
  27879. _height: number;
  27880. /** @hidden */
  27881. _minX: number;
  27882. /** @hidden */
  27883. _maxX: number;
  27884. /** @hidden */
  27885. _minZ: number;
  27886. /** @hidden */
  27887. _maxZ: number;
  27888. constructor(name: string, scene: Scene);
  27889. /**
  27890. * "GroundMesh"
  27891. * @returns "GroundMesh"
  27892. */
  27893. getClassName(): string;
  27894. /**
  27895. * The minimum of x and y subdivisions
  27896. */
  27897. get subdivisions(): number;
  27898. /**
  27899. * X subdivisions
  27900. */
  27901. get subdivisionsX(): number;
  27902. /**
  27903. * Y subdivisions
  27904. */
  27905. get subdivisionsY(): number;
  27906. /**
  27907. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27908. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27909. * @param chunksCount the number of subdivisions for x and y
  27910. * @param octreeBlocksSize (Default: 32)
  27911. */
  27912. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27913. /**
  27914. * Returns a height (y) value in the Worl system :
  27915. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27916. * @param x x coordinate
  27917. * @param z z coordinate
  27918. * @returns the ground y position if (x, z) are outside the ground surface.
  27919. */
  27920. getHeightAtCoordinates(x: number, z: number): number;
  27921. /**
  27922. * Returns a normalized vector (Vector3) orthogonal to the ground
  27923. * at the ground coordinates (x, z) expressed in the World system.
  27924. * @param x x coordinate
  27925. * @param z z coordinate
  27926. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27927. */
  27928. getNormalAtCoordinates(x: number, z: number): Vector3;
  27929. /**
  27930. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27931. * at the ground coordinates (x, z) expressed in the World system.
  27932. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27933. * @param x x coordinate
  27934. * @param z z coordinate
  27935. * @param ref vector to store the result
  27936. * @returns the GroundMesh.
  27937. */
  27938. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27939. /**
  27940. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27941. * if the ground has been updated.
  27942. * This can be used in the render loop.
  27943. * @returns the GroundMesh.
  27944. */
  27945. updateCoordinateHeights(): GroundMesh;
  27946. private _getFacetAt;
  27947. private _initHeightQuads;
  27948. private _computeHeightQuads;
  27949. /**
  27950. * Serializes this ground mesh
  27951. * @param serializationObject object to write serialization to
  27952. */
  27953. serialize(serializationObject: any): void;
  27954. /**
  27955. * Parses a serialized ground mesh
  27956. * @param parsedMesh the serialized mesh
  27957. * @param scene the scene to create the ground mesh in
  27958. * @returns the created ground mesh
  27959. */
  27960. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27961. }
  27962. }
  27963. declare module "babylonjs/Physics/physicsJoint" {
  27964. import { Vector3 } from "babylonjs/Maths/math.vector";
  27965. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  27966. /**
  27967. * Interface for Physics-Joint data
  27968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27969. */
  27970. export interface PhysicsJointData {
  27971. /**
  27972. * The main pivot of the joint
  27973. */
  27974. mainPivot?: Vector3;
  27975. /**
  27976. * The connected pivot of the joint
  27977. */
  27978. connectedPivot?: Vector3;
  27979. /**
  27980. * The main axis of the joint
  27981. */
  27982. mainAxis?: Vector3;
  27983. /**
  27984. * The connected axis of the joint
  27985. */
  27986. connectedAxis?: Vector3;
  27987. /**
  27988. * The collision of the joint
  27989. */
  27990. collision?: boolean;
  27991. /**
  27992. * Native Oimo/Cannon/Energy data
  27993. */
  27994. nativeParams?: any;
  27995. }
  27996. /**
  27997. * This is a holder class for the physics joint created by the physics plugin
  27998. * It holds a set of functions to control the underlying joint
  27999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28000. */
  28001. export class PhysicsJoint {
  28002. /**
  28003. * The type of the physics joint
  28004. */
  28005. type: number;
  28006. /**
  28007. * The data for the physics joint
  28008. */
  28009. jointData: PhysicsJointData;
  28010. private _physicsJoint;
  28011. protected _physicsPlugin: IPhysicsEnginePlugin;
  28012. /**
  28013. * Initializes the physics joint
  28014. * @param type The type of the physics joint
  28015. * @param jointData The data for the physics joint
  28016. */
  28017. constructor(
  28018. /**
  28019. * The type of the physics joint
  28020. */
  28021. type: number,
  28022. /**
  28023. * The data for the physics joint
  28024. */
  28025. jointData: PhysicsJointData);
  28026. /**
  28027. * Gets the physics joint
  28028. */
  28029. get physicsJoint(): any;
  28030. /**
  28031. * Sets the physics joint
  28032. */
  28033. set physicsJoint(newJoint: any);
  28034. /**
  28035. * Sets the physics plugin
  28036. */
  28037. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  28038. /**
  28039. * Execute a function that is physics-plugin specific.
  28040. * @param {Function} func the function that will be executed.
  28041. * It accepts two parameters: the physics world and the physics joint
  28042. */
  28043. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  28044. /**
  28045. * Distance-Joint type
  28046. */
  28047. static DistanceJoint: number;
  28048. /**
  28049. * Hinge-Joint type
  28050. */
  28051. static HingeJoint: number;
  28052. /**
  28053. * Ball-and-Socket joint type
  28054. */
  28055. static BallAndSocketJoint: number;
  28056. /**
  28057. * Wheel-Joint type
  28058. */
  28059. static WheelJoint: number;
  28060. /**
  28061. * Slider-Joint type
  28062. */
  28063. static SliderJoint: number;
  28064. /**
  28065. * Prismatic-Joint type
  28066. */
  28067. static PrismaticJoint: number;
  28068. /**
  28069. * Universal-Joint type
  28070. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  28071. */
  28072. static UniversalJoint: number;
  28073. /**
  28074. * Hinge-Joint 2 type
  28075. */
  28076. static Hinge2Joint: number;
  28077. /**
  28078. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  28079. */
  28080. static PointToPointJoint: number;
  28081. /**
  28082. * Spring-Joint type
  28083. */
  28084. static SpringJoint: number;
  28085. /**
  28086. * Lock-Joint type
  28087. */
  28088. static LockJoint: number;
  28089. }
  28090. /**
  28091. * A class representing a physics distance joint
  28092. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28093. */
  28094. export class DistanceJoint extends PhysicsJoint {
  28095. /**
  28096. *
  28097. * @param jointData The data for the Distance-Joint
  28098. */
  28099. constructor(jointData: DistanceJointData);
  28100. /**
  28101. * Update the predefined distance.
  28102. * @param maxDistance The maximum preferred distance
  28103. * @param minDistance The minimum preferred distance
  28104. */
  28105. updateDistance(maxDistance: number, minDistance?: number): void;
  28106. }
  28107. /**
  28108. * Represents a Motor-Enabled Joint
  28109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28110. */
  28111. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  28112. /**
  28113. * Initializes the Motor-Enabled Joint
  28114. * @param type The type of the joint
  28115. * @param jointData The physica joint data for the joint
  28116. */
  28117. constructor(type: number, jointData: PhysicsJointData);
  28118. /**
  28119. * Set the motor values.
  28120. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28121. * @param force the force to apply
  28122. * @param maxForce max force for this motor.
  28123. */
  28124. setMotor(force?: number, maxForce?: number): void;
  28125. /**
  28126. * Set the motor's limits.
  28127. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28128. * @param upperLimit The upper limit of the motor
  28129. * @param lowerLimit The lower limit of the motor
  28130. */
  28131. setLimit(upperLimit: number, lowerLimit?: number): void;
  28132. }
  28133. /**
  28134. * This class represents a single physics Hinge-Joint
  28135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28136. */
  28137. export class HingeJoint extends MotorEnabledJoint {
  28138. /**
  28139. * Initializes the Hinge-Joint
  28140. * @param jointData The joint data for the Hinge-Joint
  28141. */
  28142. constructor(jointData: PhysicsJointData);
  28143. /**
  28144. * Set the motor values.
  28145. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28146. * @param {number} force the force to apply
  28147. * @param {number} maxForce max force for this motor.
  28148. */
  28149. setMotor(force?: number, maxForce?: number): void;
  28150. /**
  28151. * Set the motor's limits.
  28152. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28153. * @param upperLimit The upper limit of the motor
  28154. * @param lowerLimit The lower limit of the motor
  28155. */
  28156. setLimit(upperLimit: number, lowerLimit?: number): void;
  28157. }
  28158. /**
  28159. * This class represents a dual hinge physics joint (same as wheel joint)
  28160. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28161. */
  28162. export class Hinge2Joint extends MotorEnabledJoint {
  28163. /**
  28164. * Initializes the Hinge2-Joint
  28165. * @param jointData The joint data for the Hinge2-Joint
  28166. */
  28167. constructor(jointData: PhysicsJointData);
  28168. /**
  28169. * Set the motor values.
  28170. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28171. * @param {number} targetSpeed the speed the motor is to reach
  28172. * @param {number} maxForce max force for this motor.
  28173. * @param {motorIndex} the motor's index, 0 or 1.
  28174. */
  28175. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  28176. /**
  28177. * Set the motor limits.
  28178. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28179. * @param {number} upperLimit the upper limit
  28180. * @param {number} lowerLimit lower limit
  28181. * @param {motorIndex} the motor's index, 0 or 1.
  28182. */
  28183. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28184. }
  28185. /**
  28186. * Interface for a motor enabled joint
  28187. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28188. */
  28189. export interface IMotorEnabledJoint {
  28190. /**
  28191. * Physics joint
  28192. */
  28193. physicsJoint: any;
  28194. /**
  28195. * Sets the motor of the motor-enabled joint
  28196. * @param force The force of the motor
  28197. * @param maxForce The maximum force of the motor
  28198. * @param motorIndex The index of the motor
  28199. */
  28200. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  28201. /**
  28202. * Sets the limit of the motor
  28203. * @param upperLimit The upper limit of the motor
  28204. * @param lowerLimit The lower limit of the motor
  28205. * @param motorIndex The index of the motor
  28206. */
  28207. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28208. }
  28209. /**
  28210. * Joint data for a Distance-Joint
  28211. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28212. */
  28213. export interface DistanceJointData extends PhysicsJointData {
  28214. /**
  28215. * Max distance the 2 joint objects can be apart
  28216. */
  28217. maxDistance: number;
  28218. }
  28219. /**
  28220. * Joint data from a spring joint
  28221. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28222. */
  28223. export interface SpringJointData extends PhysicsJointData {
  28224. /**
  28225. * Length of the spring
  28226. */
  28227. length: number;
  28228. /**
  28229. * Stiffness of the spring
  28230. */
  28231. stiffness: number;
  28232. /**
  28233. * Damping of the spring
  28234. */
  28235. damping: number;
  28236. /** this callback will be called when applying the force to the impostors. */
  28237. forceApplicationCallback: () => void;
  28238. }
  28239. }
  28240. declare module "babylonjs/Physics/physicsRaycastResult" {
  28241. import { Vector3 } from "babylonjs/Maths/math.vector";
  28242. /**
  28243. * Holds the data for the raycast result
  28244. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28245. */
  28246. export class PhysicsRaycastResult {
  28247. private _hasHit;
  28248. private _hitDistance;
  28249. private _hitNormalWorld;
  28250. private _hitPointWorld;
  28251. private _rayFromWorld;
  28252. private _rayToWorld;
  28253. /**
  28254. * Gets if there was a hit
  28255. */
  28256. get hasHit(): boolean;
  28257. /**
  28258. * Gets the distance from the hit
  28259. */
  28260. get hitDistance(): number;
  28261. /**
  28262. * Gets the hit normal/direction in the world
  28263. */
  28264. get hitNormalWorld(): Vector3;
  28265. /**
  28266. * Gets the hit point in the world
  28267. */
  28268. get hitPointWorld(): Vector3;
  28269. /**
  28270. * Gets the ray "start point" of the ray in the world
  28271. */
  28272. get rayFromWorld(): Vector3;
  28273. /**
  28274. * Gets the ray "end point" of the ray in the world
  28275. */
  28276. get rayToWorld(): Vector3;
  28277. /**
  28278. * Sets the hit data (normal & point in world space)
  28279. * @param hitNormalWorld defines the normal in world space
  28280. * @param hitPointWorld defines the point in world space
  28281. */
  28282. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28283. /**
  28284. * Sets the distance from the start point to the hit point
  28285. * @param distance
  28286. */
  28287. setHitDistance(distance: number): void;
  28288. /**
  28289. * Calculates the distance manually
  28290. */
  28291. calculateHitDistance(): void;
  28292. /**
  28293. * Resets all the values to default
  28294. * @param from The from point on world space
  28295. * @param to The to point on world space
  28296. */
  28297. reset(from?: Vector3, to?: Vector3): void;
  28298. }
  28299. /**
  28300. * Interface for the size containing width and height
  28301. */
  28302. interface IXYZ {
  28303. /**
  28304. * X
  28305. */
  28306. x: number;
  28307. /**
  28308. * Y
  28309. */
  28310. y: number;
  28311. /**
  28312. * Z
  28313. */
  28314. z: number;
  28315. }
  28316. }
  28317. declare module "babylonjs/Physics/IPhysicsEngine" {
  28318. import { Nullable } from "babylonjs/types";
  28319. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28321. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28322. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28323. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28324. /**
  28325. * Interface used to describe a physics joint
  28326. */
  28327. export interface PhysicsImpostorJoint {
  28328. /** Defines the main impostor to which the joint is linked */
  28329. mainImpostor: PhysicsImpostor;
  28330. /** Defines the impostor that is connected to the main impostor using this joint */
  28331. connectedImpostor: PhysicsImpostor;
  28332. /** Defines the joint itself */
  28333. joint: PhysicsJoint;
  28334. }
  28335. /** @hidden */
  28336. export interface IPhysicsEnginePlugin {
  28337. world: any;
  28338. name: string;
  28339. setGravity(gravity: Vector3): void;
  28340. setTimeStep(timeStep: number): void;
  28341. getTimeStep(): number;
  28342. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28343. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28344. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28345. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28346. removePhysicsBody(impostor: PhysicsImpostor): void;
  28347. generateJoint(joint: PhysicsImpostorJoint): void;
  28348. removeJoint(joint: PhysicsImpostorJoint): void;
  28349. isSupported(): boolean;
  28350. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28351. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28352. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28353. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28354. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28355. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28356. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28357. getBodyMass(impostor: PhysicsImpostor): number;
  28358. getBodyFriction(impostor: PhysicsImpostor): number;
  28359. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28360. getBodyRestitution(impostor: PhysicsImpostor): number;
  28361. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28362. getBodyPressure?(impostor: PhysicsImpostor): number;
  28363. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28364. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28365. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28366. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28367. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28368. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28369. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28370. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28371. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28372. sleepBody(impostor: PhysicsImpostor): void;
  28373. wakeUpBody(impostor: PhysicsImpostor): void;
  28374. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28375. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28376. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28377. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28378. getRadius(impostor: PhysicsImpostor): number;
  28379. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28380. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28381. dispose(): void;
  28382. }
  28383. /**
  28384. * Interface used to define a physics engine
  28385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28386. */
  28387. export interface IPhysicsEngine {
  28388. /**
  28389. * Gets the gravity vector used by the simulation
  28390. */
  28391. gravity: Vector3;
  28392. /**
  28393. * Sets the gravity vector used by the simulation
  28394. * @param gravity defines the gravity vector to use
  28395. */
  28396. setGravity(gravity: Vector3): void;
  28397. /**
  28398. * Set the time step of the physics engine.
  28399. * Default is 1/60.
  28400. * To slow it down, enter 1/600 for example.
  28401. * To speed it up, 1/30
  28402. * @param newTimeStep the new timestep to apply to this world.
  28403. */
  28404. setTimeStep(newTimeStep: number): void;
  28405. /**
  28406. * Get the time step of the physics engine.
  28407. * @returns the current time step
  28408. */
  28409. getTimeStep(): number;
  28410. /**
  28411. * Set the sub time step of the physics engine.
  28412. * Default is 0 meaning there is no sub steps
  28413. * To increase physics resolution precision, set a small value (like 1 ms)
  28414. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28415. */
  28416. setSubTimeStep(subTimeStep: number): void;
  28417. /**
  28418. * Get the sub time step of the physics engine.
  28419. * @returns the current sub time step
  28420. */
  28421. getSubTimeStep(): number;
  28422. /**
  28423. * Release all resources
  28424. */
  28425. dispose(): void;
  28426. /**
  28427. * Gets the name of the current physics plugin
  28428. * @returns the name of the plugin
  28429. */
  28430. getPhysicsPluginName(): string;
  28431. /**
  28432. * Adding a new impostor for the impostor tracking.
  28433. * This will be done by the impostor itself.
  28434. * @param impostor the impostor to add
  28435. */
  28436. addImpostor(impostor: PhysicsImpostor): void;
  28437. /**
  28438. * Remove an impostor from the engine.
  28439. * This impostor and its mesh will not longer be updated by the physics engine.
  28440. * @param impostor the impostor to remove
  28441. */
  28442. removeImpostor(impostor: PhysicsImpostor): void;
  28443. /**
  28444. * Add a joint to the physics engine
  28445. * @param mainImpostor defines the main impostor to which the joint is added.
  28446. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28447. * @param joint defines the joint that will connect both impostors.
  28448. */
  28449. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28450. /**
  28451. * Removes a joint from the simulation
  28452. * @param mainImpostor defines the impostor used with the joint
  28453. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28454. * @param joint defines the joint to remove
  28455. */
  28456. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28457. /**
  28458. * Gets the current plugin used to run the simulation
  28459. * @returns current plugin
  28460. */
  28461. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28462. /**
  28463. * Gets the list of physic impostors
  28464. * @returns an array of PhysicsImpostor
  28465. */
  28466. getImpostors(): Array<PhysicsImpostor>;
  28467. /**
  28468. * Gets the impostor for a physics enabled object
  28469. * @param object defines the object impersonated by the impostor
  28470. * @returns the PhysicsImpostor or null if not found
  28471. */
  28472. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28473. /**
  28474. * Gets the impostor for a physics body object
  28475. * @param body defines physics body used by the impostor
  28476. * @returns the PhysicsImpostor or null if not found
  28477. */
  28478. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28479. /**
  28480. * Does a raycast in the physics world
  28481. * @param from when should the ray start?
  28482. * @param to when should the ray end?
  28483. * @returns PhysicsRaycastResult
  28484. */
  28485. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28486. /**
  28487. * Called by the scene. No need to call it.
  28488. * @param delta defines the timespam between frames
  28489. */
  28490. _step(delta: number): void;
  28491. }
  28492. }
  28493. declare module "babylonjs/Physics/physicsImpostor" {
  28494. import { Nullable, IndicesArray } from "babylonjs/types";
  28495. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28496. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28498. import { Scene } from "babylonjs/scene";
  28499. import { Bone } from "babylonjs/Bones/bone";
  28500. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28501. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28502. import { Space } from "babylonjs/Maths/math.axis";
  28503. /**
  28504. * The interface for the physics imposter parameters
  28505. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28506. */
  28507. export interface PhysicsImpostorParameters {
  28508. /**
  28509. * The mass of the physics imposter
  28510. */
  28511. mass: number;
  28512. /**
  28513. * The friction of the physics imposter
  28514. */
  28515. friction?: number;
  28516. /**
  28517. * The coefficient of restitution of the physics imposter
  28518. */
  28519. restitution?: number;
  28520. /**
  28521. * The native options of the physics imposter
  28522. */
  28523. nativeOptions?: any;
  28524. /**
  28525. * Specifies if the parent should be ignored
  28526. */
  28527. ignoreParent?: boolean;
  28528. /**
  28529. * Specifies if bi-directional transformations should be disabled
  28530. */
  28531. disableBidirectionalTransformation?: boolean;
  28532. /**
  28533. * The pressure inside the physics imposter, soft object only
  28534. */
  28535. pressure?: number;
  28536. /**
  28537. * The stiffness the physics imposter, soft object only
  28538. */
  28539. stiffness?: number;
  28540. /**
  28541. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28542. */
  28543. velocityIterations?: number;
  28544. /**
  28545. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28546. */
  28547. positionIterations?: number;
  28548. /**
  28549. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28550. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28551. * Add to fix multiple points
  28552. */
  28553. fixedPoints?: number;
  28554. /**
  28555. * The collision margin around a soft object
  28556. */
  28557. margin?: number;
  28558. /**
  28559. * The collision margin around a soft object
  28560. */
  28561. damping?: number;
  28562. /**
  28563. * The path for a rope based on an extrusion
  28564. */
  28565. path?: any;
  28566. /**
  28567. * The shape of an extrusion used for a rope based on an extrusion
  28568. */
  28569. shape?: any;
  28570. }
  28571. /**
  28572. * Interface for a physics-enabled object
  28573. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28574. */
  28575. export interface IPhysicsEnabledObject {
  28576. /**
  28577. * The position of the physics-enabled object
  28578. */
  28579. position: Vector3;
  28580. /**
  28581. * The rotation of the physics-enabled object
  28582. */
  28583. rotationQuaternion: Nullable<Quaternion>;
  28584. /**
  28585. * The scale of the physics-enabled object
  28586. */
  28587. scaling: Vector3;
  28588. /**
  28589. * The rotation of the physics-enabled object
  28590. */
  28591. rotation?: Vector3;
  28592. /**
  28593. * The parent of the physics-enabled object
  28594. */
  28595. parent?: any;
  28596. /**
  28597. * The bounding info of the physics-enabled object
  28598. * @returns The bounding info of the physics-enabled object
  28599. */
  28600. getBoundingInfo(): BoundingInfo;
  28601. /**
  28602. * Computes the world matrix
  28603. * @param force Specifies if the world matrix should be computed by force
  28604. * @returns A world matrix
  28605. */
  28606. computeWorldMatrix(force: boolean): Matrix;
  28607. /**
  28608. * Gets the world matrix
  28609. * @returns A world matrix
  28610. */
  28611. getWorldMatrix?(): Matrix;
  28612. /**
  28613. * Gets the child meshes
  28614. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28615. * @returns An array of abstract meshes
  28616. */
  28617. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28618. /**
  28619. * Gets the vertex data
  28620. * @param kind The type of vertex data
  28621. * @returns A nullable array of numbers, or a float32 array
  28622. */
  28623. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28624. /**
  28625. * Gets the indices from the mesh
  28626. * @returns A nullable array of index arrays
  28627. */
  28628. getIndices?(): Nullable<IndicesArray>;
  28629. /**
  28630. * Gets the scene from the mesh
  28631. * @returns the indices array or null
  28632. */
  28633. getScene?(): Scene;
  28634. /**
  28635. * Gets the absolute position from the mesh
  28636. * @returns the absolute position
  28637. */
  28638. getAbsolutePosition(): Vector3;
  28639. /**
  28640. * Gets the absolute pivot point from the mesh
  28641. * @returns the absolute pivot point
  28642. */
  28643. getAbsolutePivotPoint(): Vector3;
  28644. /**
  28645. * Rotates the mesh
  28646. * @param axis The axis of rotation
  28647. * @param amount The amount of rotation
  28648. * @param space The space of the rotation
  28649. * @returns The rotation transform node
  28650. */
  28651. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28652. /**
  28653. * Translates the mesh
  28654. * @param axis The axis of translation
  28655. * @param distance The distance of translation
  28656. * @param space The space of the translation
  28657. * @returns The transform node
  28658. */
  28659. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28660. /**
  28661. * Sets the absolute position of the mesh
  28662. * @param absolutePosition The absolute position of the mesh
  28663. * @returns The transform node
  28664. */
  28665. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28666. /**
  28667. * Gets the class name of the mesh
  28668. * @returns The class name
  28669. */
  28670. getClassName(): string;
  28671. }
  28672. /**
  28673. * Represents a physics imposter
  28674. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28675. */
  28676. export class PhysicsImpostor {
  28677. /**
  28678. * The physics-enabled object used as the physics imposter
  28679. */
  28680. object: IPhysicsEnabledObject;
  28681. /**
  28682. * The type of the physics imposter
  28683. */
  28684. type: number;
  28685. private _options;
  28686. private _scene?;
  28687. /**
  28688. * The default object size of the imposter
  28689. */
  28690. static DEFAULT_OBJECT_SIZE: Vector3;
  28691. /**
  28692. * The identity quaternion of the imposter
  28693. */
  28694. static IDENTITY_QUATERNION: Quaternion;
  28695. /** @hidden */
  28696. _pluginData: any;
  28697. private _physicsEngine;
  28698. private _physicsBody;
  28699. private _bodyUpdateRequired;
  28700. private _onBeforePhysicsStepCallbacks;
  28701. private _onAfterPhysicsStepCallbacks;
  28702. /** @hidden */
  28703. _onPhysicsCollideCallbacks: Array<{
  28704. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28705. otherImpostors: Array<PhysicsImpostor>;
  28706. }>;
  28707. private _deltaPosition;
  28708. private _deltaRotation;
  28709. private _deltaRotationConjugated;
  28710. /** @hidden */
  28711. _isFromLine: boolean;
  28712. private _parent;
  28713. private _isDisposed;
  28714. private static _tmpVecs;
  28715. private static _tmpQuat;
  28716. /**
  28717. * Specifies if the physics imposter is disposed
  28718. */
  28719. get isDisposed(): boolean;
  28720. /**
  28721. * Gets the mass of the physics imposter
  28722. */
  28723. get mass(): number;
  28724. set mass(value: number);
  28725. /**
  28726. * Gets the coefficient of friction
  28727. */
  28728. get friction(): number;
  28729. /**
  28730. * Sets the coefficient of friction
  28731. */
  28732. set friction(value: number);
  28733. /**
  28734. * Gets the coefficient of restitution
  28735. */
  28736. get restitution(): number;
  28737. /**
  28738. * Sets the coefficient of restitution
  28739. */
  28740. set restitution(value: number);
  28741. /**
  28742. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28743. */
  28744. get pressure(): number;
  28745. /**
  28746. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28747. */
  28748. set pressure(value: number);
  28749. /**
  28750. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28751. */
  28752. get stiffness(): number;
  28753. /**
  28754. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28755. */
  28756. set stiffness(value: number);
  28757. /**
  28758. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28759. */
  28760. get velocityIterations(): number;
  28761. /**
  28762. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28763. */
  28764. set velocityIterations(value: number);
  28765. /**
  28766. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28767. */
  28768. get positionIterations(): number;
  28769. /**
  28770. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28771. */
  28772. set positionIterations(value: number);
  28773. /**
  28774. * The unique id of the physics imposter
  28775. * set by the physics engine when adding this impostor to the array
  28776. */
  28777. uniqueId: number;
  28778. /**
  28779. * @hidden
  28780. */
  28781. soft: boolean;
  28782. /**
  28783. * @hidden
  28784. */
  28785. segments: number;
  28786. private _joints;
  28787. /**
  28788. * Initializes the physics imposter
  28789. * @param object The physics-enabled object used as the physics imposter
  28790. * @param type The type of the physics imposter
  28791. * @param _options The options for the physics imposter
  28792. * @param _scene The Babylon scene
  28793. */
  28794. constructor(
  28795. /**
  28796. * The physics-enabled object used as the physics imposter
  28797. */
  28798. object: IPhysicsEnabledObject,
  28799. /**
  28800. * The type of the physics imposter
  28801. */
  28802. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28803. /**
  28804. * This function will completly initialize this impostor.
  28805. * It will create a new body - but only if this mesh has no parent.
  28806. * If it has, this impostor will not be used other than to define the impostor
  28807. * of the child mesh.
  28808. * @hidden
  28809. */
  28810. _init(): void;
  28811. private _getPhysicsParent;
  28812. /**
  28813. * Should a new body be generated.
  28814. * @returns boolean specifying if body initialization is required
  28815. */
  28816. isBodyInitRequired(): boolean;
  28817. /**
  28818. * Sets the updated scaling
  28819. * @param updated Specifies if the scaling is updated
  28820. */
  28821. setScalingUpdated(): void;
  28822. /**
  28823. * Force a regeneration of this or the parent's impostor's body.
  28824. * Use under cautious - This will remove all joints already implemented.
  28825. */
  28826. forceUpdate(): void;
  28827. /**
  28828. * Gets the body that holds this impostor. Either its own, or its parent.
  28829. */
  28830. get physicsBody(): any;
  28831. /**
  28832. * Get the parent of the physics imposter
  28833. * @returns Physics imposter or null
  28834. */
  28835. get parent(): Nullable<PhysicsImpostor>;
  28836. /**
  28837. * Sets the parent of the physics imposter
  28838. */
  28839. set parent(value: Nullable<PhysicsImpostor>);
  28840. /**
  28841. * Set the physics body. Used mainly by the physics engine/plugin
  28842. */
  28843. set physicsBody(physicsBody: any);
  28844. /**
  28845. * Resets the update flags
  28846. */
  28847. resetUpdateFlags(): void;
  28848. /**
  28849. * Gets the object extend size
  28850. * @returns the object extend size
  28851. */
  28852. getObjectExtendSize(): Vector3;
  28853. /**
  28854. * Gets the object center
  28855. * @returns The object center
  28856. */
  28857. getObjectCenter(): Vector3;
  28858. /**
  28859. * Get a specific parameter from the options parameters
  28860. * @param paramName The object parameter name
  28861. * @returns The object parameter
  28862. */
  28863. getParam(paramName: string): any;
  28864. /**
  28865. * Sets a specific parameter in the options given to the physics plugin
  28866. * @param paramName The parameter name
  28867. * @param value The value of the parameter
  28868. */
  28869. setParam(paramName: string, value: number): void;
  28870. /**
  28871. * Specifically change the body's mass option. Won't recreate the physics body object
  28872. * @param mass The mass of the physics imposter
  28873. */
  28874. setMass(mass: number): void;
  28875. /**
  28876. * Gets the linear velocity
  28877. * @returns linear velocity or null
  28878. */
  28879. getLinearVelocity(): Nullable<Vector3>;
  28880. /**
  28881. * Sets the linear velocity
  28882. * @param velocity linear velocity or null
  28883. */
  28884. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28885. /**
  28886. * Gets the angular velocity
  28887. * @returns angular velocity or null
  28888. */
  28889. getAngularVelocity(): Nullable<Vector3>;
  28890. /**
  28891. * Sets the angular velocity
  28892. * @param velocity The velocity or null
  28893. */
  28894. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28895. /**
  28896. * Execute a function with the physics plugin native code
  28897. * Provide a function the will have two variables - the world object and the physics body object
  28898. * @param func The function to execute with the physics plugin native code
  28899. */
  28900. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28901. /**
  28902. * Register a function that will be executed before the physics world is stepping forward
  28903. * @param func The function to execute before the physics world is stepped forward
  28904. */
  28905. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28906. /**
  28907. * Unregister a function that will be executed before the physics world is stepping forward
  28908. * @param func The function to execute before the physics world is stepped forward
  28909. */
  28910. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28911. /**
  28912. * Register a function that will be executed after the physics step
  28913. * @param func The function to execute after physics step
  28914. */
  28915. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28916. /**
  28917. * Unregisters a function that will be executed after the physics step
  28918. * @param func The function to execute after physics step
  28919. */
  28920. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28921. /**
  28922. * register a function that will be executed when this impostor collides against a different body
  28923. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28924. * @param func Callback that is executed on collision
  28925. */
  28926. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28927. /**
  28928. * Unregisters the physics imposter on contact
  28929. * @param collideAgainst The physics object to collide against
  28930. * @param func Callback to execute on collision
  28931. */
  28932. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28933. private _tmpQuat;
  28934. private _tmpQuat2;
  28935. /**
  28936. * Get the parent rotation
  28937. * @returns The parent rotation
  28938. */
  28939. getParentsRotation(): Quaternion;
  28940. /**
  28941. * this function is executed by the physics engine.
  28942. */
  28943. beforeStep: () => void;
  28944. /**
  28945. * this function is executed by the physics engine
  28946. */
  28947. afterStep: () => void;
  28948. /**
  28949. * Legacy collision detection event support
  28950. */
  28951. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28952. /**
  28953. * event and body object due to cannon's event-based architecture.
  28954. */
  28955. onCollide: (e: {
  28956. body: any;
  28957. }) => void;
  28958. /**
  28959. * Apply a force
  28960. * @param force The force to apply
  28961. * @param contactPoint The contact point for the force
  28962. * @returns The physics imposter
  28963. */
  28964. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28965. /**
  28966. * Apply an impulse
  28967. * @param force The impulse force
  28968. * @param contactPoint The contact point for the impulse force
  28969. * @returns The physics imposter
  28970. */
  28971. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28972. /**
  28973. * A help function to create a joint
  28974. * @param otherImpostor A physics imposter used to create a joint
  28975. * @param jointType The type of joint
  28976. * @param jointData The data for the joint
  28977. * @returns The physics imposter
  28978. */
  28979. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28980. /**
  28981. * Add a joint to this impostor with a different impostor
  28982. * @param otherImpostor A physics imposter used to add a joint
  28983. * @param joint The joint to add
  28984. * @returns The physics imposter
  28985. */
  28986. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28987. /**
  28988. * Add an anchor to a cloth impostor
  28989. * @param otherImpostor rigid impostor to anchor to
  28990. * @param width ratio across width from 0 to 1
  28991. * @param height ratio up height from 0 to 1
  28992. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28993. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28994. * @returns impostor the soft imposter
  28995. */
  28996. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28997. /**
  28998. * Add a hook to a rope impostor
  28999. * @param otherImpostor rigid impostor to anchor to
  29000. * @param length ratio across rope from 0 to 1
  29001. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  29002. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  29003. * @returns impostor the rope imposter
  29004. */
  29005. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  29006. /**
  29007. * Will keep this body still, in a sleep mode.
  29008. * @returns the physics imposter
  29009. */
  29010. sleep(): PhysicsImpostor;
  29011. /**
  29012. * Wake the body up.
  29013. * @returns The physics imposter
  29014. */
  29015. wakeUp(): PhysicsImpostor;
  29016. /**
  29017. * Clones the physics imposter
  29018. * @param newObject The physics imposter clones to this physics-enabled object
  29019. * @returns A nullable physics imposter
  29020. */
  29021. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  29022. /**
  29023. * Disposes the physics imposter
  29024. */
  29025. dispose(): void;
  29026. /**
  29027. * Sets the delta position
  29028. * @param position The delta position amount
  29029. */
  29030. setDeltaPosition(position: Vector3): void;
  29031. /**
  29032. * Sets the delta rotation
  29033. * @param rotation The delta rotation amount
  29034. */
  29035. setDeltaRotation(rotation: Quaternion): void;
  29036. /**
  29037. * Gets the box size of the physics imposter and stores the result in the input parameter
  29038. * @param result Stores the box size
  29039. * @returns The physics imposter
  29040. */
  29041. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  29042. /**
  29043. * Gets the radius of the physics imposter
  29044. * @returns Radius of the physics imposter
  29045. */
  29046. getRadius(): number;
  29047. /**
  29048. * Sync a bone with this impostor
  29049. * @param bone The bone to sync to the impostor.
  29050. * @param boneMesh The mesh that the bone is influencing.
  29051. * @param jointPivot The pivot of the joint / bone in local space.
  29052. * @param distToJoint Optional distance from the impostor to the joint.
  29053. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29054. */
  29055. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  29056. /**
  29057. * Sync impostor to a bone
  29058. * @param bone The bone that the impostor will be synced to.
  29059. * @param boneMesh The mesh that the bone is influencing.
  29060. * @param jointPivot The pivot of the joint / bone in local space.
  29061. * @param distToJoint Optional distance from the impostor to the joint.
  29062. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29063. * @param boneAxis Optional vector3 axis the bone is aligned with
  29064. */
  29065. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  29066. /**
  29067. * No-Imposter type
  29068. */
  29069. static NoImpostor: number;
  29070. /**
  29071. * Sphere-Imposter type
  29072. */
  29073. static SphereImpostor: number;
  29074. /**
  29075. * Box-Imposter type
  29076. */
  29077. static BoxImpostor: number;
  29078. /**
  29079. * Plane-Imposter type
  29080. */
  29081. static PlaneImpostor: number;
  29082. /**
  29083. * Mesh-imposter type
  29084. */
  29085. static MeshImpostor: number;
  29086. /**
  29087. * Capsule-Impostor type (Ammo.js plugin only)
  29088. */
  29089. static CapsuleImpostor: number;
  29090. /**
  29091. * Cylinder-Imposter type
  29092. */
  29093. static CylinderImpostor: number;
  29094. /**
  29095. * Particle-Imposter type
  29096. */
  29097. static ParticleImpostor: number;
  29098. /**
  29099. * Heightmap-Imposter type
  29100. */
  29101. static HeightmapImpostor: number;
  29102. /**
  29103. * ConvexHull-Impostor type (Ammo.js plugin only)
  29104. */
  29105. static ConvexHullImpostor: number;
  29106. /**
  29107. * Custom-Imposter type (Ammo.js plugin only)
  29108. */
  29109. static CustomImpostor: number;
  29110. /**
  29111. * Rope-Imposter type
  29112. */
  29113. static RopeImpostor: number;
  29114. /**
  29115. * Cloth-Imposter type
  29116. */
  29117. static ClothImpostor: number;
  29118. /**
  29119. * Softbody-Imposter type
  29120. */
  29121. static SoftbodyImpostor: number;
  29122. }
  29123. }
  29124. declare module "babylonjs/Meshes/mesh" {
  29125. import { Observable } from "babylonjs/Misc/observable";
  29126. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29127. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29128. import { Camera } from "babylonjs/Cameras/camera";
  29129. import { Scene } from "babylonjs/scene";
  29130. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29131. import { Color4 } from "babylonjs/Maths/math.color";
  29132. import { Engine } from "babylonjs/Engines/engine";
  29133. import { Node } from "babylonjs/node";
  29134. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29135. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29136. import { Buffer } from "babylonjs/Meshes/buffer";
  29137. import { Geometry } from "babylonjs/Meshes/geometry";
  29138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29139. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29140. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  29141. import { Effect } from "babylonjs/Materials/effect";
  29142. import { Material } from "babylonjs/Materials/material";
  29143. import { Skeleton } from "babylonjs/Bones/skeleton";
  29144. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  29145. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  29146. import { Path3D } from "babylonjs/Maths/math.path";
  29147. import { Plane } from "babylonjs/Maths/math.plane";
  29148. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29149. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  29150. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  29151. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29152. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  29153. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  29154. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  29155. /**
  29156. * @hidden
  29157. **/
  29158. export class _CreationDataStorage {
  29159. closePath?: boolean;
  29160. closeArray?: boolean;
  29161. idx: number[];
  29162. dashSize: number;
  29163. gapSize: number;
  29164. path3D: Path3D;
  29165. pathArray: Vector3[][];
  29166. arc: number;
  29167. radius: number;
  29168. cap: number;
  29169. tessellation: number;
  29170. }
  29171. /**
  29172. * @hidden
  29173. **/
  29174. class _InstanceDataStorage {
  29175. visibleInstances: any;
  29176. batchCache: _InstancesBatch;
  29177. instancesBufferSize: number;
  29178. instancesBuffer: Nullable<Buffer>;
  29179. instancesData: Float32Array;
  29180. overridenInstanceCount: number;
  29181. isFrozen: boolean;
  29182. previousBatch: Nullable<_InstancesBatch>;
  29183. hardwareInstancedRendering: boolean;
  29184. sideOrientation: number;
  29185. manualUpdate: boolean;
  29186. previousRenderId: number;
  29187. }
  29188. /**
  29189. * @hidden
  29190. **/
  29191. export class _InstancesBatch {
  29192. mustReturn: boolean;
  29193. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  29194. renderSelf: boolean[];
  29195. hardwareInstancedRendering: boolean[];
  29196. }
  29197. /**
  29198. * @hidden
  29199. **/
  29200. class _ThinInstanceDataStorage {
  29201. instancesCount: number;
  29202. matrixBuffer: Nullable<Buffer>;
  29203. matrixBufferSize: number;
  29204. matrixData: Nullable<Float32Array>;
  29205. boundingVectors: Array<Vector3>;
  29206. worldMatrices: Nullable<Matrix[]>;
  29207. }
  29208. /**
  29209. * Class used to represent renderable models
  29210. */
  29211. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  29212. /**
  29213. * Mesh side orientation : usually the external or front surface
  29214. */
  29215. static readonly FRONTSIDE: number;
  29216. /**
  29217. * Mesh side orientation : usually the internal or back surface
  29218. */
  29219. static readonly BACKSIDE: number;
  29220. /**
  29221. * Mesh side orientation : both internal and external or front and back surfaces
  29222. */
  29223. static readonly DOUBLESIDE: number;
  29224. /**
  29225. * Mesh side orientation : by default, `FRONTSIDE`
  29226. */
  29227. static readonly DEFAULTSIDE: number;
  29228. /**
  29229. * Mesh cap setting : no cap
  29230. */
  29231. static readonly NO_CAP: number;
  29232. /**
  29233. * Mesh cap setting : one cap at the beginning of the mesh
  29234. */
  29235. static readonly CAP_START: number;
  29236. /**
  29237. * Mesh cap setting : one cap at the end of the mesh
  29238. */
  29239. static readonly CAP_END: number;
  29240. /**
  29241. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29242. */
  29243. static readonly CAP_ALL: number;
  29244. /**
  29245. * Mesh pattern setting : no flip or rotate
  29246. */
  29247. static readonly NO_FLIP: number;
  29248. /**
  29249. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29250. */
  29251. static readonly FLIP_TILE: number;
  29252. /**
  29253. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29254. */
  29255. static readonly ROTATE_TILE: number;
  29256. /**
  29257. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29258. */
  29259. static readonly FLIP_ROW: number;
  29260. /**
  29261. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29262. */
  29263. static readonly ROTATE_ROW: number;
  29264. /**
  29265. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29266. */
  29267. static readonly FLIP_N_ROTATE_TILE: number;
  29268. /**
  29269. * Mesh pattern setting : rotate pattern and rotate
  29270. */
  29271. static readonly FLIP_N_ROTATE_ROW: number;
  29272. /**
  29273. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29274. */
  29275. static readonly CENTER: number;
  29276. /**
  29277. * Mesh tile positioning : part tiles on left
  29278. */
  29279. static readonly LEFT: number;
  29280. /**
  29281. * Mesh tile positioning : part tiles on right
  29282. */
  29283. static readonly RIGHT: number;
  29284. /**
  29285. * Mesh tile positioning : part tiles on top
  29286. */
  29287. static readonly TOP: number;
  29288. /**
  29289. * Mesh tile positioning : part tiles on bottom
  29290. */
  29291. static readonly BOTTOM: number;
  29292. /**
  29293. * Gets the default side orientation.
  29294. * @param orientation the orientation to value to attempt to get
  29295. * @returns the default orientation
  29296. * @hidden
  29297. */
  29298. static _GetDefaultSideOrientation(orientation?: number): number;
  29299. private _internalMeshDataInfo;
  29300. get computeBonesUsingShaders(): boolean;
  29301. set computeBonesUsingShaders(value: boolean);
  29302. /**
  29303. * An event triggered before rendering the mesh
  29304. */
  29305. get onBeforeRenderObservable(): Observable<Mesh>;
  29306. /**
  29307. * An event triggered before binding the mesh
  29308. */
  29309. get onBeforeBindObservable(): Observable<Mesh>;
  29310. /**
  29311. * An event triggered after rendering the mesh
  29312. */
  29313. get onAfterRenderObservable(): Observable<Mesh>;
  29314. /**
  29315. * An event triggered before drawing the mesh
  29316. */
  29317. get onBeforeDrawObservable(): Observable<Mesh>;
  29318. private _onBeforeDrawObserver;
  29319. /**
  29320. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29321. */
  29322. set onBeforeDraw(callback: () => void);
  29323. get hasInstances(): boolean;
  29324. get hasThinInstances(): boolean;
  29325. /**
  29326. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29327. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29328. */
  29329. delayLoadState: number;
  29330. /**
  29331. * Gets the list of instances created from this mesh
  29332. * it is not supposed to be modified manually.
  29333. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29334. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29335. */
  29336. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29337. /**
  29338. * Gets the file containing delay loading data for this mesh
  29339. */
  29340. delayLoadingFile: string;
  29341. /** @hidden */
  29342. _binaryInfo: any;
  29343. /**
  29344. * User defined function used to change how LOD level selection is done
  29345. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29346. */
  29347. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29348. /**
  29349. * Gets or sets the morph target manager
  29350. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29351. */
  29352. get morphTargetManager(): Nullable<MorphTargetManager>;
  29353. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29354. /** @hidden */
  29355. _creationDataStorage: Nullable<_CreationDataStorage>;
  29356. /** @hidden */
  29357. _geometry: Nullable<Geometry>;
  29358. /** @hidden */
  29359. _delayInfo: Array<string>;
  29360. /** @hidden */
  29361. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29362. /** @hidden */
  29363. _instanceDataStorage: _InstanceDataStorage;
  29364. /** @hidden */
  29365. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29366. private _effectiveMaterial;
  29367. /** @hidden */
  29368. _shouldGenerateFlatShading: boolean;
  29369. /** @hidden */
  29370. _originalBuilderSideOrientation: number;
  29371. /**
  29372. * Use this property to change the original side orientation defined at construction time
  29373. */
  29374. overrideMaterialSideOrientation: Nullable<number>;
  29375. /**
  29376. * Gets the source mesh (the one used to clone this one from)
  29377. */
  29378. get source(): Nullable<Mesh>;
  29379. /**
  29380. * Gets the list of clones of this mesh
  29381. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  29382. * Note that useClonedMeshMap=true is the default setting
  29383. */
  29384. get cloneMeshMap(): Nullable<{
  29385. [id: string]: Mesh | undefined;
  29386. }>;
  29387. /**
  29388. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29389. */
  29390. get isUnIndexed(): boolean;
  29391. set isUnIndexed(value: boolean);
  29392. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29393. get worldMatrixInstancedBuffer(): Float32Array;
  29394. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29395. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29396. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29397. /**
  29398. * @constructor
  29399. * @param name The value used by scene.getMeshByName() to do a lookup.
  29400. * @param scene The scene to add this mesh to.
  29401. * @param parent The parent of this mesh, if it has one
  29402. * @param source An optional Mesh from which geometry is shared, cloned.
  29403. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29404. * When false, achieved by calling a clone(), also passing False.
  29405. * This will make creation of children, recursive.
  29406. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29407. */
  29408. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29409. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29410. doNotInstantiate: boolean;
  29411. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29412. /**
  29413. * Gets the class name
  29414. * @returns the string "Mesh".
  29415. */
  29416. getClassName(): string;
  29417. /** @hidden */
  29418. get _isMesh(): boolean;
  29419. /**
  29420. * Returns a description of this mesh
  29421. * @param fullDetails define if full details about this mesh must be used
  29422. * @returns a descriptive string representing this mesh
  29423. */
  29424. toString(fullDetails?: boolean): string;
  29425. /** @hidden */
  29426. _unBindEffect(): void;
  29427. /**
  29428. * Gets a boolean indicating if this mesh has LOD
  29429. */
  29430. get hasLODLevels(): boolean;
  29431. /**
  29432. * Gets the list of MeshLODLevel associated with the current mesh
  29433. * @returns an array of MeshLODLevel
  29434. */
  29435. getLODLevels(): MeshLODLevel[];
  29436. private _sortLODLevels;
  29437. /**
  29438. * Add a mesh as LOD level triggered at the given distance.
  29439. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29440. * @param distance The distance from the center of the object to show this level
  29441. * @param mesh The mesh to be added as LOD level (can be null)
  29442. * @return This mesh (for chaining)
  29443. */
  29444. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29445. /**
  29446. * Returns the LOD level mesh at the passed distance or null if not found.
  29447. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29448. * @param distance The distance from the center of the object to show this level
  29449. * @returns a Mesh or `null`
  29450. */
  29451. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29452. /**
  29453. * Remove a mesh from the LOD array
  29454. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29455. * @param mesh defines the mesh to be removed
  29456. * @return This mesh (for chaining)
  29457. */
  29458. removeLODLevel(mesh: Mesh): Mesh;
  29459. /**
  29460. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29461. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29462. * @param camera defines the camera to use to compute distance
  29463. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29464. * @return This mesh (for chaining)
  29465. */
  29466. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29467. /**
  29468. * Gets the mesh internal Geometry object
  29469. */
  29470. get geometry(): Nullable<Geometry>;
  29471. /**
  29472. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29473. * @returns the total number of vertices
  29474. */
  29475. getTotalVertices(): number;
  29476. /**
  29477. * Returns the content of an associated vertex buffer
  29478. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29479. * - VertexBuffer.PositionKind
  29480. * - VertexBuffer.UVKind
  29481. * - VertexBuffer.UV2Kind
  29482. * - VertexBuffer.UV3Kind
  29483. * - VertexBuffer.UV4Kind
  29484. * - VertexBuffer.UV5Kind
  29485. * - VertexBuffer.UV6Kind
  29486. * - VertexBuffer.ColorKind
  29487. * - VertexBuffer.MatricesIndicesKind
  29488. * - VertexBuffer.MatricesIndicesExtraKind
  29489. * - VertexBuffer.MatricesWeightsKind
  29490. * - VertexBuffer.MatricesWeightsExtraKind
  29491. * @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
  29492. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29493. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29494. */
  29495. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29496. /**
  29497. * Returns the mesh VertexBuffer object from the requested `kind`
  29498. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29499. * - VertexBuffer.PositionKind
  29500. * - VertexBuffer.NormalKind
  29501. * - VertexBuffer.UVKind
  29502. * - VertexBuffer.UV2Kind
  29503. * - VertexBuffer.UV3Kind
  29504. * - VertexBuffer.UV4Kind
  29505. * - VertexBuffer.UV5Kind
  29506. * - VertexBuffer.UV6Kind
  29507. * - VertexBuffer.ColorKind
  29508. * - VertexBuffer.MatricesIndicesKind
  29509. * - VertexBuffer.MatricesIndicesExtraKind
  29510. * - VertexBuffer.MatricesWeightsKind
  29511. * - VertexBuffer.MatricesWeightsExtraKind
  29512. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29513. */
  29514. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29515. /**
  29516. * Tests if a specific vertex buffer is associated with this mesh
  29517. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29518. * - VertexBuffer.PositionKind
  29519. * - VertexBuffer.NormalKind
  29520. * - VertexBuffer.UVKind
  29521. * - VertexBuffer.UV2Kind
  29522. * - VertexBuffer.UV3Kind
  29523. * - VertexBuffer.UV4Kind
  29524. * - VertexBuffer.UV5Kind
  29525. * - VertexBuffer.UV6Kind
  29526. * - VertexBuffer.ColorKind
  29527. * - VertexBuffer.MatricesIndicesKind
  29528. * - VertexBuffer.MatricesIndicesExtraKind
  29529. * - VertexBuffer.MatricesWeightsKind
  29530. * - VertexBuffer.MatricesWeightsExtraKind
  29531. * @returns a boolean
  29532. */
  29533. isVerticesDataPresent(kind: string): boolean;
  29534. /**
  29535. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29536. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29537. * - VertexBuffer.PositionKind
  29538. * - VertexBuffer.UVKind
  29539. * - VertexBuffer.UV2Kind
  29540. * - VertexBuffer.UV3Kind
  29541. * - VertexBuffer.UV4Kind
  29542. * - VertexBuffer.UV5Kind
  29543. * - VertexBuffer.UV6Kind
  29544. * - VertexBuffer.ColorKind
  29545. * - VertexBuffer.MatricesIndicesKind
  29546. * - VertexBuffer.MatricesIndicesExtraKind
  29547. * - VertexBuffer.MatricesWeightsKind
  29548. * - VertexBuffer.MatricesWeightsExtraKind
  29549. * @returns a boolean
  29550. */
  29551. isVertexBufferUpdatable(kind: string): boolean;
  29552. /**
  29553. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29554. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29555. * - VertexBuffer.PositionKind
  29556. * - VertexBuffer.NormalKind
  29557. * - VertexBuffer.UVKind
  29558. * - VertexBuffer.UV2Kind
  29559. * - VertexBuffer.UV3Kind
  29560. * - VertexBuffer.UV4Kind
  29561. * - VertexBuffer.UV5Kind
  29562. * - VertexBuffer.UV6Kind
  29563. * - VertexBuffer.ColorKind
  29564. * - VertexBuffer.MatricesIndicesKind
  29565. * - VertexBuffer.MatricesIndicesExtraKind
  29566. * - VertexBuffer.MatricesWeightsKind
  29567. * - VertexBuffer.MatricesWeightsExtraKind
  29568. * @returns an array of strings
  29569. */
  29570. getVerticesDataKinds(): string[];
  29571. /**
  29572. * Returns a positive integer : the total number of indices in this mesh geometry.
  29573. * @returns the numner of indices or zero if the mesh has no geometry.
  29574. */
  29575. getTotalIndices(): number;
  29576. /**
  29577. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29578. * @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.
  29579. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29580. * @returns the indices array or an empty array if the mesh has no geometry
  29581. */
  29582. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29583. get isBlocked(): boolean;
  29584. /**
  29585. * Determine if the current mesh is ready to be rendered
  29586. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29587. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29588. * @returns true if all associated assets are ready (material, textures, shaders)
  29589. */
  29590. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29591. /**
  29592. * 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.
  29593. */
  29594. get areNormalsFrozen(): boolean;
  29595. /**
  29596. * 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.
  29597. * @returns the current mesh
  29598. */
  29599. freezeNormals(): Mesh;
  29600. /**
  29601. * 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
  29602. * @returns the current mesh
  29603. */
  29604. unfreezeNormals(): Mesh;
  29605. /**
  29606. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29607. */
  29608. set overridenInstanceCount(count: number);
  29609. /** @hidden */
  29610. _preActivate(): Mesh;
  29611. /** @hidden */
  29612. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29613. /** @hidden */
  29614. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29615. protected _afterComputeWorldMatrix(): void;
  29616. /** @hidden */
  29617. _postActivate(): void;
  29618. /**
  29619. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29620. * This means the mesh underlying bounding box and sphere are recomputed.
  29621. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29622. * @returns the current mesh
  29623. */
  29624. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29625. /** @hidden */
  29626. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29627. /**
  29628. * This function will subdivide the mesh into multiple submeshes
  29629. * @param count defines the expected number of submeshes
  29630. */
  29631. subdivide(count: number): void;
  29632. /**
  29633. * Copy a FloatArray into a specific associated vertex buffer
  29634. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29635. * - VertexBuffer.PositionKind
  29636. * - VertexBuffer.UVKind
  29637. * - VertexBuffer.UV2Kind
  29638. * - VertexBuffer.UV3Kind
  29639. * - VertexBuffer.UV4Kind
  29640. * - VertexBuffer.UV5Kind
  29641. * - VertexBuffer.UV6Kind
  29642. * - VertexBuffer.ColorKind
  29643. * - VertexBuffer.MatricesIndicesKind
  29644. * - VertexBuffer.MatricesIndicesExtraKind
  29645. * - VertexBuffer.MatricesWeightsKind
  29646. * - VertexBuffer.MatricesWeightsExtraKind
  29647. * @param data defines the data source
  29648. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29649. * @param stride defines the data stride size (can be null)
  29650. * @returns the current mesh
  29651. */
  29652. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29653. /**
  29654. * Delete a vertex buffer associated with this mesh
  29655. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29656. * - VertexBuffer.PositionKind
  29657. * - VertexBuffer.UVKind
  29658. * - VertexBuffer.UV2Kind
  29659. * - VertexBuffer.UV3Kind
  29660. * - VertexBuffer.UV4Kind
  29661. * - VertexBuffer.UV5Kind
  29662. * - VertexBuffer.UV6Kind
  29663. * - VertexBuffer.ColorKind
  29664. * - VertexBuffer.MatricesIndicesKind
  29665. * - VertexBuffer.MatricesIndicesExtraKind
  29666. * - VertexBuffer.MatricesWeightsKind
  29667. * - VertexBuffer.MatricesWeightsExtraKind
  29668. */
  29669. removeVerticesData(kind: string): void;
  29670. /**
  29671. * Flags an associated vertex buffer as updatable
  29672. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29673. * - VertexBuffer.PositionKind
  29674. * - VertexBuffer.UVKind
  29675. * - VertexBuffer.UV2Kind
  29676. * - VertexBuffer.UV3Kind
  29677. * - VertexBuffer.UV4Kind
  29678. * - VertexBuffer.UV5Kind
  29679. * - VertexBuffer.UV6Kind
  29680. * - VertexBuffer.ColorKind
  29681. * - VertexBuffer.MatricesIndicesKind
  29682. * - VertexBuffer.MatricesIndicesExtraKind
  29683. * - VertexBuffer.MatricesWeightsKind
  29684. * - VertexBuffer.MatricesWeightsExtraKind
  29685. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29686. */
  29687. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29688. /**
  29689. * Sets the mesh global Vertex Buffer
  29690. * @param buffer defines the buffer to use
  29691. * @returns the current mesh
  29692. */
  29693. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29694. /**
  29695. * Update a specific associated vertex buffer
  29696. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29697. * - VertexBuffer.PositionKind
  29698. * - VertexBuffer.UVKind
  29699. * - VertexBuffer.UV2Kind
  29700. * - VertexBuffer.UV3Kind
  29701. * - VertexBuffer.UV4Kind
  29702. * - VertexBuffer.UV5Kind
  29703. * - VertexBuffer.UV6Kind
  29704. * - VertexBuffer.ColorKind
  29705. * - VertexBuffer.MatricesIndicesKind
  29706. * - VertexBuffer.MatricesIndicesExtraKind
  29707. * - VertexBuffer.MatricesWeightsKind
  29708. * - VertexBuffer.MatricesWeightsExtraKind
  29709. * @param data defines the data source
  29710. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29711. * @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)
  29712. * @returns the current mesh
  29713. */
  29714. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29715. /**
  29716. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29717. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29718. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29719. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29720. * @returns the current mesh
  29721. */
  29722. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29723. /**
  29724. * Creates a un-shared specific occurence of the geometry for the mesh.
  29725. * @returns the current mesh
  29726. */
  29727. makeGeometryUnique(): Mesh;
  29728. /**
  29729. * Set the index buffer of this mesh
  29730. * @param indices defines the source data
  29731. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29732. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29733. * @returns the current mesh
  29734. */
  29735. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29736. /**
  29737. * Update the current index buffer
  29738. * @param indices defines the source data
  29739. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29740. * @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)
  29741. * @returns the current mesh
  29742. */
  29743. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29744. /**
  29745. * Invert the geometry to move from a right handed system to a left handed one.
  29746. * @returns the current mesh
  29747. */
  29748. toLeftHanded(): Mesh;
  29749. /** @hidden */
  29750. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29751. /** @hidden */
  29752. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29753. /**
  29754. * Registers for this mesh a javascript function called just before the rendering process
  29755. * @param func defines the function to call before rendering this mesh
  29756. * @returns the current mesh
  29757. */
  29758. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29759. /**
  29760. * Disposes a previously registered javascript function called before the rendering
  29761. * @param func defines the function to remove
  29762. * @returns the current mesh
  29763. */
  29764. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29765. /**
  29766. * Registers for this mesh a javascript function called just after the rendering is complete
  29767. * @param func defines the function to call after rendering this mesh
  29768. * @returns the current mesh
  29769. */
  29770. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29771. /**
  29772. * Disposes a previously registered javascript function called after the rendering.
  29773. * @param func defines the function to remove
  29774. * @returns the current mesh
  29775. */
  29776. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29777. /** @hidden */
  29778. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29779. /** @hidden */
  29780. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29781. /** @hidden */
  29782. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29783. /** @hidden */
  29784. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29785. /** @hidden */
  29786. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29787. /** @hidden */
  29788. _rebuild(): void;
  29789. /** @hidden */
  29790. _freeze(): void;
  29791. /** @hidden */
  29792. _unFreeze(): void;
  29793. /**
  29794. * 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
  29795. * @param subMesh defines the subMesh to render
  29796. * @param enableAlphaMode defines if alpha mode can be changed
  29797. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29798. * @returns the current mesh
  29799. */
  29800. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29801. private _onBeforeDraw;
  29802. /**
  29803. * Renormalize the mesh and patch it up if there are no weights
  29804. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29805. * However in the case of zero weights then we set just a single influence to 1.
  29806. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29807. */
  29808. cleanMatrixWeights(): void;
  29809. private normalizeSkinFourWeights;
  29810. private normalizeSkinWeightsAndExtra;
  29811. /**
  29812. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29813. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29814. * the user know there was an issue with importing the mesh
  29815. * @returns a validation object with skinned, valid and report string
  29816. */
  29817. validateSkinning(): {
  29818. skinned: boolean;
  29819. valid: boolean;
  29820. report: string;
  29821. };
  29822. /** @hidden */
  29823. _checkDelayState(): Mesh;
  29824. private _queueLoad;
  29825. /**
  29826. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29827. * A mesh is in the frustum if its bounding box intersects the frustum
  29828. * @param frustumPlanes defines the frustum to test
  29829. * @returns true if the mesh is in the frustum planes
  29830. */
  29831. isInFrustum(frustumPlanes: Plane[]): boolean;
  29832. /**
  29833. * Sets the mesh material by the material or multiMaterial `id` property
  29834. * @param id is a string identifying the material or the multiMaterial
  29835. * @returns the current mesh
  29836. */
  29837. setMaterialByID(id: string): Mesh;
  29838. /**
  29839. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29840. * @returns an array of IAnimatable
  29841. */
  29842. getAnimatables(): IAnimatable[];
  29843. /**
  29844. * Modifies the mesh geometry according to the passed transformation matrix.
  29845. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29846. * The mesh normals are modified using the same transformation.
  29847. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29848. * @param transform defines the transform matrix to use
  29849. * @see https://doc.babylonjs.com/resources/baking_transformations
  29850. * @returns the current mesh
  29851. */
  29852. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29853. /**
  29854. * Modifies the mesh geometry according to its own current World Matrix.
  29855. * The mesh World Matrix is then reset.
  29856. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29857. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29858. * @see https://doc.babylonjs.com/resources/baking_transformations
  29859. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29860. * @returns the current mesh
  29861. */
  29862. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29863. /** @hidden */
  29864. get _positions(): Nullable<Vector3[]>;
  29865. /** @hidden */
  29866. _resetPointsArrayCache(): Mesh;
  29867. /** @hidden */
  29868. _generatePointsArray(): boolean;
  29869. /**
  29870. * Returns a new Mesh object generated from the current mesh properties.
  29871. * This method must not get confused with createInstance()
  29872. * @param name is a string, the name given to the new mesh
  29873. * @param newParent can be any Node object (default `null`)
  29874. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29875. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29876. * @returns a new mesh
  29877. */
  29878. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29879. /**
  29880. * Releases resources associated with this mesh.
  29881. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29882. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29883. */
  29884. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29885. /** @hidden */
  29886. _disposeInstanceSpecificData(): void;
  29887. /** @hidden */
  29888. _disposeThinInstanceSpecificData(): void;
  29889. /**
  29890. * Modifies the mesh geometry according to a displacement map.
  29891. * 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.
  29892. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29893. * @param url is a string, the URL from the image file is to be downloaded.
  29894. * @param minHeight is the lower limit of the displacement.
  29895. * @param maxHeight is the upper limit of the displacement.
  29896. * @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.
  29897. * @param uvOffset is an optional vector2 used to offset UV.
  29898. * @param uvScale is an optional vector2 used to scale UV.
  29899. * @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.
  29900. * @returns the Mesh.
  29901. */
  29902. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29903. /**
  29904. * Modifies the mesh geometry according to a displacementMap buffer.
  29905. * 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.
  29906. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29907. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29908. * @param heightMapWidth is the width of the buffer image.
  29909. * @param heightMapHeight is the height of the buffer image.
  29910. * @param minHeight is the lower limit of the displacement.
  29911. * @param maxHeight is the upper limit of the displacement.
  29912. * @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.
  29913. * @param uvOffset is an optional vector2 used to offset UV.
  29914. * @param uvScale is an optional vector2 used to scale UV.
  29915. * @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.
  29916. * @returns the Mesh.
  29917. */
  29918. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29919. /**
  29920. * Modify the mesh to get a flat shading rendering.
  29921. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29922. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  29923. * @returns current mesh
  29924. */
  29925. convertToFlatShadedMesh(): Mesh;
  29926. /**
  29927. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  29928. * In other words, more vertices, no more indices and a single bigger VBO.
  29929. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  29930. * @returns current mesh
  29931. */
  29932. convertToUnIndexedMesh(): Mesh;
  29933. /**
  29934. * Inverses facet orientations.
  29935. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29936. * @param flipNormals will also inverts the normals
  29937. * @returns current mesh
  29938. */
  29939. flipFaces(flipNormals?: boolean): Mesh;
  29940. /**
  29941. * Increase the number of facets and hence vertices in a mesh
  29942. * Vertex normals are interpolated from existing vertex normals
  29943. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29944. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29945. */
  29946. increaseVertices(numberPerEdge: number): void;
  29947. /**
  29948. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29949. * This will undo any application of covertToFlatShadedMesh
  29950. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29951. */
  29952. forceSharedVertices(): void;
  29953. /** @hidden */
  29954. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29955. /** @hidden */
  29956. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29957. /**
  29958. * Creates a new InstancedMesh object from the mesh model.
  29959. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29960. * @param name defines the name of the new instance
  29961. * @returns a new InstancedMesh
  29962. */
  29963. createInstance(name: string): InstancedMesh;
  29964. /**
  29965. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29966. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29967. * @returns the current mesh
  29968. */
  29969. synchronizeInstances(): Mesh;
  29970. /**
  29971. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29972. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29973. * This should be used together with the simplification to avoid disappearing triangles.
  29974. * @param successCallback an optional success callback to be called after the optimization finished.
  29975. * @returns the current mesh
  29976. */
  29977. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29978. /**
  29979. * Serialize current mesh
  29980. * @param serializationObject defines the object which will receive the serialization data
  29981. */
  29982. serialize(serializationObject: any): void;
  29983. /** @hidden */
  29984. _syncGeometryWithMorphTargetManager(): void;
  29985. /** @hidden */
  29986. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29987. /**
  29988. * Returns a new Mesh object parsed from the source provided.
  29989. * @param parsedMesh is the source
  29990. * @param scene defines the hosting scene
  29991. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29992. * @returns a new Mesh
  29993. */
  29994. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29995. /**
  29996. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29997. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29998. * @param name defines the name of the mesh to create
  29999. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  30000. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  30001. * @param closePath creates a seam between the first and the last points of each path of the path array
  30002. * @param offset is taken in account only if the `pathArray` is containing a single path
  30003. * @param scene defines the hosting scene
  30004. * @param updatable defines if the mesh must be flagged as updatable
  30005. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30006. * @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)
  30007. * @returns a new Mesh
  30008. */
  30009. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30010. /**
  30011. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  30012. * @param name defines the name of the mesh to create
  30013. * @param radius sets the radius size (float) of the polygon (default 0.5)
  30014. * @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
  30015. * @param scene defines the hosting scene
  30016. * @param updatable defines if the mesh must be flagged as updatable
  30017. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30018. * @returns a new Mesh
  30019. */
  30020. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30021. /**
  30022. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  30023. * @param name defines the name of the mesh to create
  30024. * @param size sets the size (float) of each box side (default 1)
  30025. * @param scene defines the hosting scene
  30026. * @param updatable defines if the mesh must be flagged as updatable
  30027. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30028. * @returns a new Mesh
  30029. */
  30030. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30031. /**
  30032. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  30033. * @param name defines the name of the mesh to create
  30034. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30035. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30036. * @param scene defines the hosting scene
  30037. * @param updatable defines if the mesh must be flagged as updatable
  30038. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30039. * @returns a new Mesh
  30040. */
  30041. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30042. /**
  30043. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  30044. * @param name defines the name of the mesh to create
  30045. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30046. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30047. * @param scene defines the hosting scene
  30048. * @returns a new Mesh
  30049. */
  30050. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  30051. /**
  30052. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  30053. * @param name defines the name of the mesh to create
  30054. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  30055. * @param diameterTop set the top cap diameter (floats, default 1)
  30056. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  30057. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  30058. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  30059. * @param scene defines the hosting scene
  30060. * @param updatable defines if the mesh must be flagged as updatable
  30061. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30062. * @returns a new Mesh
  30063. */
  30064. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  30065. /**
  30066. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  30067. * @param name defines the name of the mesh to create
  30068. * @param diameter sets the diameter size (float) of the torus (default 1)
  30069. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  30070. * @param tessellation sets the number of torus sides (postive integer, default 16)
  30071. * @param scene defines the hosting scene
  30072. * @param updatable defines if the mesh must be flagged as updatable
  30073. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30074. * @returns a new Mesh
  30075. */
  30076. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30077. /**
  30078. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  30079. * @param name defines the name of the mesh to create
  30080. * @param radius sets the global radius size (float) of the torus knot (default 2)
  30081. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  30082. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  30083. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  30084. * @param p the number of windings on X axis (positive integers, default 2)
  30085. * @param q the number of windings on Y axis (positive integers, default 3)
  30086. * @param scene defines the hosting scene
  30087. * @param updatable defines if the mesh must be flagged as updatable
  30088. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30089. * @returns a new Mesh
  30090. */
  30091. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30092. /**
  30093. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  30094. * @param name defines the name of the mesh to create
  30095. * @param points is an array successive Vector3
  30096. * @param scene defines the hosting scene
  30097. * @param updatable defines if the mesh must be flagged as updatable
  30098. * @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).
  30099. * @returns a new Mesh
  30100. */
  30101. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  30102. /**
  30103. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  30104. * @param name defines the name of the mesh to create
  30105. * @param points is an array successive Vector3
  30106. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  30107. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  30108. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  30109. * @param scene defines the hosting scene
  30110. * @param updatable defines if the mesh must be flagged as updatable
  30111. * @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)
  30112. * @returns a new Mesh
  30113. */
  30114. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  30115. /**
  30116. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  30117. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  30118. * 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.
  30119. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30120. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  30121. * Remember you can only change the shape positions, not their number when updating a polygon.
  30122. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  30123. * @param name defines the name of the mesh to create
  30124. * @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
  30125. * @param scene defines the hosting scene
  30126. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30127. * @param updatable defines if the mesh must be flagged as updatable
  30128. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30129. * @param earcutInjection can be used to inject your own earcut reference
  30130. * @returns a new Mesh
  30131. */
  30132. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30133. /**
  30134. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  30135. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  30136. * @param name defines the name of the mesh to create
  30137. * @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
  30138. * @param depth defines the height of extrusion
  30139. * @param scene defines the hosting scene
  30140. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30141. * @param updatable defines if the mesh must be flagged as updatable
  30142. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30143. * @param earcutInjection can be used to inject your own earcut reference
  30144. * @returns a new Mesh
  30145. */
  30146. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30147. /**
  30148. * Creates an extruded shape mesh.
  30149. * 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
  30150. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30151. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30152. * @param name defines the name of the mesh to create
  30153. * @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
  30154. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30155. * @param scale is the value to scale the shape
  30156. * @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
  30157. * @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
  30158. * @param scene defines the hosting scene
  30159. * @param updatable defines if the mesh must be flagged as updatable
  30160. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30161. * @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)
  30162. * @returns a new Mesh
  30163. */
  30164. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30165. /**
  30166. * Creates an custom extruded shape mesh.
  30167. * The custom extrusion is a parametric shape.
  30168. * It has no predefined shape. Its final shape will depend on the input parameters.
  30169. * Please consider using the same method from the MeshBuilder class instead
  30170. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30171. * @param name defines the name of the mesh to create
  30172. * @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
  30173. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30174. * @param scaleFunction is a custom Javascript function called on each path point
  30175. * @param rotationFunction is a custom Javascript function called on each path point
  30176. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  30177. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  30178. * @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
  30179. * @param scene defines the hosting scene
  30180. * @param updatable defines if the mesh must be flagged as updatable
  30181. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30182. * @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)
  30183. * @returns a new Mesh
  30184. */
  30185. 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;
  30186. /**
  30187. * Creates lathe mesh.
  30188. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  30189. * Please consider using the same method from the MeshBuilder class instead
  30190. * @param name defines the name of the mesh to create
  30191. * @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
  30192. * @param radius is the radius value of the lathe
  30193. * @param tessellation is the side number of the lathe.
  30194. * @param scene defines the hosting scene
  30195. * @param updatable defines if the mesh must be flagged as updatable
  30196. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30197. * @returns a new Mesh
  30198. */
  30199. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30200. /**
  30201. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  30202. * @param name defines the name of the mesh to create
  30203. * @param size sets the size (float) of both sides of the plane at once (default 1)
  30204. * @param scene defines the hosting scene
  30205. * @param updatable defines if the mesh must be flagged as updatable
  30206. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30207. * @returns a new Mesh
  30208. */
  30209. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30210. /**
  30211. * Creates a ground mesh.
  30212. * Please consider using the same method from the MeshBuilder class instead
  30213. * @param name defines the name of the mesh to create
  30214. * @param width set the width of the ground
  30215. * @param height set the height of the ground
  30216. * @param subdivisions sets the number of subdivisions per side
  30217. * @param scene defines the hosting scene
  30218. * @param updatable defines if the mesh must be flagged as updatable
  30219. * @returns a new Mesh
  30220. */
  30221. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  30222. /**
  30223. * Creates a tiled ground mesh.
  30224. * Please consider using the same method from the MeshBuilder class instead
  30225. * @param name defines the name of the mesh to create
  30226. * @param xmin set the ground minimum X coordinate
  30227. * @param zmin set the ground minimum Y coordinate
  30228. * @param xmax set the ground maximum X coordinate
  30229. * @param zmax set the ground maximum Z coordinate
  30230. * @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
  30231. * @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
  30232. * @param scene defines the hosting scene
  30233. * @param updatable defines if the mesh must be flagged as updatable
  30234. * @returns a new Mesh
  30235. */
  30236. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  30237. w: number;
  30238. h: number;
  30239. }, precision: {
  30240. w: number;
  30241. h: number;
  30242. }, scene: Scene, updatable?: boolean): Mesh;
  30243. /**
  30244. * Creates a ground mesh from a height map.
  30245. * Please consider using the same method from the MeshBuilder class instead
  30246. * @see https://doc.babylonjs.com/babylon101/height_map
  30247. * @param name defines the name of the mesh to create
  30248. * @param url sets the URL of the height map image resource
  30249. * @param width set the ground width size
  30250. * @param height set the ground height size
  30251. * @param subdivisions sets the number of subdivision per side
  30252. * @param minHeight is the minimum altitude on the ground
  30253. * @param maxHeight is the maximum altitude on the ground
  30254. * @param scene defines the hosting scene
  30255. * @param updatable defines if the mesh must be flagged as updatable
  30256. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30257. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30258. * @returns a new Mesh
  30259. */
  30260. 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;
  30261. /**
  30262. * Creates a tube mesh.
  30263. * The tube is a parametric shape.
  30264. * It has no predefined shape. Its final shape will depend on the input parameters.
  30265. * Please consider using the same method from the MeshBuilder class instead
  30266. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30267. * @param name defines the name of the mesh to create
  30268. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30269. * @param radius sets the tube radius size
  30270. * @param tessellation is the number of sides on the tubular surface
  30271. * @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
  30272. * @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
  30273. * @param scene defines the hosting scene
  30274. * @param updatable defines if the mesh must be flagged as updatable
  30275. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30276. * @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)
  30277. * @returns a new Mesh
  30278. */
  30279. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30280. (i: number, distance: number): number;
  30281. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30282. /**
  30283. * Creates a polyhedron mesh.
  30284. * Please consider using the same method from the MeshBuilder class instead.
  30285. * * 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
  30286. * * The parameter `size` (positive float, default 1) sets the polygon size
  30287. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30288. * * 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`
  30289. * * 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
  30290. * * 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)`)
  30291. * * 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
  30292. * * 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
  30293. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30296. * @param name defines the name of the mesh to create
  30297. * @param options defines the options used to create the mesh
  30298. * @param scene defines the hosting scene
  30299. * @returns a new Mesh
  30300. */
  30301. static CreatePolyhedron(name: string, options: {
  30302. type?: number;
  30303. size?: number;
  30304. sizeX?: number;
  30305. sizeY?: number;
  30306. sizeZ?: number;
  30307. custom?: any;
  30308. faceUV?: Vector4[];
  30309. faceColors?: Color4[];
  30310. updatable?: boolean;
  30311. sideOrientation?: number;
  30312. }, scene: Scene): Mesh;
  30313. /**
  30314. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30315. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30316. * * 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`)
  30317. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30318. * * 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
  30319. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30322. * @param name defines the name of the mesh
  30323. * @param options defines the options used to create the mesh
  30324. * @param scene defines the hosting scene
  30325. * @returns a new Mesh
  30326. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30327. */
  30328. static CreateIcoSphere(name: string, options: {
  30329. radius?: number;
  30330. flat?: boolean;
  30331. subdivisions?: number;
  30332. sideOrientation?: number;
  30333. updatable?: boolean;
  30334. }, scene: Scene): Mesh;
  30335. /**
  30336. * Creates a decal mesh.
  30337. * Please consider using the same method from the MeshBuilder class instead.
  30338. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30339. * @param name defines the name of the mesh
  30340. * @param sourceMesh defines the mesh receiving the decal
  30341. * @param position sets the position of the decal in world coordinates
  30342. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30343. * @param size sets the decal scaling
  30344. * @param angle sets the angle to rotate the decal
  30345. * @returns a new Mesh
  30346. */
  30347. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30348. /** Creates a Capsule Mesh
  30349. * @param name defines the name of the mesh.
  30350. * @param options the constructors options used to shape the mesh.
  30351. * @param scene defines the scene the mesh is scoped to.
  30352. * @returns the capsule mesh
  30353. * @see https://doc.babylonjs.com/how_to/capsule_shape
  30354. */
  30355. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  30356. /**
  30357. * Prepare internal position array for software CPU skinning
  30358. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30359. */
  30360. setPositionsForCPUSkinning(): Float32Array;
  30361. /**
  30362. * Prepare internal normal array for software CPU skinning
  30363. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30364. */
  30365. setNormalsForCPUSkinning(): Float32Array;
  30366. /**
  30367. * Updates the vertex buffer by applying transformation from the bones
  30368. * @param skeleton defines the skeleton to apply to current mesh
  30369. * @returns the current mesh
  30370. */
  30371. applySkeleton(skeleton: Skeleton): Mesh;
  30372. /**
  30373. * 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
  30374. * @param meshes defines the list of meshes to scan
  30375. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30376. */
  30377. static MinMax(meshes: AbstractMesh[]): {
  30378. min: Vector3;
  30379. max: Vector3;
  30380. };
  30381. /**
  30382. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30383. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30384. * @returns a vector3
  30385. */
  30386. static Center(meshesOrMinMaxVector: {
  30387. min: Vector3;
  30388. max: Vector3;
  30389. } | AbstractMesh[]): Vector3;
  30390. /**
  30391. * Merge the array of meshes into a single mesh for performance reasons.
  30392. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30393. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30394. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30395. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30396. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30397. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30398. * @returns a new mesh
  30399. */
  30400. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30401. /** @hidden */
  30402. addInstance(instance: InstancedMesh): void;
  30403. /** @hidden */
  30404. removeInstance(instance: InstancedMesh): void;
  30405. }
  30406. }
  30407. declare module "babylonjs/Cameras/camera" {
  30408. import { SmartArray } from "babylonjs/Misc/smartArray";
  30409. import { Observable } from "babylonjs/Misc/observable";
  30410. import { Nullable } from "babylonjs/types";
  30411. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30412. import { Scene } from "babylonjs/scene";
  30413. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30414. import { Node } from "babylonjs/node";
  30415. import { Mesh } from "babylonjs/Meshes/mesh";
  30416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30417. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30418. import { Viewport } from "babylonjs/Maths/math.viewport";
  30419. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30420. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30421. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30422. import { Ray } from "babylonjs/Culling/ray";
  30423. /**
  30424. * This is the base class of all the camera used in the application.
  30425. * @see https://doc.babylonjs.com/features/cameras
  30426. */
  30427. export class Camera extends Node {
  30428. /** @hidden */
  30429. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30430. /**
  30431. * This is the default projection mode used by the cameras.
  30432. * It helps recreating a feeling of perspective and better appreciate depth.
  30433. * This is the best way to simulate real life cameras.
  30434. */
  30435. static readonly PERSPECTIVE_CAMERA: number;
  30436. /**
  30437. * This helps creating camera with an orthographic mode.
  30438. * 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.
  30439. */
  30440. static readonly ORTHOGRAPHIC_CAMERA: number;
  30441. /**
  30442. * This is the default FOV mode for perspective cameras.
  30443. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30444. */
  30445. static readonly FOVMODE_VERTICAL_FIXED: number;
  30446. /**
  30447. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30448. */
  30449. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30450. /**
  30451. * This specifies ther is no need for a camera rig.
  30452. * Basically only one eye is rendered corresponding to the camera.
  30453. */
  30454. static readonly RIG_MODE_NONE: number;
  30455. /**
  30456. * Simulates a camera Rig with one blue eye and one red eye.
  30457. * This can be use with 3d blue and red glasses.
  30458. */
  30459. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30460. /**
  30461. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30462. */
  30463. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30464. /**
  30465. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30466. */
  30467. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30468. /**
  30469. * Defines that both eyes of the camera will be rendered over under each other.
  30470. */
  30471. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30472. /**
  30473. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30474. */
  30475. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30476. /**
  30477. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30478. */
  30479. static readonly RIG_MODE_VR: number;
  30480. /**
  30481. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30482. */
  30483. static readonly RIG_MODE_WEBVR: number;
  30484. /**
  30485. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30486. */
  30487. static readonly RIG_MODE_CUSTOM: number;
  30488. /**
  30489. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30490. */
  30491. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30492. /**
  30493. * Define the input manager associated with the camera.
  30494. */
  30495. inputs: CameraInputsManager<Camera>;
  30496. /** @hidden */
  30497. _position: Vector3;
  30498. /**
  30499. * Define the current local position of the camera in the scene
  30500. */
  30501. get position(): Vector3;
  30502. set position(newPosition: Vector3);
  30503. protected _upVector: Vector3;
  30504. /**
  30505. * The vector the camera should consider as up.
  30506. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30507. */
  30508. set upVector(vec: Vector3);
  30509. get upVector(): Vector3;
  30510. /**
  30511. * Define the current limit on the left side for an orthographic camera
  30512. * In scene unit
  30513. */
  30514. orthoLeft: Nullable<number>;
  30515. /**
  30516. * Define the current limit on the right side for an orthographic camera
  30517. * In scene unit
  30518. */
  30519. orthoRight: Nullable<number>;
  30520. /**
  30521. * Define the current limit on the bottom side for an orthographic camera
  30522. * In scene unit
  30523. */
  30524. orthoBottom: Nullable<number>;
  30525. /**
  30526. * Define the current limit on the top side for an orthographic camera
  30527. * In scene unit
  30528. */
  30529. orthoTop: Nullable<number>;
  30530. /**
  30531. * Field Of View is set in Radians. (default is 0.8)
  30532. */
  30533. fov: number;
  30534. /**
  30535. * Define the minimum distance the camera can see from.
  30536. * This is important to note that the depth buffer are not infinite and the closer it starts
  30537. * the more your scene might encounter depth fighting issue.
  30538. */
  30539. minZ: number;
  30540. /**
  30541. * Define the maximum distance the camera can see to.
  30542. * This is important to note that the depth buffer are not infinite and the further it end
  30543. * the more your scene might encounter depth fighting issue.
  30544. */
  30545. maxZ: number;
  30546. /**
  30547. * Define the default inertia of the camera.
  30548. * This helps giving a smooth feeling to the camera movement.
  30549. */
  30550. inertia: number;
  30551. /**
  30552. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30553. */
  30554. mode: number;
  30555. /**
  30556. * Define whether the camera is intermediate.
  30557. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30558. */
  30559. isIntermediate: boolean;
  30560. /**
  30561. * Define the viewport of the camera.
  30562. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30563. */
  30564. viewport: Viewport;
  30565. /**
  30566. * Restricts the camera to viewing objects with the same layerMask.
  30567. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30568. */
  30569. layerMask: number;
  30570. /**
  30571. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30572. */
  30573. fovMode: number;
  30574. /**
  30575. * Rig mode of the camera.
  30576. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30577. * This is normally controlled byt the camera themselves as internal use.
  30578. */
  30579. cameraRigMode: number;
  30580. /**
  30581. * Defines the distance between both "eyes" in case of a RIG
  30582. */
  30583. interaxialDistance: number;
  30584. /**
  30585. * Defines if stereoscopic rendering is done side by side or over under.
  30586. */
  30587. isStereoscopicSideBySide: boolean;
  30588. /**
  30589. * 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
  30590. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30591. * else in the scene. (Eg. security camera)
  30592. *
  30593. * 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)
  30594. */
  30595. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30596. /**
  30597. * When set, the camera will render to this render target instead of the default canvas
  30598. *
  30599. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30600. */
  30601. outputRenderTarget: Nullable<RenderTargetTexture>;
  30602. /**
  30603. * Observable triggered when the camera view matrix has changed.
  30604. */
  30605. onViewMatrixChangedObservable: Observable<Camera>;
  30606. /**
  30607. * Observable triggered when the camera Projection matrix has changed.
  30608. */
  30609. onProjectionMatrixChangedObservable: Observable<Camera>;
  30610. /**
  30611. * Observable triggered when the inputs have been processed.
  30612. */
  30613. onAfterCheckInputsObservable: Observable<Camera>;
  30614. /**
  30615. * Observable triggered when reset has been called and applied to the camera.
  30616. */
  30617. onRestoreStateObservable: Observable<Camera>;
  30618. /**
  30619. * Is this camera a part of a rig system?
  30620. */
  30621. isRigCamera: boolean;
  30622. /**
  30623. * If isRigCamera set to true this will be set with the parent camera.
  30624. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30625. */
  30626. rigParent?: Camera;
  30627. /** @hidden */
  30628. _cameraRigParams: any;
  30629. /** @hidden */
  30630. _rigCameras: Camera[];
  30631. /** @hidden */
  30632. _rigPostProcess: Nullable<PostProcess>;
  30633. protected _webvrViewMatrix: Matrix;
  30634. /** @hidden */
  30635. _skipRendering: boolean;
  30636. /** @hidden */
  30637. _projectionMatrix: Matrix;
  30638. /** @hidden */
  30639. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30640. /** @hidden */
  30641. _activeMeshes: SmartArray<AbstractMesh>;
  30642. protected _globalPosition: Vector3;
  30643. /** @hidden */
  30644. _computedViewMatrix: Matrix;
  30645. private _doNotComputeProjectionMatrix;
  30646. private _transformMatrix;
  30647. private _frustumPlanes;
  30648. private _refreshFrustumPlanes;
  30649. private _storedFov;
  30650. private _stateStored;
  30651. /**
  30652. * Instantiates a new camera object.
  30653. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30654. * @see https://doc.babylonjs.com/features/cameras
  30655. * @param name Defines the name of the camera in the scene
  30656. * @param position Defines the position of the camera
  30657. * @param scene Defines the scene the camera belongs too
  30658. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30659. */
  30660. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30661. /**
  30662. * Store current camera state (fov, position, etc..)
  30663. * @returns the camera
  30664. */
  30665. storeState(): Camera;
  30666. /**
  30667. * Restores the camera state values if it has been stored. You must call storeState() first
  30668. */
  30669. protected _restoreStateValues(): boolean;
  30670. /**
  30671. * Restored camera state. You must call storeState() first.
  30672. * @returns true if restored and false otherwise
  30673. */
  30674. restoreState(): boolean;
  30675. /**
  30676. * Gets the class name of the camera.
  30677. * @returns the class name
  30678. */
  30679. getClassName(): string;
  30680. /** @hidden */
  30681. readonly _isCamera: boolean;
  30682. /**
  30683. * Gets a string representation of the camera useful for debug purpose.
  30684. * @param fullDetails Defines that a more verboe level of logging is required
  30685. * @returns the string representation
  30686. */
  30687. toString(fullDetails?: boolean): string;
  30688. /**
  30689. * Gets the current world space position of the camera.
  30690. */
  30691. get globalPosition(): Vector3;
  30692. /**
  30693. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30694. * @returns the active meshe list
  30695. */
  30696. getActiveMeshes(): SmartArray<AbstractMesh>;
  30697. /**
  30698. * Check whether a mesh is part of the current active mesh list of the camera
  30699. * @param mesh Defines the mesh to check
  30700. * @returns true if active, false otherwise
  30701. */
  30702. isActiveMesh(mesh: Mesh): boolean;
  30703. /**
  30704. * Is this camera ready to be used/rendered
  30705. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30706. * @return true if the camera is ready
  30707. */
  30708. isReady(completeCheck?: boolean): boolean;
  30709. /** @hidden */
  30710. _initCache(): void;
  30711. /** @hidden */
  30712. _updateCache(ignoreParentClass?: boolean): void;
  30713. /** @hidden */
  30714. _isSynchronized(): boolean;
  30715. /** @hidden */
  30716. _isSynchronizedViewMatrix(): boolean;
  30717. /** @hidden */
  30718. _isSynchronizedProjectionMatrix(): boolean;
  30719. /**
  30720. * Attach the input controls to a specific dom element to get the input from.
  30721. * @param element Defines the element the controls should be listened from
  30722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30723. */
  30724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30725. /**
  30726. * Detach the current controls from the specified dom element.
  30727. * @param element Defines the element to stop listening the inputs from
  30728. */
  30729. detachControl(element: HTMLElement): void;
  30730. /**
  30731. * Update the camera state according to the different inputs gathered during the frame.
  30732. */
  30733. update(): void;
  30734. /** @hidden */
  30735. _checkInputs(): void;
  30736. /** @hidden */
  30737. get rigCameras(): Camera[];
  30738. /**
  30739. * Gets the post process used by the rig cameras
  30740. */
  30741. get rigPostProcess(): Nullable<PostProcess>;
  30742. /**
  30743. * Internal, gets the first post proces.
  30744. * @returns the first post process to be run on this camera.
  30745. */
  30746. _getFirstPostProcess(): Nullable<PostProcess>;
  30747. private _cascadePostProcessesToRigCams;
  30748. /**
  30749. * Attach a post process to the camera.
  30750. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30751. * @param postProcess The post process to attach to the camera
  30752. * @param insertAt The position of the post process in case several of them are in use in the scene
  30753. * @returns the position the post process has been inserted at
  30754. */
  30755. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30756. /**
  30757. * Detach a post process to the camera.
  30758. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30759. * @param postProcess The post process to detach from the camera
  30760. */
  30761. detachPostProcess(postProcess: PostProcess): void;
  30762. /**
  30763. * Gets the current world matrix of the camera
  30764. */
  30765. getWorldMatrix(): Matrix;
  30766. /** @hidden */
  30767. _getViewMatrix(): Matrix;
  30768. /**
  30769. * Gets the current view matrix of the camera.
  30770. * @param force forces the camera to recompute the matrix without looking at the cached state
  30771. * @returns the view matrix
  30772. */
  30773. getViewMatrix(force?: boolean): Matrix;
  30774. /**
  30775. * Freeze the projection matrix.
  30776. * It will prevent the cache check of the camera projection compute and can speed up perf
  30777. * if no parameter of the camera are meant to change
  30778. * @param projection Defines manually a projection if necessary
  30779. */
  30780. freezeProjectionMatrix(projection?: Matrix): void;
  30781. /**
  30782. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30783. */
  30784. unfreezeProjectionMatrix(): void;
  30785. /**
  30786. * Gets the current projection matrix of the camera.
  30787. * @param force forces the camera to recompute the matrix without looking at the cached state
  30788. * @returns the projection matrix
  30789. */
  30790. getProjectionMatrix(force?: boolean): Matrix;
  30791. /**
  30792. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30793. * @returns a Matrix
  30794. */
  30795. getTransformationMatrix(): Matrix;
  30796. private _updateFrustumPlanes;
  30797. /**
  30798. * Checks if a cullable object (mesh...) is in the camera frustum
  30799. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30800. * @param target The object to check
  30801. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30802. * @returns true if the object is in frustum otherwise false
  30803. */
  30804. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30805. /**
  30806. * Checks if a cullable object (mesh...) is in the camera frustum
  30807. * Unlike isInFrustum this cheks the full bounding box
  30808. * @param target The object to check
  30809. * @returns true if the object is in frustum otherwise false
  30810. */
  30811. isCompletelyInFrustum(target: ICullable): boolean;
  30812. /**
  30813. * Gets a ray in the forward direction from the camera.
  30814. * @param length Defines the length of the ray to create
  30815. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30816. * @param origin Defines the start point of the ray which defaults to the camera position
  30817. * @returns the forward ray
  30818. */
  30819. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30820. /**
  30821. * Gets a ray in the forward direction from the camera.
  30822. * @param refRay the ray to (re)use when setting the values
  30823. * @param length Defines the length of the ray to create
  30824. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30825. * @param origin Defines the start point of the ray which defaults to the camera position
  30826. * @returns the forward ray
  30827. */
  30828. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30829. /**
  30830. * Releases resources associated with this node.
  30831. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30832. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30833. */
  30834. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30835. /** @hidden */
  30836. _isLeftCamera: boolean;
  30837. /**
  30838. * Gets the left camera of a rig setup in case of Rigged Camera
  30839. */
  30840. get isLeftCamera(): boolean;
  30841. /** @hidden */
  30842. _isRightCamera: boolean;
  30843. /**
  30844. * Gets the right camera of a rig setup in case of Rigged Camera
  30845. */
  30846. get isRightCamera(): boolean;
  30847. /**
  30848. * Gets the left camera of a rig setup in case of Rigged Camera
  30849. */
  30850. get leftCamera(): Nullable<FreeCamera>;
  30851. /**
  30852. * Gets the right camera of a rig setup in case of Rigged Camera
  30853. */
  30854. get rightCamera(): Nullable<FreeCamera>;
  30855. /**
  30856. * Gets the left camera target of a rig setup in case of Rigged Camera
  30857. * @returns the target position
  30858. */
  30859. getLeftTarget(): Nullable<Vector3>;
  30860. /**
  30861. * Gets the right camera target of a rig setup in case of Rigged Camera
  30862. * @returns the target position
  30863. */
  30864. getRightTarget(): Nullable<Vector3>;
  30865. /**
  30866. * @hidden
  30867. */
  30868. setCameraRigMode(mode: number, rigParams: any): void;
  30869. /** @hidden */
  30870. static _setStereoscopicRigMode(camera: Camera): void;
  30871. /** @hidden */
  30872. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30873. /** @hidden */
  30874. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30875. /** @hidden */
  30876. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30877. /** @hidden */
  30878. _getVRProjectionMatrix(): Matrix;
  30879. protected _updateCameraRotationMatrix(): void;
  30880. protected _updateWebVRCameraRotationMatrix(): void;
  30881. /**
  30882. * This function MUST be overwritten by the different WebVR cameras available.
  30883. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30884. * @hidden
  30885. */
  30886. _getWebVRProjectionMatrix(): Matrix;
  30887. /**
  30888. * This function MUST be overwritten by the different WebVR cameras available.
  30889. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30890. * @hidden
  30891. */
  30892. _getWebVRViewMatrix(): Matrix;
  30893. /** @hidden */
  30894. setCameraRigParameter(name: string, value: any): void;
  30895. /**
  30896. * needs to be overridden by children so sub has required properties to be copied
  30897. * @hidden
  30898. */
  30899. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30900. /**
  30901. * May need to be overridden by children
  30902. * @hidden
  30903. */
  30904. _updateRigCameras(): void;
  30905. /** @hidden */
  30906. _setupInputs(): void;
  30907. /**
  30908. * Serialiaze the camera setup to a json represention
  30909. * @returns the JSON representation
  30910. */
  30911. serialize(): any;
  30912. /**
  30913. * Clones the current camera.
  30914. * @param name The cloned camera name
  30915. * @returns the cloned camera
  30916. */
  30917. clone(name: string): Camera;
  30918. /**
  30919. * Gets the direction of the camera relative to a given local axis.
  30920. * @param localAxis Defines the reference axis to provide a relative direction.
  30921. * @return the direction
  30922. */
  30923. getDirection(localAxis: Vector3): Vector3;
  30924. /**
  30925. * Returns the current camera absolute rotation
  30926. */
  30927. get absoluteRotation(): Quaternion;
  30928. /**
  30929. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30930. * @param localAxis Defines the reference axis to provide a relative direction.
  30931. * @param result Defines the vector to store the result in
  30932. */
  30933. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30934. /**
  30935. * Gets a camera constructor for a given camera type
  30936. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30937. * @param name The name of the camera the result will be able to instantiate
  30938. * @param scene The scene the result will construct the camera in
  30939. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30940. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30941. * @returns a factory method to construc the camera
  30942. */
  30943. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30944. /**
  30945. * Compute the world matrix of the camera.
  30946. * @returns the camera world matrix
  30947. */
  30948. computeWorldMatrix(): Matrix;
  30949. /**
  30950. * Parse a JSON and creates the camera from the parsed information
  30951. * @param parsedCamera The JSON to parse
  30952. * @param scene The scene to instantiate the camera in
  30953. * @returns the newly constructed camera
  30954. */
  30955. static Parse(parsedCamera: any, scene: Scene): Camera;
  30956. }
  30957. }
  30958. declare module "babylonjs/Meshes/Builders/discBuilder" {
  30959. import { Nullable } from "babylonjs/types";
  30960. import { Scene } from "babylonjs/scene";
  30961. import { Vector4 } from "babylonjs/Maths/math.vector";
  30962. import { Mesh } from "babylonjs/Meshes/mesh";
  30963. /**
  30964. * Class containing static functions to help procedurally build meshes
  30965. */
  30966. export class DiscBuilder {
  30967. /**
  30968. * Creates a plane polygonal mesh. By default, this is a disc
  30969. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30970. * * 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
  30971. * * 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
  30972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30975. * @param name defines the name of the mesh
  30976. * @param options defines the options used to create the mesh
  30977. * @param scene defines the hosting scene
  30978. * @returns the plane polygonal mesh
  30979. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30980. */
  30981. static CreateDisc(name: string, options: {
  30982. radius?: number;
  30983. tessellation?: number;
  30984. arc?: number;
  30985. updatable?: boolean;
  30986. sideOrientation?: number;
  30987. frontUVs?: Vector4;
  30988. backUVs?: Vector4;
  30989. }, scene?: Nullable<Scene>): Mesh;
  30990. }
  30991. }
  30992. declare module "babylonjs/Materials/fresnelParameters" {
  30993. import { DeepImmutable } from "babylonjs/types";
  30994. import { Color3 } from "babylonjs/Maths/math.color";
  30995. /**
  30996. * Options to be used when creating a FresnelParameters.
  30997. */
  30998. export type IFresnelParametersCreationOptions = {
  30999. /**
  31000. * Define the color used on edges (grazing angle)
  31001. */
  31002. leftColor?: Color3;
  31003. /**
  31004. * Define the color used on center
  31005. */
  31006. rightColor?: Color3;
  31007. /**
  31008. * Define bias applied to computed fresnel term
  31009. */
  31010. bias?: number;
  31011. /**
  31012. * Defined the power exponent applied to fresnel term
  31013. */
  31014. power?: number;
  31015. /**
  31016. * Define if the fresnel effect is enable or not.
  31017. */
  31018. isEnabled?: boolean;
  31019. };
  31020. /**
  31021. * Serialized format for FresnelParameters.
  31022. */
  31023. export type IFresnelParametersSerialized = {
  31024. /**
  31025. * Define the color used on edges (grazing angle) [as an array]
  31026. */
  31027. leftColor: number[];
  31028. /**
  31029. * Define the color used on center [as an array]
  31030. */
  31031. rightColor: number[];
  31032. /**
  31033. * Define bias applied to computed fresnel term
  31034. */
  31035. bias: number;
  31036. /**
  31037. * Defined the power exponent applied to fresnel term
  31038. */
  31039. power?: number;
  31040. /**
  31041. * Define if the fresnel effect is enable or not.
  31042. */
  31043. isEnabled: boolean;
  31044. };
  31045. /**
  31046. * This represents all the required information to add a fresnel effect on a material:
  31047. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31048. */
  31049. export class FresnelParameters {
  31050. private _isEnabled;
  31051. /**
  31052. * Define if the fresnel effect is enable or not.
  31053. */
  31054. get isEnabled(): boolean;
  31055. set isEnabled(value: boolean);
  31056. /**
  31057. * Define the color used on edges (grazing angle)
  31058. */
  31059. leftColor: Color3;
  31060. /**
  31061. * Define the color used on center
  31062. */
  31063. rightColor: Color3;
  31064. /**
  31065. * Define bias applied to computed fresnel term
  31066. */
  31067. bias: number;
  31068. /**
  31069. * Defined the power exponent applied to fresnel term
  31070. */
  31071. power: number;
  31072. /**
  31073. * Creates a new FresnelParameters object.
  31074. *
  31075. * @param options provide your own settings to optionally to override defaults
  31076. */
  31077. constructor(options?: IFresnelParametersCreationOptions);
  31078. /**
  31079. * Clones the current fresnel and its valuues
  31080. * @returns a clone fresnel configuration
  31081. */
  31082. clone(): FresnelParameters;
  31083. /**
  31084. * Determines equality between FresnelParameters objects
  31085. * @param otherFresnelParameters defines the second operand
  31086. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  31087. */
  31088. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  31089. /**
  31090. * Serializes the current fresnel parameters to a JSON representation.
  31091. * @return the JSON serialization
  31092. */
  31093. serialize(): IFresnelParametersSerialized;
  31094. /**
  31095. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31096. * @param parsedFresnelParameters Define the JSON representation
  31097. * @returns the parsed parameters
  31098. */
  31099. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  31100. }
  31101. }
  31102. declare module "babylonjs/Materials/materialFlags" {
  31103. /**
  31104. * This groups all the flags used to control the materials channel.
  31105. */
  31106. export class MaterialFlags {
  31107. private static _DiffuseTextureEnabled;
  31108. /**
  31109. * Are diffuse textures enabled in the application.
  31110. */
  31111. static get DiffuseTextureEnabled(): boolean;
  31112. static set DiffuseTextureEnabled(value: boolean);
  31113. private static _DetailTextureEnabled;
  31114. /**
  31115. * Are detail textures enabled in the application.
  31116. */
  31117. static get DetailTextureEnabled(): boolean;
  31118. static set DetailTextureEnabled(value: boolean);
  31119. private static _AmbientTextureEnabled;
  31120. /**
  31121. * Are ambient textures enabled in the application.
  31122. */
  31123. static get AmbientTextureEnabled(): boolean;
  31124. static set AmbientTextureEnabled(value: boolean);
  31125. private static _OpacityTextureEnabled;
  31126. /**
  31127. * Are opacity textures enabled in the application.
  31128. */
  31129. static get OpacityTextureEnabled(): boolean;
  31130. static set OpacityTextureEnabled(value: boolean);
  31131. private static _ReflectionTextureEnabled;
  31132. /**
  31133. * Are reflection textures enabled in the application.
  31134. */
  31135. static get ReflectionTextureEnabled(): boolean;
  31136. static set ReflectionTextureEnabled(value: boolean);
  31137. private static _EmissiveTextureEnabled;
  31138. /**
  31139. * Are emissive textures enabled in the application.
  31140. */
  31141. static get EmissiveTextureEnabled(): boolean;
  31142. static set EmissiveTextureEnabled(value: boolean);
  31143. private static _SpecularTextureEnabled;
  31144. /**
  31145. * Are specular textures enabled in the application.
  31146. */
  31147. static get SpecularTextureEnabled(): boolean;
  31148. static set SpecularTextureEnabled(value: boolean);
  31149. private static _BumpTextureEnabled;
  31150. /**
  31151. * Are bump textures enabled in the application.
  31152. */
  31153. static get BumpTextureEnabled(): boolean;
  31154. static set BumpTextureEnabled(value: boolean);
  31155. private static _LightmapTextureEnabled;
  31156. /**
  31157. * Are lightmap textures enabled in the application.
  31158. */
  31159. static get LightmapTextureEnabled(): boolean;
  31160. static set LightmapTextureEnabled(value: boolean);
  31161. private static _RefractionTextureEnabled;
  31162. /**
  31163. * Are refraction textures enabled in the application.
  31164. */
  31165. static get RefractionTextureEnabled(): boolean;
  31166. static set RefractionTextureEnabled(value: boolean);
  31167. private static _ColorGradingTextureEnabled;
  31168. /**
  31169. * Are color grading textures enabled in the application.
  31170. */
  31171. static get ColorGradingTextureEnabled(): boolean;
  31172. static set ColorGradingTextureEnabled(value: boolean);
  31173. private static _FresnelEnabled;
  31174. /**
  31175. * Are fresnels enabled in the application.
  31176. */
  31177. static get FresnelEnabled(): boolean;
  31178. static set FresnelEnabled(value: boolean);
  31179. private static _ClearCoatTextureEnabled;
  31180. /**
  31181. * Are clear coat textures enabled in the application.
  31182. */
  31183. static get ClearCoatTextureEnabled(): boolean;
  31184. static set ClearCoatTextureEnabled(value: boolean);
  31185. private static _ClearCoatBumpTextureEnabled;
  31186. /**
  31187. * Are clear coat bump textures enabled in the application.
  31188. */
  31189. static get ClearCoatBumpTextureEnabled(): boolean;
  31190. static set ClearCoatBumpTextureEnabled(value: boolean);
  31191. private static _ClearCoatTintTextureEnabled;
  31192. /**
  31193. * Are clear coat tint textures enabled in the application.
  31194. */
  31195. static get ClearCoatTintTextureEnabled(): boolean;
  31196. static set ClearCoatTintTextureEnabled(value: boolean);
  31197. private static _SheenTextureEnabled;
  31198. /**
  31199. * Are sheen textures enabled in the application.
  31200. */
  31201. static get SheenTextureEnabled(): boolean;
  31202. static set SheenTextureEnabled(value: boolean);
  31203. private static _AnisotropicTextureEnabled;
  31204. /**
  31205. * Are anisotropic textures enabled in the application.
  31206. */
  31207. static get AnisotropicTextureEnabled(): boolean;
  31208. static set AnisotropicTextureEnabled(value: boolean);
  31209. private static _ThicknessTextureEnabled;
  31210. /**
  31211. * Are thickness textures enabled in the application.
  31212. */
  31213. static get ThicknessTextureEnabled(): boolean;
  31214. static set ThicknessTextureEnabled(value: boolean);
  31215. }
  31216. }
  31217. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  31218. /** @hidden */
  31219. export var defaultFragmentDeclaration: {
  31220. name: string;
  31221. shader: string;
  31222. };
  31223. }
  31224. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  31225. /** @hidden */
  31226. export var defaultUboDeclaration: {
  31227. name: string;
  31228. shader: string;
  31229. };
  31230. }
  31231. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  31232. /** @hidden */
  31233. export var prePassDeclaration: {
  31234. name: string;
  31235. shader: string;
  31236. };
  31237. }
  31238. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  31239. /** @hidden */
  31240. export var lightFragmentDeclaration: {
  31241. name: string;
  31242. shader: string;
  31243. };
  31244. }
  31245. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  31246. /** @hidden */
  31247. export var lightUboDeclaration: {
  31248. name: string;
  31249. shader: string;
  31250. };
  31251. }
  31252. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31253. /** @hidden */
  31254. export var lightsFragmentFunctions: {
  31255. name: string;
  31256. shader: string;
  31257. };
  31258. }
  31259. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31260. /** @hidden */
  31261. export var shadowsFragmentFunctions: {
  31262. name: string;
  31263. shader: string;
  31264. };
  31265. }
  31266. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31267. /** @hidden */
  31268. export var fresnelFunction: {
  31269. name: string;
  31270. shader: string;
  31271. };
  31272. }
  31273. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31274. /** @hidden */
  31275. export var bumpFragmentMainFunctions: {
  31276. name: string;
  31277. shader: string;
  31278. };
  31279. }
  31280. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31281. /** @hidden */
  31282. export var bumpFragmentFunctions: {
  31283. name: string;
  31284. shader: string;
  31285. };
  31286. }
  31287. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31288. /** @hidden */
  31289. export var logDepthDeclaration: {
  31290. name: string;
  31291. shader: string;
  31292. };
  31293. }
  31294. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31295. /** @hidden */
  31296. export var bumpFragment: {
  31297. name: string;
  31298. shader: string;
  31299. };
  31300. }
  31301. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31302. /** @hidden */
  31303. export var depthPrePass: {
  31304. name: string;
  31305. shader: string;
  31306. };
  31307. }
  31308. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31309. /** @hidden */
  31310. export var lightFragment: {
  31311. name: string;
  31312. shader: string;
  31313. };
  31314. }
  31315. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31316. /** @hidden */
  31317. export var logDepthFragment: {
  31318. name: string;
  31319. shader: string;
  31320. };
  31321. }
  31322. declare module "babylonjs/Shaders/default.fragment" {
  31323. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31324. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31325. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31326. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31327. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31328. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31329. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31330. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31331. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31332. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31333. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31334. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31335. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31336. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31337. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31338. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31339. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31340. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31341. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31342. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31343. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31344. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31345. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31346. /** @hidden */
  31347. export var defaultPixelShader: {
  31348. name: string;
  31349. shader: string;
  31350. };
  31351. }
  31352. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31353. /** @hidden */
  31354. export var defaultVertexDeclaration: {
  31355. name: string;
  31356. shader: string;
  31357. };
  31358. }
  31359. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31360. /** @hidden */
  31361. export var bumpVertexDeclaration: {
  31362. name: string;
  31363. shader: string;
  31364. };
  31365. }
  31366. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31367. /** @hidden */
  31368. export var bumpVertex: {
  31369. name: string;
  31370. shader: string;
  31371. };
  31372. }
  31373. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31374. /** @hidden */
  31375. export var fogVertex: {
  31376. name: string;
  31377. shader: string;
  31378. };
  31379. }
  31380. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31381. /** @hidden */
  31382. export var shadowsVertex: {
  31383. name: string;
  31384. shader: string;
  31385. };
  31386. }
  31387. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31388. /** @hidden */
  31389. export var pointCloudVertex: {
  31390. name: string;
  31391. shader: string;
  31392. };
  31393. }
  31394. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31395. /** @hidden */
  31396. export var logDepthVertex: {
  31397. name: string;
  31398. shader: string;
  31399. };
  31400. }
  31401. declare module "babylonjs/Shaders/default.vertex" {
  31402. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31403. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31404. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31405. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31406. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31407. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31408. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31409. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31410. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31411. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31412. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31413. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31414. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31415. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31416. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31417. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31418. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31419. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31420. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31421. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31422. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31423. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31424. /** @hidden */
  31425. export var defaultVertexShader: {
  31426. name: string;
  31427. shader: string;
  31428. };
  31429. }
  31430. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31431. import { Nullable } from "babylonjs/types";
  31432. import { Scene } from "babylonjs/scene";
  31433. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31434. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31435. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31436. /**
  31437. * @hidden
  31438. */
  31439. export interface IMaterialDetailMapDefines {
  31440. DETAIL: boolean;
  31441. DETAILDIRECTUV: number;
  31442. DETAIL_NORMALBLENDMETHOD: number;
  31443. /** @hidden */
  31444. _areTexturesDirty: boolean;
  31445. }
  31446. /**
  31447. * Define the code related to the detail map parameters of a material
  31448. *
  31449. * Inspired from:
  31450. * 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
  31451. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31452. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31453. */
  31454. export class DetailMapConfiguration {
  31455. private _texture;
  31456. /**
  31457. * The detail texture of the material.
  31458. */
  31459. texture: Nullable<BaseTexture>;
  31460. /**
  31461. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31462. * Bigger values mean stronger blending
  31463. */
  31464. diffuseBlendLevel: number;
  31465. /**
  31466. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31467. * Bigger values mean stronger blending. Only used with PBR materials
  31468. */
  31469. roughnessBlendLevel: number;
  31470. /**
  31471. * Defines how strong the bump effect from the detail map is
  31472. * Bigger values mean stronger effect
  31473. */
  31474. bumpLevel: number;
  31475. private _normalBlendMethod;
  31476. /**
  31477. * The method used to blend the bump and detail normals together
  31478. */
  31479. normalBlendMethod: number;
  31480. private _isEnabled;
  31481. /**
  31482. * Enable or disable the detail map on this material
  31483. */
  31484. isEnabled: boolean;
  31485. /** @hidden */
  31486. private _internalMarkAllSubMeshesAsTexturesDirty;
  31487. /** @hidden */
  31488. _markAllSubMeshesAsTexturesDirty(): void;
  31489. /**
  31490. * Instantiate a new detail map
  31491. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31492. */
  31493. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31494. /**
  31495. * Gets whether the submesh is ready to be used or not.
  31496. * @param defines the list of "defines" to update.
  31497. * @param scene defines the scene the material belongs to.
  31498. * @returns - boolean indicating that the submesh is ready or not.
  31499. */
  31500. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31501. /**
  31502. * Update the defines for detail map usage
  31503. * @param defines the list of "defines" to update.
  31504. * @param scene defines the scene the material belongs to.
  31505. */
  31506. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31507. /**
  31508. * Binds the material data.
  31509. * @param uniformBuffer defines the Uniform buffer to fill in.
  31510. * @param scene defines the scene the material belongs to.
  31511. * @param isFrozen defines whether the material is frozen or not.
  31512. */
  31513. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31514. /**
  31515. * Checks to see if a texture is used in the material.
  31516. * @param texture - Base texture to use.
  31517. * @returns - Boolean specifying if a texture is used in the material.
  31518. */
  31519. hasTexture(texture: BaseTexture): boolean;
  31520. /**
  31521. * Returns an array of the actively used textures.
  31522. * @param activeTextures Array of BaseTextures
  31523. */
  31524. getActiveTextures(activeTextures: BaseTexture[]): void;
  31525. /**
  31526. * Returns the animatable textures.
  31527. * @param animatables Array of animatable textures.
  31528. */
  31529. getAnimatables(animatables: IAnimatable[]): void;
  31530. /**
  31531. * Disposes the resources of the material.
  31532. * @param forceDisposeTextures - Forces the disposal of all textures.
  31533. */
  31534. dispose(forceDisposeTextures?: boolean): void;
  31535. /**
  31536. * Get the current class name useful for serialization or dynamic coding.
  31537. * @returns "DetailMap"
  31538. */
  31539. getClassName(): string;
  31540. /**
  31541. * Add the required uniforms to the current list.
  31542. * @param uniforms defines the current uniform list.
  31543. */
  31544. static AddUniforms(uniforms: string[]): void;
  31545. /**
  31546. * Add the required samplers to the current list.
  31547. * @param samplers defines the current sampler list.
  31548. */
  31549. static AddSamplers(samplers: string[]): void;
  31550. /**
  31551. * Add the required uniforms to the current buffer.
  31552. * @param uniformBuffer defines the current uniform buffer.
  31553. */
  31554. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31555. /**
  31556. * Makes a duplicate of the current instance into another one.
  31557. * @param detailMap define the instance where to copy the info
  31558. */
  31559. copyTo(detailMap: DetailMapConfiguration): void;
  31560. /**
  31561. * Serializes this detail map instance
  31562. * @returns - An object with the serialized instance.
  31563. */
  31564. serialize(): any;
  31565. /**
  31566. * Parses a detail map setting from a serialized object.
  31567. * @param source - Serialized object.
  31568. * @param scene Defines the scene we are parsing for
  31569. * @param rootUrl Defines the rootUrl to load from
  31570. */
  31571. parse(source: any, scene: Scene, rootUrl: string): void;
  31572. }
  31573. }
  31574. declare module "babylonjs/Materials/standardMaterial" {
  31575. import { SmartArray } from "babylonjs/Misc/smartArray";
  31576. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31577. import { Nullable } from "babylonjs/types";
  31578. import { Scene } from "babylonjs/scene";
  31579. import { Matrix } from "babylonjs/Maths/math.vector";
  31580. import { Color3 } from "babylonjs/Maths/math.color";
  31581. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31583. import { Mesh } from "babylonjs/Meshes/mesh";
  31584. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31585. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31586. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31587. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31588. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31589. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31590. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31591. import "babylonjs/Shaders/default.fragment";
  31592. import "babylonjs/Shaders/default.vertex";
  31593. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31594. /** @hidden */
  31595. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31596. MAINUV1: boolean;
  31597. MAINUV2: boolean;
  31598. DIFFUSE: boolean;
  31599. DIFFUSEDIRECTUV: number;
  31600. DETAIL: boolean;
  31601. DETAILDIRECTUV: number;
  31602. DETAIL_NORMALBLENDMETHOD: number;
  31603. AMBIENT: boolean;
  31604. AMBIENTDIRECTUV: number;
  31605. OPACITY: boolean;
  31606. OPACITYDIRECTUV: number;
  31607. OPACITYRGB: boolean;
  31608. REFLECTION: boolean;
  31609. EMISSIVE: boolean;
  31610. EMISSIVEDIRECTUV: number;
  31611. SPECULAR: boolean;
  31612. SPECULARDIRECTUV: number;
  31613. BUMP: boolean;
  31614. BUMPDIRECTUV: number;
  31615. PARALLAX: boolean;
  31616. PARALLAXOCCLUSION: boolean;
  31617. SPECULAROVERALPHA: boolean;
  31618. CLIPPLANE: boolean;
  31619. CLIPPLANE2: boolean;
  31620. CLIPPLANE3: boolean;
  31621. CLIPPLANE4: boolean;
  31622. CLIPPLANE5: boolean;
  31623. CLIPPLANE6: boolean;
  31624. ALPHATEST: boolean;
  31625. DEPTHPREPASS: boolean;
  31626. ALPHAFROMDIFFUSE: boolean;
  31627. POINTSIZE: boolean;
  31628. FOG: boolean;
  31629. SPECULARTERM: boolean;
  31630. DIFFUSEFRESNEL: boolean;
  31631. OPACITYFRESNEL: boolean;
  31632. REFLECTIONFRESNEL: boolean;
  31633. REFRACTIONFRESNEL: boolean;
  31634. EMISSIVEFRESNEL: boolean;
  31635. FRESNEL: boolean;
  31636. NORMAL: boolean;
  31637. UV1: boolean;
  31638. UV2: boolean;
  31639. VERTEXCOLOR: boolean;
  31640. VERTEXALPHA: boolean;
  31641. NUM_BONE_INFLUENCERS: number;
  31642. BonesPerMesh: number;
  31643. BONETEXTURE: boolean;
  31644. INSTANCES: boolean;
  31645. THIN_INSTANCES: boolean;
  31646. GLOSSINESS: boolean;
  31647. ROUGHNESS: boolean;
  31648. EMISSIVEASILLUMINATION: boolean;
  31649. LINKEMISSIVEWITHDIFFUSE: boolean;
  31650. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31651. LIGHTMAP: boolean;
  31652. LIGHTMAPDIRECTUV: number;
  31653. OBJECTSPACE_NORMALMAP: boolean;
  31654. USELIGHTMAPASSHADOWMAP: boolean;
  31655. REFLECTIONMAP_3D: boolean;
  31656. REFLECTIONMAP_SPHERICAL: boolean;
  31657. REFLECTIONMAP_PLANAR: boolean;
  31658. REFLECTIONMAP_CUBIC: boolean;
  31659. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31660. REFLECTIONMAP_PROJECTION: boolean;
  31661. REFLECTIONMAP_SKYBOX: boolean;
  31662. REFLECTIONMAP_EXPLICIT: boolean;
  31663. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31664. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31665. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31666. INVERTCUBICMAP: boolean;
  31667. LOGARITHMICDEPTH: boolean;
  31668. REFRACTION: boolean;
  31669. REFRACTIONMAP_3D: boolean;
  31670. REFLECTIONOVERALPHA: boolean;
  31671. TWOSIDEDLIGHTING: boolean;
  31672. SHADOWFLOAT: boolean;
  31673. MORPHTARGETS: boolean;
  31674. MORPHTARGETS_NORMAL: boolean;
  31675. MORPHTARGETS_TANGENT: boolean;
  31676. MORPHTARGETS_UV: boolean;
  31677. NUM_MORPH_INFLUENCERS: number;
  31678. NONUNIFORMSCALING: boolean;
  31679. PREMULTIPLYALPHA: boolean;
  31680. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31681. ALPHABLEND: boolean;
  31682. PREPASS: boolean;
  31683. PREPASS_IRRADIANCE: boolean;
  31684. PREPASS_IRRADIANCE_INDEX: number;
  31685. PREPASS_ALBEDO: boolean;
  31686. PREPASS_ALBEDO_INDEX: number;
  31687. PREPASS_DEPTHNORMAL: boolean;
  31688. PREPASS_DEPTHNORMAL_INDEX: number;
  31689. SCENE_MRT_COUNT: number;
  31690. RGBDLIGHTMAP: boolean;
  31691. RGBDREFLECTION: boolean;
  31692. RGBDREFRACTION: boolean;
  31693. IMAGEPROCESSING: boolean;
  31694. VIGNETTE: boolean;
  31695. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31696. VIGNETTEBLENDMODEOPAQUE: boolean;
  31697. TONEMAPPING: boolean;
  31698. TONEMAPPING_ACES: boolean;
  31699. CONTRAST: boolean;
  31700. COLORCURVES: boolean;
  31701. COLORGRADING: boolean;
  31702. COLORGRADING3D: boolean;
  31703. SAMPLER3DGREENDEPTH: boolean;
  31704. SAMPLER3DBGRMAP: boolean;
  31705. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31706. MULTIVIEW: boolean;
  31707. /**
  31708. * If the reflection texture on this material is in linear color space
  31709. * @hidden
  31710. */
  31711. IS_REFLECTION_LINEAR: boolean;
  31712. /**
  31713. * If the refraction texture on this material is in linear color space
  31714. * @hidden
  31715. */
  31716. IS_REFRACTION_LINEAR: boolean;
  31717. EXPOSURE: boolean;
  31718. constructor();
  31719. setReflectionMode(modeToEnable: string): void;
  31720. }
  31721. /**
  31722. * This is the default material used in Babylon. It is the best trade off between quality
  31723. * and performances.
  31724. * @see https://doc.babylonjs.com/babylon101/materials
  31725. */
  31726. export class StandardMaterial extends PushMaterial {
  31727. private _diffuseTexture;
  31728. /**
  31729. * The basic texture of the material as viewed under a light.
  31730. */
  31731. diffuseTexture: Nullable<BaseTexture>;
  31732. private _ambientTexture;
  31733. /**
  31734. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31735. */
  31736. ambientTexture: Nullable<BaseTexture>;
  31737. private _opacityTexture;
  31738. /**
  31739. * Define the transparency of the material from a texture.
  31740. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31741. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31742. */
  31743. opacityTexture: Nullable<BaseTexture>;
  31744. private _reflectionTexture;
  31745. /**
  31746. * Define the texture used to display the reflection.
  31747. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31748. */
  31749. reflectionTexture: Nullable<BaseTexture>;
  31750. private _emissiveTexture;
  31751. /**
  31752. * Define texture of the material as if self lit.
  31753. * This will be mixed in the final result even in the absence of light.
  31754. */
  31755. emissiveTexture: Nullable<BaseTexture>;
  31756. private _specularTexture;
  31757. /**
  31758. * Define how the color and intensity of the highlight given by the light in the material.
  31759. */
  31760. specularTexture: Nullable<BaseTexture>;
  31761. private _bumpTexture;
  31762. /**
  31763. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31764. * 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.
  31765. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31766. */
  31767. bumpTexture: Nullable<BaseTexture>;
  31768. private _lightmapTexture;
  31769. /**
  31770. * Complex lighting can be computationally expensive to compute at runtime.
  31771. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31772. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31773. */
  31774. lightmapTexture: Nullable<BaseTexture>;
  31775. private _refractionTexture;
  31776. /**
  31777. * Define the texture used to display the refraction.
  31778. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31779. */
  31780. refractionTexture: Nullable<BaseTexture>;
  31781. /**
  31782. * The color of the material lit by the environmental background lighting.
  31783. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31784. */
  31785. ambientColor: Color3;
  31786. /**
  31787. * The basic color of the material as viewed under a light.
  31788. */
  31789. diffuseColor: Color3;
  31790. /**
  31791. * Define how the color and intensity of the highlight given by the light in the material.
  31792. */
  31793. specularColor: Color3;
  31794. /**
  31795. * Define the color of the material as if self lit.
  31796. * This will be mixed in the final result even in the absence of light.
  31797. */
  31798. emissiveColor: Color3;
  31799. /**
  31800. * Defines how sharp are the highlights in the material.
  31801. * The bigger the value the sharper giving a more glossy feeling to the result.
  31802. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31803. */
  31804. specularPower: number;
  31805. private _useAlphaFromDiffuseTexture;
  31806. /**
  31807. * Does the transparency come from the diffuse texture alpha channel.
  31808. */
  31809. useAlphaFromDiffuseTexture: boolean;
  31810. private _useEmissiveAsIllumination;
  31811. /**
  31812. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31813. */
  31814. useEmissiveAsIllumination: boolean;
  31815. private _linkEmissiveWithDiffuse;
  31816. /**
  31817. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31818. * the emissive level when the final color is close to one.
  31819. */
  31820. linkEmissiveWithDiffuse: boolean;
  31821. private _useSpecularOverAlpha;
  31822. /**
  31823. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31824. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31825. */
  31826. useSpecularOverAlpha: boolean;
  31827. private _useReflectionOverAlpha;
  31828. /**
  31829. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31830. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31831. */
  31832. useReflectionOverAlpha: boolean;
  31833. private _disableLighting;
  31834. /**
  31835. * Does lights from the scene impacts this material.
  31836. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31837. */
  31838. disableLighting: boolean;
  31839. private _useObjectSpaceNormalMap;
  31840. /**
  31841. * Allows using an object space normal map (instead of tangent space).
  31842. */
  31843. useObjectSpaceNormalMap: boolean;
  31844. private _useParallax;
  31845. /**
  31846. * Is parallax enabled or not.
  31847. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31848. */
  31849. useParallax: boolean;
  31850. private _useParallaxOcclusion;
  31851. /**
  31852. * Is parallax occlusion enabled or not.
  31853. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31854. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31855. */
  31856. useParallaxOcclusion: boolean;
  31857. /**
  31858. * 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.
  31859. */
  31860. parallaxScaleBias: number;
  31861. private _roughness;
  31862. /**
  31863. * Helps to define how blurry the reflections should appears in the material.
  31864. */
  31865. roughness: number;
  31866. /**
  31867. * In case of refraction, define the value of the index of refraction.
  31868. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31869. */
  31870. indexOfRefraction: number;
  31871. /**
  31872. * Invert the refraction texture alongside the y axis.
  31873. * It can be useful with procedural textures or probe for instance.
  31874. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31875. */
  31876. invertRefractionY: boolean;
  31877. /**
  31878. * Defines the alpha limits in alpha test mode.
  31879. */
  31880. alphaCutOff: number;
  31881. private _useLightmapAsShadowmap;
  31882. /**
  31883. * In case of light mapping, define whether the map contains light or shadow informations.
  31884. */
  31885. useLightmapAsShadowmap: boolean;
  31886. private _diffuseFresnelParameters;
  31887. /**
  31888. * Define the diffuse fresnel parameters of the material.
  31889. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31890. */
  31891. diffuseFresnelParameters: FresnelParameters;
  31892. private _opacityFresnelParameters;
  31893. /**
  31894. * Define the opacity fresnel parameters of the material.
  31895. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31896. */
  31897. opacityFresnelParameters: FresnelParameters;
  31898. private _reflectionFresnelParameters;
  31899. /**
  31900. * Define the reflection fresnel parameters of the material.
  31901. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31902. */
  31903. reflectionFresnelParameters: FresnelParameters;
  31904. private _refractionFresnelParameters;
  31905. /**
  31906. * Define the refraction fresnel parameters of the material.
  31907. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31908. */
  31909. refractionFresnelParameters: FresnelParameters;
  31910. private _emissiveFresnelParameters;
  31911. /**
  31912. * Define the emissive fresnel parameters of the material.
  31913. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31914. */
  31915. emissiveFresnelParameters: FresnelParameters;
  31916. private _useReflectionFresnelFromSpecular;
  31917. /**
  31918. * If true automatically deducts the fresnels values from the material specularity.
  31919. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31920. */
  31921. useReflectionFresnelFromSpecular: boolean;
  31922. private _useGlossinessFromSpecularMapAlpha;
  31923. /**
  31924. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31925. */
  31926. useGlossinessFromSpecularMapAlpha: boolean;
  31927. private _maxSimultaneousLights;
  31928. /**
  31929. * Defines the maximum number of lights that can be used in the material
  31930. */
  31931. maxSimultaneousLights: number;
  31932. private _invertNormalMapX;
  31933. /**
  31934. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31935. */
  31936. invertNormalMapX: boolean;
  31937. private _invertNormalMapY;
  31938. /**
  31939. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31940. */
  31941. invertNormalMapY: boolean;
  31942. private _twoSidedLighting;
  31943. /**
  31944. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31945. */
  31946. twoSidedLighting: boolean;
  31947. /**
  31948. * Default configuration related to image processing available in the standard Material.
  31949. */
  31950. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31951. /**
  31952. * Gets the image processing configuration used either in this material.
  31953. */
  31954. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  31955. /**
  31956. * Sets the Default image processing configuration used either in the this material.
  31957. *
  31958. * If sets to null, the scene one is in use.
  31959. */
  31960. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  31961. /**
  31962. * Keep track of the image processing observer to allow dispose and replace.
  31963. */
  31964. private _imageProcessingObserver;
  31965. /**
  31966. * Attaches a new image processing configuration to the Standard Material.
  31967. * @param configuration
  31968. */
  31969. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31970. /**
  31971. * Gets wether the color curves effect is enabled.
  31972. */
  31973. get cameraColorCurvesEnabled(): boolean;
  31974. /**
  31975. * Sets wether the color curves effect is enabled.
  31976. */
  31977. set cameraColorCurvesEnabled(value: boolean);
  31978. /**
  31979. * Gets wether the color grading effect is enabled.
  31980. */
  31981. get cameraColorGradingEnabled(): boolean;
  31982. /**
  31983. * Gets wether the color grading effect is enabled.
  31984. */
  31985. set cameraColorGradingEnabled(value: boolean);
  31986. /**
  31987. * Gets wether tonemapping is enabled or not.
  31988. */
  31989. get cameraToneMappingEnabled(): boolean;
  31990. /**
  31991. * Sets wether tonemapping is enabled or not
  31992. */
  31993. set cameraToneMappingEnabled(value: boolean);
  31994. /**
  31995. * The camera exposure used on this material.
  31996. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31997. * This corresponds to a photographic exposure.
  31998. */
  31999. get cameraExposure(): number;
  32000. /**
  32001. * The camera exposure used on this material.
  32002. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32003. * This corresponds to a photographic exposure.
  32004. */
  32005. set cameraExposure(value: number);
  32006. /**
  32007. * Gets The camera contrast used on this material.
  32008. */
  32009. get cameraContrast(): number;
  32010. /**
  32011. * Sets The camera contrast used on this material.
  32012. */
  32013. set cameraContrast(value: number);
  32014. /**
  32015. * Gets the Color Grading 2D Lookup Texture.
  32016. */
  32017. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  32018. /**
  32019. * Sets the Color Grading 2D Lookup Texture.
  32020. */
  32021. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  32022. /**
  32023. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32024. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32025. * 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;
  32026. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32027. */
  32028. get cameraColorCurves(): Nullable<ColorCurves>;
  32029. /**
  32030. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32031. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32032. * 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;
  32033. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32034. */
  32035. set cameraColorCurves(value: Nullable<ColorCurves>);
  32036. /**
  32037. * Can this material render to several textures at once
  32038. */
  32039. get canRenderToMRT(): boolean;
  32040. /**
  32041. * Defines the detail map parameters for the material.
  32042. */
  32043. readonly detailMap: DetailMapConfiguration;
  32044. protected _renderTargets: SmartArray<RenderTargetTexture>;
  32045. protected _worldViewProjectionMatrix: Matrix;
  32046. protected _globalAmbientColor: Color3;
  32047. protected _useLogarithmicDepth: boolean;
  32048. protected _rebuildInParallel: boolean;
  32049. /**
  32050. * Instantiates a new standard material.
  32051. * This is the default material used in Babylon. It is the best trade off between quality
  32052. * and performances.
  32053. * @see https://doc.babylonjs.com/babylon101/materials
  32054. * @param name Define the name of the material in the scene
  32055. * @param scene Define the scene the material belong to
  32056. */
  32057. constructor(name: string, scene: Scene);
  32058. /**
  32059. * Gets a boolean indicating that current material needs to register RTT
  32060. */
  32061. get hasRenderTargetTextures(): boolean;
  32062. /**
  32063. * Gets the current class name of the material e.g. "StandardMaterial"
  32064. * Mainly use in serialization.
  32065. * @returns the class name
  32066. */
  32067. getClassName(): string;
  32068. /**
  32069. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  32070. * You can try switching to logarithmic depth.
  32071. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  32072. */
  32073. get useLogarithmicDepth(): boolean;
  32074. set useLogarithmicDepth(value: boolean);
  32075. /**
  32076. * Specifies if the material will require alpha blending
  32077. * @returns a boolean specifying if alpha blending is needed
  32078. */
  32079. needAlphaBlending(): boolean;
  32080. /**
  32081. * Specifies if this material should be rendered in alpha test mode
  32082. * @returns a boolean specifying if an alpha test is needed.
  32083. */
  32084. needAlphaTesting(): boolean;
  32085. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  32086. /**
  32087. * Get the texture used for alpha test purpose.
  32088. * @returns the diffuse texture in case of the standard material.
  32089. */
  32090. getAlphaTestTexture(): Nullable<BaseTexture>;
  32091. /**
  32092. * Get if the submesh is ready to be used and all its information available.
  32093. * Child classes can use it to update shaders
  32094. * @param mesh defines the mesh to check
  32095. * @param subMesh defines which submesh to check
  32096. * @param useInstances specifies that instances should be used
  32097. * @returns a boolean indicating that the submesh is ready or not
  32098. */
  32099. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32100. /**
  32101. * Builds the material UBO layouts.
  32102. * Used internally during the effect preparation.
  32103. */
  32104. buildUniformLayout(): void;
  32105. /**
  32106. * Unbinds the material from the mesh
  32107. */
  32108. unbind(): void;
  32109. /**
  32110. * Binds the submesh to this material by preparing the effect and shader to draw
  32111. * @param world defines the world transformation matrix
  32112. * @param mesh defines the mesh containing the submesh
  32113. * @param subMesh defines the submesh to bind the material to
  32114. */
  32115. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32116. /**
  32117. * Get the list of animatables in the material.
  32118. * @returns the list of animatables object used in the material
  32119. */
  32120. getAnimatables(): IAnimatable[];
  32121. /**
  32122. * Gets the active textures from the material
  32123. * @returns an array of textures
  32124. */
  32125. getActiveTextures(): BaseTexture[];
  32126. /**
  32127. * Specifies if the material uses a texture
  32128. * @param texture defines the texture to check against the material
  32129. * @returns a boolean specifying if the material uses the texture
  32130. */
  32131. hasTexture(texture: BaseTexture): boolean;
  32132. /**
  32133. * Disposes the material
  32134. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  32135. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  32136. */
  32137. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32138. /**
  32139. * Makes a duplicate of the material, and gives it a new name
  32140. * @param name defines the new name for the duplicated material
  32141. * @returns the cloned material
  32142. */
  32143. clone(name: string): StandardMaterial;
  32144. /**
  32145. * Serializes this material in a JSON representation
  32146. * @returns the serialized material object
  32147. */
  32148. serialize(): any;
  32149. /**
  32150. * Creates a standard material from parsed material data
  32151. * @param source defines the JSON representation of the material
  32152. * @param scene defines the hosting scene
  32153. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  32154. * @returns a new standard material
  32155. */
  32156. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  32157. /**
  32158. * Are diffuse textures enabled in the application.
  32159. */
  32160. static get DiffuseTextureEnabled(): boolean;
  32161. static set DiffuseTextureEnabled(value: boolean);
  32162. /**
  32163. * Are detail textures enabled in the application.
  32164. */
  32165. static get DetailTextureEnabled(): boolean;
  32166. static set DetailTextureEnabled(value: boolean);
  32167. /**
  32168. * Are ambient textures enabled in the application.
  32169. */
  32170. static get AmbientTextureEnabled(): boolean;
  32171. static set AmbientTextureEnabled(value: boolean);
  32172. /**
  32173. * Are opacity textures enabled in the application.
  32174. */
  32175. static get OpacityTextureEnabled(): boolean;
  32176. static set OpacityTextureEnabled(value: boolean);
  32177. /**
  32178. * Are reflection textures enabled in the application.
  32179. */
  32180. static get ReflectionTextureEnabled(): boolean;
  32181. static set ReflectionTextureEnabled(value: boolean);
  32182. /**
  32183. * Are emissive textures enabled in the application.
  32184. */
  32185. static get EmissiveTextureEnabled(): boolean;
  32186. static set EmissiveTextureEnabled(value: boolean);
  32187. /**
  32188. * Are specular textures enabled in the application.
  32189. */
  32190. static get SpecularTextureEnabled(): boolean;
  32191. static set SpecularTextureEnabled(value: boolean);
  32192. /**
  32193. * Are bump textures enabled in the application.
  32194. */
  32195. static get BumpTextureEnabled(): boolean;
  32196. static set BumpTextureEnabled(value: boolean);
  32197. /**
  32198. * Are lightmap textures enabled in the application.
  32199. */
  32200. static get LightmapTextureEnabled(): boolean;
  32201. static set LightmapTextureEnabled(value: boolean);
  32202. /**
  32203. * Are refraction textures enabled in the application.
  32204. */
  32205. static get RefractionTextureEnabled(): boolean;
  32206. static set RefractionTextureEnabled(value: boolean);
  32207. /**
  32208. * Are color grading textures enabled in the application.
  32209. */
  32210. static get ColorGradingTextureEnabled(): boolean;
  32211. static set ColorGradingTextureEnabled(value: boolean);
  32212. /**
  32213. * Are fresnels enabled in the application.
  32214. */
  32215. static get FresnelEnabled(): boolean;
  32216. static set FresnelEnabled(value: boolean);
  32217. }
  32218. }
  32219. declare module "babylonjs/Particles/solidParticleSystem" {
  32220. import { Nullable } from "babylonjs/types";
  32221. import { Mesh } from "babylonjs/Meshes/mesh";
  32222. import { Scene, IDisposable } from "babylonjs/scene";
  32223. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  32224. import { Material } from "babylonjs/Materials/material";
  32225. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32226. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32227. /**
  32228. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32229. *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.
  32230. * The SPS is also a particle system. It provides some methods to manage the particles.
  32231. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32232. *
  32233. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  32234. */
  32235. export class SolidParticleSystem implements IDisposable {
  32236. /**
  32237. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32238. * Example : var p = SPS.particles[i];
  32239. */
  32240. particles: SolidParticle[];
  32241. /**
  32242. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32243. */
  32244. nbParticles: number;
  32245. /**
  32246. * If the particles must ever face the camera (default false). Useful for planar particles.
  32247. */
  32248. billboard: boolean;
  32249. /**
  32250. * Recompute normals when adding a shape
  32251. */
  32252. recomputeNormals: boolean;
  32253. /**
  32254. * This a counter ofr your own usage. It's not set by any SPS functions.
  32255. */
  32256. counter: number;
  32257. /**
  32258. * The SPS name. This name is also given to the underlying mesh.
  32259. */
  32260. name: string;
  32261. /**
  32262. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32263. */
  32264. mesh: Mesh;
  32265. /**
  32266. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32267. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32268. */
  32269. vars: any;
  32270. /**
  32271. * This array is populated when the SPS is set as 'pickable'.
  32272. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32273. * Each element of this array is an object `{idx: int, faceId: int}`.
  32274. * `idx` is the picked particle index in the `SPS.particles` array
  32275. * `faceId` is the picked face index counted within this particle.
  32276. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32277. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32278. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32279. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32280. */
  32281. pickedParticles: {
  32282. idx: number;
  32283. faceId: number;
  32284. }[];
  32285. /**
  32286. * This array is populated when the SPS is set as 'pickable'
  32287. * Each key of this array is a submesh index.
  32288. * Each element of this array is a second array defined like this :
  32289. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32290. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32291. * `idx` is the picked particle index in the `SPS.particles` array
  32292. * `faceId` is the picked face index counted within this particle.
  32293. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32294. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32295. */
  32296. pickedBySubMesh: {
  32297. idx: number;
  32298. faceId: number;
  32299. }[][];
  32300. /**
  32301. * This array is populated when `enableDepthSort` is set to true.
  32302. * Each element of this array is an instance of the class DepthSortedParticle.
  32303. */
  32304. depthSortedParticles: DepthSortedParticle[];
  32305. /**
  32306. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32307. * @hidden
  32308. */
  32309. _bSphereOnly: boolean;
  32310. /**
  32311. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32312. * @hidden
  32313. */
  32314. _bSphereRadiusFactor: number;
  32315. private _scene;
  32316. private _positions;
  32317. private _indices;
  32318. private _normals;
  32319. private _colors;
  32320. private _uvs;
  32321. private _indices32;
  32322. private _positions32;
  32323. private _normals32;
  32324. private _fixedNormal32;
  32325. private _colors32;
  32326. private _uvs32;
  32327. private _index;
  32328. private _updatable;
  32329. private _pickable;
  32330. private _isVisibilityBoxLocked;
  32331. private _alwaysVisible;
  32332. private _depthSort;
  32333. private _expandable;
  32334. private _shapeCounter;
  32335. private _copy;
  32336. private _color;
  32337. private _computeParticleColor;
  32338. private _computeParticleTexture;
  32339. private _computeParticleRotation;
  32340. private _computeParticleVertex;
  32341. private _computeBoundingBox;
  32342. private _depthSortParticles;
  32343. private _camera;
  32344. private _mustUnrotateFixedNormals;
  32345. private _particlesIntersect;
  32346. private _needs32Bits;
  32347. private _isNotBuilt;
  32348. private _lastParticleId;
  32349. private _idxOfId;
  32350. private _multimaterialEnabled;
  32351. private _useModelMaterial;
  32352. private _indicesByMaterial;
  32353. private _materialIndexes;
  32354. private _depthSortFunction;
  32355. private _materialSortFunction;
  32356. private _materials;
  32357. private _multimaterial;
  32358. private _materialIndexesById;
  32359. private _defaultMaterial;
  32360. private _autoUpdateSubMeshes;
  32361. private _tmpVertex;
  32362. /**
  32363. * Creates a SPS (Solid Particle System) object.
  32364. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32365. * @param scene (Scene) is the scene in which the SPS is added.
  32366. * @param options defines the options of the sps e.g.
  32367. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32368. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32369. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32370. * * 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.
  32371. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32372. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32373. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32374. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32375. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32376. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32377. */
  32378. constructor(name: string, scene: Scene, options?: {
  32379. updatable?: boolean;
  32380. isPickable?: boolean;
  32381. enableDepthSort?: boolean;
  32382. particleIntersection?: boolean;
  32383. boundingSphereOnly?: boolean;
  32384. bSphereRadiusFactor?: number;
  32385. expandable?: boolean;
  32386. useModelMaterial?: boolean;
  32387. enableMultiMaterial?: boolean;
  32388. });
  32389. /**
  32390. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32391. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32392. * @returns the created mesh
  32393. */
  32394. buildMesh(): Mesh;
  32395. /**
  32396. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32397. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32398. * Thus the particles generated from `digest()` have their property `position` set yet.
  32399. * @param mesh ( Mesh ) is the mesh to be digested
  32400. * @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
  32401. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32402. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32403. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32404. * @returns the current SPS
  32405. */
  32406. digest(mesh: Mesh, options?: {
  32407. facetNb?: number;
  32408. number?: number;
  32409. delta?: number;
  32410. storage?: [];
  32411. }): SolidParticleSystem;
  32412. /**
  32413. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32414. * @hidden
  32415. */
  32416. private _unrotateFixedNormals;
  32417. /**
  32418. * Resets the temporary working copy particle
  32419. * @hidden
  32420. */
  32421. private _resetCopy;
  32422. /**
  32423. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32424. * @param p the current index in the positions array to be updated
  32425. * @param ind the current index in the indices array
  32426. * @param shape a Vector3 array, the shape geometry
  32427. * @param positions the positions array to be updated
  32428. * @param meshInd the shape indices array
  32429. * @param indices the indices array to be updated
  32430. * @param meshUV the shape uv array
  32431. * @param uvs the uv array to be updated
  32432. * @param meshCol the shape color array
  32433. * @param colors the color array to be updated
  32434. * @param meshNor the shape normals array
  32435. * @param normals the normals array to be updated
  32436. * @param idx the particle index
  32437. * @param idxInShape the particle index in its shape
  32438. * @param options the addShape() method passed options
  32439. * @model the particle model
  32440. * @hidden
  32441. */
  32442. private _meshBuilder;
  32443. /**
  32444. * Returns a shape Vector3 array from positions float array
  32445. * @param positions float array
  32446. * @returns a vector3 array
  32447. * @hidden
  32448. */
  32449. private _posToShape;
  32450. /**
  32451. * Returns a shapeUV array from a float uvs (array deep copy)
  32452. * @param uvs as a float array
  32453. * @returns a shapeUV array
  32454. * @hidden
  32455. */
  32456. private _uvsToShapeUV;
  32457. /**
  32458. * Adds a new particle object in the particles array
  32459. * @param idx particle index in particles array
  32460. * @param id particle id
  32461. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32462. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32463. * @param model particle ModelShape object
  32464. * @param shapeId model shape identifier
  32465. * @param idxInShape index of the particle in the current model
  32466. * @param bInfo model bounding info object
  32467. * @param storage target storage array, if any
  32468. * @hidden
  32469. */
  32470. private _addParticle;
  32471. /**
  32472. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32473. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32474. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32475. * @param nb (positive integer) the number of particles to be created from this model
  32476. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32477. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32478. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32479. * @returns the number of shapes in the system
  32480. */
  32481. addShape(mesh: Mesh, nb: number, options?: {
  32482. positionFunction?: any;
  32483. vertexFunction?: any;
  32484. storage?: [];
  32485. }): number;
  32486. /**
  32487. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32488. * @hidden
  32489. */
  32490. private _rebuildParticle;
  32491. /**
  32492. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32493. * @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.
  32494. * @returns the SPS.
  32495. */
  32496. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32497. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32498. * Returns an array with the removed particles.
  32499. * 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.
  32500. * The SPS can't be empty so at least one particle needs to remain in place.
  32501. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32502. * @param start index of the first particle to remove
  32503. * @param end index of the last particle to remove (included)
  32504. * @returns an array populated with the removed particles
  32505. */
  32506. removeParticles(start: number, end: number): SolidParticle[];
  32507. /**
  32508. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32509. * @param solidParticleArray an array populated with Solid Particles objects
  32510. * @returns the SPS
  32511. */
  32512. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32513. /**
  32514. * Creates a new particle and modifies the SPS mesh geometry :
  32515. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32516. * - calls _addParticle() to populate the particle array
  32517. * factorized code from addShape() and insertParticlesFromArray()
  32518. * @param idx particle index in the particles array
  32519. * @param i particle index in its shape
  32520. * @param modelShape particle ModelShape object
  32521. * @param shape shape vertex array
  32522. * @param meshInd shape indices array
  32523. * @param meshUV shape uv array
  32524. * @param meshCol shape color array
  32525. * @param meshNor shape normals array
  32526. * @param bbInfo shape bounding info
  32527. * @param storage target particle storage
  32528. * @options addShape() passed options
  32529. * @hidden
  32530. */
  32531. private _insertNewParticle;
  32532. /**
  32533. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32534. * This method calls `updateParticle()` for each particle of the SPS.
  32535. * For an animated SPS, it is usually called within the render loop.
  32536. * 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.
  32537. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32538. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32539. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32540. * @returns the SPS.
  32541. */
  32542. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32543. /**
  32544. * Disposes the SPS.
  32545. */
  32546. dispose(): void;
  32547. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32548. * idx is the particle index in the SPS
  32549. * faceId is the picked face index counted within this particle.
  32550. * Returns null if the pickInfo can't identify a picked particle.
  32551. * @param pickingInfo (PickingInfo object)
  32552. * @returns {idx: number, faceId: number} or null
  32553. */
  32554. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32555. idx: number;
  32556. faceId: number;
  32557. }>;
  32558. /**
  32559. * Returns a SolidParticle object from its identifier : particle.id
  32560. * @param id (integer) the particle Id
  32561. * @returns the searched particle or null if not found in the SPS.
  32562. */
  32563. getParticleById(id: number): Nullable<SolidParticle>;
  32564. /**
  32565. * Returns a new array populated with the particles having the passed shapeId.
  32566. * @param shapeId (integer) the shape identifier
  32567. * @returns a new solid particle array
  32568. */
  32569. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32570. /**
  32571. * Populates the passed array "ref" with the particles having the passed shapeId.
  32572. * @param shapeId the shape identifier
  32573. * @returns the SPS
  32574. * @param ref
  32575. */
  32576. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32577. /**
  32578. * Computes the required SubMeshes according the materials assigned to the particles.
  32579. * @returns the solid particle system.
  32580. * Does nothing if called before the SPS mesh is built.
  32581. */
  32582. computeSubMeshes(): SolidParticleSystem;
  32583. /**
  32584. * Sorts the solid particles by material when MultiMaterial is enabled.
  32585. * Updates the indices32 array.
  32586. * Updates the indicesByMaterial array.
  32587. * Updates the mesh indices array.
  32588. * @returns the SPS
  32589. * @hidden
  32590. */
  32591. private _sortParticlesByMaterial;
  32592. /**
  32593. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32594. * @hidden
  32595. */
  32596. private _setMaterialIndexesById;
  32597. /**
  32598. * Returns an array with unique values of Materials from the passed array
  32599. * @param array the material array to be checked and filtered
  32600. * @hidden
  32601. */
  32602. private _filterUniqueMaterialId;
  32603. /**
  32604. * Sets a new Standard Material as _defaultMaterial if not already set.
  32605. * @hidden
  32606. */
  32607. private _setDefaultMaterial;
  32608. /**
  32609. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32610. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32611. * @returns the SPS.
  32612. */
  32613. refreshVisibleSize(): SolidParticleSystem;
  32614. /**
  32615. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32616. * @param size the size (float) of the visibility box
  32617. * note : this doesn't lock the SPS mesh bounding box.
  32618. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32619. */
  32620. setVisibilityBox(size: number): void;
  32621. /**
  32622. * Gets whether the SPS as always visible or not
  32623. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32624. */
  32625. get isAlwaysVisible(): boolean;
  32626. /**
  32627. * Sets the SPS as always visible or not
  32628. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32629. */
  32630. set isAlwaysVisible(val: boolean);
  32631. /**
  32632. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32633. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32634. */
  32635. set isVisibilityBoxLocked(val: boolean);
  32636. /**
  32637. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32638. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32639. */
  32640. get isVisibilityBoxLocked(): boolean;
  32641. /**
  32642. * Tells to `setParticles()` to compute the particle rotations or not.
  32643. * Default value : true. The SPS is faster when it's set to false.
  32644. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32645. */
  32646. set computeParticleRotation(val: boolean);
  32647. /**
  32648. * Tells to `setParticles()` to compute the particle colors or not.
  32649. * Default value : true. The SPS is faster when it's set to false.
  32650. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32651. */
  32652. set computeParticleColor(val: boolean);
  32653. set computeParticleTexture(val: boolean);
  32654. /**
  32655. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32656. * Default value : false. The SPS is faster when it's set to false.
  32657. * Note : the particle custom vertex positions aren't stored values.
  32658. */
  32659. set computeParticleVertex(val: boolean);
  32660. /**
  32661. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32662. */
  32663. set computeBoundingBox(val: boolean);
  32664. /**
  32665. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32666. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32667. * Default : `true`
  32668. */
  32669. set depthSortParticles(val: boolean);
  32670. /**
  32671. * Gets if `setParticles()` computes the particle rotations or not.
  32672. * Default value : true. The SPS is faster when it's set to false.
  32673. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32674. */
  32675. get computeParticleRotation(): boolean;
  32676. /**
  32677. * Gets if `setParticles()` computes the particle colors or not.
  32678. * Default value : true. The SPS is faster when it's set to false.
  32679. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32680. */
  32681. get computeParticleColor(): boolean;
  32682. /**
  32683. * Gets if `setParticles()` computes the particle textures or not.
  32684. * Default value : true. The SPS is faster when it's set to false.
  32685. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32686. */
  32687. get computeParticleTexture(): boolean;
  32688. /**
  32689. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32690. * Default value : false. The SPS is faster when it's set to false.
  32691. * Note : the particle custom vertex positions aren't stored values.
  32692. */
  32693. get computeParticleVertex(): boolean;
  32694. /**
  32695. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32696. */
  32697. get computeBoundingBox(): boolean;
  32698. /**
  32699. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32700. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32701. * Default : `true`
  32702. */
  32703. get depthSortParticles(): boolean;
  32704. /**
  32705. * Gets if the SPS is created as expandable at construction time.
  32706. * Default : `false`
  32707. */
  32708. get expandable(): boolean;
  32709. /**
  32710. * Gets if the SPS supports the Multi Materials
  32711. */
  32712. get multimaterialEnabled(): boolean;
  32713. /**
  32714. * Gets if the SPS uses the model materials for its own multimaterial.
  32715. */
  32716. get useModelMaterial(): boolean;
  32717. /**
  32718. * The SPS used material array.
  32719. */
  32720. get materials(): Material[];
  32721. /**
  32722. * Sets the SPS MultiMaterial from the passed materials.
  32723. * Note : the passed array is internally copied and not used then by reference.
  32724. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32725. */
  32726. setMultiMaterial(materials: Material[]): void;
  32727. /**
  32728. * The SPS computed multimaterial object
  32729. */
  32730. get multimaterial(): MultiMaterial;
  32731. set multimaterial(mm: MultiMaterial);
  32732. /**
  32733. * If the subMeshes must be updated on the next call to setParticles()
  32734. */
  32735. get autoUpdateSubMeshes(): boolean;
  32736. set autoUpdateSubMeshes(val: boolean);
  32737. /**
  32738. * This function does nothing. It may be overwritten to set all the particle first values.
  32739. * The SPS doesn't call this function, you may have to call it by your own.
  32740. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32741. */
  32742. initParticles(): void;
  32743. /**
  32744. * This function does nothing. It may be overwritten to recycle a particle.
  32745. * The SPS doesn't call this function, you may have to call it by your own.
  32746. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32747. * @param particle The particle to recycle
  32748. * @returns the recycled particle
  32749. */
  32750. recycleParticle(particle: SolidParticle): SolidParticle;
  32751. /**
  32752. * Updates a particle : this function should be overwritten by the user.
  32753. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32754. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32755. * @example : just set a particle position or velocity and recycle conditions
  32756. * @param particle The particle to update
  32757. * @returns the updated particle
  32758. */
  32759. updateParticle(particle: SolidParticle): SolidParticle;
  32760. /**
  32761. * Updates a vertex of a particle : it can be overwritten by the user.
  32762. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32763. * @param particle the current particle
  32764. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32765. * @param pt the index of the current vertex in the particle shape
  32766. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32767. * @example : just set a vertex particle position or color
  32768. * @returns the sps
  32769. */
  32770. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32771. /**
  32772. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32773. * This does nothing and may be overwritten by the user.
  32774. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32775. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32776. * @param update the boolean update value actually passed to setParticles()
  32777. */
  32778. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32779. /**
  32780. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32781. * This will be passed three parameters.
  32782. * This does nothing and may be overwritten by the user.
  32783. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32784. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32785. * @param update the boolean update value actually passed to setParticles()
  32786. */
  32787. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32788. }
  32789. }
  32790. declare module "babylonjs/Particles/solidParticle" {
  32791. import { Nullable } from "babylonjs/types";
  32792. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32793. import { Color4 } from "babylonjs/Maths/math.color";
  32794. import { Mesh } from "babylonjs/Meshes/mesh";
  32795. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32796. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32797. import { Plane } from "babylonjs/Maths/math.plane";
  32798. import { Material } from "babylonjs/Materials/material";
  32799. /**
  32800. * Represents one particle of a solid particle system.
  32801. */
  32802. export class SolidParticle {
  32803. /**
  32804. * particle global index
  32805. */
  32806. idx: number;
  32807. /**
  32808. * particle identifier
  32809. */
  32810. id: number;
  32811. /**
  32812. * The color of the particle
  32813. */
  32814. color: Nullable<Color4>;
  32815. /**
  32816. * The world space position of the particle.
  32817. */
  32818. position: Vector3;
  32819. /**
  32820. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32821. */
  32822. rotation: Vector3;
  32823. /**
  32824. * The world space rotation quaternion of the particle.
  32825. */
  32826. rotationQuaternion: Nullable<Quaternion>;
  32827. /**
  32828. * The scaling of the particle.
  32829. */
  32830. scaling: Vector3;
  32831. /**
  32832. * The uvs of the particle.
  32833. */
  32834. uvs: Vector4;
  32835. /**
  32836. * The current speed of the particle.
  32837. */
  32838. velocity: Vector3;
  32839. /**
  32840. * The pivot point in the particle local space.
  32841. */
  32842. pivot: Vector3;
  32843. /**
  32844. * Must the particle be translated from its pivot point in its local space ?
  32845. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32846. * Default : false
  32847. */
  32848. translateFromPivot: boolean;
  32849. /**
  32850. * Is the particle active or not ?
  32851. */
  32852. alive: boolean;
  32853. /**
  32854. * Is the particle visible or not ?
  32855. */
  32856. isVisible: boolean;
  32857. /**
  32858. * Index of this particle in the global "positions" array (Internal use)
  32859. * @hidden
  32860. */
  32861. _pos: number;
  32862. /**
  32863. * @hidden Index of this particle in the global "indices" array (Internal use)
  32864. */
  32865. _ind: number;
  32866. /**
  32867. * @hidden ModelShape of this particle (Internal use)
  32868. */
  32869. _model: ModelShape;
  32870. /**
  32871. * ModelShape id of this particle
  32872. */
  32873. shapeId: number;
  32874. /**
  32875. * Index of the particle in its shape id
  32876. */
  32877. idxInShape: number;
  32878. /**
  32879. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32880. */
  32881. _modelBoundingInfo: BoundingInfo;
  32882. /**
  32883. * @hidden Particle BoundingInfo object (Internal use)
  32884. */
  32885. _boundingInfo: BoundingInfo;
  32886. /**
  32887. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32888. */
  32889. _sps: SolidParticleSystem;
  32890. /**
  32891. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32892. */
  32893. _stillInvisible: boolean;
  32894. /**
  32895. * @hidden Last computed particle rotation matrix
  32896. */
  32897. _rotationMatrix: number[];
  32898. /**
  32899. * Parent particle Id, if any.
  32900. * Default null.
  32901. */
  32902. parentId: Nullable<number>;
  32903. /**
  32904. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32905. */
  32906. materialIndex: Nullable<number>;
  32907. /**
  32908. * Custom object or properties.
  32909. */
  32910. props: Nullable<any>;
  32911. /**
  32912. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32913. * The possible values are :
  32914. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32915. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32916. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32917. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32918. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32919. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32920. * */
  32921. cullingStrategy: number;
  32922. /**
  32923. * @hidden Internal global position in the SPS.
  32924. */
  32925. _globalPosition: Vector3;
  32926. /**
  32927. * Creates a Solid Particle object.
  32928. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32929. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  32930. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  32931. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32932. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32933. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32934. * @param shapeId (integer) is the model shape identifier in the SPS.
  32935. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32936. * @param sps defines the sps it is associated to
  32937. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32938. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  32939. */
  32940. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  32941. /**
  32942. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  32943. * @param target the particle target
  32944. * @returns the current particle
  32945. */
  32946. copyToRef(target: SolidParticle): SolidParticle;
  32947. /**
  32948. * Legacy support, changed scale to scaling
  32949. */
  32950. get scale(): Vector3;
  32951. /**
  32952. * Legacy support, changed scale to scaling
  32953. */
  32954. set scale(scale: Vector3);
  32955. /**
  32956. * Legacy support, changed quaternion to rotationQuaternion
  32957. */
  32958. get quaternion(): Nullable<Quaternion>;
  32959. /**
  32960. * Legacy support, changed quaternion to rotationQuaternion
  32961. */
  32962. set quaternion(q: Nullable<Quaternion>);
  32963. /**
  32964. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32965. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32966. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32967. * @returns true if it intersects
  32968. */
  32969. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32970. /**
  32971. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  32972. * A particle is in the frustum if its bounding box intersects the frustum
  32973. * @param frustumPlanes defines the frustum to test
  32974. * @returns true if the particle is in the frustum planes
  32975. */
  32976. isInFrustum(frustumPlanes: Plane[]): boolean;
  32977. /**
  32978. * get the rotation matrix of the particle
  32979. * @hidden
  32980. */
  32981. getRotationMatrix(m: Matrix): void;
  32982. }
  32983. /**
  32984. * Represents the shape of the model used by one particle of a solid particle system.
  32985. * SPS internal tool, don't use it manually.
  32986. */
  32987. export class ModelShape {
  32988. /**
  32989. * The shape id
  32990. * @hidden
  32991. */
  32992. shapeID: number;
  32993. /**
  32994. * flat array of model positions (internal use)
  32995. * @hidden
  32996. */
  32997. _shape: Vector3[];
  32998. /**
  32999. * flat array of model UVs (internal use)
  33000. * @hidden
  33001. */
  33002. _shapeUV: number[];
  33003. /**
  33004. * color array of the model
  33005. * @hidden
  33006. */
  33007. _shapeColors: number[];
  33008. /**
  33009. * indices array of the model
  33010. * @hidden
  33011. */
  33012. _indices: number[];
  33013. /**
  33014. * normals array of the model
  33015. * @hidden
  33016. */
  33017. _normals: number[];
  33018. /**
  33019. * length of the shape in the model indices array (internal use)
  33020. * @hidden
  33021. */
  33022. _indicesLength: number;
  33023. /**
  33024. * Custom position function (internal use)
  33025. * @hidden
  33026. */
  33027. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  33028. /**
  33029. * Custom vertex function (internal use)
  33030. * @hidden
  33031. */
  33032. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  33033. /**
  33034. * Model material (internal use)
  33035. * @hidden
  33036. */
  33037. _material: Nullable<Material>;
  33038. /**
  33039. * 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.
  33040. * SPS internal tool, don't use it manually.
  33041. * @hidden
  33042. */
  33043. 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>);
  33044. }
  33045. /**
  33046. * Represents a Depth Sorted Particle in the solid particle system.
  33047. * @hidden
  33048. */
  33049. export class DepthSortedParticle {
  33050. /**
  33051. * Particle index
  33052. */
  33053. idx: number;
  33054. /**
  33055. * Index of the particle in the "indices" array
  33056. */
  33057. ind: number;
  33058. /**
  33059. * Length of the particle shape in the "indices" array
  33060. */
  33061. indicesLength: number;
  33062. /**
  33063. * Squared distance from the particle to the camera
  33064. */
  33065. sqDistance: number;
  33066. /**
  33067. * Material index when used with MultiMaterials
  33068. */
  33069. materialIndex: number;
  33070. /**
  33071. * Creates a new sorted particle
  33072. * @param materialIndex
  33073. */
  33074. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  33075. }
  33076. /**
  33077. * Represents a solid particle vertex
  33078. */
  33079. export class SolidParticleVertex {
  33080. /**
  33081. * Vertex position
  33082. */
  33083. position: Vector3;
  33084. /**
  33085. * Vertex color
  33086. */
  33087. color: Color4;
  33088. /**
  33089. * Vertex UV
  33090. */
  33091. uv: Vector2;
  33092. /**
  33093. * Creates a new solid particle vertex
  33094. */
  33095. constructor();
  33096. /** Vertex x coordinate */
  33097. get x(): number;
  33098. set x(val: number);
  33099. /** Vertex y coordinate */
  33100. get y(): number;
  33101. set y(val: number);
  33102. /** Vertex z coordinate */
  33103. get z(): number;
  33104. set z(val: number);
  33105. }
  33106. }
  33107. declare module "babylonjs/Collisions/meshCollisionData" {
  33108. import { Collider } from "babylonjs/Collisions/collider";
  33109. import { Vector3 } from "babylonjs/Maths/math.vector";
  33110. import { Nullable } from "babylonjs/types";
  33111. import { Observer } from "babylonjs/Misc/observable";
  33112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33113. /**
  33114. * @hidden
  33115. */
  33116. export class _MeshCollisionData {
  33117. _checkCollisions: boolean;
  33118. _collisionMask: number;
  33119. _collisionGroup: number;
  33120. _surroundingMeshes: Nullable<AbstractMesh[]>;
  33121. _collider: Nullable<Collider>;
  33122. _oldPositionForCollisions: Vector3;
  33123. _diffPositionForCollisions: Vector3;
  33124. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  33125. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  33126. _collisionResponse: boolean;
  33127. }
  33128. }
  33129. declare module "babylonjs/Meshes/abstractMesh" {
  33130. import { Observable } from "babylonjs/Misc/observable";
  33131. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  33132. import { Camera } from "babylonjs/Cameras/camera";
  33133. import { Scene, IDisposable } from "babylonjs/scene";
  33134. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  33135. import { Node } from "babylonjs/node";
  33136. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33137. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33138. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33139. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33140. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33141. import { Material } from "babylonjs/Materials/material";
  33142. import { Light } from "babylonjs/Lights/light";
  33143. import { Skeleton } from "babylonjs/Bones/skeleton";
  33144. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  33145. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  33146. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33147. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  33148. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33149. import { Plane } from "babylonjs/Maths/math.plane";
  33150. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33151. import { Ray } from "babylonjs/Culling/ray";
  33152. import { Collider } from "babylonjs/Collisions/collider";
  33153. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33154. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  33155. /** @hidden */
  33156. class _FacetDataStorage {
  33157. facetPositions: Vector3[];
  33158. facetNormals: Vector3[];
  33159. facetPartitioning: number[][];
  33160. facetNb: number;
  33161. partitioningSubdivisions: number;
  33162. partitioningBBoxRatio: number;
  33163. facetDataEnabled: boolean;
  33164. facetParameters: any;
  33165. bbSize: Vector3;
  33166. subDiv: {
  33167. max: number;
  33168. X: number;
  33169. Y: number;
  33170. Z: number;
  33171. };
  33172. facetDepthSort: boolean;
  33173. facetDepthSortEnabled: boolean;
  33174. depthSortedIndices: IndicesArray;
  33175. depthSortedFacets: {
  33176. ind: number;
  33177. sqDistance: number;
  33178. }[];
  33179. facetDepthSortFunction: (f1: {
  33180. ind: number;
  33181. sqDistance: number;
  33182. }, f2: {
  33183. ind: number;
  33184. sqDistance: number;
  33185. }) => number;
  33186. facetDepthSortFrom: Vector3;
  33187. facetDepthSortOrigin: Vector3;
  33188. invertedMatrix: Matrix;
  33189. }
  33190. /**
  33191. * @hidden
  33192. **/
  33193. class _InternalAbstractMeshDataInfo {
  33194. _hasVertexAlpha: boolean;
  33195. _useVertexColors: boolean;
  33196. _numBoneInfluencers: number;
  33197. _applyFog: boolean;
  33198. _receiveShadows: boolean;
  33199. _facetData: _FacetDataStorage;
  33200. _visibility: number;
  33201. _skeleton: Nullable<Skeleton>;
  33202. _layerMask: number;
  33203. _computeBonesUsingShaders: boolean;
  33204. _isActive: boolean;
  33205. _onlyForInstances: boolean;
  33206. _isActiveIntermediate: boolean;
  33207. _onlyForInstancesIntermediate: boolean;
  33208. _actAsRegularMesh: boolean;
  33209. }
  33210. /**
  33211. * Class used to store all common mesh properties
  33212. */
  33213. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  33214. /** No occlusion */
  33215. static OCCLUSION_TYPE_NONE: number;
  33216. /** Occlusion set to optimisitic */
  33217. static OCCLUSION_TYPE_OPTIMISTIC: number;
  33218. /** Occlusion set to strict */
  33219. static OCCLUSION_TYPE_STRICT: number;
  33220. /** Use an accurante occlusion algorithm */
  33221. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  33222. /** Use a conservative occlusion algorithm */
  33223. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  33224. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  33225. * Test order :
  33226. * Is the bounding sphere outside the frustum ?
  33227. * If not, are the bounding box vertices outside the frustum ?
  33228. * It not, then the cullable object is in the frustum.
  33229. */
  33230. static readonly CULLINGSTRATEGY_STANDARD: number;
  33231. /** Culling strategy : Bounding Sphere Only.
  33232. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  33233. * It's also less accurate than the standard because some not visible objects can still be selected.
  33234. * Test : is the bounding sphere outside the frustum ?
  33235. * If not, then the cullable object is in the frustum.
  33236. */
  33237. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  33238. /** Culling strategy : Optimistic Inclusion.
  33239. * This in an inclusion test first, then the standard exclusion test.
  33240. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  33241. * 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.
  33242. * Anyway, it's as accurate as the standard strategy.
  33243. * Test :
  33244. * Is the cullable object bounding sphere center in the frustum ?
  33245. * If not, apply the default culling strategy.
  33246. */
  33247. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  33248. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  33249. * This in an inclusion test first, then the bounding sphere only exclusion test.
  33250. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  33251. * 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.
  33252. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  33253. * Test :
  33254. * Is the cullable object bounding sphere center in the frustum ?
  33255. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  33256. */
  33257. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  33258. /**
  33259. * No billboard
  33260. */
  33261. static get BILLBOARDMODE_NONE(): number;
  33262. /** Billboard on X axis */
  33263. static get BILLBOARDMODE_X(): number;
  33264. /** Billboard on Y axis */
  33265. static get BILLBOARDMODE_Y(): number;
  33266. /** Billboard on Z axis */
  33267. static get BILLBOARDMODE_Z(): number;
  33268. /** Billboard on all axes */
  33269. static get BILLBOARDMODE_ALL(): number;
  33270. /** Billboard on using position instead of orientation */
  33271. static get BILLBOARDMODE_USE_POSITION(): number;
  33272. /** @hidden */
  33273. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33274. /**
  33275. * The culling strategy to use to check whether the mesh must be rendered or not.
  33276. * This value can be changed at any time and will be used on the next render mesh selection.
  33277. * The possible values are :
  33278. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33279. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33280. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33281. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33282. * Please read each static variable documentation to get details about the culling process.
  33283. * */
  33284. cullingStrategy: number;
  33285. /**
  33286. * Gets the number of facets in the mesh
  33287. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33288. */
  33289. get facetNb(): number;
  33290. /**
  33291. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33292. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33293. */
  33294. get partitioningSubdivisions(): number;
  33295. set partitioningSubdivisions(nb: number);
  33296. /**
  33297. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33298. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33299. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33300. */
  33301. get partitioningBBoxRatio(): number;
  33302. set partitioningBBoxRatio(ratio: number);
  33303. /**
  33304. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33305. * Works only for updatable meshes.
  33306. * Doesn't work with multi-materials
  33307. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33308. */
  33309. get mustDepthSortFacets(): boolean;
  33310. set mustDepthSortFacets(sort: boolean);
  33311. /**
  33312. * The location (Vector3) where the facet depth sort must be computed from.
  33313. * By default, the active camera position.
  33314. * Used only when facet depth sort is enabled
  33315. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33316. */
  33317. get facetDepthSortFrom(): Vector3;
  33318. set facetDepthSortFrom(location: Vector3);
  33319. /**
  33320. * gets a boolean indicating if facetData is enabled
  33321. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33322. */
  33323. get isFacetDataEnabled(): boolean;
  33324. /** @hidden */
  33325. _updateNonUniformScalingState(value: boolean): boolean;
  33326. /**
  33327. * An event triggered when this mesh collides with another one
  33328. */
  33329. onCollideObservable: Observable<AbstractMesh>;
  33330. /** Set a function to call when this mesh collides with another one */
  33331. set onCollide(callback: () => void);
  33332. /**
  33333. * An event triggered when the collision's position changes
  33334. */
  33335. onCollisionPositionChangeObservable: Observable<Vector3>;
  33336. /** Set a function to call when the collision's position changes */
  33337. set onCollisionPositionChange(callback: () => void);
  33338. /**
  33339. * An event triggered when material is changed
  33340. */
  33341. onMaterialChangedObservable: Observable<AbstractMesh>;
  33342. /**
  33343. * Gets or sets the orientation for POV movement & rotation
  33344. */
  33345. definedFacingForward: boolean;
  33346. /** @hidden */
  33347. _occlusionQuery: Nullable<WebGLQuery>;
  33348. /** @hidden */
  33349. _renderingGroup: Nullable<RenderingGroup>;
  33350. /**
  33351. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33352. */
  33353. get visibility(): number;
  33354. /**
  33355. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33356. */
  33357. set visibility(value: number);
  33358. /** Gets or sets the alpha index used to sort transparent meshes
  33359. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33360. */
  33361. alphaIndex: number;
  33362. /**
  33363. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33364. */
  33365. isVisible: boolean;
  33366. /**
  33367. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33368. */
  33369. isPickable: boolean;
  33370. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33371. showSubMeshesBoundingBox: boolean;
  33372. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33373. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33374. */
  33375. isBlocker: boolean;
  33376. /**
  33377. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33378. */
  33379. enablePointerMoveEvents: boolean;
  33380. private _renderingGroupId;
  33381. /**
  33382. * Specifies the rendering group id for this mesh (0 by default)
  33383. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33384. */
  33385. get renderingGroupId(): number;
  33386. set renderingGroupId(value: number);
  33387. private _material;
  33388. /** Gets or sets current material */
  33389. get material(): Nullable<Material>;
  33390. set material(value: Nullable<Material>);
  33391. /**
  33392. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33393. * @see https://doc.babylonjs.com/babylon101/shadows
  33394. */
  33395. get receiveShadows(): boolean;
  33396. set receiveShadows(value: boolean);
  33397. /** Defines color to use when rendering outline */
  33398. outlineColor: Color3;
  33399. /** Define width to use when rendering outline */
  33400. outlineWidth: number;
  33401. /** Defines color to use when rendering overlay */
  33402. overlayColor: Color3;
  33403. /** Defines alpha to use when rendering overlay */
  33404. overlayAlpha: number;
  33405. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33406. get hasVertexAlpha(): boolean;
  33407. set hasVertexAlpha(value: boolean);
  33408. /** 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) */
  33409. get useVertexColors(): boolean;
  33410. set useVertexColors(value: boolean);
  33411. /**
  33412. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33413. */
  33414. get computeBonesUsingShaders(): boolean;
  33415. set computeBonesUsingShaders(value: boolean);
  33416. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33417. get numBoneInfluencers(): number;
  33418. set numBoneInfluencers(value: number);
  33419. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33420. get applyFog(): boolean;
  33421. set applyFog(value: boolean);
  33422. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33423. useOctreeForRenderingSelection: boolean;
  33424. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33425. useOctreeForPicking: boolean;
  33426. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33427. useOctreeForCollisions: boolean;
  33428. /**
  33429. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33430. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33431. */
  33432. get layerMask(): number;
  33433. set layerMask(value: number);
  33434. /**
  33435. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33436. */
  33437. alwaysSelectAsActiveMesh: boolean;
  33438. /**
  33439. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33440. */
  33441. doNotSyncBoundingInfo: boolean;
  33442. /**
  33443. * Gets or sets the current action manager
  33444. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33445. */
  33446. actionManager: Nullable<AbstractActionManager>;
  33447. private _meshCollisionData;
  33448. /**
  33449. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33450. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33451. */
  33452. ellipsoid: Vector3;
  33453. /**
  33454. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33455. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33456. */
  33457. ellipsoidOffset: Vector3;
  33458. /**
  33459. * Gets or sets a collision mask used to mask collisions (default is -1).
  33460. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33461. */
  33462. get collisionMask(): number;
  33463. set collisionMask(mask: number);
  33464. /**
  33465. * Gets or sets a collision response flag (default is true).
  33466. * when collisionResponse is false, events are still triggered but colliding entity has no response
  33467. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  33468. * to respond to the collision.
  33469. */
  33470. get collisionResponse(): boolean;
  33471. set collisionResponse(response: boolean);
  33472. /**
  33473. * Gets or sets the current collision group mask (-1 by default).
  33474. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33475. */
  33476. get collisionGroup(): number;
  33477. set collisionGroup(mask: number);
  33478. /**
  33479. * Gets or sets current surrounding meshes (null by default).
  33480. *
  33481. * By default collision detection is tested against every mesh in the scene.
  33482. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33483. * meshes will be tested for the collision.
  33484. *
  33485. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33486. */
  33487. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33488. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33489. /**
  33490. * Defines edge width used when edgesRenderer is enabled
  33491. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33492. */
  33493. edgesWidth: number;
  33494. /**
  33495. * Defines edge color used when edgesRenderer is enabled
  33496. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33497. */
  33498. edgesColor: Color4;
  33499. /** @hidden */
  33500. _edgesRenderer: Nullable<IEdgesRenderer>;
  33501. /** @hidden */
  33502. _masterMesh: Nullable<AbstractMesh>;
  33503. /** @hidden */
  33504. _boundingInfo: Nullable<BoundingInfo>;
  33505. /** @hidden */
  33506. _renderId: number;
  33507. /**
  33508. * Gets or sets the list of subMeshes
  33509. * @see https://doc.babylonjs.com/how_to/multi_materials
  33510. */
  33511. subMeshes: SubMesh[];
  33512. /** @hidden */
  33513. _intersectionsInProgress: AbstractMesh[];
  33514. /** @hidden */
  33515. _unIndexed: boolean;
  33516. /** @hidden */
  33517. _lightSources: Light[];
  33518. /** Gets the list of lights affecting that mesh */
  33519. get lightSources(): Light[];
  33520. /** @hidden */
  33521. get _positions(): Nullable<Vector3[]>;
  33522. /** @hidden */
  33523. _waitingData: {
  33524. lods: Nullable<any>;
  33525. actions: Nullable<any>;
  33526. freezeWorldMatrix: Nullable<boolean>;
  33527. };
  33528. /** @hidden */
  33529. _bonesTransformMatrices: Nullable<Float32Array>;
  33530. /** @hidden */
  33531. _transformMatrixTexture: Nullable<RawTexture>;
  33532. /**
  33533. * Gets or sets a skeleton to apply skining transformations
  33534. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33535. */
  33536. set skeleton(value: Nullable<Skeleton>);
  33537. get skeleton(): Nullable<Skeleton>;
  33538. /**
  33539. * An event triggered when the mesh is rebuilt.
  33540. */
  33541. onRebuildObservable: Observable<AbstractMesh>;
  33542. /**
  33543. * Creates a new AbstractMesh
  33544. * @param name defines the name of the mesh
  33545. * @param scene defines the hosting scene
  33546. */
  33547. constructor(name: string, scene?: Nullable<Scene>);
  33548. /**
  33549. * Returns the string "AbstractMesh"
  33550. * @returns "AbstractMesh"
  33551. */
  33552. getClassName(): string;
  33553. /**
  33554. * Gets a string representation of the current mesh
  33555. * @param fullDetails defines a boolean indicating if full details must be included
  33556. * @returns a string representation of the current mesh
  33557. */
  33558. toString(fullDetails?: boolean): string;
  33559. /**
  33560. * @hidden
  33561. */
  33562. protected _getEffectiveParent(): Nullable<Node>;
  33563. /** @hidden */
  33564. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33565. /** @hidden */
  33566. _rebuild(): void;
  33567. /** @hidden */
  33568. _resyncLightSources(): void;
  33569. /** @hidden */
  33570. _resyncLightSource(light: Light): void;
  33571. /** @hidden */
  33572. _unBindEffect(): void;
  33573. /** @hidden */
  33574. _removeLightSource(light: Light, dispose: boolean): void;
  33575. private _markSubMeshesAsDirty;
  33576. /** @hidden */
  33577. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33578. /** @hidden */
  33579. _markSubMeshesAsAttributesDirty(): void;
  33580. /** @hidden */
  33581. _markSubMeshesAsMiscDirty(): void;
  33582. /**
  33583. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33584. */
  33585. get scaling(): Vector3;
  33586. set scaling(newScaling: Vector3);
  33587. /**
  33588. * Returns true if the mesh is blocked. Implemented by child classes
  33589. */
  33590. get isBlocked(): boolean;
  33591. /**
  33592. * Returns the mesh itself by default. Implemented by child classes
  33593. * @param camera defines the camera to use to pick the right LOD level
  33594. * @returns the currentAbstractMesh
  33595. */
  33596. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33597. /**
  33598. * Returns 0 by default. Implemented by child classes
  33599. * @returns an integer
  33600. */
  33601. getTotalVertices(): number;
  33602. /**
  33603. * Returns a positive integer : the total number of indices in this mesh geometry.
  33604. * @returns the numner of indices or zero if the mesh has no geometry.
  33605. */
  33606. getTotalIndices(): number;
  33607. /**
  33608. * Returns null by default. Implemented by child classes
  33609. * @returns null
  33610. */
  33611. getIndices(): Nullable<IndicesArray>;
  33612. /**
  33613. * Returns the array of the requested vertex data kind. Implemented by child classes
  33614. * @param kind defines the vertex data kind to use
  33615. * @returns null
  33616. */
  33617. getVerticesData(kind: string): Nullable<FloatArray>;
  33618. /**
  33619. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33620. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33621. * Note that a new underlying VertexBuffer object is created each call.
  33622. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33623. * @param kind defines vertex data kind:
  33624. * * VertexBuffer.PositionKind
  33625. * * VertexBuffer.UVKind
  33626. * * VertexBuffer.UV2Kind
  33627. * * VertexBuffer.UV3Kind
  33628. * * VertexBuffer.UV4Kind
  33629. * * VertexBuffer.UV5Kind
  33630. * * VertexBuffer.UV6Kind
  33631. * * VertexBuffer.ColorKind
  33632. * * VertexBuffer.MatricesIndicesKind
  33633. * * VertexBuffer.MatricesIndicesExtraKind
  33634. * * VertexBuffer.MatricesWeightsKind
  33635. * * VertexBuffer.MatricesWeightsExtraKind
  33636. * @param data defines the data source
  33637. * @param updatable defines if the data must be flagged as updatable (or static)
  33638. * @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
  33639. * @returns the current mesh
  33640. */
  33641. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33642. /**
  33643. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33644. * If the mesh has no geometry, it is simply returned as it is.
  33645. * @param kind defines vertex data kind:
  33646. * * VertexBuffer.PositionKind
  33647. * * VertexBuffer.UVKind
  33648. * * VertexBuffer.UV2Kind
  33649. * * VertexBuffer.UV3Kind
  33650. * * VertexBuffer.UV4Kind
  33651. * * VertexBuffer.UV5Kind
  33652. * * VertexBuffer.UV6Kind
  33653. * * VertexBuffer.ColorKind
  33654. * * VertexBuffer.MatricesIndicesKind
  33655. * * VertexBuffer.MatricesIndicesExtraKind
  33656. * * VertexBuffer.MatricesWeightsKind
  33657. * * VertexBuffer.MatricesWeightsExtraKind
  33658. * @param data defines the data source
  33659. * @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
  33660. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33661. * @returns the current mesh
  33662. */
  33663. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33664. /**
  33665. * Sets the mesh indices,
  33666. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33667. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33668. * @param totalVertices Defines the total number of vertices
  33669. * @returns the current mesh
  33670. */
  33671. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33672. /**
  33673. * Gets a boolean indicating if specific vertex data is present
  33674. * @param kind defines the vertex data kind to use
  33675. * @returns true is data kind is present
  33676. */
  33677. isVerticesDataPresent(kind: string): boolean;
  33678. /**
  33679. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33680. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33681. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33682. * @returns a BoundingInfo
  33683. */
  33684. getBoundingInfo(): BoundingInfo;
  33685. /**
  33686. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33687. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33688. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33689. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33690. * @returns the current mesh
  33691. */
  33692. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33693. /**
  33694. * Overwrite the current bounding info
  33695. * @param boundingInfo defines the new bounding info
  33696. * @returns the current mesh
  33697. */
  33698. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33699. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33700. get useBones(): boolean;
  33701. /** @hidden */
  33702. _preActivate(): void;
  33703. /** @hidden */
  33704. _preActivateForIntermediateRendering(renderId: number): void;
  33705. /** @hidden */
  33706. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33707. /** @hidden */
  33708. _postActivate(): void;
  33709. /** @hidden */
  33710. _freeze(): void;
  33711. /** @hidden */
  33712. _unFreeze(): void;
  33713. /**
  33714. * Gets the current world matrix
  33715. * @returns a Matrix
  33716. */
  33717. getWorldMatrix(): Matrix;
  33718. /** @hidden */
  33719. _getWorldMatrixDeterminant(): number;
  33720. /**
  33721. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33722. */
  33723. get isAnInstance(): boolean;
  33724. /**
  33725. * Gets a boolean indicating if this mesh has instances
  33726. */
  33727. get hasInstances(): boolean;
  33728. /**
  33729. * Gets a boolean indicating if this mesh has thin instances
  33730. */
  33731. get hasThinInstances(): boolean;
  33732. /**
  33733. * Perform relative position change from the point of view of behind the front of the mesh.
  33734. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33735. * Supports definition of mesh facing forward or backward
  33736. * @param amountRight defines the distance on the right axis
  33737. * @param amountUp defines the distance on the up axis
  33738. * @param amountForward defines the distance on the forward axis
  33739. * @returns the current mesh
  33740. */
  33741. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33742. /**
  33743. * Calculate relative position change from the point of view of behind the front of the mesh.
  33744. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33745. * Supports definition of mesh facing forward or backward
  33746. * @param amountRight defines the distance on the right axis
  33747. * @param amountUp defines the distance on the up axis
  33748. * @param amountForward defines the distance on the forward axis
  33749. * @returns the new displacement vector
  33750. */
  33751. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33752. /**
  33753. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33754. * Supports definition of mesh facing forward or backward
  33755. * @param flipBack defines the flip
  33756. * @param twirlClockwise defines the twirl
  33757. * @param tiltRight defines the tilt
  33758. * @returns the current mesh
  33759. */
  33760. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33761. /**
  33762. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33763. * Supports definition of mesh facing forward or backward.
  33764. * @param flipBack defines the flip
  33765. * @param twirlClockwise defines the twirl
  33766. * @param tiltRight defines the tilt
  33767. * @returns the new rotation vector
  33768. */
  33769. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33770. /**
  33771. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33772. * This means the mesh underlying bounding box and sphere are recomputed.
  33773. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33774. * @returns the current mesh
  33775. */
  33776. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33777. /** @hidden */
  33778. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33779. /** @hidden */
  33780. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33781. /** @hidden */
  33782. _updateBoundingInfo(): AbstractMesh;
  33783. /** @hidden */
  33784. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33785. /** @hidden */
  33786. protected _afterComputeWorldMatrix(): void;
  33787. /** @hidden */
  33788. get _effectiveMesh(): AbstractMesh;
  33789. /**
  33790. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33791. * A mesh is in the frustum if its bounding box intersects the frustum
  33792. * @param frustumPlanes defines the frustum to test
  33793. * @returns true if the mesh is in the frustum planes
  33794. */
  33795. isInFrustum(frustumPlanes: Plane[]): boolean;
  33796. /**
  33797. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33798. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33799. * @param frustumPlanes defines the frustum to test
  33800. * @returns true if the mesh is completely in the frustum planes
  33801. */
  33802. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33803. /**
  33804. * True if the mesh intersects another mesh or a SolidParticle object
  33805. * @param mesh defines a target mesh or SolidParticle to test
  33806. * @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)
  33807. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33808. * @returns true if there is an intersection
  33809. */
  33810. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33811. /**
  33812. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33813. * @param point defines the point to test
  33814. * @returns true if there is an intersection
  33815. */
  33816. intersectsPoint(point: Vector3): boolean;
  33817. /**
  33818. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33819. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33820. */
  33821. get checkCollisions(): boolean;
  33822. set checkCollisions(collisionEnabled: boolean);
  33823. /**
  33824. * Gets Collider object used to compute collisions (not physics)
  33825. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33826. */
  33827. get collider(): Nullable<Collider>;
  33828. /**
  33829. * Move the mesh using collision engine
  33830. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33831. * @param displacement defines the requested displacement vector
  33832. * @returns the current mesh
  33833. */
  33834. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33835. private _onCollisionPositionChange;
  33836. /** @hidden */
  33837. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33838. /** @hidden */
  33839. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33840. /** @hidden */
  33841. _checkCollision(collider: Collider): AbstractMesh;
  33842. /** @hidden */
  33843. _generatePointsArray(): boolean;
  33844. /**
  33845. * Checks if the passed Ray intersects with the mesh
  33846. * @param ray defines the ray to use
  33847. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33848. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33849. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33850. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33851. * @returns the picking info
  33852. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33853. */
  33854. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33855. /**
  33856. * Clones the current mesh
  33857. * @param name defines the mesh name
  33858. * @param newParent defines the new mesh parent
  33859. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33860. * @returns the new mesh
  33861. */
  33862. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33863. /**
  33864. * Disposes all the submeshes of the current meshnp
  33865. * @returns the current mesh
  33866. */
  33867. releaseSubMeshes(): AbstractMesh;
  33868. /**
  33869. * Releases resources associated with this abstract mesh.
  33870. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33871. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33872. */
  33873. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33874. /**
  33875. * Adds the passed mesh as a child to the current mesh
  33876. * @param mesh defines the child mesh
  33877. * @returns the current mesh
  33878. */
  33879. addChild(mesh: AbstractMesh): AbstractMesh;
  33880. /**
  33881. * Removes the passed mesh from the current mesh children list
  33882. * @param mesh defines the child mesh
  33883. * @returns the current mesh
  33884. */
  33885. removeChild(mesh: AbstractMesh): AbstractMesh;
  33886. /** @hidden */
  33887. private _initFacetData;
  33888. /**
  33889. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33890. * This method can be called within the render loop.
  33891. * 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
  33892. * @returns the current mesh
  33893. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33894. */
  33895. updateFacetData(): AbstractMesh;
  33896. /**
  33897. * Returns the facetLocalNormals array.
  33898. * The normals are expressed in the mesh local spac
  33899. * @returns an array of Vector3
  33900. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33901. */
  33902. getFacetLocalNormals(): Vector3[];
  33903. /**
  33904. * Returns the facetLocalPositions array.
  33905. * The facet positions are expressed in the mesh local space
  33906. * @returns an array of Vector3
  33907. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33908. */
  33909. getFacetLocalPositions(): Vector3[];
  33910. /**
  33911. * Returns the facetLocalPartioning array
  33912. * @returns an array of array of numbers
  33913. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33914. */
  33915. getFacetLocalPartitioning(): number[][];
  33916. /**
  33917. * Returns the i-th facet position in the world system.
  33918. * This method allocates a new Vector3 per call
  33919. * @param i defines the facet index
  33920. * @returns a new Vector3
  33921. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33922. */
  33923. getFacetPosition(i: number): Vector3;
  33924. /**
  33925. * Sets the reference Vector3 with the i-th facet position in the world system
  33926. * @param i defines the facet index
  33927. * @param ref defines the target vector
  33928. * @returns the current mesh
  33929. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33930. */
  33931. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  33932. /**
  33933. * Returns the i-th facet normal in the world system.
  33934. * This method allocates a new Vector3 per call
  33935. * @param i defines the facet index
  33936. * @returns a new Vector3
  33937. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33938. */
  33939. getFacetNormal(i: number): Vector3;
  33940. /**
  33941. * Sets the reference Vector3 with the i-th facet normal in the world system
  33942. * @param i defines the facet index
  33943. * @param ref defines the target vector
  33944. * @returns the current mesh
  33945. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33946. */
  33947. getFacetNormalToRef(i: number, ref: Vector3): this;
  33948. /**
  33949. * 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)
  33950. * @param x defines x coordinate
  33951. * @param y defines y coordinate
  33952. * @param z defines z coordinate
  33953. * @returns the array of facet indexes
  33954. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33955. */
  33956. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  33957. /**
  33958. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  33959. * @param projected sets as the (x,y,z) world projection on the facet
  33960. * @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
  33961. * @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
  33962. * @param x defines x coordinate
  33963. * @param y defines y coordinate
  33964. * @param z defines z coordinate
  33965. * @returns the face index if found (or null instead)
  33966. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33967. */
  33968. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33969. /**
  33970. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  33971. * @param projected sets as the (x,y,z) local projection on the facet
  33972. * @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
  33973. * @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
  33974. * @param x defines x coordinate
  33975. * @param y defines y coordinate
  33976. * @param z defines z coordinate
  33977. * @returns the face index if found (or null instead)
  33978. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33979. */
  33980. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33981. /**
  33982. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  33983. * @returns the parameters
  33984. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33985. */
  33986. getFacetDataParameters(): any;
  33987. /**
  33988. * Disables the feature FacetData and frees the related memory
  33989. * @returns the current mesh
  33990. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33991. */
  33992. disableFacetData(): AbstractMesh;
  33993. /**
  33994. * Updates the AbstractMesh indices array
  33995. * @param indices defines the data source
  33996. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33997. * @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)
  33998. * @returns the current mesh
  33999. */
  34000. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34001. /**
  34002. * Creates new normals data for the mesh
  34003. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  34004. * @returns the current mesh
  34005. */
  34006. createNormals(updatable: boolean): AbstractMesh;
  34007. /**
  34008. * Align the mesh with a normal
  34009. * @param normal defines the normal to use
  34010. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  34011. * @returns the current mesh
  34012. */
  34013. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  34014. /** @hidden */
  34015. _checkOcclusionQuery(): boolean;
  34016. /**
  34017. * Disables the mesh edge rendering mode
  34018. * @returns the currentAbstractMesh
  34019. */
  34020. disableEdgesRendering(): AbstractMesh;
  34021. /**
  34022. * Enables the edge rendering mode on the mesh.
  34023. * This mode makes the mesh edges visible
  34024. * @param epsilon defines the maximal distance between two angles to detect a face
  34025. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34026. * @returns the currentAbstractMesh
  34027. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34028. */
  34029. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34030. /**
  34031. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  34032. * @returns an array of particle systems in the scene that use the mesh as an emitter
  34033. */
  34034. getConnectedParticleSystems(): IParticleSystem[];
  34035. }
  34036. }
  34037. declare module "babylonjs/Actions/actionEvent" {
  34038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34039. import { Nullable } from "babylonjs/types";
  34040. import { Sprite } from "babylonjs/Sprites/sprite";
  34041. import { Scene } from "babylonjs/scene";
  34042. import { Vector2 } from "babylonjs/Maths/math.vector";
  34043. /**
  34044. * Interface used to define ActionEvent
  34045. */
  34046. export interface IActionEvent {
  34047. /** The mesh or sprite that triggered the action */
  34048. source: any;
  34049. /** The X mouse cursor position at the time of the event */
  34050. pointerX: number;
  34051. /** The Y mouse cursor position at the time of the event */
  34052. pointerY: number;
  34053. /** The mesh that is currently pointed at (can be null) */
  34054. meshUnderPointer: Nullable<AbstractMesh>;
  34055. /** the original (browser) event that triggered the ActionEvent */
  34056. sourceEvent?: any;
  34057. /** additional data for the event */
  34058. additionalData?: any;
  34059. }
  34060. /**
  34061. * ActionEvent is the event being sent when an action is triggered.
  34062. */
  34063. export class ActionEvent implements IActionEvent {
  34064. /** The mesh or sprite that triggered the action */
  34065. source: any;
  34066. /** The X mouse cursor position at the time of the event */
  34067. pointerX: number;
  34068. /** The Y mouse cursor position at the time of the event */
  34069. pointerY: number;
  34070. /** The mesh that is currently pointed at (can be null) */
  34071. meshUnderPointer: Nullable<AbstractMesh>;
  34072. /** the original (browser) event that triggered the ActionEvent */
  34073. sourceEvent?: any;
  34074. /** additional data for the event */
  34075. additionalData?: any;
  34076. /**
  34077. * Creates a new ActionEvent
  34078. * @param source The mesh or sprite that triggered the action
  34079. * @param pointerX The X mouse cursor position at the time of the event
  34080. * @param pointerY The Y mouse cursor position at the time of the event
  34081. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  34082. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  34083. * @param additionalData additional data for the event
  34084. */
  34085. constructor(
  34086. /** The mesh or sprite that triggered the action */
  34087. source: any,
  34088. /** The X mouse cursor position at the time of the event */
  34089. pointerX: number,
  34090. /** The Y mouse cursor position at the time of the event */
  34091. pointerY: number,
  34092. /** The mesh that is currently pointed at (can be null) */
  34093. meshUnderPointer: Nullable<AbstractMesh>,
  34094. /** the original (browser) event that triggered the ActionEvent */
  34095. sourceEvent?: any,
  34096. /** additional data for the event */
  34097. additionalData?: any);
  34098. /**
  34099. * Helper function to auto-create an ActionEvent from a source mesh.
  34100. * @param source The source mesh that triggered the event
  34101. * @param evt The original (browser) event
  34102. * @param additionalData additional data for the event
  34103. * @returns the new ActionEvent
  34104. */
  34105. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  34106. /**
  34107. * Helper function to auto-create an ActionEvent from a source sprite
  34108. * @param source The source sprite that triggered the event
  34109. * @param scene Scene associated with the sprite
  34110. * @param evt The original (browser) event
  34111. * @param additionalData additional data for the event
  34112. * @returns the new ActionEvent
  34113. */
  34114. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  34115. /**
  34116. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  34117. * @param scene the scene where the event occurred
  34118. * @param evt The original (browser) event
  34119. * @returns the new ActionEvent
  34120. */
  34121. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  34122. /**
  34123. * Helper function to auto-create an ActionEvent from a primitive
  34124. * @param prim defines the target primitive
  34125. * @param pointerPos defines the pointer position
  34126. * @param evt The original (browser) event
  34127. * @param additionalData additional data for the event
  34128. * @returns the new ActionEvent
  34129. */
  34130. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  34131. }
  34132. }
  34133. declare module "babylonjs/Actions/abstractActionManager" {
  34134. import { IDisposable } from "babylonjs/scene";
  34135. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  34136. import { IAction } from "babylonjs/Actions/action";
  34137. import { Nullable } from "babylonjs/types";
  34138. /**
  34139. * Abstract class used to decouple action Manager from scene and meshes.
  34140. * Do not instantiate.
  34141. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  34142. */
  34143. export abstract class AbstractActionManager implements IDisposable {
  34144. /** Gets the list of active triggers */
  34145. static Triggers: {
  34146. [key: string]: number;
  34147. };
  34148. /** Gets the cursor to use when hovering items */
  34149. hoverCursor: string;
  34150. /** Gets the list of actions */
  34151. actions: IAction[];
  34152. /**
  34153. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  34154. */
  34155. isRecursive: boolean;
  34156. /**
  34157. * Releases all associated resources
  34158. */
  34159. abstract dispose(): void;
  34160. /**
  34161. * Does this action manager has pointer triggers
  34162. */
  34163. abstract get hasPointerTriggers(): boolean;
  34164. /**
  34165. * Does this action manager has pick triggers
  34166. */
  34167. abstract get hasPickTriggers(): boolean;
  34168. /**
  34169. * Process a specific trigger
  34170. * @param trigger defines the trigger to process
  34171. * @param evt defines the event details to be processed
  34172. */
  34173. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  34174. /**
  34175. * Does this action manager handles actions of any of the given triggers
  34176. * @param triggers defines the triggers to be tested
  34177. * @return a boolean indicating whether one (or more) of the triggers is handled
  34178. */
  34179. abstract hasSpecificTriggers(triggers: number[]): boolean;
  34180. /**
  34181. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  34182. * speed.
  34183. * @param triggerA defines the trigger to be tested
  34184. * @param triggerB defines the trigger to be tested
  34185. * @return a boolean indicating whether one (or more) of the triggers is handled
  34186. */
  34187. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  34188. /**
  34189. * Does this action manager handles actions of a given trigger
  34190. * @param trigger defines the trigger to be tested
  34191. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  34192. * @return whether the trigger is handled
  34193. */
  34194. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  34195. /**
  34196. * Serialize this manager to a JSON object
  34197. * @param name defines the property name to store this manager
  34198. * @returns a JSON representation of this manager
  34199. */
  34200. abstract serialize(name: string): any;
  34201. /**
  34202. * Registers an action to this action manager
  34203. * @param action defines the action to be registered
  34204. * @return the action amended (prepared) after registration
  34205. */
  34206. abstract registerAction(action: IAction): Nullable<IAction>;
  34207. /**
  34208. * Unregisters an action to this action manager
  34209. * @param action defines the action to be unregistered
  34210. * @return a boolean indicating whether the action has been unregistered
  34211. */
  34212. abstract unregisterAction(action: IAction): Boolean;
  34213. /**
  34214. * Does exist one action manager with at least one trigger
  34215. **/
  34216. static get HasTriggers(): boolean;
  34217. /**
  34218. * Does exist one action manager with at least one pick trigger
  34219. **/
  34220. static get HasPickTriggers(): boolean;
  34221. /**
  34222. * Does exist one action manager that handles actions of a given trigger
  34223. * @param trigger defines the trigger to be tested
  34224. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  34225. **/
  34226. static HasSpecificTrigger(trigger: number): boolean;
  34227. }
  34228. }
  34229. declare module "babylonjs/node" {
  34230. import { Scene } from "babylonjs/scene";
  34231. import { Nullable } from "babylonjs/types";
  34232. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  34233. import { Engine } from "babylonjs/Engines/engine";
  34234. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  34235. import { Observable } from "babylonjs/Misc/observable";
  34236. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34237. import { IInspectable } from "babylonjs/Misc/iInspectable";
  34238. import { Animatable } from "babylonjs/Animations/animatable";
  34239. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34240. import { Animation } from "babylonjs/Animations/animation";
  34241. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34243. /**
  34244. * Defines how a node can be built from a string name.
  34245. */
  34246. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  34247. /**
  34248. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  34249. */
  34250. export class Node implements IBehaviorAware<Node> {
  34251. /** @hidden */
  34252. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  34253. private static _NodeConstructors;
  34254. /**
  34255. * Add a new node constructor
  34256. * @param type defines the type name of the node to construct
  34257. * @param constructorFunc defines the constructor function
  34258. */
  34259. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  34260. /**
  34261. * Returns a node constructor based on type name
  34262. * @param type defines the type name
  34263. * @param name defines the new node name
  34264. * @param scene defines the hosting scene
  34265. * @param options defines optional options to transmit to constructors
  34266. * @returns the new constructor or null
  34267. */
  34268. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34269. /**
  34270. * Gets or sets the name of the node
  34271. */
  34272. name: string;
  34273. /**
  34274. * Gets or sets the id of the node
  34275. */
  34276. id: string;
  34277. /**
  34278. * Gets or sets the unique id of the node
  34279. */
  34280. uniqueId: number;
  34281. /**
  34282. * Gets or sets a string used to store user defined state for the node
  34283. */
  34284. state: string;
  34285. /**
  34286. * Gets or sets an object used to store user defined information for the node
  34287. */
  34288. metadata: any;
  34289. /**
  34290. * For internal use only. Please do not use.
  34291. */
  34292. reservedDataStore: any;
  34293. /**
  34294. * List of inspectable custom properties (used by the Inspector)
  34295. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34296. */
  34297. inspectableCustomProperties: IInspectable[];
  34298. private _doNotSerialize;
  34299. /**
  34300. * Gets or sets a boolean used to define if the node must be serialized
  34301. */
  34302. get doNotSerialize(): boolean;
  34303. set doNotSerialize(value: boolean);
  34304. /** @hidden */
  34305. _isDisposed: boolean;
  34306. /**
  34307. * Gets a list of Animations associated with the node
  34308. */
  34309. animations: import("babylonjs/Animations/animation").Animation[];
  34310. protected _ranges: {
  34311. [name: string]: Nullable<AnimationRange>;
  34312. };
  34313. /**
  34314. * Callback raised when the node is ready to be used
  34315. */
  34316. onReady: Nullable<(node: Node) => void>;
  34317. private _isEnabled;
  34318. private _isParentEnabled;
  34319. private _isReady;
  34320. /** @hidden */
  34321. _currentRenderId: number;
  34322. private _parentUpdateId;
  34323. /** @hidden */
  34324. _childUpdateId: number;
  34325. /** @hidden */
  34326. _waitingParentId: Nullable<string>;
  34327. /** @hidden */
  34328. _scene: Scene;
  34329. /** @hidden */
  34330. _cache: any;
  34331. private _parentNode;
  34332. private _children;
  34333. /** @hidden */
  34334. _worldMatrix: Matrix;
  34335. /** @hidden */
  34336. _worldMatrixDeterminant: number;
  34337. /** @hidden */
  34338. _worldMatrixDeterminantIsDirty: boolean;
  34339. /** @hidden */
  34340. private _sceneRootNodesIndex;
  34341. /**
  34342. * Gets a boolean indicating if the node has been disposed
  34343. * @returns true if the node was disposed
  34344. */
  34345. isDisposed(): boolean;
  34346. /**
  34347. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34348. * @see https://doc.babylonjs.com/how_to/parenting
  34349. */
  34350. set parent(parent: Nullable<Node>);
  34351. get parent(): Nullable<Node>;
  34352. /** @hidden */
  34353. _addToSceneRootNodes(): void;
  34354. /** @hidden */
  34355. _removeFromSceneRootNodes(): void;
  34356. private _animationPropertiesOverride;
  34357. /**
  34358. * Gets or sets the animation properties override
  34359. */
  34360. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34361. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34362. /**
  34363. * Gets a string identifying the name of the class
  34364. * @returns "Node" string
  34365. */
  34366. getClassName(): string;
  34367. /** @hidden */
  34368. readonly _isNode: boolean;
  34369. /**
  34370. * An event triggered when the mesh is disposed
  34371. */
  34372. onDisposeObservable: Observable<Node>;
  34373. private _onDisposeObserver;
  34374. /**
  34375. * Sets a callback that will be raised when the node will be disposed
  34376. */
  34377. set onDispose(callback: () => void);
  34378. /**
  34379. * Creates a new Node
  34380. * @param name the name and id to be given to this node
  34381. * @param scene the scene this node will be added to
  34382. */
  34383. constructor(name: string, scene?: Nullable<Scene>);
  34384. /**
  34385. * Gets the scene of the node
  34386. * @returns a scene
  34387. */
  34388. getScene(): Scene;
  34389. /**
  34390. * Gets the engine of the node
  34391. * @returns a Engine
  34392. */
  34393. getEngine(): Engine;
  34394. private _behaviors;
  34395. /**
  34396. * Attach a behavior to the node
  34397. * @see https://doc.babylonjs.com/features/behaviour
  34398. * @param behavior defines the behavior to attach
  34399. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34400. * @returns the current Node
  34401. */
  34402. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34403. /**
  34404. * Remove an attached behavior
  34405. * @see https://doc.babylonjs.com/features/behaviour
  34406. * @param behavior defines the behavior to attach
  34407. * @returns the current Node
  34408. */
  34409. removeBehavior(behavior: Behavior<Node>): Node;
  34410. /**
  34411. * Gets the list of attached behaviors
  34412. * @see https://doc.babylonjs.com/features/behaviour
  34413. */
  34414. get behaviors(): Behavior<Node>[];
  34415. /**
  34416. * Gets an attached behavior by name
  34417. * @param name defines the name of the behavior to look for
  34418. * @see https://doc.babylonjs.com/features/behaviour
  34419. * @returns null if behavior was not found else the requested behavior
  34420. */
  34421. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34422. /**
  34423. * Returns the latest update of the World matrix
  34424. * @returns a Matrix
  34425. */
  34426. getWorldMatrix(): Matrix;
  34427. /** @hidden */
  34428. _getWorldMatrixDeterminant(): number;
  34429. /**
  34430. * Returns directly the latest state of the mesh World matrix.
  34431. * A Matrix is returned.
  34432. */
  34433. get worldMatrixFromCache(): Matrix;
  34434. /** @hidden */
  34435. _initCache(): void;
  34436. /** @hidden */
  34437. updateCache(force?: boolean): void;
  34438. /** @hidden */
  34439. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34440. /** @hidden */
  34441. _updateCache(ignoreParentClass?: boolean): void;
  34442. /** @hidden */
  34443. _isSynchronized(): boolean;
  34444. /** @hidden */
  34445. _markSyncedWithParent(): void;
  34446. /** @hidden */
  34447. isSynchronizedWithParent(): boolean;
  34448. /** @hidden */
  34449. isSynchronized(): boolean;
  34450. /**
  34451. * Is this node ready to be used/rendered
  34452. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34453. * @return true if the node is ready
  34454. */
  34455. isReady(completeCheck?: boolean): boolean;
  34456. /**
  34457. * Is this node enabled?
  34458. * 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
  34459. * @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
  34460. * @return whether this node (and its parent) is enabled
  34461. */
  34462. isEnabled(checkAncestors?: boolean): boolean;
  34463. /** @hidden */
  34464. protected _syncParentEnabledState(): void;
  34465. /**
  34466. * Set the enabled state of this node
  34467. * @param value defines the new enabled state
  34468. */
  34469. setEnabled(value: boolean): void;
  34470. /**
  34471. * Is this node a descendant of the given node?
  34472. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34473. * @param ancestor defines the parent node to inspect
  34474. * @returns a boolean indicating if this node is a descendant of the given node
  34475. */
  34476. isDescendantOf(ancestor: Node): boolean;
  34477. /** @hidden */
  34478. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34479. /**
  34480. * Will return all nodes that have this node as ascendant
  34481. * @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
  34482. * @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
  34483. * @return all children nodes of all types
  34484. */
  34485. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34486. /**
  34487. * Get all child-meshes of this node
  34488. * @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)
  34489. * @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
  34490. * @returns an array of AbstractMesh
  34491. */
  34492. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34493. /**
  34494. * Get all direct children of this node
  34495. * @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
  34496. * @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)
  34497. * @returns an array of Node
  34498. */
  34499. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34500. /** @hidden */
  34501. _setReady(state: boolean): void;
  34502. /**
  34503. * Get an animation by name
  34504. * @param name defines the name of the animation to look for
  34505. * @returns null if not found else the requested animation
  34506. */
  34507. getAnimationByName(name: string): Nullable<Animation>;
  34508. /**
  34509. * Creates an animation range for this node
  34510. * @param name defines the name of the range
  34511. * @param from defines the starting key
  34512. * @param to defines the end key
  34513. */
  34514. createAnimationRange(name: string, from: number, to: number): void;
  34515. /**
  34516. * Delete a specific animation range
  34517. * @param name defines the name of the range to delete
  34518. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34519. */
  34520. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34521. /**
  34522. * Get an animation range by name
  34523. * @param name defines the name of the animation range to look for
  34524. * @returns null if not found else the requested animation range
  34525. */
  34526. getAnimationRange(name: string): Nullable<AnimationRange>;
  34527. /**
  34528. * Gets the list of all animation ranges defined on this node
  34529. * @returns an array
  34530. */
  34531. getAnimationRanges(): Nullable<AnimationRange>[];
  34532. /**
  34533. * Will start the animation sequence
  34534. * @param name defines the range frames for animation sequence
  34535. * @param loop defines if the animation should loop (false by default)
  34536. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34537. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34538. * @returns the object created for this animation. If range does not exist, it will return null
  34539. */
  34540. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34541. /**
  34542. * Serialize animation ranges into a JSON compatible object
  34543. * @returns serialization object
  34544. */
  34545. serializeAnimationRanges(): any;
  34546. /**
  34547. * Computes the world matrix of the node
  34548. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34549. * @returns the world matrix
  34550. */
  34551. computeWorldMatrix(force?: boolean): Matrix;
  34552. /**
  34553. * Releases resources associated with this node.
  34554. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34555. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34556. */
  34557. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34558. /**
  34559. * Parse animation range data from a serialization object and store them into a given node
  34560. * @param node defines where to store the animation ranges
  34561. * @param parsedNode defines the serialization object to read data from
  34562. * @param scene defines the hosting scene
  34563. */
  34564. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34565. /**
  34566. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34567. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34568. * @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
  34569. * @returns the new bounding vectors
  34570. */
  34571. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34572. min: Vector3;
  34573. max: Vector3;
  34574. };
  34575. }
  34576. }
  34577. declare module "babylonjs/Animations/animation" {
  34578. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34579. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34580. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34581. import { Nullable } from "babylonjs/types";
  34582. import { Scene } from "babylonjs/scene";
  34583. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34584. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34585. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34586. import { Node } from "babylonjs/node";
  34587. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34588. import { Size } from "babylonjs/Maths/math.size";
  34589. import { Animatable } from "babylonjs/Animations/animatable";
  34590. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34591. /**
  34592. * @hidden
  34593. */
  34594. export class _IAnimationState {
  34595. key: number;
  34596. repeatCount: number;
  34597. workValue?: any;
  34598. loopMode?: number;
  34599. offsetValue?: any;
  34600. highLimitValue?: any;
  34601. }
  34602. /**
  34603. * Class used to store any kind of animation
  34604. */
  34605. export class Animation {
  34606. /**Name of the animation */
  34607. name: string;
  34608. /**Property to animate */
  34609. targetProperty: string;
  34610. /**The frames per second of the animation */
  34611. framePerSecond: number;
  34612. /**The data type of the animation */
  34613. dataType: number;
  34614. /**The loop mode of the animation */
  34615. loopMode?: number | undefined;
  34616. /**Specifies if blending should be enabled */
  34617. enableBlending?: boolean | undefined;
  34618. /**
  34619. * Use matrix interpolation instead of using direct key value when animating matrices
  34620. */
  34621. static AllowMatricesInterpolation: boolean;
  34622. /**
  34623. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34624. */
  34625. static AllowMatrixDecomposeForInterpolation: boolean;
  34626. /** Define the Url to load snippets */
  34627. static SnippetUrl: string;
  34628. /** Snippet ID if the animation was created from the snippet server */
  34629. snippetId: string;
  34630. /**
  34631. * Stores the key frames of the animation
  34632. */
  34633. private _keys;
  34634. /**
  34635. * Stores the easing function of the animation
  34636. */
  34637. private _easingFunction;
  34638. /**
  34639. * @hidden Internal use only
  34640. */
  34641. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34642. /**
  34643. * The set of event that will be linked to this animation
  34644. */
  34645. private _events;
  34646. /**
  34647. * Stores an array of target property paths
  34648. */
  34649. targetPropertyPath: string[];
  34650. /**
  34651. * Stores the blending speed of the animation
  34652. */
  34653. blendingSpeed: number;
  34654. /**
  34655. * Stores the animation ranges for the animation
  34656. */
  34657. private _ranges;
  34658. /**
  34659. * @hidden Internal use
  34660. */
  34661. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34662. /**
  34663. * Sets up an animation
  34664. * @param property The property to animate
  34665. * @param animationType The animation type to apply
  34666. * @param framePerSecond The frames per second of the animation
  34667. * @param easingFunction The easing function used in the animation
  34668. * @returns The created animation
  34669. */
  34670. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34671. /**
  34672. * Create and start an animation on a node
  34673. * @param name defines the name of the global animation that will be run on all nodes
  34674. * @param node defines the root node where the animation will take place
  34675. * @param targetProperty defines property to animate
  34676. * @param framePerSecond defines the number of frame per second yo use
  34677. * @param totalFrame defines the number of frames in total
  34678. * @param from defines the initial value
  34679. * @param to defines the final value
  34680. * @param loopMode defines which loop mode you want to use (off by default)
  34681. * @param easingFunction defines the easing function to use (linear by default)
  34682. * @param onAnimationEnd defines the callback to call when animation end
  34683. * @returns the animatable created for this animation
  34684. */
  34685. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34686. /**
  34687. * Create and start an animation on a node and its descendants
  34688. * @param name defines the name of the global animation that will be run on all nodes
  34689. * @param node defines the root node where the animation will take place
  34690. * @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
  34691. * @param targetProperty defines property to animate
  34692. * @param framePerSecond defines the number of frame per second to use
  34693. * @param totalFrame defines the number of frames in total
  34694. * @param from defines the initial value
  34695. * @param to defines the final value
  34696. * @param loopMode defines which loop mode you want to use (off by default)
  34697. * @param easingFunction defines the easing function to use (linear by default)
  34698. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34699. * @returns the list of animatables created for all nodes
  34700. * @example https://www.babylonjs-playground.com/#MH0VLI
  34701. */
  34702. 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[]>;
  34703. /**
  34704. * Creates a new animation, merges it with the existing animations and starts it
  34705. * @param name Name of the animation
  34706. * @param node Node which contains the scene that begins the animations
  34707. * @param targetProperty Specifies which property to animate
  34708. * @param framePerSecond The frames per second of the animation
  34709. * @param totalFrame The total number of frames
  34710. * @param from The frame at the beginning of the animation
  34711. * @param to The frame at the end of the animation
  34712. * @param loopMode Specifies the loop mode of the animation
  34713. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34714. * @param onAnimationEnd Callback to run once the animation is complete
  34715. * @returns Nullable animation
  34716. */
  34717. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34718. /**
  34719. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34720. * @param sourceAnimation defines the Animation containing keyframes to convert
  34721. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34722. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34723. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34724. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34725. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34726. */
  34727. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34728. /**
  34729. * Transition property of an host to the target Value
  34730. * @param property The property to transition
  34731. * @param targetValue The target Value of the property
  34732. * @param host The object where the property to animate belongs
  34733. * @param scene Scene used to run the animation
  34734. * @param frameRate Framerate (in frame/s) to use
  34735. * @param transition The transition type we want to use
  34736. * @param duration The duration of the animation, in milliseconds
  34737. * @param onAnimationEnd Callback trigger at the end of the animation
  34738. * @returns Nullable animation
  34739. */
  34740. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34741. /**
  34742. * Return the array of runtime animations currently using this animation
  34743. */
  34744. get runtimeAnimations(): RuntimeAnimation[];
  34745. /**
  34746. * Specifies if any of the runtime animations are currently running
  34747. */
  34748. get hasRunningRuntimeAnimations(): boolean;
  34749. /**
  34750. * Initializes the animation
  34751. * @param name Name of the animation
  34752. * @param targetProperty Property to animate
  34753. * @param framePerSecond The frames per second of the animation
  34754. * @param dataType The data type of the animation
  34755. * @param loopMode The loop mode of the animation
  34756. * @param enableBlending Specifies if blending should be enabled
  34757. */
  34758. constructor(
  34759. /**Name of the animation */
  34760. name: string,
  34761. /**Property to animate */
  34762. targetProperty: string,
  34763. /**The frames per second of the animation */
  34764. framePerSecond: number,
  34765. /**The data type of the animation */
  34766. dataType: number,
  34767. /**The loop mode of the animation */
  34768. loopMode?: number | undefined,
  34769. /**Specifies if blending should be enabled */
  34770. enableBlending?: boolean | undefined);
  34771. /**
  34772. * Converts the animation to a string
  34773. * @param fullDetails support for multiple levels of logging within scene loading
  34774. * @returns String form of the animation
  34775. */
  34776. toString(fullDetails?: boolean): string;
  34777. /**
  34778. * Add an event to this animation
  34779. * @param event Event to add
  34780. */
  34781. addEvent(event: AnimationEvent): void;
  34782. /**
  34783. * Remove all events found at the given frame
  34784. * @param frame The frame to remove events from
  34785. */
  34786. removeEvents(frame: number): void;
  34787. /**
  34788. * Retrieves all the events from the animation
  34789. * @returns Events from the animation
  34790. */
  34791. getEvents(): AnimationEvent[];
  34792. /**
  34793. * Creates an animation range
  34794. * @param name Name of the animation range
  34795. * @param from Starting frame of the animation range
  34796. * @param to Ending frame of the animation
  34797. */
  34798. createRange(name: string, from: number, to: number): void;
  34799. /**
  34800. * Deletes an animation range by name
  34801. * @param name Name of the animation range to delete
  34802. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34803. */
  34804. deleteRange(name: string, deleteFrames?: boolean): void;
  34805. /**
  34806. * Gets the animation range by name, or null if not defined
  34807. * @param name Name of the animation range
  34808. * @returns Nullable animation range
  34809. */
  34810. getRange(name: string): Nullable<AnimationRange>;
  34811. /**
  34812. * Gets the key frames from the animation
  34813. * @returns The key frames of the animation
  34814. */
  34815. getKeys(): Array<IAnimationKey>;
  34816. /**
  34817. * Gets the highest frame rate of the animation
  34818. * @returns Highest frame rate of the animation
  34819. */
  34820. getHighestFrame(): number;
  34821. /**
  34822. * Gets the easing function of the animation
  34823. * @returns Easing function of the animation
  34824. */
  34825. getEasingFunction(): IEasingFunction;
  34826. /**
  34827. * Sets the easing function of the animation
  34828. * @param easingFunction A custom mathematical formula for animation
  34829. */
  34830. setEasingFunction(easingFunction: EasingFunction): void;
  34831. /**
  34832. * Interpolates a scalar linearly
  34833. * @param startValue Start value of the animation curve
  34834. * @param endValue End value of the animation curve
  34835. * @param gradient Scalar amount to interpolate
  34836. * @returns Interpolated scalar value
  34837. */
  34838. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34839. /**
  34840. * Interpolates a scalar cubically
  34841. * @param startValue Start value of the animation curve
  34842. * @param outTangent End tangent of the animation
  34843. * @param endValue End value of the animation curve
  34844. * @param inTangent Start tangent of the animation curve
  34845. * @param gradient Scalar amount to interpolate
  34846. * @returns Interpolated scalar value
  34847. */
  34848. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34849. /**
  34850. * Interpolates a quaternion using a spherical linear interpolation
  34851. * @param startValue Start value of the animation curve
  34852. * @param endValue End value of the animation curve
  34853. * @param gradient Scalar amount to interpolate
  34854. * @returns Interpolated quaternion value
  34855. */
  34856. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34857. /**
  34858. * Interpolates a quaternion cubically
  34859. * @param startValue Start value of the animation curve
  34860. * @param outTangent End tangent of the animation curve
  34861. * @param endValue End value of the animation curve
  34862. * @param inTangent Start tangent of the animation curve
  34863. * @param gradient Scalar amount to interpolate
  34864. * @returns Interpolated quaternion value
  34865. */
  34866. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34867. /**
  34868. * Interpolates a Vector3 linearl
  34869. * @param startValue Start value of the animation curve
  34870. * @param endValue End value of the animation curve
  34871. * @param gradient Scalar amount to interpolate
  34872. * @returns Interpolated scalar value
  34873. */
  34874. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34875. /**
  34876. * Interpolates a Vector3 cubically
  34877. * @param startValue Start value of the animation curve
  34878. * @param outTangent End tangent of the animation
  34879. * @param endValue End value of the animation curve
  34880. * @param inTangent Start tangent of the animation curve
  34881. * @param gradient Scalar amount to interpolate
  34882. * @returns InterpolatedVector3 value
  34883. */
  34884. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34885. /**
  34886. * Interpolates a Vector2 linearly
  34887. * @param startValue Start value of the animation curve
  34888. * @param endValue End value of the animation curve
  34889. * @param gradient Scalar amount to interpolate
  34890. * @returns Interpolated Vector2 value
  34891. */
  34892. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34893. /**
  34894. * Interpolates a Vector2 cubically
  34895. * @param startValue Start value of the animation curve
  34896. * @param outTangent End tangent of the animation
  34897. * @param endValue End value of the animation curve
  34898. * @param inTangent Start tangent of the animation curve
  34899. * @param gradient Scalar amount to interpolate
  34900. * @returns Interpolated Vector2 value
  34901. */
  34902. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34903. /**
  34904. * Interpolates a size linearly
  34905. * @param startValue Start value of the animation curve
  34906. * @param endValue End value of the animation curve
  34907. * @param gradient Scalar amount to interpolate
  34908. * @returns Interpolated Size value
  34909. */
  34910. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34911. /**
  34912. * Interpolates a Color3 linearly
  34913. * @param startValue Start value of the animation curve
  34914. * @param endValue End value of the animation curve
  34915. * @param gradient Scalar amount to interpolate
  34916. * @returns Interpolated Color3 value
  34917. */
  34918. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34919. /**
  34920. * Interpolates a Color4 linearly
  34921. * @param startValue Start value of the animation curve
  34922. * @param endValue End value of the animation curve
  34923. * @param gradient Scalar amount to interpolate
  34924. * @returns Interpolated Color3 value
  34925. */
  34926. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34927. /**
  34928. * @hidden Internal use only
  34929. */
  34930. _getKeyValue(value: any): any;
  34931. /**
  34932. * @hidden Internal use only
  34933. */
  34934. _interpolate(currentFrame: number, state: _IAnimationState): any;
  34935. /**
  34936. * Defines the function to use to interpolate matrices
  34937. * @param startValue defines the start matrix
  34938. * @param endValue defines the end matrix
  34939. * @param gradient defines the gradient between both matrices
  34940. * @param result defines an optional target matrix where to store the interpolation
  34941. * @returns the interpolated matrix
  34942. */
  34943. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  34944. /**
  34945. * Makes a copy of the animation
  34946. * @returns Cloned animation
  34947. */
  34948. clone(): Animation;
  34949. /**
  34950. * Sets the key frames of the animation
  34951. * @param values The animation key frames to set
  34952. */
  34953. setKeys(values: Array<IAnimationKey>): void;
  34954. /**
  34955. * Serializes the animation to an object
  34956. * @returns Serialized object
  34957. */
  34958. serialize(): any;
  34959. /**
  34960. * Float animation type
  34961. */
  34962. static readonly ANIMATIONTYPE_FLOAT: number;
  34963. /**
  34964. * Vector3 animation type
  34965. */
  34966. static readonly ANIMATIONTYPE_VECTOR3: number;
  34967. /**
  34968. * Quaternion animation type
  34969. */
  34970. static readonly ANIMATIONTYPE_QUATERNION: number;
  34971. /**
  34972. * Matrix animation type
  34973. */
  34974. static readonly ANIMATIONTYPE_MATRIX: number;
  34975. /**
  34976. * Color3 animation type
  34977. */
  34978. static readonly ANIMATIONTYPE_COLOR3: number;
  34979. /**
  34980. * Color3 animation type
  34981. */
  34982. static readonly ANIMATIONTYPE_COLOR4: number;
  34983. /**
  34984. * Vector2 animation type
  34985. */
  34986. static readonly ANIMATIONTYPE_VECTOR2: number;
  34987. /**
  34988. * Size animation type
  34989. */
  34990. static readonly ANIMATIONTYPE_SIZE: number;
  34991. /**
  34992. * Relative Loop Mode
  34993. */
  34994. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  34995. /**
  34996. * Cycle Loop Mode
  34997. */
  34998. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  34999. /**
  35000. * Constant Loop Mode
  35001. */
  35002. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  35003. /** @hidden */
  35004. static _UniversalLerp(left: any, right: any, amount: number): any;
  35005. /**
  35006. * Parses an animation object and creates an animation
  35007. * @param parsedAnimation Parsed animation object
  35008. * @returns Animation object
  35009. */
  35010. static Parse(parsedAnimation: any): Animation;
  35011. /**
  35012. * Appends the serialized animations from the source animations
  35013. * @param source Source containing the animations
  35014. * @param destination Target to store the animations
  35015. */
  35016. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35017. /**
  35018. * Creates a new animation or an array of animations from a snippet saved in a remote file
  35019. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  35020. * @param url defines the url to load from
  35021. * @returns a promise that will resolve to the new animation or an array of animations
  35022. */
  35023. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  35024. /**
  35025. * Creates an animation or an array of animations from a snippet saved by the Inspector
  35026. * @param snippetId defines the snippet to load
  35027. * @returns a promise that will resolve to the new animation or a new array of animations
  35028. */
  35029. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  35030. }
  35031. }
  35032. declare module "babylonjs/Animations/animatable.interface" {
  35033. import { Nullable } from "babylonjs/types";
  35034. import { Animation } from "babylonjs/Animations/animation";
  35035. /**
  35036. * Interface containing an array of animations
  35037. */
  35038. export interface IAnimatable {
  35039. /**
  35040. * Array of animations
  35041. */
  35042. animations: Nullable<Array<Animation>>;
  35043. }
  35044. }
  35045. declare module "babylonjs/Misc/decorators" {
  35046. import { Nullable } from "babylonjs/types";
  35047. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35048. import { Scene } from "babylonjs/scene";
  35049. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35050. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  35051. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  35052. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35053. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  35054. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35055. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35056. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35057. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35058. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35059. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35060. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35061. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35062. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35063. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35064. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35065. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35066. /**
  35067. * Decorator used to define property that can be serialized as reference to a camera
  35068. * @param sourceName defines the name of the property to decorate
  35069. */
  35070. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35071. /**
  35072. * Class used to help serialization objects
  35073. */
  35074. export class SerializationHelper {
  35075. /** @hidden */
  35076. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  35077. /** @hidden */
  35078. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  35079. /** @hidden */
  35080. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  35081. /** @hidden */
  35082. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  35083. /**
  35084. * Appends the serialized animations from the source animations
  35085. * @param source Source containing the animations
  35086. * @param destination Target to store the animations
  35087. */
  35088. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35089. /**
  35090. * Static function used to serialized a specific entity
  35091. * @param entity defines the entity to serialize
  35092. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  35093. * @returns a JSON compatible object representing the serialization of the entity
  35094. */
  35095. static Serialize<T>(entity: T, serializationObject?: any): any;
  35096. /**
  35097. * Creates a new entity from a serialization data object
  35098. * @param creationFunction defines a function used to instanciated the new entity
  35099. * @param source defines the source serialization data
  35100. * @param scene defines the hosting scene
  35101. * @param rootUrl defines the root url for resources
  35102. * @returns a new entity
  35103. */
  35104. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  35105. /**
  35106. * Clones an object
  35107. * @param creationFunction defines the function used to instanciate the new object
  35108. * @param source defines the source object
  35109. * @returns the cloned object
  35110. */
  35111. static Clone<T>(creationFunction: () => T, source: T): T;
  35112. /**
  35113. * Instanciates a new object based on a source one (some data will be shared between both object)
  35114. * @param creationFunction defines the function used to instanciate the new object
  35115. * @param source defines the source object
  35116. * @returns the new object
  35117. */
  35118. static Instanciate<T>(creationFunction: () => T, source: T): T;
  35119. }
  35120. }
  35121. declare module "babylonjs/Materials/Textures/baseTexture" {
  35122. import { Observable } from "babylonjs/Misc/observable";
  35123. import { Nullable } from "babylonjs/types";
  35124. import { Scene } from "babylonjs/scene";
  35125. import { Matrix } from "babylonjs/Maths/math.vector";
  35126. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35127. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35128. import { ISize } from "babylonjs/Maths/math.size";
  35129. import "babylonjs/Misc/fileTools";
  35130. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35131. /**
  35132. * Base class of all the textures in babylon.
  35133. * It groups all the common properties the materials, post process, lights... might need
  35134. * in order to make a correct use of the texture.
  35135. */
  35136. export class BaseTexture implements IAnimatable {
  35137. /**
  35138. * Default anisotropic filtering level for the application.
  35139. * It is set to 4 as a good tradeoff between perf and quality.
  35140. */
  35141. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35142. /**
  35143. * Gets or sets the unique id of the texture
  35144. */
  35145. uniqueId: number;
  35146. /**
  35147. * Define the name of the texture.
  35148. */
  35149. name: string;
  35150. /**
  35151. * Gets or sets an object used to store user defined information.
  35152. */
  35153. metadata: any;
  35154. /**
  35155. * For internal use only. Please do not use.
  35156. */
  35157. reservedDataStore: any;
  35158. private _hasAlpha;
  35159. /**
  35160. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  35161. */
  35162. set hasAlpha(value: boolean);
  35163. get hasAlpha(): boolean;
  35164. /**
  35165. * Defines if the alpha value should be determined via the rgb values.
  35166. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  35167. */
  35168. getAlphaFromRGB: boolean;
  35169. /**
  35170. * Intensity or strength of the texture.
  35171. * It is commonly used by materials to fine tune the intensity of the texture
  35172. */
  35173. level: number;
  35174. /**
  35175. * Define the UV chanel to use starting from 0 and defaulting to 0.
  35176. * This is part of the texture as textures usually maps to one uv set.
  35177. */
  35178. coordinatesIndex: number;
  35179. protected _coordinatesMode: number;
  35180. /**
  35181. * How a texture is mapped.
  35182. *
  35183. * | Value | Type | Description |
  35184. * | ----- | ----------------------------------- | ----------- |
  35185. * | 0 | EXPLICIT_MODE | |
  35186. * | 1 | SPHERICAL_MODE | |
  35187. * | 2 | PLANAR_MODE | |
  35188. * | 3 | CUBIC_MODE | |
  35189. * | 4 | PROJECTION_MODE | |
  35190. * | 5 | SKYBOX_MODE | |
  35191. * | 6 | INVCUBIC_MODE | |
  35192. * | 7 | EQUIRECTANGULAR_MODE | |
  35193. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35194. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35195. */
  35196. set coordinatesMode(value: number);
  35197. get coordinatesMode(): number;
  35198. private _wrapU;
  35199. /**
  35200. * | Value | Type | Description |
  35201. * | ----- | ------------------ | ----------- |
  35202. * | 0 | CLAMP_ADDRESSMODE | |
  35203. * | 1 | WRAP_ADDRESSMODE | |
  35204. * | 2 | MIRROR_ADDRESSMODE | |
  35205. */
  35206. get wrapU(): number;
  35207. set wrapU(value: number);
  35208. private _wrapV;
  35209. /**
  35210. * | Value | Type | Description |
  35211. * | ----- | ------------------ | ----------- |
  35212. * | 0 | CLAMP_ADDRESSMODE | |
  35213. * | 1 | WRAP_ADDRESSMODE | |
  35214. * | 2 | MIRROR_ADDRESSMODE | |
  35215. */
  35216. get wrapV(): number;
  35217. set wrapV(value: number);
  35218. /**
  35219. * | Value | Type | Description |
  35220. * | ----- | ------------------ | ----------- |
  35221. * | 0 | CLAMP_ADDRESSMODE | |
  35222. * | 1 | WRAP_ADDRESSMODE | |
  35223. * | 2 | MIRROR_ADDRESSMODE | |
  35224. */
  35225. wrapR: number;
  35226. /**
  35227. * With compliant hardware and browser (supporting anisotropic filtering)
  35228. * this defines the level of anisotropic filtering in the texture.
  35229. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  35230. */
  35231. anisotropicFilteringLevel: number;
  35232. /**
  35233. * Define if the texture is a cube texture or if false a 2d texture.
  35234. */
  35235. get isCube(): boolean;
  35236. set isCube(value: boolean);
  35237. /**
  35238. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  35239. */
  35240. get is3D(): boolean;
  35241. set is3D(value: boolean);
  35242. /**
  35243. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  35244. */
  35245. get is2DArray(): boolean;
  35246. set is2DArray(value: boolean);
  35247. private _gammaSpace;
  35248. /**
  35249. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  35250. * HDR texture are usually stored in linear space.
  35251. * This only impacts the PBR and Background materials
  35252. */
  35253. get gammaSpace(): boolean;
  35254. set gammaSpace(gamma: boolean);
  35255. /**
  35256. * Gets or sets whether or not the texture contains RGBD data.
  35257. */
  35258. get isRGBD(): boolean;
  35259. set isRGBD(value: boolean);
  35260. /**
  35261. * Is Z inverted in the texture (useful in a cube texture).
  35262. */
  35263. invertZ: boolean;
  35264. /**
  35265. * Are mip maps generated for this texture or not.
  35266. */
  35267. get noMipmap(): boolean;
  35268. /**
  35269. * @hidden
  35270. */
  35271. lodLevelInAlpha: boolean;
  35272. /**
  35273. * With prefiltered texture, defined the offset used during the prefiltering steps.
  35274. */
  35275. get lodGenerationOffset(): number;
  35276. set lodGenerationOffset(value: number);
  35277. /**
  35278. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35279. */
  35280. get lodGenerationScale(): number;
  35281. set lodGenerationScale(value: number);
  35282. /**
  35283. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35284. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35285. * average roughness values.
  35286. */
  35287. get linearSpecularLOD(): boolean;
  35288. set linearSpecularLOD(value: boolean);
  35289. /**
  35290. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35291. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35292. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35293. */
  35294. get irradianceTexture(): Nullable<BaseTexture>;
  35295. set irradianceTexture(value: Nullable<BaseTexture>);
  35296. /**
  35297. * Define if the texture is a render target.
  35298. */
  35299. isRenderTarget: boolean;
  35300. /**
  35301. * Define the unique id of the texture in the scene.
  35302. */
  35303. get uid(): string;
  35304. /** @hidden */
  35305. _prefiltered: boolean;
  35306. /**
  35307. * Return a string representation of the texture.
  35308. * @returns the texture as a string
  35309. */
  35310. toString(): string;
  35311. /**
  35312. * Get the class name of the texture.
  35313. * @returns "BaseTexture"
  35314. */
  35315. getClassName(): string;
  35316. /**
  35317. * Define the list of animation attached to the texture.
  35318. */
  35319. animations: import("babylonjs/Animations/animation").Animation[];
  35320. /**
  35321. * An event triggered when the texture is disposed.
  35322. */
  35323. onDisposeObservable: Observable<BaseTexture>;
  35324. private _onDisposeObserver;
  35325. /**
  35326. * Callback triggered when the texture has been disposed.
  35327. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35328. */
  35329. set onDispose(callback: () => void);
  35330. /**
  35331. * Define the current state of the loading sequence when in delayed load mode.
  35332. */
  35333. delayLoadState: number;
  35334. protected _scene: Nullable<Scene>;
  35335. protected _engine: Nullable<ThinEngine>;
  35336. /** @hidden */
  35337. _texture: Nullable<InternalTexture>;
  35338. private _uid;
  35339. /**
  35340. * Define if the texture is preventinga material to render or not.
  35341. * If not and the texture is not ready, the engine will use a default black texture instead.
  35342. */
  35343. get isBlocking(): boolean;
  35344. /**
  35345. * Instantiates a new BaseTexture.
  35346. * Base class of all the textures in babylon.
  35347. * It groups all the common properties the materials, post process, lights... might need
  35348. * in order to make a correct use of the texture.
  35349. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35350. */
  35351. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35352. /**
  35353. * Get the scene the texture belongs to.
  35354. * @returns the scene or null if undefined
  35355. */
  35356. getScene(): Nullable<Scene>;
  35357. /** @hidden */
  35358. protected _getEngine(): Nullable<ThinEngine>;
  35359. /**
  35360. * Get the texture transform matrix used to offset tile the texture for istance.
  35361. * @returns the transformation matrix
  35362. */
  35363. getTextureMatrix(): Matrix;
  35364. /**
  35365. * Get the texture reflection matrix used to rotate/transform the reflection.
  35366. * @returns the reflection matrix
  35367. */
  35368. getReflectionTextureMatrix(): Matrix;
  35369. /**
  35370. * Get the underlying lower level texture from Babylon.
  35371. * @returns the insternal texture
  35372. */
  35373. getInternalTexture(): Nullable<InternalTexture>;
  35374. /**
  35375. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35376. * @returns true if ready or not blocking
  35377. */
  35378. isReadyOrNotBlocking(): boolean;
  35379. /**
  35380. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35381. * @returns true if fully ready
  35382. */
  35383. isReady(): boolean;
  35384. private _cachedSize;
  35385. /**
  35386. * Get the size of the texture.
  35387. * @returns the texture size.
  35388. */
  35389. getSize(): ISize;
  35390. /**
  35391. * Get the base size of the texture.
  35392. * It can be different from the size if the texture has been resized for POT for instance
  35393. * @returns the base size
  35394. */
  35395. getBaseSize(): ISize;
  35396. /**
  35397. * Update the sampling mode of the texture.
  35398. * Default is Trilinear mode.
  35399. *
  35400. * | Value | Type | Description |
  35401. * | ----- | ------------------ | ----------- |
  35402. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35403. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35404. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35405. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35406. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35407. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35408. * | 7 | NEAREST_LINEAR | |
  35409. * | 8 | NEAREST_NEAREST | |
  35410. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35411. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35412. * | 11 | LINEAR_LINEAR | |
  35413. * | 12 | LINEAR_NEAREST | |
  35414. *
  35415. * > _mag_: magnification filter (close to the viewer)
  35416. * > _min_: minification filter (far from the viewer)
  35417. * > _mip_: filter used between mip map levels
  35418. *@param samplingMode Define the new sampling mode of the texture
  35419. */
  35420. updateSamplingMode(samplingMode: number): void;
  35421. /**
  35422. * Scales the texture if is `canRescale()`
  35423. * @param ratio the resize factor we want to use to rescale
  35424. */
  35425. scale(ratio: number): void;
  35426. /**
  35427. * Get if the texture can rescale.
  35428. */
  35429. get canRescale(): boolean;
  35430. /** @hidden */
  35431. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35432. /** @hidden */
  35433. _rebuild(): void;
  35434. /**
  35435. * Triggers the load sequence in delayed load mode.
  35436. */
  35437. delayLoad(): void;
  35438. /**
  35439. * Clones the texture.
  35440. * @returns the cloned texture
  35441. */
  35442. clone(): Nullable<BaseTexture>;
  35443. /**
  35444. * Get the texture underlying type (INT, FLOAT...)
  35445. */
  35446. get textureType(): number;
  35447. /**
  35448. * Get the texture underlying format (RGB, RGBA...)
  35449. */
  35450. get textureFormat(): number;
  35451. /**
  35452. * Indicates that textures need to be re-calculated for all materials
  35453. */
  35454. protected _markAllSubMeshesAsTexturesDirty(): void;
  35455. /**
  35456. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35457. * This will returns an RGBA array buffer containing either in values (0-255) or
  35458. * float values (0-1) depending of the underlying buffer type.
  35459. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35460. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35461. * @param buffer defines a user defined buffer to fill with data (can be null)
  35462. * @returns The Array buffer containing the pixels data.
  35463. */
  35464. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35465. /**
  35466. * Release and destroy the underlying lower level texture aka internalTexture.
  35467. */
  35468. releaseInternalTexture(): void;
  35469. /** @hidden */
  35470. get _lodTextureHigh(): Nullable<BaseTexture>;
  35471. /** @hidden */
  35472. get _lodTextureMid(): Nullable<BaseTexture>;
  35473. /** @hidden */
  35474. get _lodTextureLow(): Nullable<BaseTexture>;
  35475. /**
  35476. * Dispose the texture and release its associated resources.
  35477. */
  35478. dispose(): void;
  35479. /**
  35480. * Serialize the texture into a JSON representation that can be parsed later on.
  35481. * @returns the JSON representation of the texture
  35482. */
  35483. serialize(): any;
  35484. /**
  35485. * Helper function to be called back once a list of texture contains only ready textures.
  35486. * @param textures Define the list of textures to wait for
  35487. * @param callback Define the callback triggered once the entire list will be ready
  35488. */
  35489. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35490. private static _isScene;
  35491. }
  35492. }
  35493. declare module "babylonjs/Materials/effect" {
  35494. import { Observable } from "babylonjs/Misc/observable";
  35495. import { Nullable } from "babylonjs/types";
  35496. import { IDisposable } from "babylonjs/scene";
  35497. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35498. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35499. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35500. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35501. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35502. import { Engine } from "babylonjs/Engines/engine";
  35503. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35504. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35505. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35506. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35507. /**
  35508. * Options to be used when creating an effect.
  35509. */
  35510. export interface IEffectCreationOptions {
  35511. /**
  35512. * Atrributes that will be used in the shader.
  35513. */
  35514. attributes: string[];
  35515. /**
  35516. * Uniform varible names that will be set in the shader.
  35517. */
  35518. uniformsNames: string[];
  35519. /**
  35520. * Uniform buffer variable names that will be set in the shader.
  35521. */
  35522. uniformBuffersNames: string[];
  35523. /**
  35524. * Sampler texture variable names that will be set in the shader.
  35525. */
  35526. samplers: string[];
  35527. /**
  35528. * Define statements that will be set in the shader.
  35529. */
  35530. defines: any;
  35531. /**
  35532. * Possible fallbacks for this effect to improve performance when needed.
  35533. */
  35534. fallbacks: Nullable<IEffectFallbacks>;
  35535. /**
  35536. * Callback that will be called when the shader is compiled.
  35537. */
  35538. onCompiled: Nullable<(effect: Effect) => void>;
  35539. /**
  35540. * Callback that will be called if an error occurs during shader compilation.
  35541. */
  35542. onError: Nullable<(effect: Effect, errors: string) => void>;
  35543. /**
  35544. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35545. */
  35546. indexParameters?: any;
  35547. /**
  35548. * Max number of lights that can be used in the shader.
  35549. */
  35550. maxSimultaneousLights?: number;
  35551. /**
  35552. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35553. */
  35554. transformFeedbackVaryings?: Nullable<string[]>;
  35555. /**
  35556. * 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
  35557. */
  35558. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35559. /**
  35560. * Is this effect rendering to several color attachments ?
  35561. */
  35562. multiTarget?: boolean;
  35563. }
  35564. /**
  35565. * Effect containing vertex and fragment shader that can be executed on an object.
  35566. */
  35567. export class Effect implements IDisposable {
  35568. /**
  35569. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35570. */
  35571. static ShadersRepository: string;
  35572. /**
  35573. * Enable logging of the shader code when a compilation error occurs
  35574. */
  35575. static LogShaderCodeOnCompilationError: boolean;
  35576. /**
  35577. * Name of the effect.
  35578. */
  35579. name: any;
  35580. /**
  35581. * String container all the define statements that should be set on the shader.
  35582. */
  35583. defines: string;
  35584. /**
  35585. * Callback that will be called when the shader is compiled.
  35586. */
  35587. onCompiled: Nullable<(effect: Effect) => void>;
  35588. /**
  35589. * Callback that will be called if an error occurs during shader compilation.
  35590. */
  35591. onError: Nullable<(effect: Effect, errors: string) => void>;
  35592. /**
  35593. * Callback that will be called when effect is bound.
  35594. */
  35595. onBind: Nullable<(effect: Effect) => void>;
  35596. /**
  35597. * Unique ID of the effect.
  35598. */
  35599. uniqueId: number;
  35600. /**
  35601. * Observable that will be called when the shader is compiled.
  35602. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35603. */
  35604. onCompileObservable: Observable<Effect>;
  35605. /**
  35606. * Observable that will be called if an error occurs during shader compilation.
  35607. */
  35608. onErrorObservable: Observable<Effect>;
  35609. /** @hidden */
  35610. _onBindObservable: Nullable<Observable<Effect>>;
  35611. /**
  35612. * @hidden
  35613. * Specifies if the effect was previously ready
  35614. */
  35615. _wasPreviouslyReady: boolean;
  35616. /**
  35617. * Observable that will be called when effect is bound.
  35618. */
  35619. get onBindObservable(): Observable<Effect>;
  35620. /** @hidden */
  35621. _bonesComputationForcedToCPU: boolean;
  35622. /** @hidden */
  35623. _multiTarget: boolean;
  35624. private static _uniqueIdSeed;
  35625. private _engine;
  35626. private _uniformBuffersNames;
  35627. private _uniformBuffersNamesList;
  35628. private _uniformsNames;
  35629. private _samplerList;
  35630. private _samplers;
  35631. private _isReady;
  35632. private _compilationError;
  35633. private _allFallbacksProcessed;
  35634. private _attributesNames;
  35635. private _attributes;
  35636. private _attributeLocationByName;
  35637. private _uniforms;
  35638. /**
  35639. * Key for the effect.
  35640. * @hidden
  35641. */
  35642. _key: string;
  35643. private _indexParameters;
  35644. private _fallbacks;
  35645. private _vertexSourceCode;
  35646. private _fragmentSourceCode;
  35647. private _vertexSourceCodeOverride;
  35648. private _fragmentSourceCodeOverride;
  35649. private _transformFeedbackVaryings;
  35650. /**
  35651. * Compiled shader to webGL program.
  35652. * @hidden
  35653. */
  35654. _pipelineContext: Nullable<IPipelineContext>;
  35655. private _valueCache;
  35656. private static _baseCache;
  35657. /**
  35658. * Instantiates an effect.
  35659. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35660. * @param baseName Name of the effect.
  35661. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35662. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35663. * @param samplers List of sampler variables that will be passed to the shader.
  35664. * @param engine Engine to be used to render the effect
  35665. * @param defines Define statements to be added to the shader.
  35666. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35667. * @param onCompiled Callback that will be called when the shader is compiled.
  35668. * @param onError Callback that will be called if an error occurs during shader compilation.
  35669. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35670. */
  35671. 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);
  35672. private _useFinalCode;
  35673. /**
  35674. * Unique key for this effect
  35675. */
  35676. get key(): string;
  35677. /**
  35678. * If the effect has been compiled and prepared.
  35679. * @returns if the effect is compiled and prepared.
  35680. */
  35681. isReady(): boolean;
  35682. private _isReadyInternal;
  35683. /**
  35684. * The engine the effect was initialized with.
  35685. * @returns the engine.
  35686. */
  35687. getEngine(): Engine;
  35688. /**
  35689. * The pipeline context for this effect
  35690. * @returns the associated pipeline context
  35691. */
  35692. getPipelineContext(): Nullable<IPipelineContext>;
  35693. /**
  35694. * The set of names of attribute variables for the shader.
  35695. * @returns An array of attribute names.
  35696. */
  35697. getAttributesNames(): string[];
  35698. /**
  35699. * Returns the attribute at the given index.
  35700. * @param index The index of the attribute.
  35701. * @returns The location of the attribute.
  35702. */
  35703. getAttributeLocation(index: number): number;
  35704. /**
  35705. * Returns the attribute based on the name of the variable.
  35706. * @param name of the attribute to look up.
  35707. * @returns the attribute location.
  35708. */
  35709. getAttributeLocationByName(name: string): number;
  35710. /**
  35711. * The number of attributes.
  35712. * @returns the numnber of attributes.
  35713. */
  35714. getAttributesCount(): number;
  35715. /**
  35716. * Gets the index of a uniform variable.
  35717. * @param uniformName of the uniform to look up.
  35718. * @returns the index.
  35719. */
  35720. getUniformIndex(uniformName: string): number;
  35721. /**
  35722. * Returns the attribute based on the name of the variable.
  35723. * @param uniformName of the uniform to look up.
  35724. * @returns the location of the uniform.
  35725. */
  35726. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35727. /**
  35728. * Returns an array of sampler variable names
  35729. * @returns The array of sampler variable names.
  35730. */
  35731. getSamplers(): string[];
  35732. /**
  35733. * Returns an array of uniform variable names
  35734. * @returns The array of uniform variable names.
  35735. */
  35736. getUniformNames(): string[];
  35737. /**
  35738. * Returns an array of uniform buffer variable names
  35739. * @returns The array of uniform buffer variable names.
  35740. */
  35741. getUniformBuffersNames(): string[];
  35742. /**
  35743. * Returns the index parameters used to create the effect
  35744. * @returns The index parameters object
  35745. */
  35746. getIndexParameters(): any;
  35747. /**
  35748. * The error from the last compilation.
  35749. * @returns the error string.
  35750. */
  35751. getCompilationError(): string;
  35752. /**
  35753. * Gets a boolean indicating that all fallbacks were used during compilation
  35754. * @returns true if all fallbacks were used
  35755. */
  35756. allFallbacksProcessed(): boolean;
  35757. /**
  35758. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35759. * @param func The callback to be used.
  35760. */
  35761. executeWhenCompiled(func: (effect: Effect) => void): void;
  35762. private _checkIsReady;
  35763. private _loadShader;
  35764. /**
  35765. * Gets the vertex shader source code of this effect
  35766. */
  35767. get vertexSourceCode(): string;
  35768. /**
  35769. * Gets the fragment shader source code of this effect
  35770. */
  35771. get fragmentSourceCode(): string;
  35772. /**
  35773. * Recompiles the webGL program
  35774. * @param vertexSourceCode The source code for the vertex shader.
  35775. * @param fragmentSourceCode The source code for the fragment shader.
  35776. * @param onCompiled Callback called when completed.
  35777. * @param onError Callback called on error.
  35778. * @hidden
  35779. */
  35780. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35781. /**
  35782. * Prepares the effect
  35783. * @hidden
  35784. */
  35785. _prepareEffect(): void;
  35786. private _getShaderCodeAndErrorLine;
  35787. private _processCompilationErrors;
  35788. /**
  35789. * Checks if the effect is supported. (Must be called after compilation)
  35790. */
  35791. get isSupported(): boolean;
  35792. /**
  35793. * Binds a texture to the engine to be used as output of the shader.
  35794. * @param channel Name of the output variable.
  35795. * @param texture Texture to bind.
  35796. * @hidden
  35797. */
  35798. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35799. /**
  35800. * Sets a texture on the engine to be used in the shader.
  35801. * @param channel Name of the sampler variable.
  35802. * @param texture Texture to set.
  35803. */
  35804. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35805. /**
  35806. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35807. * @param channel Name of the sampler variable.
  35808. * @param texture Texture to set.
  35809. */
  35810. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35811. /**
  35812. * Sets an array of textures on the engine to be used in the shader.
  35813. * @param channel Name of the variable.
  35814. * @param textures Textures to set.
  35815. */
  35816. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35817. /**
  35818. * 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)
  35819. * @param channel Name of the sampler variable.
  35820. * @param postProcess Post process to get the input texture from.
  35821. */
  35822. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35823. /**
  35824. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35825. * 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)
  35826. * @param channel Name of the sampler variable.
  35827. * @param postProcess Post process to get the output texture from.
  35828. */
  35829. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35830. /** @hidden */
  35831. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35832. /** @hidden */
  35833. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35834. /** @hidden */
  35835. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35836. /** @hidden */
  35837. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35838. /**
  35839. * Binds a buffer to a uniform.
  35840. * @param buffer Buffer to bind.
  35841. * @param name Name of the uniform variable to bind to.
  35842. */
  35843. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35844. /**
  35845. * Binds block to a uniform.
  35846. * @param blockName Name of the block to bind.
  35847. * @param index Index to bind.
  35848. */
  35849. bindUniformBlock(blockName: string, index: number): void;
  35850. /**
  35851. * Sets an interger value on a uniform variable.
  35852. * @param uniformName Name of the variable.
  35853. * @param value Value to be set.
  35854. * @returns this effect.
  35855. */
  35856. setInt(uniformName: string, value: number): Effect;
  35857. /**
  35858. * Sets an int array on a uniform variable.
  35859. * @param uniformName Name of the variable.
  35860. * @param array array to be set.
  35861. * @returns this effect.
  35862. */
  35863. setIntArray(uniformName: string, array: Int32Array): Effect;
  35864. /**
  35865. * 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)
  35866. * @param uniformName Name of the variable.
  35867. * @param array array to be set.
  35868. * @returns this effect.
  35869. */
  35870. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35871. /**
  35872. * 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)
  35873. * @param uniformName Name of the variable.
  35874. * @param array array to be set.
  35875. * @returns this effect.
  35876. */
  35877. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35878. /**
  35879. * 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)
  35880. * @param uniformName Name of the variable.
  35881. * @param array array to be set.
  35882. * @returns this effect.
  35883. */
  35884. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35885. /**
  35886. * Sets an float array on a uniform variable.
  35887. * @param uniformName Name of the variable.
  35888. * @param array array to be set.
  35889. * @returns this effect.
  35890. */
  35891. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35892. /**
  35893. * 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)
  35894. * @param uniformName Name of the variable.
  35895. * @param array array to be set.
  35896. * @returns this effect.
  35897. */
  35898. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35899. /**
  35900. * 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)
  35901. * @param uniformName Name of the variable.
  35902. * @param array array to be set.
  35903. * @returns this effect.
  35904. */
  35905. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35906. /**
  35907. * 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)
  35908. * @param uniformName Name of the variable.
  35909. * @param array array to be set.
  35910. * @returns this effect.
  35911. */
  35912. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35913. /**
  35914. * Sets an array on a uniform variable.
  35915. * @param uniformName Name of the variable.
  35916. * @param array array to be set.
  35917. * @returns this effect.
  35918. */
  35919. setArray(uniformName: string, array: number[]): Effect;
  35920. /**
  35921. * 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)
  35922. * @param uniformName Name of the variable.
  35923. * @param array array to be set.
  35924. * @returns this effect.
  35925. */
  35926. setArray2(uniformName: string, array: number[]): Effect;
  35927. /**
  35928. * 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)
  35929. * @param uniformName Name of the variable.
  35930. * @param array array to be set.
  35931. * @returns this effect.
  35932. */
  35933. setArray3(uniformName: string, array: number[]): Effect;
  35934. /**
  35935. * 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)
  35936. * @param uniformName Name of the variable.
  35937. * @param array array to be set.
  35938. * @returns this effect.
  35939. */
  35940. setArray4(uniformName: string, array: number[]): Effect;
  35941. /**
  35942. * Sets matrices on a uniform variable.
  35943. * @param uniformName Name of the variable.
  35944. * @param matrices matrices to be set.
  35945. * @returns this effect.
  35946. */
  35947. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  35948. /**
  35949. * Sets matrix on a uniform variable.
  35950. * @param uniformName Name of the variable.
  35951. * @param matrix matrix to be set.
  35952. * @returns this effect.
  35953. */
  35954. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  35955. /**
  35956. * 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)
  35957. * @param uniformName Name of the variable.
  35958. * @param matrix matrix to be set.
  35959. * @returns this effect.
  35960. */
  35961. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35962. /**
  35963. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  35964. * @param uniformName Name of the variable.
  35965. * @param matrix matrix to be set.
  35966. * @returns this effect.
  35967. */
  35968. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35969. /**
  35970. * Sets a float on a uniform variable.
  35971. * @param uniformName Name of the variable.
  35972. * @param value value to be set.
  35973. * @returns this effect.
  35974. */
  35975. setFloat(uniformName: string, value: number): Effect;
  35976. /**
  35977. * Sets a boolean on a uniform variable.
  35978. * @param uniformName Name of the variable.
  35979. * @param bool value to be set.
  35980. * @returns this effect.
  35981. */
  35982. setBool(uniformName: string, bool: boolean): Effect;
  35983. /**
  35984. * Sets a Vector2 on a uniform variable.
  35985. * @param uniformName Name of the variable.
  35986. * @param vector2 vector2 to be set.
  35987. * @returns this effect.
  35988. */
  35989. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  35990. /**
  35991. * Sets a float2 on a uniform variable.
  35992. * @param uniformName Name of the variable.
  35993. * @param x First float in float2.
  35994. * @param y Second float in float2.
  35995. * @returns this effect.
  35996. */
  35997. setFloat2(uniformName: string, x: number, y: number): Effect;
  35998. /**
  35999. * Sets a Vector3 on a uniform variable.
  36000. * @param uniformName Name of the variable.
  36001. * @param vector3 Value to be set.
  36002. * @returns this effect.
  36003. */
  36004. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  36005. /**
  36006. * Sets a float3 on a uniform variable.
  36007. * @param uniformName Name of the variable.
  36008. * @param x First float in float3.
  36009. * @param y Second float in float3.
  36010. * @param z Third float in float3.
  36011. * @returns this effect.
  36012. */
  36013. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  36014. /**
  36015. * Sets a Vector4 on a uniform variable.
  36016. * @param uniformName Name of the variable.
  36017. * @param vector4 Value to be set.
  36018. * @returns this effect.
  36019. */
  36020. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  36021. /**
  36022. * Sets a float4 on a uniform variable.
  36023. * @param uniformName Name of the variable.
  36024. * @param x First float in float4.
  36025. * @param y Second float in float4.
  36026. * @param z Third float in float4.
  36027. * @param w Fourth float in float4.
  36028. * @returns this effect.
  36029. */
  36030. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  36031. /**
  36032. * Sets a Color3 on a uniform variable.
  36033. * @param uniformName Name of the variable.
  36034. * @param color3 Value to be set.
  36035. * @returns this effect.
  36036. */
  36037. setColor3(uniformName: string, color3: IColor3Like): Effect;
  36038. /**
  36039. * Sets a Color4 on a uniform variable.
  36040. * @param uniformName Name of the variable.
  36041. * @param color3 Value to be set.
  36042. * @param alpha Alpha value to be set.
  36043. * @returns this effect.
  36044. */
  36045. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  36046. /**
  36047. * Sets a Color4 on a uniform variable
  36048. * @param uniformName defines the name of the variable
  36049. * @param color4 defines the value to be set
  36050. * @returns this effect.
  36051. */
  36052. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  36053. /** Release all associated resources */
  36054. dispose(): void;
  36055. /**
  36056. * This function will add a new shader to the shader store
  36057. * @param name the name of the shader
  36058. * @param pixelShader optional pixel shader content
  36059. * @param vertexShader optional vertex shader content
  36060. */
  36061. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  36062. /**
  36063. * Store of each shader (The can be looked up using effect.key)
  36064. */
  36065. static ShadersStore: {
  36066. [key: string]: string;
  36067. };
  36068. /**
  36069. * Store of each included file for a shader (The can be looked up using effect.key)
  36070. */
  36071. static IncludesShadersStore: {
  36072. [key: string]: string;
  36073. };
  36074. /**
  36075. * Resets the cache of effects.
  36076. */
  36077. static ResetCache(): void;
  36078. }
  36079. }
  36080. declare module "babylonjs/Engines/engineCapabilities" {
  36081. /**
  36082. * Interface used to describe the capabilities of the engine relatively to the current browser
  36083. */
  36084. export interface EngineCapabilities {
  36085. /** Maximum textures units per fragment shader */
  36086. maxTexturesImageUnits: number;
  36087. /** Maximum texture units per vertex shader */
  36088. maxVertexTextureImageUnits: number;
  36089. /** Maximum textures units in the entire pipeline */
  36090. maxCombinedTexturesImageUnits: number;
  36091. /** Maximum texture size */
  36092. maxTextureSize: number;
  36093. /** Maximum texture samples */
  36094. maxSamples?: number;
  36095. /** Maximum cube texture size */
  36096. maxCubemapTextureSize: number;
  36097. /** Maximum render texture size */
  36098. maxRenderTextureSize: number;
  36099. /** Maximum number of vertex attributes */
  36100. maxVertexAttribs: number;
  36101. /** Maximum number of varyings */
  36102. maxVaryingVectors: number;
  36103. /** Maximum number of uniforms per vertex shader */
  36104. maxVertexUniformVectors: number;
  36105. /** Maximum number of uniforms per fragment shader */
  36106. maxFragmentUniformVectors: number;
  36107. /** Defines if standard derivates (dx/dy) are supported */
  36108. standardDerivatives: boolean;
  36109. /** Defines if s3tc texture compression is supported */
  36110. s3tc?: WEBGL_compressed_texture_s3tc;
  36111. /** Defines if pvrtc texture compression is supported */
  36112. pvrtc: any;
  36113. /** Defines if etc1 texture compression is supported */
  36114. etc1: any;
  36115. /** Defines if etc2 texture compression is supported */
  36116. etc2: any;
  36117. /** Defines if astc texture compression is supported */
  36118. astc: any;
  36119. /** Defines if bptc texture compression is supported */
  36120. bptc: any;
  36121. /** Defines if float textures are supported */
  36122. textureFloat: boolean;
  36123. /** Defines if vertex array objects are supported */
  36124. vertexArrayObject: boolean;
  36125. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  36126. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  36127. /** Gets the maximum level of anisotropy supported */
  36128. maxAnisotropy: number;
  36129. /** Defines if instancing is supported */
  36130. instancedArrays: boolean;
  36131. /** Defines if 32 bits indices are supported */
  36132. uintIndices: boolean;
  36133. /** Defines if high precision shaders are supported */
  36134. highPrecisionShaderSupported: boolean;
  36135. /** Defines if depth reading in the fragment shader is supported */
  36136. fragmentDepthSupported: boolean;
  36137. /** Defines if float texture linear filtering is supported*/
  36138. textureFloatLinearFiltering: boolean;
  36139. /** Defines if rendering to float textures is supported */
  36140. textureFloatRender: boolean;
  36141. /** Defines if half float textures are supported*/
  36142. textureHalfFloat: boolean;
  36143. /** Defines if half float texture linear filtering is supported*/
  36144. textureHalfFloatLinearFiltering: boolean;
  36145. /** Defines if rendering to half float textures is supported */
  36146. textureHalfFloatRender: boolean;
  36147. /** Defines if textureLOD shader command is supported */
  36148. textureLOD: boolean;
  36149. /** Defines if draw buffers extension is supported */
  36150. drawBuffersExtension: boolean;
  36151. /** Defines if depth textures are supported */
  36152. depthTextureExtension: boolean;
  36153. /** Defines if float color buffer are supported */
  36154. colorBufferFloat: boolean;
  36155. /** Gets disjoint timer query extension (null if not supported) */
  36156. timerQuery?: EXT_disjoint_timer_query;
  36157. /** Defines if timestamp can be used with timer query */
  36158. canUseTimestampForTimerQuery: boolean;
  36159. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  36160. multiview?: any;
  36161. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  36162. oculusMultiview?: any;
  36163. /** Function used to let the system compiles shaders in background */
  36164. parallelShaderCompile?: {
  36165. COMPLETION_STATUS_KHR: number;
  36166. };
  36167. /** Max number of texture samples for MSAA */
  36168. maxMSAASamples: number;
  36169. /** Defines if the blend min max extension is supported */
  36170. blendMinMax: boolean;
  36171. }
  36172. }
  36173. declare module "babylonjs/States/depthCullingState" {
  36174. import { Nullable } from "babylonjs/types";
  36175. /**
  36176. * @hidden
  36177. **/
  36178. export class DepthCullingState {
  36179. private _isDepthTestDirty;
  36180. private _isDepthMaskDirty;
  36181. private _isDepthFuncDirty;
  36182. private _isCullFaceDirty;
  36183. private _isCullDirty;
  36184. private _isZOffsetDirty;
  36185. private _isFrontFaceDirty;
  36186. private _depthTest;
  36187. private _depthMask;
  36188. private _depthFunc;
  36189. private _cull;
  36190. private _cullFace;
  36191. private _zOffset;
  36192. private _frontFace;
  36193. /**
  36194. * Initializes the state.
  36195. */
  36196. constructor();
  36197. get isDirty(): boolean;
  36198. get zOffset(): number;
  36199. set zOffset(value: number);
  36200. get cullFace(): Nullable<number>;
  36201. set cullFace(value: Nullable<number>);
  36202. get cull(): Nullable<boolean>;
  36203. set cull(value: Nullable<boolean>);
  36204. get depthFunc(): Nullable<number>;
  36205. set depthFunc(value: Nullable<number>);
  36206. get depthMask(): boolean;
  36207. set depthMask(value: boolean);
  36208. get depthTest(): boolean;
  36209. set depthTest(value: boolean);
  36210. get frontFace(): Nullable<number>;
  36211. set frontFace(value: Nullable<number>);
  36212. reset(): void;
  36213. apply(gl: WebGLRenderingContext): void;
  36214. }
  36215. }
  36216. declare module "babylonjs/States/stencilState" {
  36217. /**
  36218. * @hidden
  36219. **/
  36220. export class StencilState {
  36221. /** 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 */
  36222. static readonly ALWAYS: number;
  36223. /** Passed to stencilOperation to specify that stencil value must be kept */
  36224. static readonly KEEP: number;
  36225. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36226. static readonly REPLACE: number;
  36227. private _isStencilTestDirty;
  36228. private _isStencilMaskDirty;
  36229. private _isStencilFuncDirty;
  36230. private _isStencilOpDirty;
  36231. private _stencilTest;
  36232. private _stencilMask;
  36233. private _stencilFunc;
  36234. private _stencilFuncRef;
  36235. private _stencilFuncMask;
  36236. private _stencilOpStencilFail;
  36237. private _stencilOpDepthFail;
  36238. private _stencilOpStencilDepthPass;
  36239. get isDirty(): boolean;
  36240. get stencilFunc(): number;
  36241. set stencilFunc(value: number);
  36242. get stencilFuncRef(): number;
  36243. set stencilFuncRef(value: number);
  36244. get stencilFuncMask(): number;
  36245. set stencilFuncMask(value: number);
  36246. get stencilOpStencilFail(): number;
  36247. set stencilOpStencilFail(value: number);
  36248. get stencilOpDepthFail(): number;
  36249. set stencilOpDepthFail(value: number);
  36250. get stencilOpStencilDepthPass(): number;
  36251. set stencilOpStencilDepthPass(value: number);
  36252. get stencilMask(): number;
  36253. set stencilMask(value: number);
  36254. get stencilTest(): boolean;
  36255. set stencilTest(value: boolean);
  36256. constructor();
  36257. reset(): void;
  36258. apply(gl: WebGLRenderingContext): void;
  36259. }
  36260. }
  36261. declare module "babylonjs/States/alphaCullingState" {
  36262. /**
  36263. * @hidden
  36264. **/
  36265. export class AlphaState {
  36266. private _isAlphaBlendDirty;
  36267. private _isBlendFunctionParametersDirty;
  36268. private _isBlendEquationParametersDirty;
  36269. private _isBlendConstantsDirty;
  36270. private _alphaBlend;
  36271. private _blendFunctionParameters;
  36272. private _blendEquationParameters;
  36273. private _blendConstants;
  36274. /**
  36275. * Initializes the state.
  36276. */
  36277. constructor();
  36278. get isDirty(): boolean;
  36279. get alphaBlend(): boolean;
  36280. set alphaBlend(value: boolean);
  36281. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36282. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36283. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36284. reset(): void;
  36285. apply(gl: WebGLRenderingContext): void;
  36286. }
  36287. }
  36288. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36289. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36290. /** @hidden */
  36291. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36292. attributeProcessor(attribute: string): string;
  36293. varyingProcessor(varying: string, isFragment: boolean): string;
  36294. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36295. }
  36296. }
  36297. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36298. /**
  36299. * Interface for attribute information associated with buffer instanciation
  36300. */
  36301. export interface InstancingAttributeInfo {
  36302. /**
  36303. * Name of the GLSL attribute
  36304. * if attribute index is not specified, this is used to retrieve the index from the effect
  36305. */
  36306. attributeName: string;
  36307. /**
  36308. * Index/offset of the attribute in the vertex shader
  36309. * if not specified, this will be computes from the name.
  36310. */
  36311. index?: number;
  36312. /**
  36313. * size of the attribute, 1, 2, 3 or 4
  36314. */
  36315. attributeSize: number;
  36316. /**
  36317. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36318. */
  36319. offset: number;
  36320. /**
  36321. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36322. * default to 1
  36323. */
  36324. divisor?: number;
  36325. /**
  36326. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36327. * default is FLOAT
  36328. */
  36329. attributeType?: number;
  36330. /**
  36331. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36332. */
  36333. normalized?: boolean;
  36334. }
  36335. }
  36336. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36337. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36338. import { Nullable } from "babylonjs/types";
  36339. module "babylonjs/Engines/thinEngine" {
  36340. interface ThinEngine {
  36341. /**
  36342. * Update a video texture
  36343. * @param texture defines the texture to update
  36344. * @param video defines the video element to use
  36345. * @param invertY defines if data must be stored with Y axis inverted
  36346. */
  36347. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36348. }
  36349. }
  36350. }
  36351. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36352. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36353. import { Nullable } from "babylonjs/types";
  36354. module "babylonjs/Engines/thinEngine" {
  36355. interface ThinEngine {
  36356. /**
  36357. * Creates a dynamic texture
  36358. * @param width defines the width of the texture
  36359. * @param height defines the height of the texture
  36360. * @param generateMipMaps defines if the engine should generate the mip levels
  36361. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36362. * @returns the dynamic texture inside an InternalTexture
  36363. */
  36364. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36365. /**
  36366. * Update the content of a dynamic texture
  36367. * @param texture defines the texture to update
  36368. * @param canvas defines the canvas containing the source
  36369. * @param invertY defines if data must be stored with Y axis inverted
  36370. * @param premulAlpha defines if alpha is stored as premultiplied
  36371. * @param format defines the format of the data
  36372. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36373. */
  36374. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36375. }
  36376. }
  36377. }
  36378. declare module "babylonjs/Materials/Textures/videoTexture" {
  36379. import { Observable } from "babylonjs/Misc/observable";
  36380. import { Nullable } from "babylonjs/types";
  36381. import { Scene } from "babylonjs/scene";
  36382. import { Texture } from "babylonjs/Materials/Textures/texture";
  36383. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36384. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36385. /**
  36386. * Settings for finer control over video usage
  36387. */
  36388. export interface VideoTextureSettings {
  36389. /**
  36390. * Applies `autoplay` to video, if specified
  36391. */
  36392. autoPlay?: boolean;
  36393. /**
  36394. * Applies `loop` to video, if specified
  36395. */
  36396. loop?: boolean;
  36397. /**
  36398. * Automatically updates internal texture from video at every frame in the render loop
  36399. */
  36400. autoUpdateTexture: boolean;
  36401. /**
  36402. * Image src displayed during the video loading or until the user interacts with the video.
  36403. */
  36404. poster?: string;
  36405. }
  36406. /**
  36407. * If you want to display a video in your scene, this is the special texture for that.
  36408. * This special texture works similar to other textures, with the exception of a few parameters.
  36409. * @see https://doc.babylonjs.com/how_to/video_texture
  36410. */
  36411. export class VideoTexture extends Texture {
  36412. /**
  36413. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36414. */
  36415. readonly autoUpdateTexture: boolean;
  36416. /**
  36417. * The video instance used by the texture internally
  36418. */
  36419. readonly video: HTMLVideoElement;
  36420. private _onUserActionRequestedObservable;
  36421. /**
  36422. * Event triggerd when a dom action is required by the user to play the video.
  36423. * This happens due to recent changes in browser policies preventing video to auto start.
  36424. */
  36425. get onUserActionRequestedObservable(): Observable<Texture>;
  36426. private _generateMipMaps;
  36427. private _stillImageCaptured;
  36428. private _displayingPosterTexture;
  36429. private _settings;
  36430. private _createInternalTextureOnEvent;
  36431. private _frameId;
  36432. private _currentSrc;
  36433. /**
  36434. * Creates a video texture.
  36435. * If you want to display a video in your scene, this is the special texture for that.
  36436. * This special texture works similar to other textures, with the exception of a few parameters.
  36437. * @see https://doc.babylonjs.com/how_to/video_texture
  36438. * @param name optional name, will detect from video source, if not defined
  36439. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36440. * @param scene is obviously the current scene.
  36441. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36442. * @param invertY is false by default but can be used to invert video on Y axis
  36443. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36444. * @param settings allows finer control over video usage
  36445. */
  36446. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36447. private _getName;
  36448. private _getVideo;
  36449. private _createInternalTexture;
  36450. private reset;
  36451. /**
  36452. * @hidden Internal method to initiate `update`.
  36453. */
  36454. _rebuild(): void;
  36455. /**
  36456. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36457. */
  36458. update(): void;
  36459. /**
  36460. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36461. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36462. */
  36463. updateTexture(isVisible: boolean): void;
  36464. protected _updateInternalTexture: () => void;
  36465. /**
  36466. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36467. * @param url New url.
  36468. */
  36469. updateURL(url: string): void;
  36470. /**
  36471. * Clones the texture.
  36472. * @returns the cloned texture
  36473. */
  36474. clone(): VideoTexture;
  36475. /**
  36476. * Dispose the texture and release its associated resources.
  36477. */
  36478. dispose(): void;
  36479. /**
  36480. * Creates a video texture straight from a stream.
  36481. * @param scene Define the scene the texture should be created in
  36482. * @param stream Define the stream the texture should be created from
  36483. * @returns The created video texture as a promise
  36484. */
  36485. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36486. /**
  36487. * Creates a video texture straight from your WebCam video feed.
  36488. * @param scene Define the scene the texture should be created in
  36489. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36490. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36491. * @returns The created video texture as a promise
  36492. */
  36493. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36494. minWidth: number;
  36495. maxWidth: number;
  36496. minHeight: number;
  36497. maxHeight: number;
  36498. deviceId: string;
  36499. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36500. /**
  36501. * Creates a video texture straight from your WebCam video feed.
  36502. * @param scene Define the scene the texture should be created in
  36503. * @param onReady Define a callback to triggered once the texture will be ready
  36504. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36505. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36506. */
  36507. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36508. minWidth: number;
  36509. maxWidth: number;
  36510. minHeight: number;
  36511. maxHeight: number;
  36512. deviceId: string;
  36513. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36514. }
  36515. }
  36516. declare module "babylonjs/Engines/thinEngine" {
  36517. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36518. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36519. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36520. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36521. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36522. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36523. import { Observable } from "babylonjs/Misc/observable";
  36524. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36525. import { StencilState } from "babylonjs/States/stencilState";
  36526. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36527. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36528. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36529. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36530. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36531. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36532. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36533. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36534. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36535. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36536. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36537. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36538. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36539. import { WebRequest } from "babylonjs/Misc/webRequest";
  36540. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36541. /**
  36542. * Defines the interface used by objects working like Scene
  36543. * @hidden
  36544. */
  36545. export interface ISceneLike {
  36546. _addPendingData(data: any): void;
  36547. _removePendingData(data: any): void;
  36548. offlineProvider: IOfflineProvider;
  36549. }
  36550. /**
  36551. * Information about the current host
  36552. */
  36553. export interface HostInformation {
  36554. /**
  36555. * Defines if the current host is a mobile
  36556. */
  36557. isMobile: boolean;
  36558. }
  36559. /** Interface defining initialization parameters for Engine class */
  36560. export interface EngineOptions extends WebGLContextAttributes {
  36561. /**
  36562. * Defines if the engine should no exceed a specified device ratio
  36563. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36564. */
  36565. limitDeviceRatio?: number;
  36566. /**
  36567. * Defines if webvr should be enabled automatically
  36568. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36569. */
  36570. autoEnableWebVR?: boolean;
  36571. /**
  36572. * Defines if webgl2 should be turned off even if supported
  36573. * @see https://doc.babylonjs.com/features/webgl2
  36574. */
  36575. disableWebGL2Support?: boolean;
  36576. /**
  36577. * Defines if webaudio should be initialized as well
  36578. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36579. */
  36580. audioEngine?: boolean;
  36581. /**
  36582. * Defines if animations should run using a deterministic lock step
  36583. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36584. */
  36585. deterministicLockstep?: boolean;
  36586. /** Defines the maximum steps to use with deterministic lock step mode */
  36587. lockstepMaxSteps?: number;
  36588. /** Defines the seconds between each deterministic lock step */
  36589. timeStep?: number;
  36590. /**
  36591. * Defines that engine should ignore context lost events
  36592. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36593. */
  36594. doNotHandleContextLost?: boolean;
  36595. /**
  36596. * Defines that engine should ignore modifying touch action attribute and style
  36597. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36598. */
  36599. doNotHandleTouchAction?: boolean;
  36600. /**
  36601. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36602. */
  36603. useHighPrecisionFloats?: boolean;
  36604. /**
  36605. * Make the canvas XR Compatible for XR sessions
  36606. */
  36607. xrCompatible?: boolean;
  36608. /**
  36609. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36610. */
  36611. useHighPrecisionMatrix?: boolean;
  36612. /**
  36613. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  36614. */
  36615. failIfMajorPerformanceCaveat?: boolean;
  36616. }
  36617. /**
  36618. * The base engine class (root of all engines)
  36619. */
  36620. export class ThinEngine {
  36621. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36622. static ExceptionList: ({
  36623. key: string;
  36624. capture: string;
  36625. captureConstraint: number;
  36626. targets: string[];
  36627. } | {
  36628. key: string;
  36629. capture: null;
  36630. captureConstraint: null;
  36631. targets: string[];
  36632. })[];
  36633. /** @hidden */
  36634. static _TextureLoaders: IInternalTextureLoader[];
  36635. /**
  36636. * Returns the current npm package of the sdk
  36637. */
  36638. static get NpmPackage(): string;
  36639. /**
  36640. * Returns the current version of the framework
  36641. */
  36642. static get Version(): string;
  36643. /**
  36644. * Returns a string describing the current engine
  36645. */
  36646. get description(): string;
  36647. /**
  36648. * Gets or sets the epsilon value used by collision engine
  36649. */
  36650. static CollisionsEpsilon: number;
  36651. /**
  36652. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36653. */
  36654. static get ShadersRepository(): string;
  36655. static set ShadersRepository(value: string);
  36656. /** @hidden */
  36657. _shaderProcessor: IShaderProcessor;
  36658. /**
  36659. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36660. */
  36661. forcePOTTextures: boolean;
  36662. /**
  36663. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36664. */
  36665. isFullscreen: boolean;
  36666. /**
  36667. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36668. */
  36669. cullBackFaces: boolean;
  36670. /**
  36671. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36672. */
  36673. renderEvenInBackground: boolean;
  36674. /**
  36675. * Gets or sets a boolean indicating that cache can be kept between frames
  36676. */
  36677. preventCacheWipeBetweenFrames: boolean;
  36678. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36679. validateShaderPrograms: boolean;
  36680. /**
  36681. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36682. * This can provide greater z depth for distant objects.
  36683. */
  36684. useReverseDepthBuffer: boolean;
  36685. /**
  36686. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36687. */
  36688. disableUniformBuffers: boolean;
  36689. /** @hidden */
  36690. _uniformBuffers: UniformBuffer[];
  36691. /**
  36692. * Gets a boolean indicating that the engine supports uniform buffers
  36693. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36694. */
  36695. get supportsUniformBuffers(): boolean;
  36696. /** @hidden */
  36697. _gl: WebGLRenderingContext;
  36698. /** @hidden */
  36699. _webGLVersion: number;
  36700. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36701. protected _windowIsBackground: boolean;
  36702. protected _creationOptions: EngineOptions;
  36703. protected _highPrecisionShadersAllowed: boolean;
  36704. /** @hidden */
  36705. get _shouldUseHighPrecisionShader(): boolean;
  36706. /**
  36707. * Gets a boolean indicating that only power of 2 textures are supported
  36708. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36709. */
  36710. get needPOTTextures(): boolean;
  36711. /** @hidden */
  36712. _badOS: boolean;
  36713. /** @hidden */
  36714. _badDesktopOS: boolean;
  36715. private _hardwareScalingLevel;
  36716. /** @hidden */
  36717. _caps: EngineCapabilities;
  36718. private _isStencilEnable;
  36719. private _glVersion;
  36720. private _glRenderer;
  36721. private _glVendor;
  36722. /** @hidden */
  36723. _videoTextureSupported: boolean;
  36724. protected _renderingQueueLaunched: boolean;
  36725. protected _activeRenderLoops: (() => void)[];
  36726. /**
  36727. * Observable signaled when a context lost event is raised
  36728. */
  36729. onContextLostObservable: Observable<ThinEngine>;
  36730. /**
  36731. * Observable signaled when a context restored event is raised
  36732. */
  36733. onContextRestoredObservable: Observable<ThinEngine>;
  36734. private _onContextLost;
  36735. private _onContextRestored;
  36736. protected _contextWasLost: boolean;
  36737. /** @hidden */
  36738. _doNotHandleContextLost: boolean;
  36739. /**
  36740. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36741. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36742. */
  36743. get doNotHandleContextLost(): boolean;
  36744. set doNotHandleContextLost(value: boolean);
  36745. /**
  36746. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36747. */
  36748. disableVertexArrayObjects: boolean;
  36749. /** @hidden */
  36750. protected _colorWrite: boolean;
  36751. /** @hidden */
  36752. protected _colorWriteChanged: boolean;
  36753. /** @hidden */
  36754. protected _depthCullingState: DepthCullingState;
  36755. /** @hidden */
  36756. protected _stencilState: StencilState;
  36757. /** @hidden */
  36758. _alphaState: AlphaState;
  36759. /** @hidden */
  36760. _alphaMode: number;
  36761. /** @hidden */
  36762. _alphaEquation: number;
  36763. /** @hidden */
  36764. _internalTexturesCache: InternalTexture[];
  36765. /** @hidden */
  36766. protected _activeChannel: number;
  36767. private _currentTextureChannel;
  36768. /** @hidden */
  36769. protected _boundTexturesCache: {
  36770. [key: string]: Nullable<InternalTexture>;
  36771. };
  36772. /** @hidden */
  36773. protected _currentEffect: Nullable<Effect>;
  36774. /** @hidden */
  36775. protected _currentProgram: Nullable<WebGLProgram>;
  36776. private _compiledEffects;
  36777. private _vertexAttribArraysEnabled;
  36778. /** @hidden */
  36779. protected _cachedViewport: Nullable<IViewportLike>;
  36780. private _cachedVertexArrayObject;
  36781. /** @hidden */
  36782. protected _cachedVertexBuffers: any;
  36783. /** @hidden */
  36784. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36785. /** @hidden */
  36786. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36787. /** @hidden */
  36788. _currentRenderTarget: Nullable<InternalTexture>;
  36789. private _uintIndicesCurrentlySet;
  36790. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36791. /** @hidden */
  36792. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36793. /** @hidden */
  36794. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36795. private _currentBufferPointers;
  36796. private _currentInstanceLocations;
  36797. private _currentInstanceBuffers;
  36798. private _textureUnits;
  36799. /** @hidden */
  36800. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36801. /** @hidden */
  36802. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36803. /** @hidden */
  36804. _boundRenderFunction: any;
  36805. private _vaoRecordInProgress;
  36806. private _mustWipeVertexAttributes;
  36807. private _emptyTexture;
  36808. private _emptyCubeTexture;
  36809. private _emptyTexture3D;
  36810. private _emptyTexture2DArray;
  36811. /** @hidden */
  36812. _frameHandler: number;
  36813. private _nextFreeTextureSlots;
  36814. private _maxSimultaneousTextures;
  36815. private _activeRequests;
  36816. /** @hidden */
  36817. _transformTextureUrl: Nullable<(url: string) => string>;
  36818. /**
  36819. * Gets information about the current host
  36820. */
  36821. hostInformation: HostInformation;
  36822. protected get _supportsHardwareTextureRescaling(): boolean;
  36823. private _framebufferDimensionsObject;
  36824. /**
  36825. * sets the object from which width and height will be taken from when getting render width and height
  36826. * Will fallback to the gl object
  36827. * @param dimensions the framebuffer width and height that will be used.
  36828. */
  36829. set framebufferDimensionsObject(dimensions: Nullable<{
  36830. framebufferWidth: number;
  36831. framebufferHeight: number;
  36832. }>);
  36833. /**
  36834. * Gets the current viewport
  36835. */
  36836. get currentViewport(): Nullable<IViewportLike>;
  36837. /**
  36838. * Gets the default empty texture
  36839. */
  36840. get emptyTexture(): InternalTexture;
  36841. /**
  36842. * Gets the default empty 3D texture
  36843. */
  36844. get emptyTexture3D(): InternalTexture;
  36845. /**
  36846. * Gets the default empty 2D array texture
  36847. */
  36848. get emptyTexture2DArray(): InternalTexture;
  36849. /**
  36850. * Gets the default empty cube texture
  36851. */
  36852. get emptyCubeTexture(): InternalTexture;
  36853. /**
  36854. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36855. */
  36856. readonly premultipliedAlpha: boolean;
  36857. /**
  36858. * Observable event triggered before each texture is initialized
  36859. */
  36860. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36861. /**
  36862. * Creates a new engine
  36863. * @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
  36864. * @param antialias defines enable antialiasing (default: false)
  36865. * @param options defines further options to be sent to the getContext() function
  36866. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36867. */
  36868. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36869. private _rebuildInternalTextures;
  36870. private _rebuildEffects;
  36871. /**
  36872. * Gets a boolean indicating if all created effects are ready
  36873. * @returns true if all effects are ready
  36874. */
  36875. areAllEffectsReady(): boolean;
  36876. protected _rebuildBuffers(): void;
  36877. protected _initGLContext(): void;
  36878. /**
  36879. * Gets version of the current webGL context
  36880. */
  36881. get webGLVersion(): number;
  36882. /**
  36883. * Gets a string identifying the name of the class
  36884. * @returns "Engine" string
  36885. */
  36886. getClassName(): string;
  36887. /**
  36888. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36889. */
  36890. get isStencilEnable(): boolean;
  36891. /** @hidden */
  36892. _prepareWorkingCanvas(): void;
  36893. /**
  36894. * Reset the texture cache to empty state
  36895. */
  36896. resetTextureCache(): void;
  36897. /**
  36898. * Gets an object containing information about the current webGL context
  36899. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36900. */
  36901. getGlInfo(): {
  36902. vendor: string;
  36903. renderer: string;
  36904. version: string;
  36905. };
  36906. /**
  36907. * Defines the hardware scaling level.
  36908. * By default the hardware scaling level is computed from the window device ratio.
  36909. * 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.
  36910. * @param level defines the level to use
  36911. */
  36912. setHardwareScalingLevel(level: number): void;
  36913. /**
  36914. * Gets the current hardware scaling level.
  36915. * By default the hardware scaling level is computed from the window device ratio.
  36916. * 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.
  36917. * @returns a number indicating the current hardware scaling level
  36918. */
  36919. getHardwareScalingLevel(): number;
  36920. /**
  36921. * Gets the list of loaded textures
  36922. * @returns an array containing all loaded textures
  36923. */
  36924. getLoadedTexturesCache(): InternalTexture[];
  36925. /**
  36926. * Gets the object containing all engine capabilities
  36927. * @returns the EngineCapabilities object
  36928. */
  36929. getCaps(): EngineCapabilities;
  36930. /**
  36931. * stop executing a render loop function and remove it from the execution array
  36932. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36933. */
  36934. stopRenderLoop(renderFunction?: () => void): void;
  36935. /** @hidden */
  36936. _renderLoop(): void;
  36937. /**
  36938. * Gets the HTML canvas attached with the current webGL context
  36939. * @returns a HTML canvas
  36940. */
  36941. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36942. /**
  36943. * Gets host window
  36944. * @returns the host window object
  36945. */
  36946. getHostWindow(): Nullable<Window>;
  36947. /**
  36948. * Gets the current render width
  36949. * @param useScreen defines if screen size must be used (or the current render target if any)
  36950. * @returns a number defining the current render width
  36951. */
  36952. getRenderWidth(useScreen?: boolean): number;
  36953. /**
  36954. * Gets the current render height
  36955. * @param useScreen defines if screen size must be used (or the current render target if any)
  36956. * @returns a number defining the current render height
  36957. */
  36958. getRenderHeight(useScreen?: boolean): number;
  36959. /**
  36960. * Can be used to override the current requestAnimationFrame requester.
  36961. * @hidden
  36962. */
  36963. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36964. /**
  36965. * Register and execute a render loop. The engine can have more than one render function
  36966. * @param renderFunction defines the function to continuously execute
  36967. */
  36968. runRenderLoop(renderFunction: () => void): void;
  36969. /**
  36970. * Clear the current render buffer or the current render target (if any is set up)
  36971. * @param color defines the color to use
  36972. * @param backBuffer defines if the back buffer must be cleared
  36973. * @param depth defines if the depth buffer must be cleared
  36974. * @param stencil defines if the stencil buffer must be cleared
  36975. */
  36976. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36977. private _viewportCached;
  36978. /** @hidden */
  36979. _viewport(x: number, y: number, width: number, height: number): void;
  36980. /**
  36981. * Set the WebGL's viewport
  36982. * @param viewport defines the viewport element to be used
  36983. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36984. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36985. */
  36986. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36987. /**
  36988. * Begin a new frame
  36989. */
  36990. beginFrame(): void;
  36991. /**
  36992. * Enf the current frame
  36993. */
  36994. endFrame(): void;
  36995. /**
  36996. * Resize the view according to the canvas' size
  36997. */
  36998. resize(): void;
  36999. /**
  37000. * Force a specific size of the canvas
  37001. * @param width defines the new canvas' width
  37002. * @param height defines the new canvas' height
  37003. * @returns true if the size was changed
  37004. */
  37005. setSize(width: number, height: number): boolean;
  37006. /**
  37007. * Binds the frame buffer to the specified texture.
  37008. * @param texture The texture to render to or null for the default canvas
  37009. * @param faceIndex The face of the texture to render to in case of cube texture
  37010. * @param requiredWidth The width of the target to render to
  37011. * @param requiredHeight The height of the target to render to
  37012. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  37013. * @param lodLevel defines the lod level to bind to the frame buffer
  37014. * @param layer defines the 2d array index to bind to frame buffer to
  37015. */
  37016. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  37017. /** @hidden */
  37018. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  37019. /**
  37020. * Unbind the current render target texture from the webGL context
  37021. * @param texture defines the render target texture to unbind
  37022. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  37023. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  37024. */
  37025. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  37026. /**
  37027. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  37028. */
  37029. flushFramebuffer(): void;
  37030. /**
  37031. * Unbind the current render target and bind the default framebuffer
  37032. */
  37033. restoreDefaultFramebuffer(): void;
  37034. /** @hidden */
  37035. protected _resetVertexBufferBinding(): void;
  37036. /**
  37037. * Creates a vertex buffer
  37038. * @param data the data for the vertex buffer
  37039. * @returns the new WebGL static buffer
  37040. */
  37041. createVertexBuffer(data: DataArray): DataBuffer;
  37042. private _createVertexBuffer;
  37043. /**
  37044. * Creates a dynamic vertex buffer
  37045. * @param data the data for the dynamic vertex buffer
  37046. * @returns the new WebGL dynamic buffer
  37047. */
  37048. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  37049. protected _resetIndexBufferBinding(): void;
  37050. /**
  37051. * Creates a new index buffer
  37052. * @param indices defines the content of the index buffer
  37053. * @param updatable defines if the index buffer must be updatable
  37054. * @returns a new webGL buffer
  37055. */
  37056. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  37057. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  37058. /**
  37059. * Bind a webGL buffer to the webGL context
  37060. * @param buffer defines the buffer to bind
  37061. */
  37062. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  37063. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  37064. private bindBuffer;
  37065. /**
  37066. * update the bound buffer with the given data
  37067. * @param data defines the data to update
  37068. */
  37069. updateArrayBuffer(data: Float32Array): void;
  37070. private _vertexAttribPointer;
  37071. /** @hidden */
  37072. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  37073. private _bindVertexBuffersAttributes;
  37074. /**
  37075. * Records a vertex array object
  37076. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37077. * @param vertexBuffers defines the list of vertex buffers to store
  37078. * @param indexBuffer defines the index buffer to store
  37079. * @param effect defines the effect to store
  37080. * @returns the new vertex array object
  37081. */
  37082. recordVertexArrayObject(vertexBuffers: {
  37083. [key: string]: VertexBuffer;
  37084. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  37085. /**
  37086. * Bind a specific vertex array object
  37087. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37088. * @param vertexArrayObject defines the vertex array object to bind
  37089. * @param indexBuffer defines the index buffer to bind
  37090. */
  37091. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  37092. /**
  37093. * Bind webGl buffers directly to the webGL context
  37094. * @param vertexBuffer defines the vertex buffer to bind
  37095. * @param indexBuffer defines the index buffer to bind
  37096. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  37097. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  37098. * @param effect defines the effect associated with the vertex buffer
  37099. */
  37100. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  37101. private _unbindVertexArrayObject;
  37102. /**
  37103. * Bind a list of vertex buffers to the webGL context
  37104. * @param vertexBuffers defines the list of vertex buffers to bind
  37105. * @param indexBuffer defines the index buffer to bind
  37106. * @param effect defines the effect associated with the vertex buffers
  37107. */
  37108. bindBuffers(vertexBuffers: {
  37109. [key: string]: Nullable<VertexBuffer>;
  37110. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  37111. /**
  37112. * Unbind all instance attributes
  37113. */
  37114. unbindInstanceAttributes(): void;
  37115. /**
  37116. * Release and free the memory of a vertex array object
  37117. * @param vao defines the vertex array object to delete
  37118. */
  37119. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  37120. /** @hidden */
  37121. _releaseBuffer(buffer: DataBuffer): boolean;
  37122. protected _deleteBuffer(buffer: DataBuffer): void;
  37123. /**
  37124. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  37125. * @param instancesBuffer defines the webGL buffer to update and bind
  37126. * @param data defines the data to store in the buffer
  37127. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  37128. */
  37129. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  37130. /**
  37131. * Bind the content of a webGL buffer used with instantiation
  37132. * @param instancesBuffer defines the webGL buffer to bind
  37133. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  37134. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  37135. */
  37136. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  37137. /**
  37138. * Disable the instance attribute corresponding to the name in parameter
  37139. * @param name defines the name of the attribute to disable
  37140. */
  37141. disableInstanceAttributeByName(name: string): void;
  37142. /**
  37143. * Disable the instance attribute corresponding to the location in parameter
  37144. * @param attributeLocation defines the attribute location of the attribute to disable
  37145. */
  37146. disableInstanceAttribute(attributeLocation: number): void;
  37147. /**
  37148. * Disable the attribute corresponding to the location in parameter
  37149. * @param attributeLocation defines the attribute location of the attribute to disable
  37150. */
  37151. disableAttributeByIndex(attributeLocation: number): void;
  37152. /**
  37153. * Send a draw order
  37154. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37155. * @param indexStart defines the starting index
  37156. * @param indexCount defines the number of index to draw
  37157. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37158. */
  37159. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  37160. /**
  37161. * Draw a list of points
  37162. * @param verticesStart defines the index of first vertex to draw
  37163. * @param verticesCount defines the count of vertices to draw
  37164. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37165. */
  37166. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37167. /**
  37168. * Draw a list of unindexed primitives
  37169. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37170. * @param verticesStart defines the index of first vertex to draw
  37171. * @param verticesCount defines the count of vertices to draw
  37172. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37173. */
  37174. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37175. /**
  37176. * Draw a list of indexed primitives
  37177. * @param fillMode defines the primitive to use
  37178. * @param indexStart defines the starting index
  37179. * @param indexCount defines the number of index to draw
  37180. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37181. */
  37182. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  37183. /**
  37184. * Draw a list of unindexed primitives
  37185. * @param fillMode defines the primitive to use
  37186. * @param verticesStart defines the index of first vertex to draw
  37187. * @param verticesCount defines the count of vertices to draw
  37188. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37189. */
  37190. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37191. private _drawMode;
  37192. /** @hidden */
  37193. protected _reportDrawCall(): void;
  37194. /** @hidden */
  37195. _releaseEffect(effect: Effect): void;
  37196. /** @hidden */
  37197. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37198. /**
  37199. * Create a new effect (used to store vertex/fragment shaders)
  37200. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  37201. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  37202. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  37203. * @param samplers defines an array of string used to represent textures
  37204. * @param defines defines the string containing the defines to use to compile the shaders
  37205. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  37206. * @param onCompiled defines a function to call when the effect creation is successful
  37207. * @param onError defines a function to call when the effect creation has failed
  37208. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  37209. * @returns the new Effect
  37210. */
  37211. 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;
  37212. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  37213. private _compileShader;
  37214. private _compileRawShader;
  37215. /** @hidden */
  37216. _getShaderSource(shader: WebGLShader): Nullable<string>;
  37217. /**
  37218. * Directly creates a webGL program
  37219. * @param pipelineContext defines the pipeline context to attach to
  37220. * @param vertexCode defines the vertex shader code to use
  37221. * @param fragmentCode defines the fragment shader code to use
  37222. * @param context defines the webGL context to use (if not set, the current one will be used)
  37223. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37224. * @returns the new webGL program
  37225. */
  37226. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37227. /**
  37228. * Creates a webGL program
  37229. * @param pipelineContext defines the pipeline context to attach to
  37230. * @param vertexCode defines the vertex shader code to use
  37231. * @param fragmentCode defines the fragment shader code to use
  37232. * @param defines defines the string containing the defines to use to compile the shaders
  37233. * @param context defines the webGL context to use (if not set, the current one will be used)
  37234. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37235. * @returns the new webGL program
  37236. */
  37237. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37238. /**
  37239. * Creates a new pipeline context
  37240. * @returns the new pipeline
  37241. */
  37242. createPipelineContext(): IPipelineContext;
  37243. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37244. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37245. /** @hidden */
  37246. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37247. /** @hidden */
  37248. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37249. /** @hidden */
  37250. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37251. /**
  37252. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37253. * @param pipelineContext defines the pipeline context to use
  37254. * @param uniformsNames defines the list of uniform names
  37255. * @returns an array of webGL uniform locations
  37256. */
  37257. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37258. /**
  37259. * Gets the lsit of active attributes for a given webGL program
  37260. * @param pipelineContext defines the pipeline context to use
  37261. * @param attributesNames defines the list of attribute names to get
  37262. * @returns an array of indices indicating the offset of each attribute
  37263. */
  37264. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37265. /**
  37266. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37267. * @param effect defines the effect to activate
  37268. */
  37269. enableEffect(effect: Nullable<Effect>): void;
  37270. /**
  37271. * Set the value of an uniform to a number (int)
  37272. * @param uniform defines the webGL uniform location where to store the value
  37273. * @param value defines the int number to store
  37274. * @returns true if the value was set
  37275. */
  37276. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  37277. /**
  37278. * Set the value of an uniform to an array of int32
  37279. * @param uniform defines the webGL uniform location where to store the value
  37280. * @param array defines the array of int32 to store
  37281. * @returns true if the value was set
  37282. */
  37283. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37284. /**
  37285. * Set the value of an uniform to an array of int32 (stored as vec2)
  37286. * @param uniform defines the webGL uniform location where to store the value
  37287. * @param array defines the array of int32 to store
  37288. * @returns true if the value was set
  37289. */
  37290. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37291. /**
  37292. * Set the value of an uniform to an array of int32 (stored as vec3)
  37293. * @param uniform defines the webGL uniform location where to store the value
  37294. * @param array defines the array of int32 to store
  37295. * @returns true if the value was set
  37296. */
  37297. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37298. /**
  37299. * Set the value of an uniform to an array of int32 (stored as vec4)
  37300. * @param uniform defines the webGL uniform location where to store the value
  37301. * @param array defines the array of int32 to store
  37302. * @returns true if the value was set
  37303. */
  37304. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37305. /**
  37306. * Set the value of an uniform to an array of number
  37307. * @param uniform defines the webGL uniform location where to store the value
  37308. * @param array defines the array of number to store
  37309. * @returns true if the value was set
  37310. */
  37311. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37312. /**
  37313. * Set the value of an uniform to an array of number (stored as vec2)
  37314. * @param uniform defines the webGL uniform location where to store the value
  37315. * @param array defines the array of number to store
  37316. * @returns true if the value was set
  37317. */
  37318. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37319. /**
  37320. * Set the value of an uniform to an array of number (stored as vec3)
  37321. * @param uniform defines the webGL uniform location where to store the value
  37322. * @param array defines the array of number to store
  37323. * @returns true if the value was set
  37324. */
  37325. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37326. /**
  37327. * Set the value of an uniform to an array of number (stored as vec4)
  37328. * @param uniform defines the webGL uniform location where to store the value
  37329. * @param array defines the array of number to store
  37330. * @returns true if the value was set
  37331. */
  37332. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37333. /**
  37334. * Set the value of an uniform to an array of float32 (stored as matrices)
  37335. * @param uniform defines the webGL uniform location where to store the value
  37336. * @param matrices defines the array of float32 to store
  37337. * @returns true if the value was set
  37338. */
  37339. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  37340. /**
  37341. * Set the value of an uniform to a matrix (3x3)
  37342. * @param uniform defines the webGL uniform location where to store the value
  37343. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37344. * @returns true if the value was set
  37345. */
  37346. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  37347. /**
  37348. * Set the value of an uniform to a matrix (2x2)
  37349. * @param uniform defines the webGL uniform location where to store the value
  37350. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37351. * @returns true if the value was set
  37352. */
  37353. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  37354. /**
  37355. * Set the value of an uniform to a number (float)
  37356. * @param uniform defines the webGL uniform location where to store the value
  37357. * @param value defines the float number to store
  37358. * @returns true if the value was transfered
  37359. */
  37360. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  37361. /**
  37362. * Set the value of an uniform to a vec2
  37363. * @param uniform defines the webGL uniform location where to store the value
  37364. * @param x defines the 1st component of the value
  37365. * @param y defines the 2nd component of the value
  37366. * @returns true if the value was set
  37367. */
  37368. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  37369. /**
  37370. * Set the value of an uniform to a vec3
  37371. * @param uniform defines the webGL uniform location where to store the value
  37372. * @param x defines the 1st component of the value
  37373. * @param y defines the 2nd component of the value
  37374. * @param z defines the 3rd component of the value
  37375. * @returns true if the value was set
  37376. */
  37377. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  37378. /**
  37379. * Set the value of an uniform to a vec4
  37380. * @param uniform defines the webGL uniform location where to store the value
  37381. * @param x defines the 1st component of the value
  37382. * @param y defines the 2nd component of the value
  37383. * @param z defines the 3rd component of the value
  37384. * @param w defines the 4th component of the value
  37385. * @returns true if the value was set
  37386. */
  37387. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  37388. /**
  37389. * Apply all cached states (depth, culling, stencil and alpha)
  37390. */
  37391. applyStates(): void;
  37392. /**
  37393. * Enable or disable color writing
  37394. * @param enable defines the state to set
  37395. */
  37396. setColorWrite(enable: boolean): void;
  37397. /**
  37398. * Gets a boolean indicating if color writing is enabled
  37399. * @returns the current color writing state
  37400. */
  37401. getColorWrite(): boolean;
  37402. /**
  37403. * Gets the depth culling state manager
  37404. */
  37405. get depthCullingState(): DepthCullingState;
  37406. /**
  37407. * Gets the alpha state manager
  37408. */
  37409. get alphaState(): AlphaState;
  37410. /**
  37411. * Gets the stencil state manager
  37412. */
  37413. get stencilState(): StencilState;
  37414. /**
  37415. * Clears the list of texture accessible through engine.
  37416. * This can help preventing texture load conflict due to name collision.
  37417. */
  37418. clearInternalTexturesCache(): void;
  37419. /**
  37420. * Force the entire cache to be cleared
  37421. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37422. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37423. */
  37424. wipeCaches(bruteForce?: boolean): void;
  37425. /** @hidden */
  37426. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37427. min: number;
  37428. mag: number;
  37429. };
  37430. /** @hidden */
  37431. _createTexture(): WebGLTexture;
  37432. /**
  37433. * Usually called from Texture.ts.
  37434. * Passed information to create a WebGLTexture
  37435. * @param url defines a value which contains one of the following:
  37436. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37437. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37438. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37439. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37440. * @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)
  37441. * @param scene needed for loading to the correct scene
  37442. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37443. * @param onLoad optional callback to be called upon successful completion
  37444. * @param onError optional callback to be called upon failure
  37445. * @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
  37446. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37447. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37448. * @param forcedExtension defines the extension to use to pick the right loader
  37449. * @param mimeType defines an optional mime type
  37450. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37451. */
  37452. 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;
  37453. /**
  37454. * Loads an image as an HTMLImageElement.
  37455. * @param input url string, ArrayBuffer, or Blob to load
  37456. * @param onLoad callback called when the image successfully loads
  37457. * @param onError callback called when the image fails to load
  37458. * @param offlineProvider offline provider for caching
  37459. * @param mimeType optional mime type
  37460. * @returns the HTMLImageElement of the loaded image
  37461. * @hidden
  37462. */
  37463. 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>;
  37464. /**
  37465. * @hidden
  37466. */
  37467. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37468. private _unpackFlipYCached;
  37469. /**
  37470. * In case you are sharing the context with other applications, it might
  37471. * be interested to not cache the unpack flip y state to ensure a consistent
  37472. * value would be set.
  37473. */
  37474. enableUnpackFlipYCached: boolean;
  37475. /** @hidden */
  37476. _unpackFlipY(value: boolean): void;
  37477. /** @hidden */
  37478. _getUnpackAlignement(): number;
  37479. private _getTextureTarget;
  37480. /**
  37481. * Update the sampling mode of a given texture
  37482. * @param samplingMode defines the required sampling mode
  37483. * @param texture defines the texture to update
  37484. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37485. */
  37486. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37487. /**
  37488. * Update the sampling mode of a given texture
  37489. * @param texture defines the texture to update
  37490. * @param wrapU defines the texture wrap mode of the u coordinates
  37491. * @param wrapV defines the texture wrap mode of the v coordinates
  37492. * @param wrapR defines the texture wrap mode of the r coordinates
  37493. */
  37494. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37495. /** @hidden */
  37496. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37497. width: number;
  37498. height: number;
  37499. layers?: number;
  37500. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37501. /** @hidden */
  37502. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37503. /** @hidden */
  37504. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37505. /**
  37506. * Update a portion of an internal texture
  37507. * @param texture defines the texture to update
  37508. * @param imageData defines the data to store into the texture
  37509. * @param xOffset defines the x coordinates of the update rectangle
  37510. * @param yOffset defines the y coordinates of the update rectangle
  37511. * @param width defines the width of the update rectangle
  37512. * @param height defines the height of the update rectangle
  37513. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37514. * @param lod defines the lod level to update (0 by default)
  37515. */
  37516. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37517. /** @hidden */
  37518. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37519. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37520. private _prepareWebGLTexture;
  37521. /** @hidden */
  37522. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37523. private _getDepthStencilBuffer;
  37524. /** @hidden */
  37525. _releaseFramebufferObjects(texture: InternalTexture): void;
  37526. /** @hidden */
  37527. _releaseTexture(texture: InternalTexture): void;
  37528. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37529. protected _setProgram(program: WebGLProgram): void;
  37530. protected _boundUniforms: {
  37531. [key: number]: WebGLUniformLocation;
  37532. };
  37533. /**
  37534. * Binds an effect to the webGL context
  37535. * @param effect defines the effect to bind
  37536. */
  37537. bindSamplers(effect: Effect): void;
  37538. private _activateCurrentTexture;
  37539. /** @hidden */
  37540. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37541. /** @hidden */
  37542. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37543. /**
  37544. * Unbind all textures from the webGL context
  37545. */
  37546. unbindAllTextures(): void;
  37547. /**
  37548. * Sets a texture to the according uniform.
  37549. * @param channel The texture channel
  37550. * @param uniform The uniform to set
  37551. * @param texture The texture to apply
  37552. */
  37553. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37554. private _bindSamplerUniformToChannel;
  37555. private _getTextureWrapMode;
  37556. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37557. /**
  37558. * Sets an array of texture to the webGL context
  37559. * @param channel defines the channel where the texture array must be set
  37560. * @param uniform defines the associated uniform location
  37561. * @param textures defines the array of textures to bind
  37562. */
  37563. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37564. /** @hidden */
  37565. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37566. private _setTextureParameterFloat;
  37567. private _setTextureParameterInteger;
  37568. /**
  37569. * Unbind all vertex attributes from the webGL context
  37570. */
  37571. unbindAllAttributes(): void;
  37572. /**
  37573. * 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
  37574. */
  37575. releaseEffects(): void;
  37576. /**
  37577. * Dispose and release all associated resources
  37578. */
  37579. dispose(): void;
  37580. /**
  37581. * Attach a new callback raised when context lost event is fired
  37582. * @param callback defines the callback to call
  37583. */
  37584. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37585. /**
  37586. * Attach a new callback raised when context restored event is fired
  37587. * @param callback defines the callback to call
  37588. */
  37589. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37590. /**
  37591. * Get the current error code of the webGL context
  37592. * @returns the error code
  37593. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37594. */
  37595. getError(): number;
  37596. private _canRenderToFloatFramebuffer;
  37597. private _canRenderToHalfFloatFramebuffer;
  37598. private _canRenderToFramebuffer;
  37599. /** @hidden */
  37600. _getWebGLTextureType(type: number): number;
  37601. /** @hidden */
  37602. _getInternalFormat(format: number): number;
  37603. /** @hidden */
  37604. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37605. /** @hidden */
  37606. _getRGBAMultiSampleBufferFormat(type: number): number;
  37607. /** @hidden */
  37608. _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;
  37609. /**
  37610. * Loads a file from a url
  37611. * @param url url to load
  37612. * @param onSuccess callback called when the file successfully loads
  37613. * @param onProgress callback called while file is loading (if the server supports this mode)
  37614. * @param offlineProvider defines the offline provider for caching
  37615. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37616. * @param onError callback called when the file fails to load
  37617. * @returns a file request object
  37618. * @hidden
  37619. */
  37620. 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;
  37621. /**
  37622. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37623. * @param x defines the x coordinate of the rectangle where pixels must be read
  37624. * @param y defines the y coordinate of the rectangle where pixels must be read
  37625. * @param width defines the width of the rectangle where pixels must be read
  37626. * @param height defines the height of the rectangle where pixels must be read
  37627. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37628. * @returns a Uint8Array containing RGBA colors
  37629. */
  37630. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37631. private static _IsSupported;
  37632. private static _HasMajorPerformanceCaveat;
  37633. /**
  37634. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37635. */
  37636. static get IsSupported(): boolean;
  37637. /**
  37638. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37639. * @returns true if the engine can be created
  37640. * @ignorenaming
  37641. */
  37642. static isSupported(): boolean;
  37643. /**
  37644. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  37645. */
  37646. static get HasMajorPerformanceCaveat(): boolean;
  37647. /**
  37648. * Find the next highest power of two.
  37649. * @param x Number to start search from.
  37650. * @return Next highest power of two.
  37651. */
  37652. static CeilingPOT(x: number): number;
  37653. /**
  37654. * Find the next lowest power of two.
  37655. * @param x Number to start search from.
  37656. * @return Next lowest power of two.
  37657. */
  37658. static FloorPOT(x: number): number;
  37659. /**
  37660. * Find the nearest power of two.
  37661. * @param x Number to start search from.
  37662. * @return Next nearest power of two.
  37663. */
  37664. static NearestPOT(x: number): number;
  37665. /**
  37666. * Get the closest exponent of two
  37667. * @param value defines the value to approximate
  37668. * @param max defines the maximum value to return
  37669. * @param mode defines how to define the closest value
  37670. * @returns closest exponent of two of the given value
  37671. */
  37672. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37673. /**
  37674. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37675. * @param func - the function to be called
  37676. * @param requester - the object that will request the next frame. Falls back to window.
  37677. * @returns frame number
  37678. */
  37679. static QueueNewFrame(func: () => void, requester?: any): number;
  37680. /**
  37681. * Gets host document
  37682. * @returns the host document object
  37683. */
  37684. getHostDocument(): Nullable<Document>;
  37685. }
  37686. }
  37687. declare module "babylonjs/Maths/sphericalPolynomial" {
  37688. import { Vector3 } from "babylonjs/Maths/math.vector";
  37689. import { Color3 } from "babylonjs/Maths/math.color";
  37690. /**
  37691. * Class representing spherical harmonics coefficients to the 3rd degree
  37692. */
  37693. export class SphericalHarmonics {
  37694. /**
  37695. * Defines whether or not the harmonics have been prescaled for rendering.
  37696. */
  37697. preScaled: boolean;
  37698. /**
  37699. * The l0,0 coefficients of the spherical harmonics
  37700. */
  37701. l00: Vector3;
  37702. /**
  37703. * The l1,-1 coefficients of the spherical harmonics
  37704. */
  37705. l1_1: Vector3;
  37706. /**
  37707. * The l1,0 coefficients of the spherical harmonics
  37708. */
  37709. l10: Vector3;
  37710. /**
  37711. * The l1,1 coefficients of the spherical harmonics
  37712. */
  37713. l11: Vector3;
  37714. /**
  37715. * The l2,-2 coefficients of the spherical harmonics
  37716. */
  37717. l2_2: Vector3;
  37718. /**
  37719. * The l2,-1 coefficients of the spherical harmonics
  37720. */
  37721. l2_1: Vector3;
  37722. /**
  37723. * The l2,0 coefficients of the spherical harmonics
  37724. */
  37725. l20: Vector3;
  37726. /**
  37727. * The l2,1 coefficients of the spherical harmonics
  37728. */
  37729. l21: Vector3;
  37730. /**
  37731. * The l2,2 coefficients of the spherical harmonics
  37732. */
  37733. l22: Vector3;
  37734. /**
  37735. * Adds a light to the spherical harmonics
  37736. * @param direction the direction of the light
  37737. * @param color the color of the light
  37738. * @param deltaSolidAngle the delta solid angle of the light
  37739. */
  37740. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37741. /**
  37742. * Scales the spherical harmonics by the given amount
  37743. * @param scale the amount to scale
  37744. */
  37745. scaleInPlace(scale: number): void;
  37746. /**
  37747. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37748. *
  37749. * ```
  37750. * E_lm = A_l * L_lm
  37751. * ```
  37752. *
  37753. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37754. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37755. * the scaling factors are given in equation 9.
  37756. */
  37757. convertIncidentRadianceToIrradiance(): void;
  37758. /**
  37759. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37760. *
  37761. * ```
  37762. * L = (1/pi) * E * rho
  37763. * ```
  37764. *
  37765. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37766. */
  37767. convertIrradianceToLambertianRadiance(): void;
  37768. /**
  37769. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37770. * required operations at run time.
  37771. *
  37772. * This is simply done by scaling back the SH with Ylm constants parameter.
  37773. * The trigonometric part being applied by the shader at run time.
  37774. */
  37775. preScaleForRendering(): void;
  37776. /**
  37777. * Constructs a spherical harmonics from an array.
  37778. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37779. * @returns the spherical harmonics
  37780. */
  37781. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37782. /**
  37783. * Gets the spherical harmonics from polynomial
  37784. * @param polynomial the spherical polynomial
  37785. * @returns the spherical harmonics
  37786. */
  37787. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37788. }
  37789. /**
  37790. * Class representing spherical polynomial coefficients to the 3rd degree
  37791. */
  37792. export class SphericalPolynomial {
  37793. private _harmonics;
  37794. /**
  37795. * The spherical harmonics used to create the polynomials.
  37796. */
  37797. get preScaledHarmonics(): SphericalHarmonics;
  37798. /**
  37799. * The x coefficients of the spherical polynomial
  37800. */
  37801. x: Vector3;
  37802. /**
  37803. * The y coefficients of the spherical polynomial
  37804. */
  37805. y: Vector3;
  37806. /**
  37807. * The z coefficients of the spherical polynomial
  37808. */
  37809. z: Vector3;
  37810. /**
  37811. * The xx coefficients of the spherical polynomial
  37812. */
  37813. xx: Vector3;
  37814. /**
  37815. * The yy coefficients of the spherical polynomial
  37816. */
  37817. yy: Vector3;
  37818. /**
  37819. * The zz coefficients of the spherical polynomial
  37820. */
  37821. zz: Vector3;
  37822. /**
  37823. * The xy coefficients of the spherical polynomial
  37824. */
  37825. xy: Vector3;
  37826. /**
  37827. * The yz coefficients of the spherical polynomial
  37828. */
  37829. yz: Vector3;
  37830. /**
  37831. * The zx coefficients of the spherical polynomial
  37832. */
  37833. zx: Vector3;
  37834. /**
  37835. * Adds an ambient color to the spherical polynomial
  37836. * @param color the color to add
  37837. */
  37838. addAmbient(color: Color3): void;
  37839. /**
  37840. * Scales the spherical polynomial by the given amount
  37841. * @param scale the amount to scale
  37842. */
  37843. scaleInPlace(scale: number): void;
  37844. /**
  37845. * Gets the spherical polynomial from harmonics
  37846. * @param harmonics the spherical harmonics
  37847. * @returns the spherical polynomial
  37848. */
  37849. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37850. /**
  37851. * Constructs a spherical polynomial from an array.
  37852. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37853. * @returns the spherical polynomial
  37854. */
  37855. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37856. }
  37857. }
  37858. declare module "babylonjs/Materials/Textures/internalTexture" {
  37859. import { Observable } from "babylonjs/Misc/observable";
  37860. import { Nullable, int } from "babylonjs/types";
  37861. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37862. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37863. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37864. /**
  37865. * Defines the source of the internal texture
  37866. */
  37867. export enum InternalTextureSource {
  37868. /**
  37869. * The source of the texture data is unknown
  37870. */
  37871. Unknown = 0,
  37872. /**
  37873. * Texture data comes from an URL
  37874. */
  37875. Url = 1,
  37876. /**
  37877. * Texture data is only used for temporary storage
  37878. */
  37879. Temp = 2,
  37880. /**
  37881. * Texture data comes from raw data (ArrayBuffer)
  37882. */
  37883. Raw = 3,
  37884. /**
  37885. * Texture content is dynamic (video or dynamic texture)
  37886. */
  37887. Dynamic = 4,
  37888. /**
  37889. * Texture content is generated by rendering to it
  37890. */
  37891. RenderTarget = 5,
  37892. /**
  37893. * Texture content is part of a multi render target process
  37894. */
  37895. MultiRenderTarget = 6,
  37896. /**
  37897. * Texture data comes from a cube data file
  37898. */
  37899. Cube = 7,
  37900. /**
  37901. * Texture data comes from a raw cube data
  37902. */
  37903. CubeRaw = 8,
  37904. /**
  37905. * Texture data come from a prefiltered cube data file
  37906. */
  37907. CubePrefiltered = 9,
  37908. /**
  37909. * Texture content is raw 3D data
  37910. */
  37911. Raw3D = 10,
  37912. /**
  37913. * Texture content is raw 2D array data
  37914. */
  37915. Raw2DArray = 11,
  37916. /**
  37917. * Texture content is a depth texture
  37918. */
  37919. Depth = 12,
  37920. /**
  37921. * Texture data comes from a raw cube data encoded with RGBD
  37922. */
  37923. CubeRawRGBD = 13
  37924. }
  37925. /**
  37926. * Class used to store data associated with WebGL texture data for the engine
  37927. * This class should not be used directly
  37928. */
  37929. export class InternalTexture {
  37930. /** @hidden */
  37931. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37932. /**
  37933. * Defines if the texture is ready
  37934. */
  37935. isReady: boolean;
  37936. /**
  37937. * Defines if the texture is a cube texture
  37938. */
  37939. isCube: boolean;
  37940. /**
  37941. * Defines if the texture contains 3D data
  37942. */
  37943. is3D: boolean;
  37944. /**
  37945. * Defines if the texture contains 2D array data
  37946. */
  37947. is2DArray: boolean;
  37948. /**
  37949. * Defines if the texture contains multiview data
  37950. */
  37951. isMultiview: boolean;
  37952. /**
  37953. * Gets the URL used to load this texture
  37954. */
  37955. url: string;
  37956. /**
  37957. * Gets the sampling mode of the texture
  37958. */
  37959. samplingMode: number;
  37960. /**
  37961. * Gets a boolean indicating if the texture needs mipmaps generation
  37962. */
  37963. generateMipMaps: boolean;
  37964. /**
  37965. * Gets the number of samples used by the texture (WebGL2+ only)
  37966. */
  37967. samples: number;
  37968. /**
  37969. * Gets the type of the texture (int, float...)
  37970. */
  37971. type: number;
  37972. /**
  37973. * Gets the format of the texture (RGB, RGBA...)
  37974. */
  37975. format: number;
  37976. /**
  37977. * Observable called when the texture is loaded
  37978. */
  37979. onLoadedObservable: Observable<InternalTexture>;
  37980. /**
  37981. * Gets the width of the texture
  37982. */
  37983. width: number;
  37984. /**
  37985. * Gets the height of the texture
  37986. */
  37987. height: number;
  37988. /**
  37989. * Gets the depth of the texture
  37990. */
  37991. depth: number;
  37992. /**
  37993. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37994. */
  37995. baseWidth: number;
  37996. /**
  37997. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37998. */
  37999. baseHeight: number;
  38000. /**
  38001. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  38002. */
  38003. baseDepth: number;
  38004. /**
  38005. * Gets a boolean indicating if the texture is inverted on Y axis
  38006. */
  38007. invertY: boolean;
  38008. /** @hidden */
  38009. _invertVScale: boolean;
  38010. /** @hidden */
  38011. _associatedChannel: number;
  38012. /** @hidden */
  38013. _source: InternalTextureSource;
  38014. /** @hidden */
  38015. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  38016. /** @hidden */
  38017. _bufferView: Nullable<ArrayBufferView>;
  38018. /** @hidden */
  38019. _bufferViewArray: Nullable<ArrayBufferView[]>;
  38020. /** @hidden */
  38021. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  38022. /** @hidden */
  38023. _size: number;
  38024. /** @hidden */
  38025. _extension: string;
  38026. /** @hidden */
  38027. _files: Nullable<string[]>;
  38028. /** @hidden */
  38029. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38030. /** @hidden */
  38031. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38032. /** @hidden */
  38033. _framebuffer: Nullable<WebGLFramebuffer>;
  38034. /** @hidden */
  38035. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  38036. /** @hidden */
  38037. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  38038. /** @hidden */
  38039. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  38040. /** @hidden */
  38041. _attachments: Nullable<number[]>;
  38042. /** @hidden */
  38043. _textureArray: Nullable<InternalTexture[]>;
  38044. /** @hidden */
  38045. _cachedCoordinatesMode: Nullable<number>;
  38046. /** @hidden */
  38047. _cachedWrapU: Nullable<number>;
  38048. /** @hidden */
  38049. _cachedWrapV: Nullable<number>;
  38050. /** @hidden */
  38051. _cachedWrapR: Nullable<number>;
  38052. /** @hidden */
  38053. _cachedAnisotropicFilteringLevel: Nullable<number>;
  38054. /** @hidden */
  38055. _isDisabled: boolean;
  38056. /** @hidden */
  38057. _compression: Nullable<string>;
  38058. /** @hidden */
  38059. _generateStencilBuffer: boolean;
  38060. /** @hidden */
  38061. _generateDepthBuffer: boolean;
  38062. /** @hidden */
  38063. _comparisonFunction: number;
  38064. /** @hidden */
  38065. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  38066. /** @hidden */
  38067. _lodGenerationScale: number;
  38068. /** @hidden */
  38069. _lodGenerationOffset: number;
  38070. /** @hidden */
  38071. _depthStencilTexture: Nullable<InternalTexture>;
  38072. /** @hidden */
  38073. _colorTextureArray: Nullable<WebGLTexture>;
  38074. /** @hidden */
  38075. _depthStencilTextureArray: Nullable<WebGLTexture>;
  38076. /** @hidden */
  38077. _lodTextureHigh: Nullable<BaseTexture>;
  38078. /** @hidden */
  38079. _lodTextureMid: Nullable<BaseTexture>;
  38080. /** @hidden */
  38081. _lodTextureLow: Nullable<BaseTexture>;
  38082. /** @hidden */
  38083. _isRGBD: boolean;
  38084. /** @hidden */
  38085. _linearSpecularLOD: boolean;
  38086. /** @hidden */
  38087. _irradianceTexture: Nullable<BaseTexture>;
  38088. /** @hidden */
  38089. _webGLTexture: Nullable<WebGLTexture>;
  38090. /** @hidden */
  38091. _references: number;
  38092. /** @hidden */
  38093. _gammaSpace: Nullable<boolean>;
  38094. private _engine;
  38095. /**
  38096. * Gets the Engine the texture belongs to.
  38097. * @returns The babylon engine
  38098. */
  38099. getEngine(): ThinEngine;
  38100. /**
  38101. * Gets the data source type of the texture
  38102. */
  38103. get source(): InternalTextureSource;
  38104. /**
  38105. * Creates a new InternalTexture
  38106. * @param engine defines the engine to use
  38107. * @param source defines the type of data that will be used
  38108. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38109. */
  38110. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  38111. /**
  38112. * Increments the number of references (ie. the number of Texture that point to it)
  38113. */
  38114. incrementReferences(): void;
  38115. /**
  38116. * Change the size of the texture (not the size of the content)
  38117. * @param width defines the new width
  38118. * @param height defines the new height
  38119. * @param depth defines the new depth (1 by default)
  38120. */
  38121. updateSize(width: int, height: int, depth?: int): void;
  38122. /** @hidden */
  38123. _rebuild(): void;
  38124. /** @hidden */
  38125. _swapAndDie(target: InternalTexture): void;
  38126. /**
  38127. * Dispose the current allocated resources
  38128. */
  38129. dispose(): void;
  38130. }
  38131. }
  38132. declare module "babylonjs/Audio/analyser" {
  38133. import { Scene } from "babylonjs/scene";
  38134. /**
  38135. * Class used to work with sound analyzer using fast fourier transform (FFT)
  38136. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38137. */
  38138. export class Analyser {
  38139. /**
  38140. * Gets or sets the smoothing
  38141. * @ignorenaming
  38142. */
  38143. SMOOTHING: number;
  38144. /**
  38145. * Gets or sets the FFT table size
  38146. * @ignorenaming
  38147. */
  38148. FFT_SIZE: number;
  38149. /**
  38150. * Gets or sets the bar graph amplitude
  38151. * @ignorenaming
  38152. */
  38153. BARGRAPHAMPLITUDE: number;
  38154. /**
  38155. * Gets or sets the position of the debug canvas
  38156. * @ignorenaming
  38157. */
  38158. DEBUGCANVASPOS: {
  38159. x: number;
  38160. y: number;
  38161. };
  38162. /**
  38163. * Gets or sets the debug canvas size
  38164. * @ignorenaming
  38165. */
  38166. DEBUGCANVASSIZE: {
  38167. width: number;
  38168. height: number;
  38169. };
  38170. private _byteFreqs;
  38171. private _byteTime;
  38172. private _floatFreqs;
  38173. private _webAudioAnalyser;
  38174. private _debugCanvas;
  38175. private _debugCanvasContext;
  38176. private _scene;
  38177. private _registerFunc;
  38178. private _audioEngine;
  38179. /**
  38180. * Creates a new analyser
  38181. * @param scene defines hosting scene
  38182. */
  38183. constructor(scene: Scene);
  38184. /**
  38185. * Get the number of data values you will have to play with for the visualization
  38186. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  38187. * @returns a number
  38188. */
  38189. getFrequencyBinCount(): number;
  38190. /**
  38191. * Gets the current frequency data as a byte array
  38192. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38193. * @returns a Uint8Array
  38194. */
  38195. getByteFrequencyData(): Uint8Array;
  38196. /**
  38197. * Gets the current waveform as a byte array
  38198. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  38199. * @returns a Uint8Array
  38200. */
  38201. getByteTimeDomainData(): Uint8Array;
  38202. /**
  38203. * Gets the current frequency data as a float array
  38204. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38205. * @returns a Float32Array
  38206. */
  38207. getFloatFrequencyData(): Float32Array;
  38208. /**
  38209. * Renders the debug canvas
  38210. */
  38211. drawDebugCanvas(): void;
  38212. /**
  38213. * Stops rendering the debug canvas and removes it
  38214. */
  38215. stopDebugCanvas(): void;
  38216. /**
  38217. * Connects two audio nodes
  38218. * @param inputAudioNode defines first node to connect
  38219. * @param outputAudioNode defines second node to connect
  38220. */
  38221. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  38222. /**
  38223. * Releases all associated resources
  38224. */
  38225. dispose(): void;
  38226. }
  38227. }
  38228. declare module "babylonjs/Audio/audioEngine" {
  38229. import { IDisposable } from "babylonjs/scene";
  38230. import { Analyser } from "babylonjs/Audio/analyser";
  38231. import { Nullable } from "babylonjs/types";
  38232. import { Observable } from "babylonjs/Misc/observable";
  38233. /**
  38234. * This represents an audio engine and it is responsible
  38235. * to play, synchronize and analyse sounds throughout the application.
  38236. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38237. */
  38238. export interface IAudioEngine extends IDisposable {
  38239. /**
  38240. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38241. */
  38242. readonly canUseWebAudio: boolean;
  38243. /**
  38244. * Gets the current AudioContext if available.
  38245. */
  38246. readonly audioContext: Nullable<AudioContext>;
  38247. /**
  38248. * The master gain node defines the global audio volume of your audio engine.
  38249. */
  38250. readonly masterGain: GainNode;
  38251. /**
  38252. * Gets whether or not mp3 are supported by your browser.
  38253. */
  38254. readonly isMP3supported: boolean;
  38255. /**
  38256. * Gets whether or not ogg are supported by your browser.
  38257. */
  38258. readonly isOGGsupported: boolean;
  38259. /**
  38260. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38261. * @ignoreNaming
  38262. */
  38263. WarnedWebAudioUnsupported: boolean;
  38264. /**
  38265. * Defines if the audio engine relies on a custom unlocked button.
  38266. * In this case, the embedded button will not be displayed.
  38267. */
  38268. useCustomUnlockedButton: boolean;
  38269. /**
  38270. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38271. */
  38272. readonly unlocked: boolean;
  38273. /**
  38274. * Event raised when audio has been unlocked on the browser.
  38275. */
  38276. onAudioUnlockedObservable: Observable<AudioEngine>;
  38277. /**
  38278. * Event raised when audio has been locked on the browser.
  38279. */
  38280. onAudioLockedObservable: Observable<AudioEngine>;
  38281. /**
  38282. * Flags the audio engine in Locked state.
  38283. * This happens due to new browser policies preventing audio to autoplay.
  38284. */
  38285. lock(): void;
  38286. /**
  38287. * Unlocks the audio engine once a user action has been done on the dom.
  38288. * This is helpful to resume play once browser policies have been satisfied.
  38289. */
  38290. unlock(): void;
  38291. /**
  38292. * Gets the global volume sets on the master gain.
  38293. * @returns the global volume if set or -1 otherwise
  38294. */
  38295. getGlobalVolume(): number;
  38296. /**
  38297. * Sets the global volume of your experience (sets on the master gain).
  38298. * @param newVolume Defines the new global volume of the application
  38299. */
  38300. setGlobalVolume(newVolume: number): void;
  38301. /**
  38302. * Connect the audio engine to an audio analyser allowing some amazing
  38303. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38304. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38305. * @param analyser The analyser to connect to the engine
  38306. */
  38307. connectToAnalyser(analyser: Analyser): void;
  38308. }
  38309. /**
  38310. * This represents the default audio engine used in babylon.
  38311. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38312. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38313. */
  38314. export class AudioEngine implements IAudioEngine {
  38315. private _audioContext;
  38316. private _audioContextInitialized;
  38317. private _muteButton;
  38318. private _hostElement;
  38319. /**
  38320. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38321. */
  38322. canUseWebAudio: boolean;
  38323. /**
  38324. * The master gain node defines the global audio volume of your audio engine.
  38325. */
  38326. masterGain: GainNode;
  38327. /**
  38328. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38329. * @ignoreNaming
  38330. */
  38331. WarnedWebAudioUnsupported: boolean;
  38332. /**
  38333. * Gets whether or not mp3 are supported by your browser.
  38334. */
  38335. isMP3supported: boolean;
  38336. /**
  38337. * Gets whether or not ogg are supported by your browser.
  38338. */
  38339. isOGGsupported: boolean;
  38340. /**
  38341. * Gets whether audio has been unlocked on the device.
  38342. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38343. * a user interaction has happened.
  38344. */
  38345. unlocked: boolean;
  38346. /**
  38347. * Defines if the audio engine relies on a custom unlocked button.
  38348. * In this case, the embedded button will not be displayed.
  38349. */
  38350. useCustomUnlockedButton: boolean;
  38351. /**
  38352. * Event raised when audio has been unlocked on the browser.
  38353. */
  38354. onAudioUnlockedObservable: Observable<AudioEngine>;
  38355. /**
  38356. * Event raised when audio has been locked on the browser.
  38357. */
  38358. onAudioLockedObservable: Observable<AudioEngine>;
  38359. /**
  38360. * Gets the current AudioContext if available.
  38361. */
  38362. get audioContext(): Nullable<AudioContext>;
  38363. private _connectedAnalyser;
  38364. /**
  38365. * Instantiates a new audio engine.
  38366. *
  38367. * There should be only one per page as some browsers restrict the number
  38368. * of audio contexts you can create.
  38369. * @param hostElement defines the host element where to display the mute icon if necessary
  38370. */
  38371. constructor(hostElement?: Nullable<HTMLElement>);
  38372. /**
  38373. * Flags the audio engine in Locked state.
  38374. * This happens due to new browser policies preventing audio to autoplay.
  38375. */
  38376. lock(): void;
  38377. /**
  38378. * Unlocks the audio engine once a user action has been done on the dom.
  38379. * This is helpful to resume play once browser policies have been satisfied.
  38380. */
  38381. unlock(): void;
  38382. private _resumeAudioContext;
  38383. private _initializeAudioContext;
  38384. private _tryToRun;
  38385. private _triggerRunningState;
  38386. private _triggerSuspendedState;
  38387. private _displayMuteButton;
  38388. private _moveButtonToTopLeft;
  38389. private _onResize;
  38390. private _hideMuteButton;
  38391. /**
  38392. * Destroy and release the resources associated with the audio ccontext.
  38393. */
  38394. dispose(): void;
  38395. /**
  38396. * Gets the global volume sets on the master gain.
  38397. * @returns the global volume if set or -1 otherwise
  38398. */
  38399. getGlobalVolume(): number;
  38400. /**
  38401. * Sets the global volume of your experience (sets on the master gain).
  38402. * @param newVolume Defines the new global volume of the application
  38403. */
  38404. setGlobalVolume(newVolume: number): void;
  38405. /**
  38406. * Connect the audio engine to an audio analyser allowing some amazing
  38407. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38408. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38409. * @param analyser The analyser to connect to the engine
  38410. */
  38411. connectToAnalyser(analyser: Analyser): void;
  38412. }
  38413. }
  38414. declare module "babylonjs/Loading/loadingScreen" {
  38415. /**
  38416. * Interface used to present a loading screen while loading a scene
  38417. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38418. */
  38419. export interface ILoadingScreen {
  38420. /**
  38421. * Function called to display the loading screen
  38422. */
  38423. displayLoadingUI: () => void;
  38424. /**
  38425. * Function called to hide the loading screen
  38426. */
  38427. hideLoadingUI: () => void;
  38428. /**
  38429. * Gets or sets the color to use for the background
  38430. */
  38431. loadingUIBackgroundColor: string;
  38432. /**
  38433. * Gets or sets the text to display while loading
  38434. */
  38435. loadingUIText: string;
  38436. }
  38437. /**
  38438. * Class used for the default loading screen
  38439. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38440. */
  38441. export class DefaultLoadingScreen implements ILoadingScreen {
  38442. private _renderingCanvas;
  38443. private _loadingText;
  38444. private _loadingDivBackgroundColor;
  38445. private _loadingDiv;
  38446. private _loadingTextDiv;
  38447. /** Gets or sets the logo url to use for the default loading screen */
  38448. static DefaultLogoUrl: string;
  38449. /** Gets or sets the spinner url to use for the default loading screen */
  38450. static DefaultSpinnerUrl: string;
  38451. /**
  38452. * Creates a new default loading screen
  38453. * @param _renderingCanvas defines the canvas used to render the scene
  38454. * @param _loadingText defines the default text to display
  38455. * @param _loadingDivBackgroundColor defines the default background color
  38456. */
  38457. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38458. /**
  38459. * Function called to display the loading screen
  38460. */
  38461. displayLoadingUI(): void;
  38462. /**
  38463. * Function called to hide the loading screen
  38464. */
  38465. hideLoadingUI(): void;
  38466. /**
  38467. * Gets or sets the text to display while loading
  38468. */
  38469. set loadingUIText(text: string);
  38470. get loadingUIText(): string;
  38471. /**
  38472. * Gets or sets the color to use for the background
  38473. */
  38474. get loadingUIBackgroundColor(): string;
  38475. set loadingUIBackgroundColor(color: string);
  38476. private _resizeLoadingUI;
  38477. }
  38478. }
  38479. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38480. /**
  38481. * Interface for any object that can request an animation frame
  38482. */
  38483. export interface ICustomAnimationFrameRequester {
  38484. /**
  38485. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38486. */
  38487. renderFunction?: Function;
  38488. /**
  38489. * Called to request the next frame to render to
  38490. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38491. */
  38492. requestAnimationFrame: Function;
  38493. /**
  38494. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38495. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38496. */
  38497. requestID?: number;
  38498. }
  38499. }
  38500. declare module "babylonjs/Misc/performanceMonitor" {
  38501. /**
  38502. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38503. */
  38504. export class PerformanceMonitor {
  38505. private _enabled;
  38506. private _rollingFrameTime;
  38507. private _lastFrameTimeMs;
  38508. /**
  38509. * constructor
  38510. * @param frameSampleSize The number of samples required to saturate the sliding window
  38511. */
  38512. constructor(frameSampleSize?: number);
  38513. /**
  38514. * Samples current frame
  38515. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38516. */
  38517. sampleFrame(timeMs?: number): void;
  38518. /**
  38519. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38520. */
  38521. get averageFrameTime(): number;
  38522. /**
  38523. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38524. */
  38525. get averageFrameTimeVariance(): number;
  38526. /**
  38527. * Returns the frame time of the most recent frame
  38528. */
  38529. get instantaneousFrameTime(): number;
  38530. /**
  38531. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38532. */
  38533. get averageFPS(): number;
  38534. /**
  38535. * Returns the average framerate in frames per second using the most recent frame time
  38536. */
  38537. get instantaneousFPS(): number;
  38538. /**
  38539. * Returns true if enough samples have been taken to completely fill the sliding window
  38540. */
  38541. get isSaturated(): boolean;
  38542. /**
  38543. * Enables contributions to the sliding window sample set
  38544. */
  38545. enable(): void;
  38546. /**
  38547. * Disables contributions to the sliding window sample set
  38548. * Samples will not be interpolated over the disabled period
  38549. */
  38550. disable(): void;
  38551. /**
  38552. * Returns true if sampling is enabled
  38553. */
  38554. get isEnabled(): boolean;
  38555. /**
  38556. * Resets performance monitor
  38557. */
  38558. reset(): void;
  38559. }
  38560. /**
  38561. * RollingAverage
  38562. *
  38563. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38564. */
  38565. export class RollingAverage {
  38566. /**
  38567. * Current average
  38568. */
  38569. average: number;
  38570. /**
  38571. * Current variance
  38572. */
  38573. variance: number;
  38574. protected _samples: Array<number>;
  38575. protected _sampleCount: number;
  38576. protected _pos: number;
  38577. protected _m2: number;
  38578. /**
  38579. * constructor
  38580. * @param length The number of samples required to saturate the sliding window
  38581. */
  38582. constructor(length: number);
  38583. /**
  38584. * Adds a sample to the sample set
  38585. * @param v The sample value
  38586. */
  38587. add(v: number): void;
  38588. /**
  38589. * Returns previously added values or null if outside of history or outside the sliding window domain
  38590. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38591. * @return Value previously recorded with add() or null if outside of range
  38592. */
  38593. history(i: number): number;
  38594. /**
  38595. * Returns true if enough samples have been taken to completely fill the sliding window
  38596. * @return true if sample-set saturated
  38597. */
  38598. isSaturated(): boolean;
  38599. /**
  38600. * Resets the rolling average (equivalent to 0 samples taken so far)
  38601. */
  38602. reset(): void;
  38603. /**
  38604. * Wraps a value around the sample range boundaries
  38605. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38606. * @return Wrapped position in sample range
  38607. */
  38608. protected _wrapPosition(i: number): number;
  38609. }
  38610. }
  38611. declare module "babylonjs/Misc/perfCounter" {
  38612. /**
  38613. * This class is used to track a performance counter which is number based.
  38614. * The user has access to many properties which give statistics of different nature.
  38615. *
  38616. * The implementer can track two kinds of Performance Counter: time and count.
  38617. * 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.
  38618. * 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.
  38619. */
  38620. export class PerfCounter {
  38621. /**
  38622. * Gets or sets a global boolean to turn on and off all the counters
  38623. */
  38624. static Enabled: boolean;
  38625. /**
  38626. * Returns the smallest value ever
  38627. */
  38628. get min(): number;
  38629. /**
  38630. * Returns the biggest value ever
  38631. */
  38632. get max(): number;
  38633. /**
  38634. * Returns the average value since the performance counter is running
  38635. */
  38636. get average(): number;
  38637. /**
  38638. * Returns the average value of the last second the counter was monitored
  38639. */
  38640. get lastSecAverage(): number;
  38641. /**
  38642. * Returns the current value
  38643. */
  38644. get current(): number;
  38645. /**
  38646. * Gets the accumulated total
  38647. */
  38648. get total(): number;
  38649. /**
  38650. * Gets the total value count
  38651. */
  38652. get count(): number;
  38653. /**
  38654. * Creates a new counter
  38655. */
  38656. constructor();
  38657. /**
  38658. * Call this method to start monitoring a new frame.
  38659. * 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.
  38660. */
  38661. fetchNewFrame(): void;
  38662. /**
  38663. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38664. * @param newCount the count value to add to the monitored count
  38665. * @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.
  38666. */
  38667. addCount(newCount: number, fetchResult: boolean): void;
  38668. /**
  38669. * Start monitoring this performance counter
  38670. */
  38671. beginMonitoring(): void;
  38672. /**
  38673. * Compute the time lapsed since the previous beginMonitoring() call.
  38674. * @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
  38675. */
  38676. endMonitoring(newFrame?: boolean): void;
  38677. private _fetchResult;
  38678. private _startMonitoringTime;
  38679. private _min;
  38680. private _max;
  38681. private _average;
  38682. private _current;
  38683. private _totalValueCount;
  38684. private _totalAccumulated;
  38685. private _lastSecAverage;
  38686. private _lastSecAccumulated;
  38687. private _lastSecTime;
  38688. private _lastSecValueCount;
  38689. }
  38690. }
  38691. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38692. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38693. import { Nullable } from "babylonjs/types";
  38694. module "babylonjs/Engines/thinEngine" {
  38695. interface ThinEngine {
  38696. /** @hidden */
  38697. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38698. }
  38699. }
  38700. }
  38701. declare module "babylonjs/Engines/engine" {
  38702. import { Observable } from "babylonjs/Misc/observable";
  38703. import { Nullable } from "babylonjs/types";
  38704. import { Scene } from "babylonjs/scene";
  38705. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38706. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38707. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38708. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38709. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38710. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38711. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38712. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38713. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38714. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38715. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38716. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38717. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38718. import "babylonjs/Engines/Extensions/engine.alpha";
  38719. import "babylonjs/Engines/Extensions/engine.readTexture";
  38720. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  38721. import { Material } from "babylonjs/Materials/material";
  38722. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38723. /**
  38724. * Defines the interface used by display changed events
  38725. */
  38726. export interface IDisplayChangedEventArgs {
  38727. /** Gets the vrDisplay object (if any) */
  38728. vrDisplay: Nullable<any>;
  38729. /** Gets a boolean indicating if webVR is supported */
  38730. vrSupported: boolean;
  38731. }
  38732. /**
  38733. * Defines the interface used by objects containing a viewport (like a camera)
  38734. */
  38735. interface IViewportOwnerLike {
  38736. /**
  38737. * Gets or sets the viewport
  38738. */
  38739. viewport: IViewportLike;
  38740. }
  38741. /**
  38742. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38743. */
  38744. export class Engine extends ThinEngine {
  38745. /** Defines that alpha blending is disabled */
  38746. static readonly ALPHA_DISABLE: number;
  38747. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38748. static readonly ALPHA_ADD: number;
  38749. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38750. static readonly ALPHA_COMBINE: number;
  38751. /** Defines that alpha blending to DEST - SRC * DEST */
  38752. static readonly ALPHA_SUBTRACT: number;
  38753. /** Defines that alpha blending to SRC * DEST */
  38754. static readonly ALPHA_MULTIPLY: number;
  38755. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38756. static readonly ALPHA_MAXIMIZED: number;
  38757. /** Defines that alpha blending to SRC + DEST */
  38758. static readonly ALPHA_ONEONE: number;
  38759. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38760. static readonly ALPHA_PREMULTIPLIED: number;
  38761. /**
  38762. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38763. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38764. */
  38765. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38766. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38767. static readonly ALPHA_INTERPOLATE: number;
  38768. /**
  38769. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38770. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38771. */
  38772. static readonly ALPHA_SCREENMODE: number;
  38773. /** Defines that the ressource is not delayed*/
  38774. static readonly DELAYLOADSTATE_NONE: number;
  38775. /** Defines that the ressource was successfully delay loaded */
  38776. static readonly DELAYLOADSTATE_LOADED: number;
  38777. /** Defines that the ressource is currently delay loading */
  38778. static readonly DELAYLOADSTATE_LOADING: number;
  38779. /** Defines that the ressource is delayed and has not started loading */
  38780. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38781. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38782. static readonly NEVER: number;
  38783. /** 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 */
  38784. static readonly ALWAYS: number;
  38785. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38786. static readonly LESS: number;
  38787. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38788. static readonly EQUAL: number;
  38789. /** 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 */
  38790. static readonly LEQUAL: number;
  38791. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38792. static readonly GREATER: number;
  38793. /** 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 */
  38794. static readonly GEQUAL: number;
  38795. /** 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 */
  38796. static readonly NOTEQUAL: number;
  38797. /** Passed to stencilOperation to specify that stencil value must be kept */
  38798. static readonly KEEP: number;
  38799. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38800. static readonly REPLACE: number;
  38801. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38802. static readonly INCR: number;
  38803. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38804. static readonly DECR: number;
  38805. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38806. static readonly INVERT: number;
  38807. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38808. static readonly INCR_WRAP: number;
  38809. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38810. static readonly DECR_WRAP: number;
  38811. /** Texture is not repeating outside of 0..1 UVs */
  38812. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38813. /** Texture is repeating outside of 0..1 UVs */
  38814. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38815. /** Texture is repeating and mirrored */
  38816. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38817. /** ALPHA */
  38818. static readonly TEXTUREFORMAT_ALPHA: number;
  38819. /** LUMINANCE */
  38820. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38821. /** LUMINANCE_ALPHA */
  38822. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38823. /** RGB */
  38824. static readonly TEXTUREFORMAT_RGB: number;
  38825. /** RGBA */
  38826. static readonly TEXTUREFORMAT_RGBA: number;
  38827. /** RED */
  38828. static readonly TEXTUREFORMAT_RED: number;
  38829. /** RED (2nd reference) */
  38830. static readonly TEXTUREFORMAT_R: number;
  38831. /** RG */
  38832. static readonly TEXTUREFORMAT_RG: number;
  38833. /** RED_INTEGER */
  38834. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38835. /** RED_INTEGER (2nd reference) */
  38836. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38837. /** RG_INTEGER */
  38838. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38839. /** RGB_INTEGER */
  38840. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38841. /** RGBA_INTEGER */
  38842. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38843. /** UNSIGNED_BYTE */
  38844. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38845. /** UNSIGNED_BYTE (2nd reference) */
  38846. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38847. /** FLOAT */
  38848. static readonly TEXTURETYPE_FLOAT: number;
  38849. /** HALF_FLOAT */
  38850. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38851. /** BYTE */
  38852. static readonly TEXTURETYPE_BYTE: number;
  38853. /** SHORT */
  38854. static readonly TEXTURETYPE_SHORT: number;
  38855. /** UNSIGNED_SHORT */
  38856. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38857. /** INT */
  38858. static readonly TEXTURETYPE_INT: number;
  38859. /** UNSIGNED_INT */
  38860. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38861. /** UNSIGNED_SHORT_4_4_4_4 */
  38862. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38863. /** UNSIGNED_SHORT_5_5_5_1 */
  38864. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38865. /** UNSIGNED_SHORT_5_6_5 */
  38866. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38867. /** UNSIGNED_INT_2_10_10_10_REV */
  38868. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38869. /** UNSIGNED_INT_24_8 */
  38870. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38871. /** UNSIGNED_INT_10F_11F_11F_REV */
  38872. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38873. /** UNSIGNED_INT_5_9_9_9_REV */
  38874. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38875. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38876. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38877. /** nearest is mag = nearest and min = nearest and mip = linear */
  38878. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38879. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38880. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38881. /** Trilinear is mag = linear and min = linear and mip = linear */
  38882. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38883. /** nearest is mag = nearest and min = nearest and mip = linear */
  38884. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38885. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38886. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38887. /** Trilinear is mag = linear and min = linear and mip = linear */
  38888. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38889. /** mag = nearest and min = nearest and mip = nearest */
  38890. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38891. /** mag = nearest and min = linear and mip = nearest */
  38892. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38893. /** mag = nearest and min = linear and mip = linear */
  38894. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38895. /** mag = nearest and min = linear and mip = none */
  38896. static readonly TEXTURE_NEAREST_LINEAR: number;
  38897. /** mag = nearest and min = nearest and mip = none */
  38898. static readonly TEXTURE_NEAREST_NEAREST: number;
  38899. /** mag = linear and min = nearest and mip = nearest */
  38900. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38901. /** mag = linear and min = nearest and mip = linear */
  38902. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38903. /** mag = linear and min = linear and mip = none */
  38904. static readonly TEXTURE_LINEAR_LINEAR: number;
  38905. /** mag = linear and min = nearest and mip = none */
  38906. static readonly TEXTURE_LINEAR_NEAREST: number;
  38907. /** Explicit coordinates mode */
  38908. static readonly TEXTURE_EXPLICIT_MODE: number;
  38909. /** Spherical coordinates mode */
  38910. static readonly TEXTURE_SPHERICAL_MODE: number;
  38911. /** Planar coordinates mode */
  38912. static readonly TEXTURE_PLANAR_MODE: number;
  38913. /** Cubic coordinates mode */
  38914. static readonly TEXTURE_CUBIC_MODE: number;
  38915. /** Projection coordinates mode */
  38916. static readonly TEXTURE_PROJECTION_MODE: number;
  38917. /** Skybox coordinates mode */
  38918. static readonly TEXTURE_SKYBOX_MODE: number;
  38919. /** Inverse Cubic coordinates mode */
  38920. static readonly TEXTURE_INVCUBIC_MODE: number;
  38921. /** Equirectangular coordinates mode */
  38922. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38923. /** Equirectangular Fixed coordinates mode */
  38924. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38925. /** Equirectangular Fixed Mirrored coordinates mode */
  38926. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38927. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38928. static readonly SCALEMODE_FLOOR: number;
  38929. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38930. static readonly SCALEMODE_NEAREST: number;
  38931. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38932. static readonly SCALEMODE_CEILING: number;
  38933. /**
  38934. * Returns the current npm package of the sdk
  38935. */
  38936. static get NpmPackage(): string;
  38937. /**
  38938. * Returns the current version of the framework
  38939. */
  38940. static get Version(): string;
  38941. /** Gets the list of created engines */
  38942. static get Instances(): Engine[];
  38943. /**
  38944. * Gets the latest created engine
  38945. */
  38946. static get LastCreatedEngine(): Nullable<Engine>;
  38947. /**
  38948. * Gets the latest created scene
  38949. */
  38950. static get LastCreatedScene(): Nullable<Scene>;
  38951. /**
  38952. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38953. * @param flag defines which part of the materials must be marked as dirty
  38954. * @param predicate defines a predicate used to filter which materials should be affected
  38955. */
  38956. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38957. /**
  38958. * Method called to create the default loading screen.
  38959. * This can be overriden in your own app.
  38960. * @param canvas The rendering canvas element
  38961. * @returns The loading screen
  38962. */
  38963. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38964. /**
  38965. * Method called to create the default rescale post process on each engine.
  38966. */
  38967. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38968. /**
  38969. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38970. **/
  38971. enableOfflineSupport: boolean;
  38972. /**
  38973. * 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)
  38974. **/
  38975. disableManifestCheck: boolean;
  38976. /**
  38977. * Gets the list of created scenes
  38978. */
  38979. scenes: Scene[];
  38980. /**
  38981. * Event raised when a new scene is created
  38982. */
  38983. onNewSceneAddedObservable: Observable<Scene>;
  38984. /**
  38985. * Gets the list of created postprocesses
  38986. */
  38987. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38988. /**
  38989. * Gets a boolean indicating if the pointer is currently locked
  38990. */
  38991. isPointerLock: boolean;
  38992. /**
  38993. * Observable event triggered each time the rendering canvas is resized
  38994. */
  38995. onResizeObservable: Observable<Engine>;
  38996. /**
  38997. * Observable event triggered each time the canvas loses focus
  38998. */
  38999. onCanvasBlurObservable: Observable<Engine>;
  39000. /**
  39001. * Observable event triggered each time the canvas gains focus
  39002. */
  39003. onCanvasFocusObservable: Observable<Engine>;
  39004. /**
  39005. * Observable event triggered each time the canvas receives pointerout event
  39006. */
  39007. onCanvasPointerOutObservable: Observable<PointerEvent>;
  39008. /**
  39009. * Observable raised when the engine begins a new frame
  39010. */
  39011. onBeginFrameObservable: Observable<Engine>;
  39012. /**
  39013. * If set, will be used to request the next animation frame for the render loop
  39014. */
  39015. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  39016. /**
  39017. * Observable raised when the engine ends the current frame
  39018. */
  39019. onEndFrameObservable: Observable<Engine>;
  39020. /**
  39021. * Observable raised when the engine is about to compile a shader
  39022. */
  39023. onBeforeShaderCompilationObservable: Observable<Engine>;
  39024. /**
  39025. * Observable raised when the engine has jsut compiled a shader
  39026. */
  39027. onAfterShaderCompilationObservable: Observable<Engine>;
  39028. /**
  39029. * Gets the audio engine
  39030. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39031. * @ignorenaming
  39032. */
  39033. static audioEngine: IAudioEngine;
  39034. /**
  39035. * Default AudioEngine factory responsible of creating the Audio Engine.
  39036. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  39037. */
  39038. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  39039. /**
  39040. * Default offline support factory responsible of creating a tool used to store data locally.
  39041. * By default, this will create a Database object if the workload has been embedded.
  39042. */
  39043. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  39044. private _loadingScreen;
  39045. private _pointerLockRequested;
  39046. private _rescalePostProcess;
  39047. private _deterministicLockstep;
  39048. private _lockstepMaxSteps;
  39049. private _timeStep;
  39050. protected get _supportsHardwareTextureRescaling(): boolean;
  39051. private _fps;
  39052. private _deltaTime;
  39053. /** @hidden */
  39054. _drawCalls: PerfCounter;
  39055. /** 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 */
  39056. canvasTabIndex: number;
  39057. /**
  39058. * Turn this value on if you want to pause FPS computation when in background
  39059. */
  39060. disablePerformanceMonitorInBackground: boolean;
  39061. private _performanceMonitor;
  39062. /**
  39063. * Gets the performance monitor attached to this engine
  39064. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39065. */
  39066. get performanceMonitor(): PerformanceMonitor;
  39067. private _onFocus;
  39068. private _onBlur;
  39069. private _onCanvasPointerOut;
  39070. private _onCanvasBlur;
  39071. private _onCanvasFocus;
  39072. private _onFullscreenChange;
  39073. private _onPointerLockChange;
  39074. /**
  39075. * Gets the HTML element used to attach event listeners
  39076. * @returns a HTML element
  39077. */
  39078. getInputElement(): Nullable<HTMLElement>;
  39079. /**
  39080. * Creates a new engine
  39081. * @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
  39082. * @param antialias defines enable antialiasing (default: false)
  39083. * @param options defines further options to be sent to the getContext() function
  39084. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39085. */
  39086. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39087. /**
  39088. * Gets current aspect ratio
  39089. * @param viewportOwner defines the camera to use to get the aspect ratio
  39090. * @param useScreen defines if screen size must be used (or the current render target if any)
  39091. * @returns a number defining the aspect ratio
  39092. */
  39093. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  39094. /**
  39095. * Gets current screen aspect ratio
  39096. * @returns a number defining the aspect ratio
  39097. */
  39098. getScreenAspectRatio(): number;
  39099. /**
  39100. * Gets the client rect of the HTML canvas attached with the current webGL context
  39101. * @returns a client rectanglee
  39102. */
  39103. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  39104. /**
  39105. * Gets the client rect of the HTML element used for events
  39106. * @returns a client rectanglee
  39107. */
  39108. getInputElementClientRect(): Nullable<ClientRect>;
  39109. /**
  39110. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  39111. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39112. * @returns true if engine is in deterministic lock step mode
  39113. */
  39114. isDeterministicLockStep(): boolean;
  39115. /**
  39116. * Gets the max steps when engine is running in deterministic lock step
  39117. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39118. * @returns the max steps
  39119. */
  39120. getLockstepMaxSteps(): number;
  39121. /**
  39122. * Returns the time in ms between steps when using deterministic lock step.
  39123. * @returns time step in (ms)
  39124. */
  39125. getTimeStep(): number;
  39126. /**
  39127. * Force the mipmap generation for the given render target texture
  39128. * @param texture defines the render target texture to use
  39129. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  39130. */
  39131. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  39132. /** States */
  39133. /**
  39134. * Set various states to the webGL context
  39135. * @param culling defines backface culling state
  39136. * @param zOffset defines the value to apply to zOffset (0 by default)
  39137. * @param force defines if states must be applied even if cache is up to date
  39138. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  39139. */
  39140. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  39141. /**
  39142. * Set the z offset to apply to current rendering
  39143. * @param value defines the offset to apply
  39144. */
  39145. setZOffset(value: number): void;
  39146. /**
  39147. * Gets the current value of the zOffset
  39148. * @returns the current zOffset state
  39149. */
  39150. getZOffset(): number;
  39151. /**
  39152. * Enable or disable depth buffering
  39153. * @param enable defines the state to set
  39154. */
  39155. setDepthBuffer(enable: boolean): void;
  39156. /**
  39157. * Gets a boolean indicating if depth writing is enabled
  39158. * @returns the current depth writing state
  39159. */
  39160. getDepthWrite(): boolean;
  39161. /**
  39162. * Enable or disable depth writing
  39163. * @param enable defines the state to set
  39164. */
  39165. setDepthWrite(enable: boolean): void;
  39166. /**
  39167. * Gets a boolean indicating if stencil buffer is enabled
  39168. * @returns the current stencil buffer state
  39169. */
  39170. getStencilBuffer(): boolean;
  39171. /**
  39172. * Enable or disable the stencil buffer
  39173. * @param enable defines if the stencil buffer must be enabled or disabled
  39174. */
  39175. setStencilBuffer(enable: boolean): void;
  39176. /**
  39177. * Gets the current stencil mask
  39178. * @returns a number defining the new stencil mask to use
  39179. */
  39180. getStencilMask(): number;
  39181. /**
  39182. * Sets the current stencil mask
  39183. * @param mask defines the new stencil mask to use
  39184. */
  39185. setStencilMask(mask: number): void;
  39186. /**
  39187. * Gets the current stencil function
  39188. * @returns a number defining the stencil function to use
  39189. */
  39190. getStencilFunction(): number;
  39191. /**
  39192. * Gets the current stencil reference value
  39193. * @returns a number defining the stencil reference value to use
  39194. */
  39195. getStencilFunctionReference(): number;
  39196. /**
  39197. * Gets the current stencil mask
  39198. * @returns a number defining the stencil mask to use
  39199. */
  39200. getStencilFunctionMask(): number;
  39201. /**
  39202. * Sets the current stencil function
  39203. * @param stencilFunc defines the new stencil function to use
  39204. */
  39205. setStencilFunction(stencilFunc: number): void;
  39206. /**
  39207. * Sets the current stencil reference
  39208. * @param reference defines the new stencil reference to use
  39209. */
  39210. setStencilFunctionReference(reference: number): void;
  39211. /**
  39212. * Sets the current stencil mask
  39213. * @param mask defines the new stencil mask to use
  39214. */
  39215. setStencilFunctionMask(mask: number): void;
  39216. /**
  39217. * Gets the current stencil operation when stencil fails
  39218. * @returns a number defining stencil operation to use when stencil fails
  39219. */
  39220. getStencilOperationFail(): number;
  39221. /**
  39222. * Gets the current stencil operation when depth fails
  39223. * @returns a number defining stencil operation to use when depth fails
  39224. */
  39225. getStencilOperationDepthFail(): number;
  39226. /**
  39227. * Gets the current stencil operation when stencil passes
  39228. * @returns a number defining stencil operation to use when stencil passes
  39229. */
  39230. getStencilOperationPass(): number;
  39231. /**
  39232. * Sets the stencil operation to use when stencil fails
  39233. * @param operation defines the stencil operation to use when stencil fails
  39234. */
  39235. setStencilOperationFail(operation: number): void;
  39236. /**
  39237. * Sets the stencil operation to use when depth fails
  39238. * @param operation defines the stencil operation to use when depth fails
  39239. */
  39240. setStencilOperationDepthFail(operation: number): void;
  39241. /**
  39242. * Sets the stencil operation to use when stencil passes
  39243. * @param operation defines the stencil operation to use when stencil passes
  39244. */
  39245. setStencilOperationPass(operation: number): void;
  39246. /**
  39247. * Sets a boolean indicating if the dithering state is enabled or disabled
  39248. * @param value defines the dithering state
  39249. */
  39250. setDitheringState(value: boolean): void;
  39251. /**
  39252. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39253. * @param value defines the rasterizer state
  39254. */
  39255. setRasterizerState(value: boolean): void;
  39256. /**
  39257. * Gets the current depth function
  39258. * @returns a number defining the depth function
  39259. */
  39260. getDepthFunction(): Nullable<number>;
  39261. /**
  39262. * Sets the current depth function
  39263. * @param depthFunc defines the function to use
  39264. */
  39265. setDepthFunction(depthFunc: number): void;
  39266. /**
  39267. * Sets the current depth function to GREATER
  39268. */
  39269. setDepthFunctionToGreater(): void;
  39270. /**
  39271. * Sets the current depth function to GEQUAL
  39272. */
  39273. setDepthFunctionToGreaterOrEqual(): void;
  39274. /**
  39275. * Sets the current depth function to LESS
  39276. */
  39277. setDepthFunctionToLess(): void;
  39278. /**
  39279. * Sets the current depth function to LEQUAL
  39280. */
  39281. setDepthFunctionToLessOrEqual(): void;
  39282. private _cachedStencilBuffer;
  39283. private _cachedStencilFunction;
  39284. private _cachedStencilMask;
  39285. private _cachedStencilOperationPass;
  39286. private _cachedStencilOperationFail;
  39287. private _cachedStencilOperationDepthFail;
  39288. private _cachedStencilReference;
  39289. /**
  39290. * Caches the the state of the stencil buffer
  39291. */
  39292. cacheStencilState(): void;
  39293. /**
  39294. * Restores the state of the stencil buffer
  39295. */
  39296. restoreStencilState(): void;
  39297. /**
  39298. * Directly set the WebGL Viewport
  39299. * @param x defines the x coordinate of the viewport (in screen space)
  39300. * @param y defines the y coordinate of the viewport (in screen space)
  39301. * @param width defines the width of the viewport (in screen space)
  39302. * @param height defines the height of the viewport (in screen space)
  39303. * @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
  39304. */
  39305. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39306. /**
  39307. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39308. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39309. * @param y defines the y-coordinate of the corner of the clear rectangle
  39310. * @param width defines the width of the clear rectangle
  39311. * @param height defines the height of the clear rectangle
  39312. * @param clearColor defines the clear color
  39313. */
  39314. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39315. /**
  39316. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39317. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39318. * @param y defines the y-coordinate of the corner of the clear rectangle
  39319. * @param width defines the width of the clear rectangle
  39320. * @param height defines the height of the clear rectangle
  39321. */
  39322. enableScissor(x: number, y: number, width: number, height: number): void;
  39323. /**
  39324. * Disable previously set scissor test rectangle
  39325. */
  39326. disableScissor(): void;
  39327. protected _reportDrawCall(): void;
  39328. /**
  39329. * Initializes a webVR display and starts listening to display change events
  39330. * The onVRDisplayChangedObservable will be notified upon these changes
  39331. * @returns The onVRDisplayChangedObservable
  39332. */
  39333. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39334. /** @hidden */
  39335. _prepareVRComponent(): void;
  39336. /** @hidden */
  39337. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39338. /** @hidden */
  39339. _submitVRFrame(): void;
  39340. /**
  39341. * Call this function to leave webVR mode
  39342. * Will do nothing if webVR is not supported or if there is no webVR device
  39343. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39344. */
  39345. disableVR(): void;
  39346. /**
  39347. * Gets a boolean indicating that the system is in VR mode and is presenting
  39348. * @returns true if VR mode is engaged
  39349. */
  39350. isVRPresenting(): boolean;
  39351. /** @hidden */
  39352. _requestVRFrame(): void;
  39353. /** @hidden */
  39354. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39355. /**
  39356. * Gets the source code of the vertex shader associated with a specific webGL program
  39357. * @param program defines the program to use
  39358. * @returns a string containing the source code of the vertex shader associated with the program
  39359. */
  39360. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39361. /**
  39362. * Gets the source code of the fragment shader associated with a specific webGL program
  39363. * @param program defines the program to use
  39364. * @returns a string containing the source code of the fragment shader associated with the program
  39365. */
  39366. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39367. /**
  39368. * Sets a depth stencil texture from a render target to the according uniform.
  39369. * @param channel The texture channel
  39370. * @param uniform The uniform to set
  39371. * @param texture The render target texture containing the depth stencil texture to apply
  39372. */
  39373. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39374. /**
  39375. * Sets a texture to the webGL context from a postprocess
  39376. * @param channel defines the channel to use
  39377. * @param postProcess defines the source postprocess
  39378. */
  39379. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39380. /**
  39381. * Binds the output of the passed in post process to the texture channel specified
  39382. * @param channel The channel the texture should be bound to
  39383. * @param postProcess The post process which's output should be bound
  39384. */
  39385. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39386. protected _rebuildBuffers(): void;
  39387. /** @hidden */
  39388. _renderFrame(): void;
  39389. _renderLoop(): void;
  39390. /** @hidden */
  39391. _renderViews(): boolean;
  39392. /**
  39393. * Toggle full screen mode
  39394. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39395. */
  39396. switchFullscreen(requestPointerLock: boolean): void;
  39397. /**
  39398. * Enters full screen mode
  39399. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39400. */
  39401. enterFullscreen(requestPointerLock: boolean): void;
  39402. /**
  39403. * Exits full screen mode
  39404. */
  39405. exitFullscreen(): void;
  39406. /**
  39407. * Enters Pointerlock mode
  39408. */
  39409. enterPointerlock(): void;
  39410. /**
  39411. * Exits Pointerlock mode
  39412. */
  39413. exitPointerlock(): void;
  39414. /**
  39415. * Begin a new frame
  39416. */
  39417. beginFrame(): void;
  39418. /**
  39419. * Enf the current frame
  39420. */
  39421. endFrame(): void;
  39422. resize(): void;
  39423. /**
  39424. * Force a specific size of the canvas
  39425. * @param width defines the new canvas' width
  39426. * @param height defines the new canvas' height
  39427. * @returns true if the size was changed
  39428. */
  39429. setSize(width: number, height: number): boolean;
  39430. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39431. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39432. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39433. _releaseTexture(texture: InternalTexture): void;
  39434. /**
  39435. * @hidden
  39436. * Rescales a texture
  39437. * @param source input texutre
  39438. * @param destination destination texture
  39439. * @param scene scene to use to render the resize
  39440. * @param internalFormat format to use when resizing
  39441. * @param onComplete callback to be called when resize has completed
  39442. */
  39443. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39444. /**
  39445. * Gets the current framerate
  39446. * @returns a number representing the framerate
  39447. */
  39448. getFps(): number;
  39449. /**
  39450. * Gets the time spent between current and previous frame
  39451. * @returns a number representing the delta time in ms
  39452. */
  39453. getDeltaTime(): number;
  39454. private _measureFps;
  39455. /** @hidden */
  39456. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39457. /**
  39458. * Updates the sample count of a render target texture
  39459. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39460. * @param texture defines the texture to update
  39461. * @param samples defines the sample count to set
  39462. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39463. */
  39464. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39465. /**
  39466. * Updates a depth texture Comparison Mode and Function.
  39467. * If the comparison Function is equal to 0, the mode will be set to none.
  39468. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39469. * @param texture The texture to set the comparison function for
  39470. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39471. */
  39472. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39473. /**
  39474. * Creates a webGL buffer to use with instanciation
  39475. * @param capacity defines the size of the buffer
  39476. * @returns the webGL buffer
  39477. */
  39478. createInstancesBuffer(capacity: number): DataBuffer;
  39479. /**
  39480. * Delete a webGL buffer used with instanciation
  39481. * @param buffer defines the webGL buffer to delete
  39482. */
  39483. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39484. private _clientWaitAsync;
  39485. /** @hidden */
  39486. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39487. dispose(): void;
  39488. private _disableTouchAction;
  39489. /**
  39490. * Display the loading screen
  39491. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39492. */
  39493. displayLoadingUI(): void;
  39494. /**
  39495. * Hide the loading screen
  39496. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39497. */
  39498. hideLoadingUI(): void;
  39499. /**
  39500. * Gets the current loading screen object
  39501. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39502. */
  39503. get loadingScreen(): ILoadingScreen;
  39504. /**
  39505. * Sets the current loading screen object
  39506. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39507. */
  39508. set loadingScreen(loadingScreen: ILoadingScreen);
  39509. /**
  39510. * Sets the current loading screen text
  39511. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39512. */
  39513. set loadingUIText(text: string);
  39514. /**
  39515. * Sets the current loading screen background color
  39516. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39517. */
  39518. set loadingUIBackgroundColor(color: string);
  39519. /** Pointerlock and fullscreen */
  39520. /**
  39521. * Ask the browser to promote the current element to pointerlock mode
  39522. * @param element defines the DOM element to promote
  39523. */
  39524. static _RequestPointerlock(element: HTMLElement): void;
  39525. /**
  39526. * Asks the browser to exit pointerlock mode
  39527. */
  39528. static _ExitPointerlock(): void;
  39529. /**
  39530. * Ask the browser to promote the current element to fullscreen rendering mode
  39531. * @param element defines the DOM element to promote
  39532. */
  39533. static _RequestFullscreen(element: HTMLElement): void;
  39534. /**
  39535. * Asks the browser to exit fullscreen mode
  39536. */
  39537. static _ExitFullscreen(): void;
  39538. }
  39539. }
  39540. declare module "babylonjs/Engines/engineStore" {
  39541. import { Nullable } from "babylonjs/types";
  39542. import { Engine } from "babylonjs/Engines/engine";
  39543. import { Scene } from "babylonjs/scene";
  39544. /**
  39545. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39546. * during the life time of the application.
  39547. */
  39548. export class EngineStore {
  39549. /** Gets the list of created engines */
  39550. static Instances: import("babylonjs/Engines/engine").Engine[];
  39551. /** @hidden */
  39552. static _LastCreatedScene: Nullable<Scene>;
  39553. /**
  39554. * Gets the latest created engine
  39555. */
  39556. static get LastCreatedEngine(): Nullable<Engine>;
  39557. /**
  39558. * Gets the latest created scene
  39559. */
  39560. static get LastCreatedScene(): Nullable<Scene>;
  39561. /**
  39562. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39563. * @ignorenaming
  39564. */
  39565. static UseFallbackTexture: boolean;
  39566. /**
  39567. * Texture content used if a texture cannot loaded
  39568. * @ignorenaming
  39569. */
  39570. static FallbackTexture: string;
  39571. }
  39572. }
  39573. declare module "babylonjs/Misc/promise" {
  39574. /**
  39575. * Helper class that provides a small promise polyfill
  39576. */
  39577. export class PromisePolyfill {
  39578. /**
  39579. * Static function used to check if the polyfill is required
  39580. * If this is the case then the function will inject the polyfill to window.Promise
  39581. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39582. */
  39583. static Apply(force?: boolean): void;
  39584. }
  39585. }
  39586. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39587. /**
  39588. * Interface for screenshot methods with describe argument called `size` as object with options
  39589. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39590. */
  39591. export interface IScreenshotSize {
  39592. /**
  39593. * number in pixels for canvas height
  39594. */
  39595. height?: number;
  39596. /**
  39597. * multiplier allowing render at a higher or lower resolution
  39598. * If value is defined then height and width will be ignored and taken from camera
  39599. */
  39600. precision?: number;
  39601. /**
  39602. * number in pixels for canvas width
  39603. */
  39604. width?: number;
  39605. }
  39606. }
  39607. declare module "babylonjs/Misc/tools" {
  39608. import { Nullable, float } from "babylonjs/types";
  39609. import { DomManagement } from "babylonjs/Misc/domManagement";
  39610. import { WebRequest } from "babylonjs/Misc/webRequest";
  39611. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39612. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39613. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39614. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39615. import { Camera } from "babylonjs/Cameras/camera";
  39616. import { Engine } from "babylonjs/Engines/engine";
  39617. interface IColor4Like {
  39618. r: float;
  39619. g: float;
  39620. b: float;
  39621. a: float;
  39622. }
  39623. /**
  39624. * Class containing a set of static utilities functions
  39625. */
  39626. export class Tools {
  39627. /**
  39628. * Gets or sets the base URL to use to load assets
  39629. */
  39630. static get BaseUrl(): string;
  39631. static set BaseUrl(value: string);
  39632. /**
  39633. * Enable/Disable Custom HTTP Request Headers globally.
  39634. * default = false
  39635. * @see CustomRequestHeaders
  39636. */
  39637. static UseCustomRequestHeaders: boolean;
  39638. /**
  39639. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39640. * i.e. when loading files, where the server/service expects an Authorization header
  39641. */
  39642. static CustomRequestHeaders: {
  39643. [key: string]: string;
  39644. };
  39645. /**
  39646. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39647. */
  39648. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39649. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39650. /**
  39651. * Default behaviour for cors in the application.
  39652. * It can be a string if the expected behavior is identical in the entire app.
  39653. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39654. */
  39655. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39656. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39657. /**
  39658. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39659. * @ignorenaming
  39660. */
  39661. static get UseFallbackTexture(): boolean;
  39662. static set UseFallbackTexture(value: boolean);
  39663. /**
  39664. * Use this object to register external classes like custom textures or material
  39665. * to allow the laoders to instantiate them
  39666. */
  39667. static get RegisteredExternalClasses(): {
  39668. [key: string]: Object;
  39669. };
  39670. static set RegisteredExternalClasses(classes: {
  39671. [key: string]: Object;
  39672. });
  39673. /**
  39674. * Texture content used if a texture cannot loaded
  39675. * @ignorenaming
  39676. */
  39677. static get fallbackTexture(): string;
  39678. static set fallbackTexture(value: string);
  39679. /**
  39680. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39681. * @param u defines the coordinate on X axis
  39682. * @param v defines the coordinate on Y axis
  39683. * @param width defines the width of the source data
  39684. * @param height defines the height of the source data
  39685. * @param pixels defines the source byte array
  39686. * @param color defines the output color
  39687. */
  39688. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39689. /**
  39690. * Interpolates between a and b via alpha
  39691. * @param a The lower value (returned when alpha = 0)
  39692. * @param b The upper value (returned when alpha = 1)
  39693. * @param alpha The interpolation-factor
  39694. * @return The mixed value
  39695. */
  39696. static Mix(a: number, b: number, alpha: number): number;
  39697. /**
  39698. * Tries to instantiate a new object from a given class name
  39699. * @param className defines the class name to instantiate
  39700. * @returns the new object or null if the system was not able to do the instantiation
  39701. */
  39702. static Instantiate(className: string): any;
  39703. /**
  39704. * Provides a slice function that will work even on IE
  39705. * @param data defines the array to slice
  39706. * @param start defines the start of the data (optional)
  39707. * @param end defines the end of the data (optional)
  39708. * @returns the new sliced array
  39709. */
  39710. static Slice<T>(data: T, start?: number, end?: number): T;
  39711. /**
  39712. * Polyfill for setImmediate
  39713. * @param action defines the action to execute after the current execution block
  39714. */
  39715. static SetImmediate(action: () => void): void;
  39716. /**
  39717. * Function indicating if a number is an exponent of 2
  39718. * @param value defines the value to test
  39719. * @returns true if the value is an exponent of 2
  39720. */
  39721. static IsExponentOfTwo(value: number): boolean;
  39722. private static _tmpFloatArray;
  39723. /**
  39724. * Returns the nearest 32-bit single precision float representation of a Number
  39725. * @param value A Number. If the parameter is of a different type, it will get converted
  39726. * to a number or to NaN if it cannot be converted
  39727. * @returns number
  39728. */
  39729. static FloatRound(value: number): number;
  39730. /**
  39731. * Extracts the filename from a path
  39732. * @param path defines the path to use
  39733. * @returns the filename
  39734. */
  39735. static GetFilename(path: string): string;
  39736. /**
  39737. * Extracts the "folder" part of a path (everything before the filename).
  39738. * @param uri The URI to extract the info from
  39739. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39740. * @returns The "folder" part of the path
  39741. */
  39742. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39743. /**
  39744. * Extracts text content from a DOM element hierarchy
  39745. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39746. */
  39747. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39748. /**
  39749. * Convert an angle in radians to degrees
  39750. * @param angle defines the angle to convert
  39751. * @returns the angle in degrees
  39752. */
  39753. static ToDegrees(angle: number): number;
  39754. /**
  39755. * Convert an angle in degrees to radians
  39756. * @param angle defines the angle to convert
  39757. * @returns the angle in radians
  39758. */
  39759. static ToRadians(angle: number): number;
  39760. /**
  39761. * Returns an array if obj is not an array
  39762. * @param obj defines the object to evaluate as an array
  39763. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39764. * @returns either obj directly if obj is an array or a new array containing obj
  39765. */
  39766. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39767. /**
  39768. * Gets the pointer prefix to use
  39769. * @param engine defines the engine we are finding the prefix for
  39770. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39771. */
  39772. static GetPointerPrefix(engine: Engine): string;
  39773. /**
  39774. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39775. * @param url define the url we are trying
  39776. * @param element define the dom element where to configure the cors policy
  39777. */
  39778. static SetCorsBehavior(url: string | string[], element: {
  39779. crossOrigin: string | null;
  39780. }): void;
  39781. /**
  39782. * Removes unwanted characters from an url
  39783. * @param url defines the url to clean
  39784. * @returns the cleaned url
  39785. */
  39786. static CleanUrl(url: string): string;
  39787. /**
  39788. * Gets or sets a function used to pre-process url before using them to load assets
  39789. */
  39790. static get PreprocessUrl(): (url: string) => string;
  39791. static set PreprocessUrl(processor: (url: string) => string);
  39792. /**
  39793. * Loads an image as an HTMLImageElement.
  39794. * @param input url string, ArrayBuffer, or Blob to load
  39795. * @param onLoad callback called when the image successfully loads
  39796. * @param onError callback called when the image fails to load
  39797. * @param offlineProvider offline provider for caching
  39798. * @param mimeType optional mime type
  39799. * @returns the HTMLImageElement of the loaded image
  39800. */
  39801. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39802. /**
  39803. * Loads a file from a url
  39804. * @param url url string, ArrayBuffer, or Blob to load
  39805. * @param onSuccess callback called when the file successfully loads
  39806. * @param onProgress callback called while file is loading (if the server supports this mode)
  39807. * @param offlineProvider defines the offline provider for caching
  39808. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39809. * @param onError callback called when the file fails to load
  39810. * @returns a file request object
  39811. */
  39812. 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;
  39813. /**
  39814. * Loads a file from a url
  39815. * @param url the file url to load
  39816. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39817. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39818. */
  39819. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39820. /**
  39821. * Load a script (identified by an url). When the url returns, the
  39822. * content of this file is added into a new script element, attached to the DOM (body element)
  39823. * @param scriptUrl defines the url of the script to laod
  39824. * @param onSuccess defines the callback called when the script is loaded
  39825. * @param onError defines the callback to call if an error occurs
  39826. * @param scriptId defines the id of the script element
  39827. */
  39828. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39829. /**
  39830. * Load an asynchronous script (identified by an url). When the url returns, the
  39831. * content of this file is added into a new script element, attached to the DOM (body element)
  39832. * @param scriptUrl defines the url of the script to laod
  39833. * @param scriptId defines the id of the script element
  39834. * @returns a promise request object
  39835. */
  39836. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39837. /**
  39838. * Loads a file from a blob
  39839. * @param fileToLoad defines the blob to use
  39840. * @param callback defines the callback to call when data is loaded
  39841. * @param progressCallback defines the callback to call during loading process
  39842. * @returns a file request object
  39843. */
  39844. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39845. /**
  39846. * Reads a file from a File object
  39847. * @param file defines the file to load
  39848. * @param onSuccess defines the callback to call when data is loaded
  39849. * @param onProgress defines the callback to call during loading process
  39850. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39851. * @param onError defines the callback to call when an error occurs
  39852. * @returns a file request object
  39853. */
  39854. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39855. /**
  39856. * Creates a data url from a given string content
  39857. * @param content defines the content to convert
  39858. * @returns the new data url link
  39859. */
  39860. static FileAsURL(content: string): string;
  39861. /**
  39862. * Format the given number to a specific decimal format
  39863. * @param value defines the number to format
  39864. * @param decimals defines the number of decimals to use
  39865. * @returns the formatted string
  39866. */
  39867. static Format(value: number, decimals?: number): string;
  39868. /**
  39869. * Tries to copy an object by duplicating every property
  39870. * @param source defines the source object
  39871. * @param destination defines the target object
  39872. * @param doNotCopyList defines a list of properties to avoid
  39873. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39874. */
  39875. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39876. /**
  39877. * Gets a boolean indicating if the given object has no own property
  39878. * @param obj defines the object to test
  39879. * @returns true if object has no own property
  39880. */
  39881. static IsEmpty(obj: any): boolean;
  39882. /**
  39883. * Function used to register events at window level
  39884. * @param windowElement defines the Window object to use
  39885. * @param events defines the events to register
  39886. */
  39887. static RegisterTopRootEvents(windowElement: Window, events: {
  39888. name: string;
  39889. handler: Nullable<(e: FocusEvent) => any>;
  39890. }[]): void;
  39891. /**
  39892. * Function used to unregister events from window level
  39893. * @param windowElement defines the Window object to use
  39894. * @param events defines the events to unregister
  39895. */
  39896. static UnregisterTopRootEvents(windowElement: Window, events: {
  39897. name: string;
  39898. handler: Nullable<(e: FocusEvent) => any>;
  39899. }[]): void;
  39900. /**
  39901. * @ignore
  39902. */
  39903. static _ScreenshotCanvas: HTMLCanvasElement;
  39904. /**
  39905. * Dumps the current bound framebuffer
  39906. * @param width defines the rendering width
  39907. * @param height defines the rendering height
  39908. * @param engine defines the hosting engine
  39909. * @param successCallback defines the callback triggered once the data are available
  39910. * @param mimeType defines the mime type of the result
  39911. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39912. */
  39913. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39914. /**
  39915. * Converts the canvas data to blob.
  39916. * This acts as a polyfill for browsers not supporting the to blob function.
  39917. * @param canvas Defines the canvas to extract the data from
  39918. * @param successCallback Defines the callback triggered once the data are available
  39919. * @param mimeType Defines the mime type of the result
  39920. */
  39921. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39922. /**
  39923. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39924. * @param successCallback defines the callback triggered once the data are available
  39925. * @param mimeType defines the mime type of the result
  39926. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39927. */
  39928. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39929. /**
  39930. * Downloads a blob in the browser
  39931. * @param blob defines the blob to download
  39932. * @param fileName defines the name of the downloaded file
  39933. */
  39934. static Download(blob: Blob, fileName: string): void;
  39935. /**
  39936. * Captures a screenshot of the current rendering
  39937. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39938. * @param engine defines the rendering engine
  39939. * @param camera defines the source camera
  39940. * @param size This parameter can be set to a single number or to an object with the
  39941. * following (optional) properties: precision, width, height. If a single number is passed,
  39942. * it will be used for both width and height. If an object is passed, the screenshot size
  39943. * will be derived from the parameters. The precision property is a multiplier allowing
  39944. * rendering at a higher or lower resolution
  39945. * @param successCallback defines the callback receives a single parameter which contains the
  39946. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39947. * src parameter of an <img> to display it
  39948. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39949. * Check your browser for supported MIME types
  39950. */
  39951. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39952. /**
  39953. * Captures a screenshot of the current rendering
  39954. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39955. * @param engine defines the rendering engine
  39956. * @param camera defines the source camera
  39957. * @param size This parameter can be set to a single number or to an object with the
  39958. * following (optional) properties: precision, width, height. If a single number is passed,
  39959. * it will be used for both width and height. If an object is passed, the screenshot size
  39960. * will be derived from the parameters. The precision property is a multiplier allowing
  39961. * rendering at a higher or lower resolution
  39962. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39963. * Check your browser for supported MIME types
  39964. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39965. * to the src parameter of an <img> to display it
  39966. */
  39967. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39968. /**
  39969. * Generates an image screenshot from the specified camera.
  39970. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39971. * @param engine The engine to use for rendering
  39972. * @param camera The camera to use for rendering
  39973. * @param size This parameter can be set to a single number or to an object with the
  39974. * following (optional) properties: precision, width, height. If a single number is passed,
  39975. * it will be used for both width and height. If an object is passed, the screenshot size
  39976. * will be derived from the parameters. The precision property is a multiplier allowing
  39977. * rendering at a higher or lower resolution
  39978. * @param successCallback The callback receives a single parameter which contains the
  39979. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39980. * src parameter of an <img> to display it
  39981. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39982. * Check your browser for supported MIME types
  39983. * @param samples Texture samples (default: 1)
  39984. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39985. * @param fileName A name for for the downloaded file.
  39986. */
  39987. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39988. /**
  39989. * Generates an image screenshot from the specified camera.
  39990. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39991. * @param engine The engine to use for rendering
  39992. * @param camera The camera to use for rendering
  39993. * @param size This parameter can be set to a single number or to an object with the
  39994. * following (optional) properties: precision, width, height. If a single number is passed,
  39995. * it will be used for both width and height. If an object is passed, the screenshot size
  39996. * will be derived from the parameters. The precision property is a multiplier allowing
  39997. * rendering at a higher or lower resolution
  39998. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39999. * Check your browser for supported MIME types
  40000. * @param samples Texture samples (default: 1)
  40001. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  40002. * @param fileName A name for for the downloaded file.
  40003. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  40004. * to the src parameter of an <img> to display it
  40005. */
  40006. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  40007. /**
  40008. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  40009. * Be aware Math.random() could cause collisions, but:
  40010. * "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"
  40011. * @returns a pseudo random id
  40012. */
  40013. static RandomId(): string;
  40014. /**
  40015. * Test if the given uri is a base64 string
  40016. * @param uri The uri to test
  40017. * @return True if the uri is a base64 string or false otherwise
  40018. */
  40019. static IsBase64(uri: string): boolean;
  40020. /**
  40021. * Decode the given base64 uri.
  40022. * @param uri The uri to decode
  40023. * @return The decoded base64 data.
  40024. */
  40025. static DecodeBase64(uri: string): ArrayBuffer;
  40026. /**
  40027. * Gets the absolute url.
  40028. * @param url the input url
  40029. * @return the absolute url
  40030. */
  40031. static GetAbsoluteUrl(url: string): string;
  40032. /**
  40033. * No log
  40034. */
  40035. static readonly NoneLogLevel: number;
  40036. /**
  40037. * Only message logs
  40038. */
  40039. static readonly MessageLogLevel: number;
  40040. /**
  40041. * Only warning logs
  40042. */
  40043. static readonly WarningLogLevel: number;
  40044. /**
  40045. * Only error logs
  40046. */
  40047. static readonly ErrorLogLevel: number;
  40048. /**
  40049. * All logs
  40050. */
  40051. static readonly AllLogLevel: number;
  40052. /**
  40053. * Gets a value indicating the number of loading errors
  40054. * @ignorenaming
  40055. */
  40056. static get errorsCount(): number;
  40057. /**
  40058. * Callback called when a new log is added
  40059. */
  40060. static OnNewCacheEntry: (entry: string) => void;
  40061. /**
  40062. * Log a message to the console
  40063. * @param message defines the message to log
  40064. */
  40065. static Log(message: string): void;
  40066. /**
  40067. * Write a warning message to the console
  40068. * @param message defines the message to log
  40069. */
  40070. static Warn(message: string): void;
  40071. /**
  40072. * Write an error message to the console
  40073. * @param message defines the message to log
  40074. */
  40075. static Error(message: string): void;
  40076. /**
  40077. * Gets current log cache (list of logs)
  40078. */
  40079. static get LogCache(): string;
  40080. /**
  40081. * Clears the log cache
  40082. */
  40083. static ClearLogCache(): void;
  40084. /**
  40085. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40086. */
  40087. static set LogLevels(level: number);
  40088. /**
  40089. * Checks if the window object exists
  40090. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  40091. */
  40092. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  40093. /**
  40094. * No performance log
  40095. */
  40096. static readonly PerformanceNoneLogLevel: number;
  40097. /**
  40098. * Use user marks to log performance
  40099. */
  40100. static readonly PerformanceUserMarkLogLevel: number;
  40101. /**
  40102. * Log performance to the console
  40103. */
  40104. static readonly PerformanceConsoleLogLevel: number;
  40105. private static _performance;
  40106. /**
  40107. * Sets the current performance log level
  40108. */
  40109. static set PerformanceLogLevel(level: number);
  40110. private static _StartPerformanceCounterDisabled;
  40111. private static _EndPerformanceCounterDisabled;
  40112. private static _StartUserMark;
  40113. private static _EndUserMark;
  40114. private static _StartPerformanceConsole;
  40115. private static _EndPerformanceConsole;
  40116. /**
  40117. * Starts a performance counter
  40118. */
  40119. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40120. /**
  40121. * Ends a specific performance coutner
  40122. */
  40123. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40124. /**
  40125. * Gets either window.performance.now() if supported or Date.now() else
  40126. */
  40127. static get Now(): number;
  40128. /**
  40129. * This method will return the name of the class used to create the instance of the given object.
  40130. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40131. * @param object the object to get the class name from
  40132. * @param isType defines if the object is actually a type
  40133. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40134. */
  40135. static GetClassName(object: any, isType?: boolean): string;
  40136. /**
  40137. * Gets the first element of an array satisfying a given predicate
  40138. * @param array defines the array to browse
  40139. * @param predicate defines the predicate to use
  40140. * @returns null if not found or the element
  40141. */
  40142. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40143. /**
  40144. * This method will return the name of the full name of the class, including its owning module (if any).
  40145. * 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).
  40146. * @param object the object to get the class name from
  40147. * @param isType defines if the object is actually a type
  40148. * @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.
  40149. * @ignorenaming
  40150. */
  40151. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40152. /**
  40153. * Returns a promise that resolves after the given amount of time.
  40154. * @param delay Number of milliseconds to delay
  40155. * @returns Promise that resolves after the given amount of time
  40156. */
  40157. static DelayAsync(delay: number): Promise<void>;
  40158. /**
  40159. * Utility function to detect if the current user agent is Safari
  40160. * @returns whether or not the current user agent is safari
  40161. */
  40162. static IsSafari(): boolean;
  40163. }
  40164. /**
  40165. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40166. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40167. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40168. * @param name The name of the class, case should be preserved
  40169. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40170. */
  40171. export function className(name: string, module?: string): (target: Object) => void;
  40172. /**
  40173. * An implementation of a loop for asynchronous functions.
  40174. */
  40175. export class AsyncLoop {
  40176. /**
  40177. * Defines the number of iterations for the loop
  40178. */
  40179. iterations: number;
  40180. /**
  40181. * Defines the current index of the loop.
  40182. */
  40183. index: number;
  40184. private _done;
  40185. private _fn;
  40186. private _successCallback;
  40187. /**
  40188. * Constructor.
  40189. * @param iterations the number of iterations.
  40190. * @param func the function to run each iteration
  40191. * @param successCallback the callback that will be called upon succesful execution
  40192. * @param offset starting offset.
  40193. */
  40194. constructor(
  40195. /**
  40196. * Defines the number of iterations for the loop
  40197. */
  40198. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40199. /**
  40200. * Execute the next iteration. Must be called after the last iteration was finished.
  40201. */
  40202. executeNext(): void;
  40203. /**
  40204. * Break the loop and run the success callback.
  40205. */
  40206. breakLoop(): void;
  40207. /**
  40208. * Create and run an async loop.
  40209. * @param iterations the number of iterations.
  40210. * @param fn the function to run each iteration
  40211. * @param successCallback the callback that will be called upon succesful execution
  40212. * @param offset starting offset.
  40213. * @returns the created async loop object
  40214. */
  40215. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40216. /**
  40217. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40218. * @param iterations total number of iterations
  40219. * @param syncedIterations number of synchronous iterations in each async iteration.
  40220. * @param fn the function to call each iteration.
  40221. * @param callback a success call back that will be called when iterating stops.
  40222. * @param breakFunction a break condition (optional)
  40223. * @param timeout timeout settings for the setTimeout function. default - 0.
  40224. * @returns the created async loop object
  40225. */
  40226. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40227. }
  40228. }
  40229. declare module "babylonjs/Misc/stringDictionary" {
  40230. import { Nullable } from "babylonjs/types";
  40231. /**
  40232. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40233. * The underlying implementation relies on an associative array to ensure the best performances.
  40234. * The value can be anything including 'null' but except 'undefined'
  40235. */
  40236. export class StringDictionary<T> {
  40237. /**
  40238. * This will clear this dictionary and copy the content from the 'source' one.
  40239. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40240. * @param source the dictionary to take the content from and copy to this dictionary
  40241. */
  40242. copyFrom(source: StringDictionary<T>): void;
  40243. /**
  40244. * Get a value based from its key
  40245. * @param key the given key to get the matching value from
  40246. * @return the value if found, otherwise undefined is returned
  40247. */
  40248. get(key: string): T | undefined;
  40249. /**
  40250. * Get a value from its key or add it if it doesn't exist.
  40251. * This method will ensure you that a given key/data will be present in the dictionary.
  40252. * @param key the given key to get the matching value from
  40253. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40254. * The factory will only be invoked if there's no data for the given key.
  40255. * @return the value corresponding to the key.
  40256. */
  40257. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40258. /**
  40259. * Get a value from its key if present in the dictionary otherwise add it
  40260. * @param key the key to get the value from
  40261. * @param val if there's no such key/value pair in the dictionary add it with this value
  40262. * @return the value corresponding to the key
  40263. */
  40264. getOrAdd(key: string, val: T): T;
  40265. /**
  40266. * Check if there's a given key in the dictionary
  40267. * @param key the key to check for
  40268. * @return true if the key is present, false otherwise
  40269. */
  40270. contains(key: string): boolean;
  40271. /**
  40272. * Add a new key and its corresponding value
  40273. * @param key the key to add
  40274. * @param value the value corresponding to the key
  40275. * @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
  40276. */
  40277. add(key: string, value: T): boolean;
  40278. /**
  40279. * Update a specific value associated to a key
  40280. * @param key defines the key to use
  40281. * @param value defines the value to store
  40282. * @returns true if the value was updated (or false if the key was not found)
  40283. */
  40284. set(key: string, value: T): boolean;
  40285. /**
  40286. * Get the element of the given key and remove it from the dictionary
  40287. * @param key defines the key to search
  40288. * @returns the value associated with the key or null if not found
  40289. */
  40290. getAndRemove(key: string): Nullable<T>;
  40291. /**
  40292. * Remove a key/value from the dictionary.
  40293. * @param key the key to remove
  40294. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40295. */
  40296. remove(key: string): boolean;
  40297. /**
  40298. * Clear the whole content of the dictionary
  40299. */
  40300. clear(): void;
  40301. /**
  40302. * Gets the current count
  40303. */
  40304. get count(): number;
  40305. /**
  40306. * Execute a callback on each key/val of the dictionary.
  40307. * Note that you can remove any element in this dictionary in the callback implementation
  40308. * @param callback the callback to execute on a given key/value pair
  40309. */
  40310. forEach(callback: (key: string, val: T) => void): void;
  40311. /**
  40312. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40313. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40314. * Note that you can remove any element in this dictionary in the callback implementation
  40315. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40316. * @returns the first item
  40317. */
  40318. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40319. private _count;
  40320. private _data;
  40321. }
  40322. }
  40323. declare module "babylonjs/Collisions/collisionCoordinator" {
  40324. import { Nullable } from "babylonjs/types";
  40325. import { Scene } from "babylonjs/scene";
  40326. import { Vector3 } from "babylonjs/Maths/math.vector";
  40327. import { Collider } from "babylonjs/Collisions/collider";
  40328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40329. /** @hidden */
  40330. export interface ICollisionCoordinator {
  40331. createCollider(): Collider;
  40332. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40333. init(scene: Scene): void;
  40334. }
  40335. /** @hidden */
  40336. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40337. private _scene;
  40338. private _scaledPosition;
  40339. private _scaledVelocity;
  40340. private _finalPosition;
  40341. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40342. createCollider(): Collider;
  40343. init(scene: Scene): void;
  40344. private _collideWithWorld;
  40345. }
  40346. }
  40347. declare module "babylonjs/Inputs/scene.inputManager" {
  40348. import { Nullable } from "babylonjs/types";
  40349. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40350. import { Vector2 } from "babylonjs/Maths/math.vector";
  40351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40352. import { Scene } from "babylonjs/scene";
  40353. /**
  40354. * Class used to manage all inputs for the scene.
  40355. */
  40356. export class InputManager {
  40357. /** The distance in pixel that you have to move to prevent some events */
  40358. static DragMovementThreshold: number;
  40359. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40360. static LongPressDelay: number;
  40361. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40362. static DoubleClickDelay: number;
  40363. /** If you need to check double click without raising a single click at first click, enable this flag */
  40364. static ExclusiveDoubleClickMode: boolean;
  40365. /** 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. */
  40366. private _alreadyAttached;
  40367. private _wheelEventName;
  40368. private _onPointerMove;
  40369. private _onPointerDown;
  40370. private _onPointerUp;
  40371. private _initClickEvent;
  40372. private _initActionManager;
  40373. private _delayedSimpleClick;
  40374. private _delayedSimpleClickTimeout;
  40375. private _previousDelayedSimpleClickTimeout;
  40376. private _meshPickProceed;
  40377. private _previousButtonPressed;
  40378. private _currentPickResult;
  40379. private _previousPickResult;
  40380. private _totalPointersPressed;
  40381. private _doubleClickOccured;
  40382. private _pointerOverMesh;
  40383. private _pickedDownMesh;
  40384. private _pickedUpMesh;
  40385. private _pointerX;
  40386. private _pointerY;
  40387. private _unTranslatedPointerX;
  40388. private _unTranslatedPointerY;
  40389. private _startingPointerPosition;
  40390. private _previousStartingPointerPosition;
  40391. private _startingPointerTime;
  40392. private _previousStartingPointerTime;
  40393. private _pointerCaptures;
  40394. private _meshUnderPointerId;
  40395. private _onKeyDown;
  40396. private _onKeyUp;
  40397. private _onCanvasFocusObserver;
  40398. private _onCanvasBlurObserver;
  40399. private _scene;
  40400. /**
  40401. * Creates a new InputManager
  40402. * @param scene defines the hosting scene
  40403. */
  40404. constructor(scene: Scene);
  40405. /**
  40406. * Gets the mesh that is currently under the pointer
  40407. */
  40408. get meshUnderPointer(): Nullable<AbstractMesh>;
  40409. /**
  40410. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  40411. * @param pointerId the pointer id to use
  40412. * @returns The mesh under this pointer id or null if not found
  40413. */
  40414. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  40415. /**
  40416. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40417. */
  40418. get unTranslatedPointer(): Vector2;
  40419. /**
  40420. * Gets or sets the current on-screen X position of the pointer
  40421. */
  40422. get pointerX(): number;
  40423. set pointerX(value: number);
  40424. /**
  40425. * Gets or sets the current on-screen Y position of the pointer
  40426. */
  40427. get pointerY(): number;
  40428. set pointerY(value: number);
  40429. private _updatePointerPosition;
  40430. private _processPointerMove;
  40431. private _setRayOnPointerInfo;
  40432. private _checkPrePointerObservable;
  40433. /**
  40434. * Use this method to simulate a pointer move on a mesh
  40435. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40436. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40437. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40438. */
  40439. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40440. /**
  40441. * Use this method to simulate a pointer down on a mesh
  40442. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40443. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40444. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40445. */
  40446. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40447. private _processPointerDown;
  40448. /** @hidden */
  40449. _isPointerSwiping(): boolean;
  40450. /**
  40451. * Use this method to simulate a pointer up on a mesh
  40452. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40453. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40454. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40455. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40456. */
  40457. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40458. private _processPointerUp;
  40459. /**
  40460. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40461. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40462. * @returns true if the pointer was captured
  40463. */
  40464. isPointerCaptured(pointerId?: number): boolean;
  40465. /**
  40466. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40467. * @param attachUp defines if you want to attach events to pointerup
  40468. * @param attachDown defines if you want to attach events to pointerdown
  40469. * @param attachMove defines if you want to attach events to pointermove
  40470. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40471. */
  40472. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40473. /**
  40474. * Detaches all event handlers
  40475. */
  40476. detachControl(): void;
  40477. /**
  40478. * Force the value of meshUnderPointer
  40479. * @param mesh defines the mesh to use
  40480. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  40481. */
  40482. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  40483. /**
  40484. * Gets the mesh under the pointer
  40485. * @returns a Mesh or null if no mesh is under the pointer
  40486. */
  40487. getPointerOverMesh(): Nullable<AbstractMesh>;
  40488. }
  40489. }
  40490. declare module "babylonjs/Animations/animationGroup" {
  40491. import { Animatable } from "babylonjs/Animations/animatable";
  40492. import { Animation } from "babylonjs/Animations/animation";
  40493. import { Scene, IDisposable } from "babylonjs/scene";
  40494. import { Observable } from "babylonjs/Misc/observable";
  40495. import { Nullable } from "babylonjs/types";
  40496. import "babylonjs/Animations/animatable";
  40497. /**
  40498. * This class defines the direct association between an animation and a target
  40499. */
  40500. export class TargetedAnimation {
  40501. /**
  40502. * Animation to perform
  40503. */
  40504. animation: Animation;
  40505. /**
  40506. * Target to animate
  40507. */
  40508. target: any;
  40509. /**
  40510. * Returns the string "TargetedAnimation"
  40511. * @returns "TargetedAnimation"
  40512. */
  40513. getClassName(): string;
  40514. /**
  40515. * Serialize the object
  40516. * @returns the JSON object representing the current entity
  40517. */
  40518. serialize(): any;
  40519. }
  40520. /**
  40521. * Use this class to create coordinated animations on multiple targets
  40522. */
  40523. export class AnimationGroup implements IDisposable {
  40524. /** The name of the animation group */
  40525. name: string;
  40526. private _scene;
  40527. private _targetedAnimations;
  40528. private _animatables;
  40529. private _from;
  40530. private _to;
  40531. private _isStarted;
  40532. private _isPaused;
  40533. private _speedRatio;
  40534. private _loopAnimation;
  40535. private _isAdditive;
  40536. /**
  40537. * Gets or sets the unique id of the node
  40538. */
  40539. uniqueId: number;
  40540. /**
  40541. * This observable will notify when one animation have ended
  40542. */
  40543. onAnimationEndObservable: Observable<TargetedAnimation>;
  40544. /**
  40545. * Observer raised when one animation loops
  40546. */
  40547. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40548. /**
  40549. * Observer raised when all animations have looped
  40550. */
  40551. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40552. /**
  40553. * This observable will notify when all animations have ended.
  40554. */
  40555. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40556. /**
  40557. * This observable will notify when all animations have paused.
  40558. */
  40559. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40560. /**
  40561. * This observable will notify when all animations are playing.
  40562. */
  40563. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40564. /**
  40565. * Gets the first frame
  40566. */
  40567. get from(): number;
  40568. /**
  40569. * Gets the last frame
  40570. */
  40571. get to(): number;
  40572. /**
  40573. * Define if the animations are started
  40574. */
  40575. get isStarted(): boolean;
  40576. /**
  40577. * Gets a value indicating that the current group is playing
  40578. */
  40579. get isPlaying(): boolean;
  40580. /**
  40581. * Gets or sets the speed ratio to use for all animations
  40582. */
  40583. get speedRatio(): number;
  40584. /**
  40585. * Gets or sets the speed ratio to use for all animations
  40586. */
  40587. set speedRatio(value: number);
  40588. /**
  40589. * Gets or sets if all animations should loop or not
  40590. */
  40591. get loopAnimation(): boolean;
  40592. set loopAnimation(value: boolean);
  40593. /**
  40594. * Gets or sets if all animations should be evaluated additively
  40595. */
  40596. get isAdditive(): boolean;
  40597. set isAdditive(value: boolean);
  40598. /**
  40599. * Gets the targeted animations for this animation group
  40600. */
  40601. get targetedAnimations(): Array<TargetedAnimation>;
  40602. /**
  40603. * returning the list of animatables controlled by this animation group.
  40604. */
  40605. get animatables(): Array<Animatable>;
  40606. /**
  40607. * Gets the list of target animations
  40608. */
  40609. get children(): TargetedAnimation[];
  40610. /**
  40611. * Instantiates a new Animation Group.
  40612. * This helps managing several animations at once.
  40613. * @see https://doc.babylonjs.com/how_to/group
  40614. * @param name Defines the name of the group
  40615. * @param scene Defines the scene the group belongs to
  40616. */
  40617. constructor(
  40618. /** The name of the animation group */
  40619. name: string, scene?: Nullable<Scene>);
  40620. /**
  40621. * Add an animation (with its target) in the group
  40622. * @param animation defines the animation we want to add
  40623. * @param target defines the target of the animation
  40624. * @returns the TargetedAnimation object
  40625. */
  40626. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40627. /**
  40628. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40629. * It can add constant keys at begin or end
  40630. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40631. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40632. * @returns the animation group
  40633. */
  40634. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40635. private _animationLoopCount;
  40636. private _animationLoopFlags;
  40637. private _processLoop;
  40638. /**
  40639. * Start all animations on given targets
  40640. * @param loop defines if animations must loop
  40641. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40642. * @param from defines the from key (optional)
  40643. * @param to defines the to key (optional)
  40644. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40645. * @returns the current animation group
  40646. */
  40647. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40648. /**
  40649. * Pause all animations
  40650. * @returns the animation group
  40651. */
  40652. pause(): AnimationGroup;
  40653. /**
  40654. * Play all animations to initial state
  40655. * This function will start() the animations if they were not started or will restart() them if they were paused
  40656. * @param loop defines if animations must loop
  40657. * @returns the animation group
  40658. */
  40659. play(loop?: boolean): AnimationGroup;
  40660. /**
  40661. * Reset all animations to initial state
  40662. * @returns the animation group
  40663. */
  40664. reset(): AnimationGroup;
  40665. /**
  40666. * Restart animations from key 0
  40667. * @returns the animation group
  40668. */
  40669. restart(): AnimationGroup;
  40670. /**
  40671. * Stop all animations
  40672. * @returns the animation group
  40673. */
  40674. stop(): AnimationGroup;
  40675. /**
  40676. * Set animation weight for all animatables
  40677. * @param weight defines the weight to use
  40678. * @return the animationGroup
  40679. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40680. */
  40681. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40682. /**
  40683. * Synchronize and normalize all animatables with a source animatable
  40684. * @param root defines the root animatable to synchronize with
  40685. * @return the animationGroup
  40686. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40687. */
  40688. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40689. /**
  40690. * Goes to a specific frame in this animation group
  40691. * @param frame the frame number to go to
  40692. * @return the animationGroup
  40693. */
  40694. goToFrame(frame: number): AnimationGroup;
  40695. /**
  40696. * Dispose all associated resources
  40697. */
  40698. dispose(): void;
  40699. private _checkAnimationGroupEnded;
  40700. /**
  40701. * Clone the current animation group and returns a copy
  40702. * @param newName defines the name of the new group
  40703. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40704. * @returns the new aniamtion group
  40705. */
  40706. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40707. /**
  40708. * Serializes the animationGroup to an object
  40709. * @returns Serialized object
  40710. */
  40711. serialize(): any;
  40712. /**
  40713. * Returns a new AnimationGroup object parsed from the source provided.
  40714. * @param parsedAnimationGroup defines the source
  40715. * @param scene defines the scene that will receive the animationGroup
  40716. * @returns a new AnimationGroup
  40717. */
  40718. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40719. /**
  40720. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40721. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40722. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40723. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40724. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40725. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40726. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40727. */
  40728. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40729. /**
  40730. * Returns the string "AnimationGroup"
  40731. * @returns "AnimationGroup"
  40732. */
  40733. getClassName(): string;
  40734. /**
  40735. * Creates a detailled string about the object
  40736. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40737. * @returns a string representing the object
  40738. */
  40739. toString(fullDetails?: boolean): string;
  40740. }
  40741. }
  40742. declare module "babylonjs/scene" {
  40743. import { Nullable } from "babylonjs/types";
  40744. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40745. import { Observable } from "babylonjs/Misc/observable";
  40746. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40747. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40748. import { Geometry } from "babylonjs/Meshes/geometry";
  40749. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40750. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40752. import { Mesh } from "babylonjs/Meshes/mesh";
  40753. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40754. import { Bone } from "babylonjs/Bones/bone";
  40755. import { Skeleton } from "babylonjs/Bones/skeleton";
  40756. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40757. import { Camera } from "babylonjs/Cameras/camera";
  40758. import { AbstractScene } from "babylonjs/abstractScene";
  40759. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40760. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40761. import { Material } from "babylonjs/Materials/material";
  40762. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40763. import { Effect } from "babylonjs/Materials/effect";
  40764. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40765. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40766. import { Light } from "babylonjs/Lights/light";
  40767. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40768. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40769. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40770. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40771. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40772. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40773. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40774. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40775. import { Engine } from "babylonjs/Engines/engine";
  40776. import { Node } from "babylonjs/node";
  40777. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40778. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40779. import { WebRequest } from "babylonjs/Misc/webRequest";
  40780. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40781. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40782. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40783. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40784. import { Plane } from "babylonjs/Maths/math.plane";
  40785. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40786. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40787. import { Ray } from "babylonjs/Culling/ray";
  40788. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40789. import { Animation } from "babylonjs/Animations/animation";
  40790. import { Animatable } from "babylonjs/Animations/animatable";
  40791. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40792. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40793. import { Collider } from "babylonjs/Collisions/collider";
  40794. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40795. /**
  40796. * Define an interface for all classes that will hold resources
  40797. */
  40798. export interface IDisposable {
  40799. /**
  40800. * Releases all held resources
  40801. */
  40802. dispose(): void;
  40803. }
  40804. /** Interface defining initialization parameters for Scene class */
  40805. export interface SceneOptions {
  40806. /**
  40807. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40808. * It will improve performance when the number of geometries becomes important.
  40809. */
  40810. useGeometryUniqueIdsMap?: boolean;
  40811. /**
  40812. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40813. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40814. */
  40815. useMaterialMeshMap?: boolean;
  40816. /**
  40817. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40818. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40819. */
  40820. useClonedMeshMap?: boolean;
  40821. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40822. virtual?: boolean;
  40823. }
  40824. /**
  40825. * Represents a scene to be rendered by the engine.
  40826. * @see https://doc.babylonjs.com/features/scene
  40827. */
  40828. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40829. /** The fog is deactivated */
  40830. static readonly FOGMODE_NONE: number;
  40831. /** The fog density is following an exponential function */
  40832. static readonly FOGMODE_EXP: number;
  40833. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40834. static readonly FOGMODE_EXP2: number;
  40835. /** The fog density is following a linear function. */
  40836. static readonly FOGMODE_LINEAR: number;
  40837. /**
  40838. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40839. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40840. */
  40841. static MinDeltaTime: number;
  40842. /**
  40843. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40844. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40845. */
  40846. static MaxDeltaTime: number;
  40847. /**
  40848. * Factory used to create the default material.
  40849. * @param name The name of the material to create
  40850. * @param scene The scene to create the material for
  40851. * @returns The default material
  40852. */
  40853. static DefaultMaterialFactory(scene: Scene): Material;
  40854. /**
  40855. * Factory used to create the a collision coordinator.
  40856. * @returns The collision coordinator
  40857. */
  40858. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40859. /** @hidden */
  40860. _inputManager: InputManager;
  40861. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40862. cameraToUseForPointers: Nullable<Camera>;
  40863. /** @hidden */
  40864. readonly _isScene: boolean;
  40865. /** @hidden */
  40866. _blockEntityCollection: boolean;
  40867. /**
  40868. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40869. */
  40870. autoClear: boolean;
  40871. /**
  40872. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40873. */
  40874. autoClearDepthAndStencil: boolean;
  40875. /**
  40876. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40877. */
  40878. clearColor: Color4;
  40879. /**
  40880. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40881. */
  40882. ambientColor: Color3;
  40883. /**
  40884. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40885. * It should only be one of the following (if not the default embedded one):
  40886. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40887. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40888. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40889. * The material properties need to be setup according to the type of texture in use.
  40890. */
  40891. environmentBRDFTexture: BaseTexture;
  40892. /**
  40893. * Texture used in all pbr material as the reflection texture.
  40894. * As in the majority of the scene they are the same (exception for multi room and so on),
  40895. * this is easier to reference from here than from all the materials.
  40896. */
  40897. get environmentTexture(): Nullable<BaseTexture>;
  40898. /**
  40899. * Texture used in all pbr material as the reflection texture.
  40900. * As in the majority of the scene they are the same (exception for multi room and so on),
  40901. * this is easier to set here than in all the materials.
  40902. */
  40903. set environmentTexture(value: Nullable<BaseTexture>);
  40904. /** @hidden */
  40905. protected _environmentIntensity: number;
  40906. /**
  40907. * Intensity of the environment in all pbr material.
  40908. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40909. * As in the majority of the scene they are the same (exception for multi room and so on),
  40910. * this is easier to reference from here than from all the materials.
  40911. */
  40912. get environmentIntensity(): number;
  40913. /**
  40914. * Intensity of the environment in all pbr material.
  40915. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40916. * As in the majority of the scene they are the same (exception for multi room and so on),
  40917. * this is easier to set here than in all the materials.
  40918. */
  40919. set environmentIntensity(value: number);
  40920. /** @hidden */
  40921. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40922. /**
  40923. * Default image processing configuration used either in the rendering
  40924. * Forward main pass or through the imageProcessingPostProcess if present.
  40925. * As in the majority of the scene they are the same (exception for multi camera),
  40926. * this is easier to reference from here than from all the materials and post process.
  40927. *
  40928. * No setter as we it is a shared configuration, you can set the values instead.
  40929. */
  40930. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40931. private _forceWireframe;
  40932. /**
  40933. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40934. */
  40935. set forceWireframe(value: boolean);
  40936. get forceWireframe(): boolean;
  40937. private _skipFrustumClipping;
  40938. /**
  40939. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40940. */
  40941. set skipFrustumClipping(value: boolean);
  40942. get skipFrustumClipping(): boolean;
  40943. private _forcePointsCloud;
  40944. /**
  40945. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40946. */
  40947. set forcePointsCloud(value: boolean);
  40948. get forcePointsCloud(): boolean;
  40949. /**
  40950. * Gets or sets the active clipplane 1
  40951. */
  40952. clipPlane: Nullable<Plane>;
  40953. /**
  40954. * Gets or sets the active clipplane 2
  40955. */
  40956. clipPlane2: Nullable<Plane>;
  40957. /**
  40958. * Gets or sets the active clipplane 3
  40959. */
  40960. clipPlane3: Nullable<Plane>;
  40961. /**
  40962. * Gets or sets the active clipplane 4
  40963. */
  40964. clipPlane4: Nullable<Plane>;
  40965. /**
  40966. * Gets or sets the active clipplane 5
  40967. */
  40968. clipPlane5: Nullable<Plane>;
  40969. /**
  40970. * Gets or sets the active clipplane 6
  40971. */
  40972. clipPlane6: Nullable<Plane>;
  40973. /**
  40974. * Gets or sets a boolean indicating if animations are enabled
  40975. */
  40976. animationsEnabled: boolean;
  40977. private _animationPropertiesOverride;
  40978. /**
  40979. * Gets or sets the animation properties override
  40980. */
  40981. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40982. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40983. /**
  40984. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40985. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40986. */
  40987. useConstantAnimationDeltaTime: boolean;
  40988. /**
  40989. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40990. * Please note that it requires to run a ray cast through the scene on every frame
  40991. */
  40992. constantlyUpdateMeshUnderPointer: boolean;
  40993. /**
  40994. * Defines the HTML cursor to use when hovering over interactive elements
  40995. */
  40996. hoverCursor: string;
  40997. /**
  40998. * Defines the HTML default cursor to use (empty by default)
  40999. */
  41000. defaultCursor: string;
  41001. /**
  41002. * Defines whether cursors are handled by the scene.
  41003. */
  41004. doNotHandleCursors: boolean;
  41005. /**
  41006. * This is used to call preventDefault() on pointer down
  41007. * in order to block unwanted artifacts like system double clicks
  41008. */
  41009. preventDefaultOnPointerDown: boolean;
  41010. /**
  41011. * This is used to call preventDefault() on pointer up
  41012. * in order to block unwanted artifacts like system double clicks
  41013. */
  41014. preventDefaultOnPointerUp: boolean;
  41015. /**
  41016. * Gets or sets user defined metadata
  41017. */
  41018. metadata: any;
  41019. /**
  41020. * For internal use only. Please do not use.
  41021. */
  41022. reservedDataStore: any;
  41023. /**
  41024. * Gets the name of the plugin used to load this scene (null by default)
  41025. */
  41026. loadingPluginName: string;
  41027. /**
  41028. * Use this array to add regular expressions used to disable offline support for specific urls
  41029. */
  41030. disableOfflineSupportExceptionRules: RegExp[];
  41031. /**
  41032. * An event triggered when the scene is disposed.
  41033. */
  41034. onDisposeObservable: Observable<Scene>;
  41035. private _onDisposeObserver;
  41036. /** Sets a function to be executed when this scene is disposed. */
  41037. set onDispose(callback: () => void);
  41038. /**
  41039. * An event triggered before rendering the scene (right after animations and physics)
  41040. */
  41041. onBeforeRenderObservable: Observable<Scene>;
  41042. private _onBeforeRenderObserver;
  41043. /** Sets a function to be executed before rendering this scene */
  41044. set beforeRender(callback: Nullable<() => void>);
  41045. /**
  41046. * An event triggered after rendering the scene
  41047. */
  41048. onAfterRenderObservable: Observable<Scene>;
  41049. /**
  41050. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  41051. */
  41052. onAfterRenderCameraObservable: Observable<Camera>;
  41053. private _onAfterRenderObserver;
  41054. /** Sets a function to be executed after rendering this scene */
  41055. set afterRender(callback: Nullable<() => void>);
  41056. /**
  41057. * An event triggered before animating the scene
  41058. */
  41059. onBeforeAnimationsObservable: Observable<Scene>;
  41060. /**
  41061. * An event triggered after animations processing
  41062. */
  41063. onAfterAnimationsObservable: Observable<Scene>;
  41064. /**
  41065. * An event triggered before draw calls are ready to be sent
  41066. */
  41067. onBeforeDrawPhaseObservable: Observable<Scene>;
  41068. /**
  41069. * An event triggered after draw calls have been sent
  41070. */
  41071. onAfterDrawPhaseObservable: Observable<Scene>;
  41072. /**
  41073. * An event triggered when the scene is ready
  41074. */
  41075. onReadyObservable: Observable<Scene>;
  41076. /**
  41077. * An event triggered before rendering a camera
  41078. */
  41079. onBeforeCameraRenderObservable: Observable<Camera>;
  41080. private _onBeforeCameraRenderObserver;
  41081. /** Sets a function to be executed before rendering a camera*/
  41082. set beforeCameraRender(callback: () => void);
  41083. /**
  41084. * An event triggered after rendering a camera
  41085. */
  41086. onAfterCameraRenderObservable: Observable<Camera>;
  41087. private _onAfterCameraRenderObserver;
  41088. /** Sets a function to be executed after rendering a camera*/
  41089. set afterCameraRender(callback: () => void);
  41090. /**
  41091. * An event triggered when active meshes evaluation is about to start
  41092. */
  41093. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  41094. /**
  41095. * An event triggered when active meshes evaluation is done
  41096. */
  41097. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  41098. /**
  41099. * An event triggered when particles rendering is about to start
  41100. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41101. */
  41102. onBeforeParticlesRenderingObservable: Observable<Scene>;
  41103. /**
  41104. * An event triggered when particles rendering is done
  41105. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41106. */
  41107. onAfterParticlesRenderingObservable: Observable<Scene>;
  41108. /**
  41109. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  41110. */
  41111. onDataLoadedObservable: Observable<Scene>;
  41112. /**
  41113. * An event triggered when a camera is created
  41114. */
  41115. onNewCameraAddedObservable: Observable<Camera>;
  41116. /**
  41117. * An event triggered when a camera is removed
  41118. */
  41119. onCameraRemovedObservable: Observable<Camera>;
  41120. /**
  41121. * An event triggered when a light is created
  41122. */
  41123. onNewLightAddedObservable: Observable<Light>;
  41124. /**
  41125. * An event triggered when a light is removed
  41126. */
  41127. onLightRemovedObservable: Observable<Light>;
  41128. /**
  41129. * An event triggered when a geometry is created
  41130. */
  41131. onNewGeometryAddedObservable: Observable<Geometry>;
  41132. /**
  41133. * An event triggered when a geometry is removed
  41134. */
  41135. onGeometryRemovedObservable: Observable<Geometry>;
  41136. /**
  41137. * An event triggered when a transform node is created
  41138. */
  41139. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  41140. /**
  41141. * An event triggered when a transform node is removed
  41142. */
  41143. onTransformNodeRemovedObservable: Observable<TransformNode>;
  41144. /**
  41145. * An event triggered when a mesh is created
  41146. */
  41147. onNewMeshAddedObservable: Observable<AbstractMesh>;
  41148. /**
  41149. * An event triggered when a mesh is removed
  41150. */
  41151. onMeshRemovedObservable: Observable<AbstractMesh>;
  41152. /**
  41153. * An event triggered when a skeleton is created
  41154. */
  41155. onNewSkeletonAddedObservable: Observable<Skeleton>;
  41156. /**
  41157. * An event triggered when a skeleton is removed
  41158. */
  41159. onSkeletonRemovedObservable: Observable<Skeleton>;
  41160. /**
  41161. * An event triggered when a material is created
  41162. */
  41163. onNewMaterialAddedObservable: Observable<Material>;
  41164. /**
  41165. * An event triggered when a material is removed
  41166. */
  41167. onMaterialRemovedObservable: Observable<Material>;
  41168. /**
  41169. * An event triggered when a texture is created
  41170. */
  41171. onNewTextureAddedObservable: Observable<BaseTexture>;
  41172. /**
  41173. * An event triggered when a texture is removed
  41174. */
  41175. onTextureRemovedObservable: Observable<BaseTexture>;
  41176. /**
  41177. * An event triggered when render targets are about to be rendered
  41178. * Can happen multiple times per frame.
  41179. */
  41180. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  41181. /**
  41182. * An event triggered when render targets were rendered.
  41183. * Can happen multiple times per frame.
  41184. */
  41185. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  41186. /**
  41187. * An event triggered before calculating deterministic simulation step
  41188. */
  41189. onBeforeStepObservable: Observable<Scene>;
  41190. /**
  41191. * An event triggered after calculating deterministic simulation step
  41192. */
  41193. onAfterStepObservable: Observable<Scene>;
  41194. /**
  41195. * An event triggered when the activeCamera property is updated
  41196. */
  41197. onActiveCameraChanged: Observable<Scene>;
  41198. /**
  41199. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  41200. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41201. * 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)
  41202. */
  41203. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41204. /**
  41205. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  41206. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41207. * 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)
  41208. */
  41209. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41210. /**
  41211. * This Observable will when a mesh has been imported into the scene.
  41212. */
  41213. onMeshImportedObservable: Observable<AbstractMesh>;
  41214. /**
  41215. * This Observable will when an animation file has been imported into the scene.
  41216. */
  41217. onAnimationFileImportedObservable: Observable<Scene>;
  41218. /**
  41219. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  41220. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  41221. */
  41222. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41223. /** @hidden */
  41224. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41225. /**
  41226. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41227. */
  41228. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41229. /**
  41230. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41231. */
  41232. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41233. /**
  41234. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41235. */
  41236. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41237. /** Callback called when a pointer move is detected */
  41238. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41239. /** Callback called when a pointer down is detected */
  41240. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41241. /** Callback called when a pointer up is detected */
  41242. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41243. /** Callback called when a pointer pick is detected */
  41244. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41245. /**
  41246. * 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).
  41247. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41248. */
  41249. onPrePointerObservable: Observable<PointerInfoPre>;
  41250. /**
  41251. * Observable event triggered each time an input event is received from the rendering canvas
  41252. */
  41253. onPointerObservable: Observable<PointerInfo>;
  41254. /**
  41255. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41256. */
  41257. get unTranslatedPointer(): Vector2;
  41258. /**
  41259. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41260. */
  41261. static get DragMovementThreshold(): number;
  41262. static set DragMovementThreshold(value: number);
  41263. /**
  41264. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41265. */
  41266. static get LongPressDelay(): number;
  41267. static set LongPressDelay(value: number);
  41268. /**
  41269. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41270. */
  41271. static get DoubleClickDelay(): number;
  41272. static set DoubleClickDelay(value: number);
  41273. /** If you need to check double click without raising a single click at first click, enable this flag */
  41274. static get ExclusiveDoubleClickMode(): boolean;
  41275. static set ExclusiveDoubleClickMode(value: boolean);
  41276. /** @hidden */
  41277. _mirroredCameraPosition: Nullable<Vector3>;
  41278. /**
  41279. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41280. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41281. */
  41282. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41283. /**
  41284. * Observable event triggered each time an keyboard event is received from the hosting window
  41285. */
  41286. onKeyboardObservable: Observable<KeyboardInfo>;
  41287. private _useRightHandedSystem;
  41288. /**
  41289. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41290. */
  41291. set useRightHandedSystem(value: boolean);
  41292. get useRightHandedSystem(): boolean;
  41293. private _timeAccumulator;
  41294. private _currentStepId;
  41295. private _currentInternalStep;
  41296. /**
  41297. * Sets the step Id used by deterministic lock step
  41298. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41299. * @param newStepId defines the step Id
  41300. */
  41301. setStepId(newStepId: number): void;
  41302. /**
  41303. * Gets the step Id used by deterministic lock step
  41304. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41305. * @returns the step Id
  41306. */
  41307. getStepId(): number;
  41308. /**
  41309. * Gets the internal step used by deterministic lock step
  41310. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41311. * @returns the internal step
  41312. */
  41313. getInternalStep(): number;
  41314. private _fogEnabled;
  41315. /**
  41316. * Gets or sets a boolean indicating if fog is enabled on this scene
  41317. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41318. * (Default is true)
  41319. */
  41320. set fogEnabled(value: boolean);
  41321. get fogEnabled(): boolean;
  41322. private _fogMode;
  41323. /**
  41324. * Gets or sets the fog mode to use
  41325. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41326. * | mode | value |
  41327. * | --- | --- |
  41328. * | FOGMODE_NONE | 0 |
  41329. * | FOGMODE_EXP | 1 |
  41330. * | FOGMODE_EXP2 | 2 |
  41331. * | FOGMODE_LINEAR | 3 |
  41332. */
  41333. set fogMode(value: number);
  41334. get fogMode(): number;
  41335. /**
  41336. * Gets or sets the fog color to use
  41337. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41338. * (Default is Color3(0.2, 0.2, 0.3))
  41339. */
  41340. fogColor: Color3;
  41341. /**
  41342. * Gets or sets the fog density to use
  41343. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41344. * (Default is 0.1)
  41345. */
  41346. fogDensity: number;
  41347. /**
  41348. * Gets or sets the fog start distance to use
  41349. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41350. * (Default is 0)
  41351. */
  41352. fogStart: number;
  41353. /**
  41354. * Gets or sets the fog end distance to use
  41355. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41356. * (Default is 1000)
  41357. */
  41358. fogEnd: number;
  41359. /**
  41360. * Flag indicating that the frame buffer binding is handled by another component
  41361. */
  41362. prePass: boolean;
  41363. private _shadowsEnabled;
  41364. /**
  41365. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41366. */
  41367. set shadowsEnabled(value: boolean);
  41368. get shadowsEnabled(): boolean;
  41369. private _lightsEnabled;
  41370. /**
  41371. * Gets or sets a boolean indicating if lights are enabled on this scene
  41372. */
  41373. set lightsEnabled(value: boolean);
  41374. get lightsEnabled(): boolean;
  41375. /** All of the active cameras added to this scene. */
  41376. activeCameras: Camera[];
  41377. /** @hidden */
  41378. _activeCamera: Nullable<Camera>;
  41379. /** Gets or sets the current active camera */
  41380. get activeCamera(): Nullable<Camera>;
  41381. set activeCamera(value: Nullable<Camera>);
  41382. private _defaultMaterial;
  41383. /** The default material used on meshes when no material is affected */
  41384. get defaultMaterial(): Material;
  41385. /** The default material used on meshes when no material is affected */
  41386. set defaultMaterial(value: Material);
  41387. private _texturesEnabled;
  41388. /**
  41389. * Gets or sets a boolean indicating if textures are enabled on this scene
  41390. */
  41391. set texturesEnabled(value: boolean);
  41392. get texturesEnabled(): boolean;
  41393. /**
  41394. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41395. */
  41396. physicsEnabled: boolean;
  41397. /**
  41398. * Gets or sets a boolean indicating if particles are enabled on this scene
  41399. */
  41400. particlesEnabled: boolean;
  41401. /**
  41402. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41403. */
  41404. spritesEnabled: boolean;
  41405. private _skeletonsEnabled;
  41406. /**
  41407. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41408. */
  41409. set skeletonsEnabled(value: boolean);
  41410. get skeletonsEnabled(): boolean;
  41411. /**
  41412. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41413. */
  41414. lensFlaresEnabled: boolean;
  41415. /**
  41416. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41417. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41418. */
  41419. collisionsEnabled: boolean;
  41420. private _collisionCoordinator;
  41421. /** @hidden */
  41422. get collisionCoordinator(): ICollisionCoordinator;
  41423. /**
  41424. * Defines the gravity applied to this scene (used only for collisions)
  41425. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41426. */
  41427. gravity: Vector3;
  41428. /**
  41429. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41430. */
  41431. postProcessesEnabled: boolean;
  41432. /**
  41433. * Gets the current postprocess manager
  41434. */
  41435. postProcessManager: PostProcessManager;
  41436. /**
  41437. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41438. */
  41439. renderTargetsEnabled: boolean;
  41440. /**
  41441. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41442. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41443. */
  41444. dumpNextRenderTargets: boolean;
  41445. /**
  41446. * The list of user defined render targets added to the scene
  41447. */
  41448. customRenderTargets: RenderTargetTexture[];
  41449. /**
  41450. * Defines if texture loading must be delayed
  41451. * If true, textures will only be loaded when they need to be rendered
  41452. */
  41453. useDelayedTextureLoading: boolean;
  41454. /**
  41455. * Gets the list of meshes imported to the scene through SceneLoader
  41456. */
  41457. importedMeshesFiles: String[];
  41458. /**
  41459. * Gets or sets a boolean indicating if probes are enabled on this scene
  41460. */
  41461. probesEnabled: boolean;
  41462. /**
  41463. * Gets or sets the current offline provider to use to store scene data
  41464. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41465. */
  41466. offlineProvider: IOfflineProvider;
  41467. /**
  41468. * Gets or sets the action manager associated with the scene
  41469. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41470. */
  41471. actionManager: AbstractActionManager;
  41472. private _meshesForIntersections;
  41473. /**
  41474. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41475. */
  41476. proceduralTexturesEnabled: boolean;
  41477. private _engine;
  41478. private _totalVertices;
  41479. /** @hidden */
  41480. _activeIndices: PerfCounter;
  41481. /** @hidden */
  41482. _activeParticles: PerfCounter;
  41483. /** @hidden */
  41484. _activeBones: PerfCounter;
  41485. private _animationRatio;
  41486. /** @hidden */
  41487. _animationTimeLast: number;
  41488. /** @hidden */
  41489. _animationTime: number;
  41490. /**
  41491. * Gets or sets a general scale for animation speed
  41492. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41493. */
  41494. animationTimeScale: number;
  41495. /** @hidden */
  41496. _cachedMaterial: Nullable<Material>;
  41497. /** @hidden */
  41498. _cachedEffect: Nullable<Effect>;
  41499. /** @hidden */
  41500. _cachedVisibility: Nullable<number>;
  41501. private _renderId;
  41502. private _frameId;
  41503. private _executeWhenReadyTimeoutId;
  41504. private _intermediateRendering;
  41505. private _viewUpdateFlag;
  41506. private _projectionUpdateFlag;
  41507. /** @hidden */
  41508. _toBeDisposed: Nullable<IDisposable>[];
  41509. private _activeRequests;
  41510. /** @hidden */
  41511. _pendingData: any[];
  41512. private _isDisposed;
  41513. /**
  41514. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41515. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41516. */
  41517. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41518. private _activeMeshes;
  41519. private _processedMaterials;
  41520. private _renderTargets;
  41521. /** @hidden */
  41522. _activeParticleSystems: SmartArray<IParticleSystem>;
  41523. private _activeSkeletons;
  41524. private _softwareSkinnedMeshes;
  41525. private _renderingManager;
  41526. /** @hidden */
  41527. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41528. private _transformMatrix;
  41529. private _sceneUbo;
  41530. /** @hidden */
  41531. _viewMatrix: Matrix;
  41532. private _projectionMatrix;
  41533. /** @hidden */
  41534. _forcedViewPosition: Nullable<Vector3>;
  41535. /** @hidden */
  41536. _frustumPlanes: Plane[];
  41537. /**
  41538. * Gets the list of frustum planes (built from the active camera)
  41539. */
  41540. get frustumPlanes(): Plane[];
  41541. /**
  41542. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41543. * This is useful if there are more lights that the maximum simulteanous authorized
  41544. */
  41545. requireLightSorting: boolean;
  41546. /** @hidden */
  41547. readonly useMaterialMeshMap: boolean;
  41548. /** @hidden */
  41549. readonly useClonedMeshMap: boolean;
  41550. private _externalData;
  41551. private _uid;
  41552. /**
  41553. * @hidden
  41554. * Backing store of defined scene components.
  41555. */
  41556. _components: ISceneComponent[];
  41557. /**
  41558. * @hidden
  41559. * Backing store of defined scene components.
  41560. */
  41561. _serializableComponents: ISceneSerializableComponent[];
  41562. /**
  41563. * List of components to register on the next registration step.
  41564. */
  41565. private _transientComponents;
  41566. /**
  41567. * Registers the transient components if needed.
  41568. */
  41569. private _registerTransientComponents;
  41570. /**
  41571. * @hidden
  41572. * Add a component to the scene.
  41573. * Note that the ccomponent could be registered on th next frame if this is called after
  41574. * the register component stage.
  41575. * @param component Defines the component to add to the scene
  41576. */
  41577. _addComponent(component: ISceneComponent): void;
  41578. /**
  41579. * @hidden
  41580. * Gets a component from the scene.
  41581. * @param name defines the name of the component to retrieve
  41582. * @returns the component or null if not present
  41583. */
  41584. _getComponent(name: string): Nullable<ISceneComponent>;
  41585. /**
  41586. * @hidden
  41587. * Defines the actions happening before camera updates.
  41588. */
  41589. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41590. /**
  41591. * @hidden
  41592. * Defines the actions happening before clear the canvas.
  41593. */
  41594. _beforeClearStage: Stage<SimpleStageAction>;
  41595. /**
  41596. * @hidden
  41597. * Defines the actions when collecting render targets for the frame.
  41598. */
  41599. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41600. /**
  41601. * @hidden
  41602. * Defines the actions happening for one camera in the frame.
  41603. */
  41604. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41605. /**
  41606. * @hidden
  41607. * Defines the actions happening during the per mesh ready checks.
  41608. */
  41609. _isReadyForMeshStage: Stage<MeshStageAction>;
  41610. /**
  41611. * @hidden
  41612. * Defines the actions happening before evaluate active mesh checks.
  41613. */
  41614. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41615. /**
  41616. * @hidden
  41617. * Defines the actions happening during the evaluate sub mesh checks.
  41618. */
  41619. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41620. /**
  41621. * @hidden
  41622. * Defines the actions happening during the active mesh stage.
  41623. */
  41624. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41625. /**
  41626. * @hidden
  41627. * Defines the actions happening during the per camera render target step.
  41628. */
  41629. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41630. /**
  41631. * @hidden
  41632. * Defines the actions happening just before the active camera is drawing.
  41633. */
  41634. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41635. /**
  41636. * @hidden
  41637. * Defines the actions happening just before a render target is drawing.
  41638. */
  41639. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41640. /**
  41641. * @hidden
  41642. * Defines the actions happening just before a rendering group is drawing.
  41643. */
  41644. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41645. /**
  41646. * @hidden
  41647. * Defines the actions happening just before a mesh is drawing.
  41648. */
  41649. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41650. /**
  41651. * @hidden
  41652. * Defines the actions happening just after a mesh has been drawn.
  41653. */
  41654. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41655. /**
  41656. * @hidden
  41657. * Defines the actions happening just after a rendering group has been drawn.
  41658. */
  41659. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41660. /**
  41661. * @hidden
  41662. * Defines the actions happening just after the active camera has been drawn.
  41663. */
  41664. _afterCameraDrawStage: Stage<CameraStageAction>;
  41665. /**
  41666. * @hidden
  41667. * Defines the actions happening just after a render target has been drawn.
  41668. */
  41669. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41670. /**
  41671. * @hidden
  41672. * Defines the actions happening just after rendering all cameras and computing intersections.
  41673. */
  41674. _afterRenderStage: Stage<SimpleStageAction>;
  41675. /**
  41676. * @hidden
  41677. * Defines the actions happening when a pointer move event happens.
  41678. */
  41679. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41680. /**
  41681. * @hidden
  41682. * Defines the actions happening when a pointer down event happens.
  41683. */
  41684. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41685. /**
  41686. * @hidden
  41687. * Defines the actions happening when a pointer up event happens.
  41688. */
  41689. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41690. /**
  41691. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41692. */
  41693. private geometriesByUniqueId;
  41694. /**
  41695. * Creates a new Scene
  41696. * @param engine defines the engine to use to render this scene
  41697. * @param options defines the scene options
  41698. */
  41699. constructor(engine: Engine, options?: SceneOptions);
  41700. /**
  41701. * Gets a string identifying the name of the class
  41702. * @returns "Scene" string
  41703. */
  41704. getClassName(): string;
  41705. private _defaultMeshCandidates;
  41706. /**
  41707. * @hidden
  41708. */
  41709. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41710. private _defaultSubMeshCandidates;
  41711. /**
  41712. * @hidden
  41713. */
  41714. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41715. /**
  41716. * Sets the default candidate providers for the scene.
  41717. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41718. * and getCollidingSubMeshCandidates to their default function
  41719. */
  41720. setDefaultCandidateProviders(): void;
  41721. /**
  41722. * Gets the mesh that is currently under the pointer
  41723. */
  41724. get meshUnderPointer(): Nullable<AbstractMesh>;
  41725. /**
  41726. * Gets or sets the current on-screen X position of the pointer
  41727. */
  41728. get pointerX(): number;
  41729. set pointerX(value: number);
  41730. /**
  41731. * Gets or sets the current on-screen Y position of the pointer
  41732. */
  41733. get pointerY(): number;
  41734. set pointerY(value: number);
  41735. /**
  41736. * Gets the cached material (ie. the latest rendered one)
  41737. * @returns the cached material
  41738. */
  41739. getCachedMaterial(): Nullable<Material>;
  41740. /**
  41741. * Gets the cached effect (ie. the latest rendered one)
  41742. * @returns the cached effect
  41743. */
  41744. getCachedEffect(): Nullable<Effect>;
  41745. /**
  41746. * Gets the cached visibility state (ie. the latest rendered one)
  41747. * @returns the cached visibility state
  41748. */
  41749. getCachedVisibility(): Nullable<number>;
  41750. /**
  41751. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41752. * @param material defines the current material
  41753. * @param effect defines the current effect
  41754. * @param visibility defines the current visibility state
  41755. * @returns true if one parameter is not cached
  41756. */
  41757. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41758. /**
  41759. * Gets the engine associated with the scene
  41760. * @returns an Engine
  41761. */
  41762. getEngine(): Engine;
  41763. /**
  41764. * Gets the total number of vertices rendered per frame
  41765. * @returns the total number of vertices rendered per frame
  41766. */
  41767. getTotalVertices(): number;
  41768. /**
  41769. * Gets the performance counter for total vertices
  41770. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41771. */
  41772. get totalVerticesPerfCounter(): PerfCounter;
  41773. /**
  41774. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41775. * @returns the total number of active indices rendered per frame
  41776. */
  41777. getActiveIndices(): number;
  41778. /**
  41779. * Gets the performance counter for active indices
  41780. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41781. */
  41782. get totalActiveIndicesPerfCounter(): PerfCounter;
  41783. /**
  41784. * Gets the total number of active particles rendered per frame
  41785. * @returns the total number of active particles rendered per frame
  41786. */
  41787. getActiveParticles(): number;
  41788. /**
  41789. * Gets the performance counter for active particles
  41790. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41791. */
  41792. get activeParticlesPerfCounter(): PerfCounter;
  41793. /**
  41794. * Gets the total number of active bones rendered per frame
  41795. * @returns the total number of active bones rendered per frame
  41796. */
  41797. getActiveBones(): number;
  41798. /**
  41799. * Gets the performance counter for active bones
  41800. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41801. */
  41802. get activeBonesPerfCounter(): PerfCounter;
  41803. /**
  41804. * Gets the array of active meshes
  41805. * @returns an array of AbstractMesh
  41806. */
  41807. getActiveMeshes(): SmartArray<AbstractMesh>;
  41808. /**
  41809. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41810. * @returns a number
  41811. */
  41812. getAnimationRatio(): number;
  41813. /**
  41814. * Gets an unique Id for the current render phase
  41815. * @returns a number
  41816. */
  41817. getRenderId(): number;
  41818. /**
  41819. * Gets an unique Id for the current frame
  41820. * @returns a number
  41821. */
  41822. getFrameId(): number;
  41823. /** Call this function if you want to manually increment the render Id*/
  41824. incrementRenderId(): void;
  41825. private _createUbo;
  41826. /**
  41827. * Use this method to simulate a pointer move on a mesh
  41828. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41829. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41830. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41831. * @returns the current scene
  41832. */
  41833. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41834. /**
  41835. * Use this method to simulate a pointer down on a mesh
  41836. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41837. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41838. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41839. * @returns the current scene
  41840. */
  41841. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41842. /**
  41843. * Use this method to simulate a pointer up on a mesh
  41844. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41845. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41846. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41847. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41848. * @returns the current scene
  41849. */
  41850. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41851. /**
  41852. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41853. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41854. * @returns true if the pointer was captured
  41855. */
  41856. isPointerCaptured(pointerId?: number): boolean;
  41857. /**
  41858. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41859. * @param attachUp defines if you want to attach events to pointerup
  41860. * @param attachDown defines if you want to attach events to pointerdown
  41861. * @param attachMove defines if you want to attach events to pointermove
  41862. */
  41863. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41864. /** Detaches all event handlers*/
  41865. detachControl(): void;
  41866. /**
  41867. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41868. * Delay loaded resources are not taking in account
  41869. * @return true if all required resources are ready
  41870. */
  41871. isReady(): boolean;
  41872. /** Resets all cached information relative to material (including effect and visibility) */
  41873. resetCachedMaterial(): void;
  41874. /**
  41875. * Registers a function to be called before every frame render
  41876. * @param func defines the function to register
  41877. */
  41878. registerBeforeRender(func: () => void): void;
  41879. /**
  41880. * Unregisters a function called before every frame render
  41881. * @param func defines the function to unregister
  41882. */
  41883. unregisterBeforeRender(func: () => void): void;
  41884. /**
  41885. * Registers a function to be called after every frame render
  41886. * @param func defines the function to register
  41887. */
  41888. registerAfterRender(func: () => void): void;
  41889. /**
  41890. * Unregisters a function called after every frame render
  41891. * @param func defines the function to unregister
  41892. */
  41893. unregisterAfterRender(func: () => void): void;
  41894. private _executeOnceBeforeRender;
  41895. /**
  41896. * The provided function will run before render once and will be disposed afterwards.
  41897. * A timeout delay can be provided so that the function will be executed in N ms.
  41898. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41899. * @param func The function to be executed.
  41900. * @param timeout optional delay in ms
  41901. */
  41902. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41903. /** @hidden */
  41904. _addPendingData(data: any): void;
  41905. /** @hidden */
  41906. _removePendingData(data: any): void;
  41907. /**
  41908. * Returns the number of items waiting to be loaded
  41909. * @returns the number of items waiting to be loaded
  41910. */
  41911. getWaitingItemsCount(): number;
  41912. /**
  41913. * Returns a boolean indicating if the scene is still loading data
  41914. */
  41915. get isLoading(): boolean;
  41916. /**
  41917. * Registers a function to be executed when the scene is ready
  41918. * @param {Function} func - the function to be executed
  41919. */
  41920. executeWhenReady(func: () => void): void;
  41921. /**
  41922. * Returns a promise that resolves when the scene is ready
  41923. * @returns A promise that resolves when the scene is ready
  41924. */
  41925. whenReadyAsync(): Promise<void>;
  41926. /** @hidden */
  41927. _checkIsReady(): void;
  41928. /**
  41929. * Gets all animatable attached to the scene
  41930. */
  41931. get animatables(): Animatable[];
  41932. /**
  41933. * Resets the last animation time frame.
  41934. * Useful to override when animations start running when loading a scene for the first time.
  41935. */
  41936. resetLastAnimationTimeFrame(): void;
  41937. /**
  41938. * Gets the current view matrix
  41939. * @returns a Matrix
  41940. */
  41941. getViewMatrix(): Matrix;
  41942. /**
  41943. * Gets the current projection matrix
  41944. * @returns a Matrix
  41945. */
  41946. getProjectionMatrix(): Matrix;
  41947. /**
  41948. * Gets the current transform matrix
  41949. * @returns a Matrix made of View * Projection
  41950. */
  41951. getTransformMatrix(): Matrix;
  41952. /**
  41953. * Sets the current transform matrix
  41954. * @param viewL defines the View matrix to use
  41955. * @param projectionL defines the Projection matrix to use
  41956. * @param viewR defines the right View matrix to use (if provided)
  41957. * @param projectionR defines the right Projection matrix to use (if provided)
  41958. */
  41959. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41960. /**
  41961. * Gets the uniform buffer used to store scene data
  41962. * @returns a UniformBuffer
  41963. */
  41964. getSceneUniformBuffer(): UniformBuffer;
  41965. /**
  41966. * Gets an unique (relatively to the current scene) Id
  41967. * @returns an unique number for the scene
  41968. */
  41969. getUniqueId(): number;
  41970. /**
  41971. * Add a mesh to the list of scene's meshes
  41972. * @param newMesh defines the mesh to add
  41973. * @param recursive if all child meshes should also be added to the scene
  41974. */
  41975. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41976. /**
  41977. * Remove a mesh for the list of scene's meshes
  41978. * @param toRemove defines the mesh to remove
  41979. * @param recursive if all child meshes should also be removed from the scene
  41980. * @returns the index where the mesh was in the mesh list
  41981. */
  41982. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41983. /**
  41984. * Add a transform node to the list of scene's transform nodes
  41985. * @param newTransformNode defines the transform node to add
  41986. */
  41987. addTransformNode(newTransformNode: TransformNode): void;
  41988. /**
  41989. * Remove a transform node for the list of scene's transform nodes
  41990. * @param toRemove defines the transform node to remove
  41991. * @returns the index where the transform node was in the transform node list
  41992. */
  41993. removeTransformNode(toRemove: TransformNode): number;
  41994. /**
  41995. * Remove a skeleton for the list of scene's skeletons
  41996. * @param toRemove defines the skeleton to remove
  41997. * @returns the index where the skeleton was in the skeleton list
  41998. */
  41999. removeSkeleton(toRemove: Skeleton): number;
  42000. /**
  42001. * Remove a morph target for the list of scene's morph targets
  42002. * @param toRemove defines the morph target to remove
  42003. * @returns the index where the morph target was in the morph target list
  42004. */
  42005. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  42006. /**
  42007. * Remove a light for the list of scene's lights
  42008. * @param toRemove defines the light to remove
  42009. * @returns the index where the light was in the light list
  42010. */
  42011. removeLight(toRemove: Light): number;
  42012. /**
  42013. * Remove a camera for the list of scene's cameras
  42014. * @param toRemove defines the camera to remove
  42015. * @returns the index where the camera was in the camera list
  42016. */
  42017. removeCamera(toRemove: Camera): number;
  42018. /**
  42019. * Remove a particle system for the list of scene's particle systems
  42020. * @param toRemove defines the particle system to remove
  42021. * @returns the index where the particle system was in the particle system list
  42022. */
  42023. removeParticleSystem(toRemove: IParticleSystem): number;
  42024. /**
  42025. * Remove a animation for the list of scene's animations
  42026. * @param toRemove defines the animation to remove
  42027. * @returns the index where the animation was in the animation list
  42028. */
  42029. removeAnimation(toRemove: Animation): number;
  42030. /**
  42031. * Will stop the animation of the given target
  42032. * @param target - the target
  42033. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  42034. * @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)
  42035. */
  42036. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  42037. /**
  42038. * Removes the given animation group from this scene.
  42039. * @param toRemove The animation group to remove
  42040. * @returns The index of the removed animation group
  42041. */
  42042. removeAnimationGroup(toRemove: AnimationGroup): number;
  42043. /**
  42044. * Removes the given multi-material from this scene.
  42045. * @param toRemove The multi-material to remove
  42046. * @returns The index of the removed multi-material
  42047. */
  42048. removeMultiMaterial(toRemove: MultiMaterial): number;
  42049. /**
  42050. * Removes the given material from this scene.
  42051. * @param toRemove The material to remove
  42052. * @returns The index of the removed material
  42053. */
  42054. removeMaterial(toRemove: Material): number;
  42055. /**
  42056. * Removes the given action manager from this scene.
  42057. * @param toRemove The action manager to remove
  42058. * @returns The index of the removed action manager
  42059. */
  42060. removeActionManager(toRemove: AbstractActionManager): number;
  42061. /**
  42062. * Removes the given texture from this scene.
  42063. * @param toRemove The texture to remove
  42064. * @returns The index of the removed texture
  42065. */
  42066. removeTexture(toRemove: BaseTexture): number;
  42067. /**
  42068. * Adds the given light to this scene
  42069. * @param newLight The light to add
  42070. */
  42071. addLight(newLight: Light): void;
  42072. /**
  42073. * Sorts the list list based on light priorities
  42074. */
  42075. sortLightsByPriority(): void;
  42076. /**
  42077. * Adds the given camera to this scene
  42078. * @param newCamera The camera to add
  42079. */
  42080. addCamera(newCamera: Camera): void;
  42081. /**
  42082. * Adds the given skeleton to this scene
  42083. * @param newSkeleton The skeleton to add
  42084. */
  42085. addSkeleton(newSkeleton: Skeleton): void;
  42086. /**
  42087. * Adds the given particle system to this scene
  42088. * @param newParticleSystem The particle system to add
  42089. */
  42090. addParticleSystem(newParticleSystem: IParticleSystem): void;
  42091. /**
  42092. * Adds the given animation to this scene
  42093. * @param newAnimation The animation to add
  42094. */
  42095. addAnimation(newAnimation: Animation): void;
  42096. /**
  42097. * Adds the given animation group to this scene.
  42098. * @param newAnimationGroup The animation group to add
  42099. */
  42100. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  42101. /**
  42102. * Adds the given multi-material to this scene
  42103. * @param newMultiMaterial The multi-material to add
  42104. */
  42105. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  42106. /**
  42107. * Adds the given material to this scene
  42108. * @param newMaterial The material to add
  42109. */
  42110. addMaterial(newMaterial: Material): void;
  42111. /**
  42112. * Adds the given morph target to this scene
  42113. * @param newMorphTargetManager The morph target to add
  42114. */
  42115. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  42116. /**
  42117. * Adds the given geometry to this scene
  42118. * @param newGeometry The geometry to add
  42119. */
  42120. addGeometry(newGeometry: Geometry): void;
  42121. /**
  42122. * Adds the given action manager to this scene
  42123. * @param newActionManager The action manager to add
  42124. */
  42125. addActionManager(newActionManager: AbstractActionManager): void;
  42126. /**
  42127. * Adds the given texture to this scene.
  42128. * @param newTexture The texture to add
  42129. */
  42130. addTexture(newTexture: BaseTexture): void;
  42131. /**
  42132. * Switch active camera
  42133. * @param newCamera defines the new active camera
  42134. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  42135. */
  42136. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  42137. /**
  42138. * sets the active camera of the scene using its ID
  42139. * @param id defines the camera's ID
  42140. * @return the new active camera or null if none found.
  42141. */
  42142. setActiveCameraByID(id: string): Nullable<Camera>;
  42143. /**
  42144. * sets the active camera of the scene using its name
  42145. * @param name defines the camera's name
  42146. * @returns the new active camera or null if none found.
  42147. */
  42148. setActiveCameraByName(name: string): Nullable<Camera>;
  42149. /**
  42150. * get an animation group using its name
  42151. * @param name defines the material's name
  42152. * @return the animation group or null if none found.
  42153. */
  42154. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  42155. /**
  42156. * Get a material using its unique id
  42157. * @param uniqueId defines the material's unique id
  42158. * @return the material or null if none found.
  42159. */
  42160. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  42161. /**
  42162. * get a material using its id
  42163. * @param id defines the material's ID
  42164. * @return the material or null if none found.
  42165. */
  42166. getMaterialByID(id: string): Nullable<Material>;
  42167. /**
  42168. * Gets a the last added material using a given id
  42169. * @param id defines the material's ID
  42170. * @return the last material with the given id or null if none found.
  42171. */
  42172. getLastMaterialByID(id: string): Nullable<Material>;
  42173. /**
  42174. * Gets a material using its name
  42175. * @param name defines the material's name
  42176. * @return the material or null if none found.
  42177. */
  42178. getMaterialByName(name: string): Nullable<Material>;
  42179. /**
  42180. * Get a texture using its unique id
  42181. * @param uniqueId defines the texture's unique id
  42182. * @return the texture or null if none found.
  42183. */
  42184. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  42185. /**
  42186. * Gets a camera using its id
  42187. * @param id defines the id to look for
  42188. * @returns the camera or null if not found
  42189. */
  42190. getCameraByID(id: string): Nullable<Camera>;
  42191. /**
  42192. * Gets a camera using its unique id
  42193. * @param uniqueId defines the unique id to look for
  42194. * @returns the camera or null if not found
  42195. */
  42196. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  42197. /**
  42198. * Gets a camera using its name
  42199. * @param name defines the camera's name
  42200. * @return the camera or null if none found.
  42201. */
  42202. getCameraByName(name: string): Nullable<Camera>;
  42203. /**
  42204. * Gets a bone using its id
  42205. * @param id defines the bone's id
  42206. * @return the bone or null if not found
  42207. */
  42208. getBoneByID(id: string): Nullable<Bone>;
  42209. /**
  42210. * Gets a bone using its id
  42211. * @param name defines the bone's name
  42212. * @return the bone or null if not found
  42213. */
  42214. getBoneByName(name: string): Nullable<Bone>;
  42215. /**
  42216. * Gets a light node using its name
  42217. * @param name defines the the light's name
  42218. * @return the light or null if none found.
  42219. */
  42220. getLightByName(name: string): Nullable<Light>;
  42221. /**
  42222. * Gets a light node using its id
  42223. * @param id defines the light's id
  42224. * @return the light or null if none found.
  42225. */
  42226. getLightByID(id: string): Nullable<Light>;
  42227. /**
  42228. * Gets a light node using its scene-generated unique ID
  42229. * @param uniqueId defines the light's unique id
  42230. * @return the light or null if none found.
  42231. */
  42232. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42233. /**
  42234. * Gets a particle system by id
  42235. * @param id defines the particle system id
  42236. * @return the corresponding system or null if none found
  42237. */
  42238. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42239. /**
  42240. * Gets a geometry using its ID
  42241. * @param id defines the geometry's id
  42242. * @return the geometry or null if none found.
  42243. */
  42244. getGeometryByID(id: string): Nullable<Geometry>;
  42245. private _getGeometryByUniqueID;
  42246. /**
  42247. * Add a new geometry to this scene
  42248. * @param geometry defines the geometry to be added to the scene.
  42249. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42250. * @return a boolean defining if the geometry was added or not
  42251. */
  42252. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42253. /**
  42254. * Removes an existing geometry
  42255. * @param geometry defines the geometry to be removed from the scene
  42256. * @return a boolean defining if the geometry was removed or not
  42257. */
  42258. removeGeometry(geometry: Geometry): boolean;
  42259. /**
  42260. * Gets the list of geometries attached to the scene
  42261. * @returns an array of Geometry
  42262. */
  42263. getGeometries(): Geometry[];
  42264. /**
  42265. * Gets the first added mesh found of a given ID
  42266. * @param id defines the id to search for
  42267. * @return the mesh found or null if not found at all
  42268. */
  42269. getMeshByID(id: string): Nullable<AbstractMesh>;
  42270. /**
  42271. * Gets a list of meshes using their id
  42272. * @param id defines the id to search for
  42273. * @returns a list of meshes
  42274. */
  42275. getMeshesByID(id: string): Array<AbstractMesh>;
  42276. /**
  42277. * Gets the first added transform node found of a given ID
  42278. * @param id defines the id to search for
  42279. * @return the found transform node or null if not found at all.
  42280. */
  42281. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42282. /**
  42283. * Gets a transform node with its auto-generated unique id
  42284. * @param uniqueId efines the unique id to search for
  42285. * @return the found transform node or null if not found at all.
  42286. */
  42287. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42288. /**
  42289. * Gets a list of transform nodes using their id
  42290. * @param id defines the id to search for
  42291. * @returns a list of transform nodes
  42292. */
  42293. getTransformNodesByID(id: string): Array<TransformNode>;
  42294. /**
  42295. * Gets a mesh with its auto-generated unique id
  42296. * @param uniqueId defines the unique id to search for
  42297. * @return the found mesh or null if not found at all.
  42298. */
  42299. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42300. /**
  42301. * Gets a the last added mesh using a given id
  42302. * @param id defines the id to search for
  42303. * @return the found mesh or null if not found at all.
  42304. */
  42305. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42306. /**
  42307. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42308. * @param id defines the id to search for
  42309. * @return the found node or null if not found at all
  42310. */
  42311. getLastEntryByID(id: string): Nullable<Node>;
  42312. /**
  42313. * Gets a node (Mesh, Camera, Light) using a given id
  42314. * @param id defines the id to search for
  42315. * @return the found node or null if not found at all
  42316. */
  42317. getNodeByID(id: string): Nullable<Node>;
  42318. /**
  42319. * Gets a node (Mesh, Camera, Light) using a given name
  42320. * @param name defines the name to search for
  42321. * @return the found node or null if not found at all.
  42322. */
  42323. getNodeByName(name: string): Nullable<Node>;
  42324. /**
  42325. * Gets a mesh using a given name
  42326. * @param name defines the name to search for
  42327. * @return the found mesh or null if not found at all.
  42328. */
  42329. getMeshByName(name: string): Nullable<AbstractMesh>;
  42330. /**
  42331. * Gets a transform node using a given name
  42332. * @param name defines the name to search for
  42333. * @return the found transform node or null if not found at all.
  42334. */
  42335. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42336. /**
  42337. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42338. * @param id defines the id to search for
  42339. * @return the found skeleton or null if not found at all.
  42340. */
  42341. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42342. /**
  42343. * Gets a skeleton using a given auto generated unique id
  42344. * @param uniqueId defines the unique id to search for
  42345. * @return the found skeleton or null if not found at all.
  42346. */
  42347. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42348. /**
  42349. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42350. * @param id defines the id to search for
  42351. * @return the found skeleton or null if not found at all.
  42352. */
  42353. getSkeletonById(id: string): Nullable<Skeleton>;
  42354. /**
  42355. * Gets a skeleton using a given name
  42356. * @param name defines the name to search for
  42357. * @return the found skeleton or null if not found at all.
  42358. */
  42359. getSkeletonByName(name: string): Nullable<Skeleton>;
  42360. /**
  42361. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42362. * @param id defines the id to search for
  42363. * @return the found morph target manager or null if not found at all.
  42364. */
  42365. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42366. /**
  42367. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42368. * @param id defines the id to search for
  42369. * @return the found morph target or null if not found at all.
  42370. */
  42371. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42372. /**
  42373. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42374. * @param name defines the name to search for
  42375. * @return the found morph target or null if not found at all.
  42376. */
  42377. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42378. /**
  42379. * Gets a post process using a given name (if many are found, this function will pick the first one)
  42380. * @param name defines the name to search for
  42381. * @return the found post process or null if not found at all.
  42382. */
  42383. getPostProcessByName(name: string): Nullable<PostProcess>;
  42384. /**
  42385. * Gets a boolean indicating if the given mesh is active
  42386. * @param mesh defines the mesh to look for
  42387. * @returns true if the mesh is in the active list
  42388. */
  42389. isActiveMesh(mesh: AbstractMesh): boolean;
  42390. /**
  42391. * Return a unique id as a string which can serve as an identifier for the scene
  42392. */
  42393. get uid(): string;
  42394. /**
  42395. * Add an externaly attached data from its key.
  42396. * This method call will fail and return false, if such key already exists.
  42397. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42398. * @param key the unique key that identifies the data
  42399. * @param data the data object to associate to the key for this Engine instance
  42400. * @return true if no such key were already present and the data was added successfully, false otherwise
  42401. */
  42402. addExternalData<T>(key: string, data: T): boolean;
  42403. /**
  42404. * Get an externaly attached data from its key
  42405. * @param key the unique key that identifies the data
  42406. * @return the associated data, if present (can be null), or undefined if not present
  42407. */
  42408. getExternalData<T>(key: string): Nullable<T>;
  42409. /**
  42410. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42411. * @param key the unique key that identifies the data
  42412. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42413. * @return the associated data, can be null if the factory returned null.
  42414. */
  42415. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42416. /**
  42417. * Remove an externaly attached data from the Engine instance
  42418. * @param key the unique key that identifies the data
  42419. * @return true if the data was successfully removed, false if it doesn't exist
  42420. */
  42421. removeExternalData(key: string): boolean;
  42422. private _evaluateSubMesh;
  42423. /**
  42424. * Clear the processed materials smart array preventing retention point in material dispose.
  42425. */
  42426. freeProcessedMaterials(): void;
  42427. private _preventFreeActiveMeshesAndRenderingGroups;
  42428. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42429. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42430. * when disposing several meshes in a row or a hierarchy of meshes.
  42431. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42432. */
  42433. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42434. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42435. /**
  42436. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42437. */
  42438. freeActiveMeshes(): void;
  42439. /**
  42440. * Clear the info related to rendering groups preventing retention points during dispose.
  42441. */
  42442. freeRenderingGroups(): void;
  42443. /** @hidden */
  42444. _isInIntermediateRendering(): boolean;
  42445. /**
  42446. * Lambda returning the list of potentially active meshes.
  42447. */
  42448. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42449. /**
  42450. * Lambda returning the list of potentially active sub meshes.
  42451. */
  42452. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42453. /**
  42454. * Lambda returning the list of potentially intersecting sub meshes.
  42455. */
  42456. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42457. /**
  42458. * Lambda returning the list of potentially colliding sub meshes.
  42459. */
  42460. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42461. private _activeMeshesFrozen;
  42462. private _skipEvaluateActiveMeshesCompletely;
  42463. /**
  42464. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42465. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42466. * @returns the current scene
  42467. */
  42468. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42469. /**
  42470. * Use this function to restart evaluating active meshes on every frame
  42471. * @returns the current scene
  42472. */
  42473. unfreezeActiveMeshes(): Scene;
  42474. private _evaluateActiveMeshes;
  42475. private _activeMesh;
  42476. /**
  42477. * Update the transform matrix to update from the current active camera
  42478. * @param force defines a boolean used to force the update even if cache is up to date
  42479. */
  42480. updateTransformMatrix(force?: boolean): void;
  42481. private _bindFrameBuffer;
  42482. /** @hidden */
  42483. _allowPostProcessClearColor: boolean;
  42484. /** @hidden */
  42485. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42486. private _processSubCameras;
  42487. private _checkIntersections;
  42488. /** @hidden */
  42489. _advancePhysicsEngineStep(step: number): void;
  42490. /**
  42491. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42492. */
  42493. getDeterministicFrameTime: () => number;
  42494. /** @hidden */
  42495. _animate(): void;
  42496. /** Execute all animations (for a frame) */
  42497. animate(): void;
  42498. /**
  42499. * Render the scene
  42500. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42501. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42502. */
  42503. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42504. /**
  42505. * Freeze all materials
  42506. * A frozen material will not be updatable but should be faster to render
  42507. */
  42508. freezeMaterials(): void;
  42509. /**
  42510. * Unfreeze all materials
  42511. * A frozen material will not be updatable but should be faster to render
  42512. */
  42513. unfreezeMaterials(): void;
  42514. /**
  42515. * Releases all held ressources
  42516. */
  42517. dispose(): void;
  42518. /**
  42519. * Gets if the scene is already disposed
  42520. */
  42521. get isDisposed(): boolean;
  42522. /**
  42523. * Call this function to reduce memory footprint of the scene.
  42524. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42525. */
  42526. clearCachedVertexData(): void;
  42527. /**
  42528. * This function will remove the local cached buffer data from texture.
  42529. * It will save memory but will prevent the texture from being rebuilt
  42530. */
  42531. cleanCachedTextureBuffer(): void;
  42532. /**
  42533. * Get the world extend vectors with an optional filter
  42534. *
  42535. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42536. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42537. */
  42538. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42539. min: Vector3;
  42540. max: Vector3;
  42541. };
  42542. /**
  42543. * Creates a ray that can be used to pick in the scene
  42544. * @param x defines the x coordinate of the origin (on-screen)
  42545. * @param y defines the y coordinate of the origin (on-screen)
  42546. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42547. * @param camera defines the camera to use for the picking
  42548. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42549. * @returns a Ray
  42550. */
  42551. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42552. /**
  42553. * Creates a ray that can be used to pick in the scene
  42554. * @param x defines the x coordinate of the origin (on-screen)
  42555. * @param y defines the y coordinate of the origin (on-screen)
  42556. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42557. * @param result defines the ray where to store the picking ray
  42558. * @param camera defines the camera to use for the picking
  42559. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42560. * @returns the current scene
  42561. */
  42562. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42563. /**
  42564. * Creates a ray that can be used to pick in the scene
  42565. * @param x defines the x coordinate of the origin (on-screen)
  42566. * @param y defines the y coordinate of the origin (on-screen)
  42567. * @param camera defines the camera to use for the picking
  42568. * @returns a Ray
  42569. */
  42570. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42571. /**
  42572. * Creates a ray that can be used to pick in the scene
  42573. * @param x defines the x coordinate of the origin (on-screen)
  42574. * @param y defines the y coordinate of the origin (on-screen)
  42575. * @param result defines the ray where to store the picking ray
  42576. * @param camera defines the camera to use for the picking
  42577. * @returns the current scene
  42578. */
  42579. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42580. /** Launch a ray to try to pick a mesh in the scene
  42581. * @param x position on screen
  42582. * @param y position on screen
  42583. * @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
  42584. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42585. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42586. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42587. * @returns a PickingInfo
  42588. */
  42589. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42590. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42591. * @param x position on screen
  42592. * @param y position on screen
  42593. * @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
  42594. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42595. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42596. * @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)
  42597. */
  42598. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42599. /** Use the given ray to pick a mesh in the scene
  42600. * @param ray The ray to use to pick meshes
  42601. * @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
  42602. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42603. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42604. * @returns a PickingInfo
  42605. */
  42606. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42607. /**
  42608. * Launch a ray to try to pick a mesh in the scene
  42609. * @param x X position on screen
  42610. * @param y Y position on screen
  42611. * @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
  42612. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42613. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42614. * @returns an array of PickingInfo
  42615. */
  42616. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42617. /**
  42618. * Launch a ray to try to pick a mesh in the scene
  42619. * @param ray Ray to use
  42620. * @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
  42621. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42622. * @returns an array of PickingInfo
  42623. */
  42624. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42625. /**
  42626. * Force the value of meshUnderPointer
  42627. * @param mesh defines the mesh to use
  42628. * @param pointerId optional pointer id when using more than one pointer
  42629. */
  42630. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42631. /**
  42632. * Gets the mesh under the pointer
  42633. * @returns a Mesh or null if no mesh is under the pointer
  42634. */
  42635. getPointerOverMesh(): Nullable<AbstractMesh>;
  42636. /** @hidden */
  42637. _rebuildGeometries(): void;
  42638. /** @hidden */
  42639. _rebuildTextures(): void;
  42640. private _getByTags;
  42641. /**
  42642. * Get a list of meshes by tags
  42643. * @param tagsQuery defines the tags query to use
  42644. * @param forEach defines a predicate used to filter results
  42645. * @returns an array of Mesh
  42646. */
  42647. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42648. /**
  42649. * Get a list of cameras by tags
  42650. * @param tagsQuery defines the tags query to use
  42651. * @param forEach defines a predicate used to filter results
  42652. * @returns an array of Camera
  42653. */
  42654. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42655. /**
  42656. * Get a list of lights by tags
  42657. * @param tagsQuery defines the tags query to use
  42658. * @param forEach defines a predicate used to filter results
  42659. * @returns an array of Light
  42660. */
  42661. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42662. /**
  42663. * Get a list of materials by tags
  42664. * @param tagsQuery defines the tags query to use
  42665. * @param forEach defines a predicate used to filter results
  42666. * @returns an array of Material
  42667. */
  42668. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42669. /**
  42670. * Get a list of transform nodes by tags
  42671. * @param tagsQuery defines the tags query to use
  42672. * @param forEach defines a predicate used to filter results
  42673. * @returns an array of TransformNode
  42674. */
  42675. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  42676. /**
  42677. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42678. * This allowed control for front to back rendering or reversly depending of the special needs.
  42679. *
  42680. * @param renderingGroupId The rendering group id corresponding to its index
  42681. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42682. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42683. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42684. */
  42685. 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;
  42686. /**
  42687. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42688. *
  42689. * @param renderingGroupId The rendering group id corresponding to its index
  42690. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42691. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42692. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42693. */
  42694. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42695. /**
  42696. * Gets the current auto clear configuration for one rendering group of the rendering
  42697. * manager.
  42698. * @param index the rendering group index to get the information for
  42699. * @returns The auto clear setup for the requested rendering group
  42700. */
  42701. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42702. private _blockMaterialDirtyMechanism;
  42703. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42704. get blockMaterialDirtyMechanism(): boolean;
  42705. set blockMaterialDirtyMechanism(value: boolean);
  42706. /**
  42707. * Will flag all materials as dirty to trigger new shader compilation
  42708. * @param flag defines the flag used to specify which material part must be marked as dirty
  42709. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42710. */
  42711. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42712. /** @hidden */
  42713. _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;
  42714. /** @hidden */
  42715. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42716. /** @hidden */
  42717. _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;
  42718. /** @hidden */
  42719. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42720. /** @hidden */
  42721. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42722. /** @hidden */
  42723. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42724. }
  42725. }
  42726. declare module "babylonjs/assetContainer" {
  42727. import { AbstractScene } from "babylonjs/abstractScene";
  42728. import { Scene } from "babylonjs/scene";
  42729. import { Mesh } from "babylonjs/Meshes/mesh";
  42730. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42731. import { Skeleton } from "babylonjs/Bones/skeleton";
  42732. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42733. import { Animatable } from "babylonjs/Animations/animatable";
  42734. import { Nullable } from "babylonjs/types";
  42735. import { Node } from "babylonjs/node";
  42736. /**
  42737. * Set of assets to keep when moving a scene into an asset container.
  42738. */
  42739. export class KeepAssets extends AbstractScene {
  42740. }
  42741. /**
  42742. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42743. */
  42744. export class InstantiatedEntries {
  42745. /**
  42746. * List of new root nodes (eg. nodes with no parent)
  42747. */
  42748. rootNodes: TransformNode[];
  42749. /**
  42750. * List of new skeletons
  42751. */
  42752. skeletons: Skeleton[];
  42753. /**
  42754. * List of new animation groups
  42755. */
  42756. animationGroups: AnimationGroup[];
  42757. }
  42758. /**
  42759. * Container with a set of assets that can be added or removed from a scene.
  42760. */
  42761. export class AssetContainer extends AbstractScene {
  42762. private _wasAddedToScene;
  42763. /**
  42764. * The scene the AssetContainer belongs to.
  42765. */
  42766. scene: Scene;
  42767. /**
  42768. * Instantiates an AssetContainer.
  42769. * @param scene The scene the AssetContainer belongs to.
  42770. */
  42771. constructor(scene: Scene);
  42772. /**
  42773. * Instantiate or clone all meshes and add the new ones to the scene.
  42774. * Skeletons and animation groups will all be cloned
  42775. * @param nameFunction defines an optional function used to get new names for clones
  42776. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42777. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42778. */
  42779. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42780. /**
  42781. * Adds all the assets from the container to the scene.
  42782. */
  42783. addAllToScene(): void;
  42784. /**
  42785. * Removes all the assets in the container from the scene
  42786. */
  42787. removeAllFromScene(): void;
  42788. /**
  42789. * Disposes all the assets in the container
  42790. */
  42791. dispose(): void;
  42792. private _moveAssets;
  42793. /**
  42794. * Removes all the assets contained in the scene and adds them to the container.
  42795. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42796. */
  42797. moveAllFromScene(keepAssets?: KeepAssets): void;
  42798. /**
  42799. * 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.
  42800. * @returns the root mesh
  42801. */
  42802. createRootMesh(): Mesh;
  42803. /**
  42804. * Merge animations (direct and animation groups) from this asset container into a scene
  42805. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42806. * @param animatables set of animatables to retarget to a node from the scene
  42807. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42808. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42809. */
  42810. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42811. }
  42812. }
  42813. declare module "babylonjs/abstractScene" {
  42814. import { Scene } from "babylonjs/scene";
  42815. import { Nullable } from "babylonjs/types";
  42816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42817. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42818. import { Geometry } from "babylonjs/Meshes/geometry";
  42819. import { Skeleton } from "babylonjs/Bones/skeleton";
  42820. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42821. import { AssetContainer } from "babylonjs/assetContainer";
  42822. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42823. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42824. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42825. import { Material } from "babylonjs/Materials/material";
  42826. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42827. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42828. import { Camera } from "babylonjs/Cameras/camera";
  42829. import { Light } from "babylonjs/Lights/light";
  42830. import { Node } from "babylonjs/node";
  42831. import { Animation } from "babylonjs/Animations/animation";
  42832. /**
  42833. * Defines how the parser contract is defined.
  42834. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42835. */
  42836. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42837. /**
  42838. * Defines how the individual parser contract is defined.
  42839. * These parser can parse an individual asset
  42840. */
  42841. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42842. /**
  42843. * Base class of the scene acting as a container for the different elements composing a scene.
  42844. * This class is dynamically extended by the different components of the scene increasing
  42845. * flexibility and reducing coupling
  42846. */
  42847. export abstract class AbstractScene {
  42848. /**
  42849. * Stores the list of available parsers in the application.
  42850. */
  42851. private static _BabylonFileParsers;
  42852. /**
  42853. * Stores the list of available individual parsers in the application.
  42854. */
  42855. private static _IndividualBabylonFileParsers;
  42856. /**
  42857. * Adds a parser in the list of available ones
  42858. * @param name Defines the name of the parser
  42859. * @param parser Defines the parser to add
  42860. */
  42861. static AddParser(name: string, parser: BabylonFileParser): void;
  42862. /**
  42863. * Gets a general parser from the list of avaialble ones
  42864. * @param name Defines the name of the parser
  42865. * @returns the requested parser or null
  42866. */
  42867. static GetParser(name: string): Nullable<BabylonFileParser>;
  42868. /**
  42869. * Adds n individual parser in the list of available ones
  42870. * @param name Defines the name of the parser
  42871. * @param parser Defines the parser to add
  42872. */
  42873. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42874. /**
  42875. * Gets an individual parser from the list of avaialble ones
  42876. * @param name Defines the name of the parser
  42877. * @returns the requested parser or null
  42878. */
  42879. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42880. /**
  42881. * Parser json data and populate both a scene and its associated container object
  42882. * @param jsonData Defines the data to parse
  42883. * @param scene Defines the scene to parse the data for
  42884. * @param container Defines the container attached to the parsing sequence
  42885. * @param rootUrl Defines the root url of the data
  42886. */
  42887. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42888. /**
  42889. * Gets the list of root nodes (ie. nodes with no parent)
  42890. */
  42891. rootNodes: Node[];
  42892. /** All of the cameras added to this scene
  42893. * @see https://doc.babylonjs.com/babylon101/cameras
  42894. */
  42895. cameras: Camera[];
  42896. /**
  42897. * All of the lights added to this scene
  42898. * @see https://doc.babylonjs.com/babylon101/lights
  42899. */
  42900. lights: Light[];
  42901. /**
  42902. * All of the (abstract) meshes added to this scene
  42903. */
  42904. meshes: AbstractMesh[];
  42905. /**
  42906. * The list of skeletons added to the scene
  42907. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42908. */
  42909. skeletons: Skeleton[];
  42910. /**
  42911. * All of the particle systems added to this scene
  42912. * @see https://doc.babylonjs.com/babylon101/particles
  42913. */
  42914. particleSystems: IParticleSystem[];
  42915. /**
  42916. * Gets a list of Animations associated with the scene
  42917. */
  42918. animations: Animation[];
  42919. /**
  42920. * All of the animation groups added to this scene
  42921. * @see https://doc.babylonjs.com/how_to/group
  42922. */
  42923. animationGroups: AnimationGroup[];
  42924. /**
  42925. * All of the multi-materials added to this scene
  42926. * @see https://doc.babylonjs.com/how_to/multi_materials
  42927. */
  42928. multiMaterials: MultiMaterial[];
  42929. /**
  42930. * All of the materials added to this scene
  42931. * In the context of a Scene, it is not supposed to be modified manually.
  42932. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42933. * Note also that the order of the Material within the array is not significant and might change.
  42934. * @see https://doc.babylonjs.com/babylon101/materials
  42935. */
  42936. materials: Material[];
  42937. /**
  42938. * The list of morph target managers added to the scene
  42939. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42940. */
  42941. morphTargetManagers: MorphTargetManager[];
  42942. /**
  42943. * The list of geometries used in the scene.
  42944. */
  42945. geometries: Geometry[];
  42946. /**
  42947. * All of the tranform nodes added to this scene
  42948. * In the context of a Scene, it is not supposed to be modified manually.
  42949. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42950. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42951. * @see https://doc.babylonjs.com/how_to/transformnode
  42952. */
  42953. transformNodes: TransformNode[];
  42954. /**
  42955. * ActionManagers available on the scene.
  42956. */
  42957. actionManagers: AbstractActionManager[];
  42958. /**
  42959. * Textures to keep.
  42960. */
  42961. textures: BaseTexture[];
  42962. /** @hidden */
  42963. protected _environmentTexture: Nullable<BaseTexture>;
  42964. /**
  42965. * Texture used in all pbr material as the reflection texture.
  42966. * As in the majority of the scene they are the same (exception for multi room and so on),
  42967. * this is easier to reference from here than from all the materials.
  42968. */
  42969. get environmentTexture(): Nullable<BaseTexture>;
  42970. set environmentTexture(value: Nullable<BaseTexture>);
  42971. /**
  42972. * The list of postprocesses added to the scene
  42973. */
  42974. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42975. /**
  42976. * @returns all meshes, lights, cameras, transformNodes and bones
  42977. */
  42978. getNodes(): Array<Node>;
  42979. }
  42980. }
  42981. declare module "babylonjs/Audio/sound" {
  42982. import { Observable } from "babylonjs/Misc/observable";
  42983. import { Vector3 } from "babylonjs/Maths/math.vector";
  42984. import { Nullable } from "babylonjs/types";
  42985. import { Scene } from "babylonjs/scene";
  42986. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42987. /**
  42988. * Interface used to define options for Sound class
  42989. */
  42990. export interface ISoundOptions {
  42991. /**
  42992. * Does the sound autoplay once loaded.
  42993. */
  42994. autoplay?: boolean;
  42995. /**
  42996. * Does the sound loop after it finishes playing once.
  42997. */
  42998. loop?: boolean;
  42999. /**
  43000. * Sound's volume
  43001. */
  43002. volume?: number;
  43003. /**
  43004. * Is it a spatial sound?
  43005. */
  43006. spatialSound?: boolean;
  43007. /**
  43008. * Maximum distance to hear that sound
  43009. */
  43010. maxDistance?: number;
  43011. /**
  43012. * Uses user defined attenuation function
  43013. */
  43014. useCustomAttenuation?: boolean;
  43015. /**
  43016. * Define the roll off factor of spatial sounds.
  43017. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43018. */
  43019. rolloffFactor?: number;
  43020. /**
  43021. * Define the reference distance the sound should be heard perfectly.
  43022. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43023. */
  43024. refDistance?: number;
  43025. /**
  43026. * Define the distance attenuation model the sound will follow.
  43027. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43028. */
  43029. distanceModel?: string;
  43030. /**
  43031. * Defines the playback speed (1 by default)
  43032. */
  43033. playbackRate?: number;
  43034. /**
  43035. * Defines if the sound is from a streaming source
  43036. */
  43037. streaming?: boolean;
  43038. /**
  43039. * Defines an optional length (in seconds) inside the sound file
  43040. */
  43041. length?: number;
  43042. /**
  43043. * Defines an optional offset (in seconds) inside the sound file
  43044. */
  43045. offset?: number;
  43046. /**
  43047. * If true, URLs will not be required to state the audio file codec to use.
  43048. */
  43049. skipCodecCheck?: boolean;
  43050. }
  43051. /**
  43052. * Defines a sound that can be played in the application.
  43053. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  43054. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43055. */
  43056. export class Sound {
  43057. /**
  43058. * The name of the sound in the scene.
  43059. */
  43060. name: string;
  43061. /**
  43062. * Does the sound autoplay once loaded.
  43063. */
  43064. autoplay: boolean;
  43065. /**
  43066. * Does the sound loop after it finishes playing once.
  43067. */
  43068. loop: boolean;
  43069. /**
  43070. * Does the sound use a custom attenuation curve to simulate the falloff
  43071. * happening when the source gets further away from the camera.
  43072. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43073. */
  43074. useCustomAttenuation: boolean;
  43075. /**
  43076. * The sound track id this sound belongs to.
  43077. */
  43078. soundTrackId: number;
  43079. /**
  43080. * Is this sound currently played.
  43081. */
  43082. isPlaying: boolean;
  43083. /**
  43084. * Is this sound currently paused.
  43085. */
  43086. isPaused: boolean;
  43087. /**
  43088. * Does this sound enables spatial sound.
  43089. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43090. */
  43091. spatialSound: boolean;
  43092. /**
  43093. * Define the reference distance the sound should be heard perfectly.
  43094. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43095. */
  43096. refDistance: number;
  43097. /**
  43098. * Define the roll off factor of spatial sounds.
  43099. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43100. */
  43101. rolloffFactor: number;
  43102. /**
  43103. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  43104. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43105. */
  43106. maxDistance: number;
  43107. /**
  43108. * Define the distance attenuation model the sound will follow.
  43109. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43110. */
  43111. distanceModel: string;
  43112. /**
  43113. * @hidden
  43114. * Back Compat
  43115. **/
  43116. onended: () => any;
  43117. /**
  43118. * Gets or sets an object used to store user defined information for the sound.
  43119. */
  43120. metadata: any;
  43121. /**
  43122. * Observable event when the current playing sound finishes.
  43123. */
  43124. onEndedObservable: Observable<Sound>;
  43125. private _panningModel;
  43126. private _playbackRate;
  43127. private _streaming;
  43128. private _startTime;
  43129. private _startOffset;
  43130. private _position;
  43131. /** @hidden */
  43132. _positionInEmitterSpace: boolean;
  43133. private _localDirection;
  43134. private _volume;
  43135. private _isReadyToPlay;
  43136. private _isDirectional;
  43137. private _readyToPlayCallback;
  43138. private _audioBuffer;
  43139. private _soundSource;
  43140. private _streamingSource;
  43141. private _soundPanner;
  43142. private _soundGain;
  43143. private _inputAudioNode;
  43144. private _outputAudioNode;
  43145. private _coneInnerAngle;
  43146. private _coneOuterAngle;
  43147. private _coneOuterGain;
  43148. private _scene;
  43149. private _connectedTransformNode;
  43150. private _customAttenuationFunction;
  43151. private _registerFunc;
  43152. private _isOutputConnected;
  43153. private _htmlAudioElement;
  43154. private _urlType;
  43155. private _length?;
  43156. private _offset?;
  43157. /** @hidden */
  43158. static _SceneComponentInitialization: (scene: Scene) => void;
  43159. /**
  43160. * Create a sound and attach it to a scene
  43161. * @param name Name of your sound
  43162. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  43163. * @param scene defines the scene the sound belongs to
  43164. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  43165. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  43166. */
  43167. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  43168. /**
  43169. * Release the sound and its associated resources
  43170. */
  43171. dispose(): void;
  43172. /**
  43173. * Gets if the sounds is ready to be played or not.
  43174. * @returns true if ready, otherwise false
  43175. */
  43176. isReady(): boolean;
  43177. private _soundLoaded;
  43178. /**
  43179. * Sets the data of the sound from an audiobuffer
  43180. * @param audioBuffer The audioBuffer containing the data
  43181. */
  43182. setAudioBuffer(audioBuffer: AudioBuffer): void;
  43183. /**
  43184. * Updates the current sounds options such as maxdistance, loop...
  43185. * @param options A JSON object containing values named as the object properties
  43186. */
  43187. updateOptions(options: ISoundOptions): void;
  43188. private _createSpatialParameters;
  43189. private _updateSpatialParameters;
  43190. /**
  43191. * Switch the panning model to HRTF:
  43192. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43193. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43194. */
  43195. switchPanningModelToHRTF(): void;
  43196. /**
  43197. * Switch the panning model to Equal Power:
  43198. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43199. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43200. */
  43201. switchPanningModelToEqualPower(): void;
  43202. private _switchPanningModel;
  43203. /**
  43204. * Connect this sound to a sound track audio node like gain...
  43205. * @param soundTrackAudioNode the sound track audio node to connect to
  43206. */
  43207. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  43208. /**
  43209. * Transform this sound into a directional source
  43210. * @param coneInnerAngle Size of the inner cone in degree
  43211. * @param coneOuterAngle Size of the outer cone in degree
  43212. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  43213. */
  43214. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  43215. /**
  43216. * Gets or sets the inner angle for the directional cone.
  43217. */
  43218. get directionalConeInnerAngle(): number;
  43219. /**
  43220. * Gets or sets the inner angle for the directional cone.
  43221. */
  43222. set directionalConeInnerAngle(value: number);
  43223. /**
  43224. * Gets or sets the outer angle for the directional cone.
  43225. */
  43226. get directionalConeOuterAngle(): number;
  43227. /**
  43228. * Gets or sets the outer angle for the directional cone.
  43229. */
  43230. set directionalConeOuterAngle(value: number);
  43231. /**
  43232. * Sets the position of the emitter if spatial sound is enabled
  43233. * @param newPosition Defines the new posisiton
  43234. */
  43235. setPosition(newPosition: Vector3): void;
  43236. /**
  43237. * Sets the local direction of the emitter if spatial sound is enabled
  43238. * @param newLocalDirection Defines the new local direction
  43239. */
  43240. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43241. private _updateDirection;
  43242. /** @hidden */
  43243. updateDistanceFromListener(): void;
  43244. /**
  43245. * Sets a new custom attenuation function for the sound.
  43246. * @param callback Defines the function used for the attenuation
  43247. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43248. */
  43249. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43250. /**
  43251. * Play the sound
  43252. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43253. * @param offset (optional) Start the sound at a specific time in seconds
  43254. * @param length (optional) Sound duration (in seconds)
  43255. */
  43256. play(time?: number, offset?: number, length?: number): void;
  43257. private _onended;
  43258. /**
  43259. * Stop the sound
  43260. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43261. */
  43262. stop(time?: number): void;
  43263. /**
  43264. * Put the sound in pause
  43265. */
  43266. pause(): void;
  43267. /**
  43268. * Sets a dedicated volume for this sounds
  43269. * @param newVolume Define the new volume of the sound
  43270. * @param time Define time for gradual change to new volume
  43271. */
  43272. setVolume(newVolume: number, time?: number): void;
  43273. /**
  43274. * Set the sound play back rate
  43275. * @param newPlaybackRate Define the playback rate the sound should be played at
  43276. */
  43277. setPlaybackRate(newPlaybackRate: number): void;
  43278. /**
  43279. * Gets the volume of the sound.
  43280. * @returns the volume of the sound
  43281. */
  43282. getVolume(): number;
  43283. /**
  43284. * Attach the sound to a dedicated mesh
  43285. * @param transformNode The transform node to connect the sound with
  43286. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43287. */
  43288. attachToMesh(transformNode: TransformNode): void;
  43289. /**
  43290. * Detach the sound from the previously attached mesh
  43291. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43292. */
  43293. detachFromMesh(): void;
  43294. private _onRegisterAfterWorldMatrixUpdate;
  43295. /**
  43296. * Clone the current sound in the scene.
  43297. * @returns the new sound clone
  43298. */
  43299. clone(): Nullable<Sound>;
  43300. /**
  43301. * Gets the current underlying audio buffer containing the data
  43302. * @returns the audio buffer
  43303. */
  43304. getAudioBuffer(): Nullable<AudioBuffer>;
  43305. /**
  43306. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43307. * @returns the source node
  43308. */
  43309. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43310. /**
  43311. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43312. * @returns the gain node
  43313. */
  43314. getSoundGain(): Nullable<GainNode>;
  43315. /**
  43316. * Serializes the Sound in a JSON representation
  43317. * @returns the JSON representation of the sound
  43318. */
  43319. serialize(): any;
  43320. /**
  43321. * Parse a JSON representation of a sound to innstantiate in a given scene
  43322. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43323. * @param scene Define the scene the new parsed sound should be created in
  43324. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43325. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43326. * @returns the newly parsed sound
  43327. */
  43328. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43329. }
  43330. }
  43331. declare module "babylonjs/Actions/directAudioActions" {
  43332. import { Action } from "babylonjs/Actions/action";
  43333. import { Condition } from "babylonjs/Actions/condition";
  43334. import { Sound } from "babylonjs/Audio/sound";
  43335. /**
  43336. * This defines an action helpful to play a defined sound on a triggered action.
  43337. */
  43338. export class PlaySoundAction extends Action {
  43339. private _sound;
  43340. /**
  43341. * Instantiate the action
  43342. * @param triggerOptions defines the trigger options
  43343. * @param sound defines the sound to play
  43344. * @param condition defines the trigger related conditions
  43345. */
  43346. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43347. /** @hidden */
  43348. _prepare(): void;
  43349. /**
  43350. * Execute the action and play the sound.
  43351. */
  43352. execute(): void;
  43353. /**
  43354. * Serializes the actions and its related information.
  43355. * @param parent defines the object to serialize in
  43356. * @returns the serialized object
  43357. */
  43358. serialize(parent: any): any;
  43359. }
  43360. /**
  43361. * This defines an action helpful to stop a defined sound on a triggered action.
  43362. */
  43363. export class StopSoundAction extends Action {
  43364. private _sound;
  43365. /**
  43366. * Instantiate the action
  43367. * @param triggerOptions defines the trigger options
  43368. * @param sound defines the sound to stop
  43369. * @param condition defines the trigger related conditions
  43370. */
  43371. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43372. /** @hidden */
  43373. _prepare(): void;
  43374. /**
  43375. * Execute the action and stop the sound.
  43376. */
  43377. execute(): void;
  43378. /**
  43379. * Serializes the actions and its related information.
  43380. * @param parent defines the object to serialize in
  43381. * @returns the serialized object
  43382. */
  43383. serialize(parent: any): any;
  43384. }
  43385. }
  43386. declare module "babylonjs/Actions/interpolateValueAction" {
  43387. import { Action } from "babylonjs/Actions/action";
  43388. import { Condition } from "babylonjs/Actions/condition";
  43389. import { Observable } from "babylonjs/Misc/observable";
  43390. /**
  43391. * This defines an action responsible to change the value of a property
  43392. * by interpolating between its current value and the newly set one once triggered.
  43393. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43394. */
  43395. export class InterpolateValueAction extends Action {
  43396. /**
  43397. * Defines the path of the property where the value should be interpolated
  43398. */
  43399. propertyPath: string;
  43400. /**
  43401. * Defines the target value at the end of the interpolation.
  43402. */
  43403. value: any;
  43404. /**
  43405. * Defines the time it will take for the property to interpolate to the value.
  43406. */
  43407. duration: number;
  43408. /**
  43409. * Defines if the other scene animations should be stopped when the action has been triggered
  43410. */
  43411. stopOtherAnimations?: boolean;
  43412. /**
  43413. * Defines a callback raised once the interpolation animation has been done.
  43414. */
  43415. onInterpolationDone?: () => void;
  43416. /**
  43417. * Observable triggered once the interpolation animation has been done.
  43418. */
  43419. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43420. private _target;
  43421. private _effectiveTarget;
  43422. private _property;
  43423. /**
  43424. * Instantiate the action
  43425. * @param triggerOptions defines the trigger options
  43426. * @param target defines the object containing the value to interpolate
  43427. * @param propertyPath defines the path to the property in the target object
  43428. * @param value defines the target value at the end of the interpolation
  43429. * @param duration deines the time it will take for the property to interpolate to the value.
  43430. * @param condition defines the trigger related conditions
  43431. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43432. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43433. */
  43434. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43435. /** @hidden */
  43436. _prepare(): void;
  43437. /**
  43438. * Execute the action starts the value interpolation.
  43439. */
  43440. execute(): void;
  43441. /**
  43442. * Serializes the actions and its related information.
  43443. * @param parent defines the object to serialize in
  43444. * @returns the serialized object
  43445. */
  43446. serialize(parent: any): any;
  43447. }
  43448. }
  43449. declare module "babylonjs/Actions/index" {
  43450. export * from "babylonjs/Actions/abstractActionManager";
  43451. export * from "babylonjs/Actions/action";
  43452. export * from "babylonjs/Actions/actionEvent";
  43453. export * from "babylonjs/Actions/actionManager";
  43454. export * from "babylonjs/Actions/condition";
  43455. export * from "babylonjs/Actions/directActions";
  43456. export * from "babylonjs/Actions/directAudioActions";
  43457. export * from "babylonjs/Actions/interpolateValueAction";
  43458. }
  43459. declare module "babylonjs/Animations/index" {
  43460. export * from "babylonjs/Animations/animatable";
  43461. export * from "babylonjs/Animations/animation";
  43462. export * from "babylonjs/Animations/animationGroup";
  43463. export * from "babylonjs/Animations/animationPropertiesOverride";
  43464. export * from "babylonjs/Animations/easing";
  43465. export * from "babylonjs/Animations/runtimeAnimation";
  43466. export * from "babylonjs/Animations/animationEvent";
  43467. export * from "babylonjs/Animations/animationGroup";
  43468. export * from "babylonjs/Animations/animationKey";
  43469. export * from "babylonjs/Animations/animationRange";
  43470. export * from "babylonjs/Animations/animatable.interface";
  43471. }
  43472. declare module "babylonjs/Audio/soundTrack" {
  43473. import { Sound } from "babylonjs/Audio/sound";
  43474. import { Analyser } from "babylonjs/Audio/analyser";
  43475. import { Scene } from "babylonjs/scene";
  43476. /**
  43477. * Options allowed during the creation of a sound track.
  43478. */
  43479. export interface ISoundTrackOptions {
  43480. /**
  43481. * The volume the sound track should take during creation
  43482. */
  43483. volume?: number;
  43484. /**
  43485. * Define if the sound track is the main sound track of the scene
  43486. */
  43487. mainTrack?: boolean;
  43488. }
  43489. /**
  43490. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43491. * It will be also used in a future release to apply effects on a specific track.
  43492. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43493. */
  43494. export class SoundTrack {
  43495. /**
  43496. * The unique identifier of the sound track in the scene.
  43497. */
  43498. id: number;
  43499. /**
  43500. * The list of sounds included in the sound track.
  43501. */
  43502. soundCollection: Array<Sound>;
  43503. private _outputAudioNode;
  43504. private _scene;
  43505. private _connectedAnalyser;
  43506. private _options;
  43507. private _isInitialized;
  43508. /**
  43509. * Creates a new sound track.
  43510. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43511. * @param scene Define the scene the sound track belongs to
  43512. * @param options
  43513. */
  43514. constructor(scene: Scene, options?: ISoundTrackOptions);
  43515. private _initializeSoundTrackAudioGraph;
  43516. /**
  43517. * Release the sound track and its associated resources
  43518. */
  43519. dispose(): void;
  43520. /**
  43521. * Adds a sound to this sound track
  43522. * @param sound define the cound to add
  43523. * @ignoreNaming
  43524. */
  43525. AddSound(sound: Sound): void;
  43526. /**
  43527. * Removes a sound to this sound track
  43528. * @param sound define the cound to remove
  43529. * @ignoreNaming
  43530. */
  43531. RemoveSound(sound: Sound): void;
  43532. /**
  43533. * Set a global volume for the full sound track.
  43534. * @param newVolume Define the new volume of the sound track
  43535. */
  43536. setVolume(newVolume: number): void;
  43537. /**
  43538. * Switch the panning model to HRTF:
  43539. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43540. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43541. */
  43542. switchPanningModelToHRTF(): void;
  43543. /**
  43544. * Switch the panning model to Equal Power:
  43545. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43546. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43547. */
  43548. switchPanningModelToEqualPower(): void;
  43549. /**
  43550. * Connect the sound track to an audio analyser allowing some amazing
  43551. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43552. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43553. * @param analyser The analyser to connect to the engine
  43554. */
  43555. connectToAnalyser(analyser: Analyser): void;
  43556. }
  43557. }
  43558. declare module "babylonjs/Audio/audioSceneComponent" {
  43559. import { Sound } from "babylonjs/Audio/sound";
  43560. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43561. import { Nullable } from "babylonjs/types";
  43562. import { Vector3 } from "babylonjs/Maths/math.vector";
  43563. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43564. import { Scene } from "babylonjs/scene";
  43565. import { AbstractScene } from "babylonjs/abstractScene";
  43566. import "babylonjs/Audio/audioEngine";
  43567. module "babylonjs/abstractScene" {
  43568. interface AbstractScene {
  43569. /**
  43570. * The list of sounds used in the scene.
  43571. */
  43572. sounds: Nullable<Array<Sound>>;
  43573. }
  43574. }
  43575. module "babylonjs/scene" {
  43576. interface Scene {
  43577. /**
  43578. * @hidden
  43579. * Backing field
  43580. */
  43581. _mainSoundTrack: SoundTrack;
  43582. /**
  43583. * The main sound track played by the scene.
  43584. * It cotains your primary collection of sounds.
  43585. */
  43586. mainSoundTrack: SoundTrack;
  43587. /**
  43588. * The list of sound tracks added to the scene
  43589. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43590. */
  43591. soundTracks: Nullable<Array<SoundTrack>>;
  43592. /**
  43593. * Gets a sound using a given name
  43594. * @param name defines the name to search for
  43595. * @return the found sound or null if not found at all.
  43596. */
  43597. getSoundByName(name: string): Nullable<Sound>;
  43598. /**
  43599. * Gets or sets if audio support is enabled
  43600. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43601. */
  43602. audioEnabled: boolean;
  43603. /**
  43604. * Gets or sets if audio will be output to headphones
  43605. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43606. */
  43607. headphone: boolean;
  43608. /**
  43609. * Gets or sets custom audio listener position provider
  43610. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43611. */
  43612. audioListenerPositionProvider: Nullable<() => Vector3>;
  43613. /**
  43614. * Gets or sets a refresh rate when using 3D audio positioning
  43615. */
  43616. audioPositioningRefreshRate: number;
  43617. }
  43618. }
  43619. /**
  43620. * Defines the sound scene component responsible to manage any sounds
  43621. * in a given scene.
  43622. */
  43623. export class AudioSceneComponent implements ISceneSerializableComponent {
  43624. private static _CameraDirectionLH;
  43625. private static _CameraDirectionRH;
  43626. /**
  43627. * The component name helpfull to identify the component in the list of scene components.
  43628. */
  43629. readonly name: string;
  43630. /**
  43631. * The scene the component belongs to.
  43632. */
  43633. scene: Scene;
  43634. private _audioEnabled;
  43635. /**
  43636. * Gets whether audio is enabled or not.
  43637. * Please use related enable/disable method to switch state.
  43638. */
  43639. get audioEnabled(): boolean;
  43640. private _headphone;
  43641. /**
  43642. * Gets whether audio is outputing to headphone or not.
  43643. * Please use the according Switch methods to change output.
  43644. */
  43645. get headphone(): boolean;
  43646. /**
  43647. * Gets or sets a refresh rate when using 3D audio positioning
  43648. */
  43649. audioPositioningRefreshRate: number;
  43650. private _audioListenerPositionProvider;
  43651. /**
  43652. * Gets the current audio listener position provider
  43653. */
  43654. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43655. /**
  43656. * Sets a custom listener position for all sounds in the scene
  43657. * By default, this is the position of the first active camera
  43658. */
  43659. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43660. /**
  43661. * Creates a new instance of the component for the given scene
  43662. * @param scene Defines the scene to register the component in
  43663. */
  43664. constructor(scene: Scene);
  43665. /**
  43666. * Registers the component in a given scene
  43667. */
  43668. register(): void;
  43669. /**
  43670. * Rebuilds the elements related to this component in case of
  43671. * context lost for instance.
  43672. */
  43673. rebuild(): void;
  43674. /**
  43675. * Serializes the component data to the specified json object
  43676. * @param serializationObject The object to serialize to
  43677. */
  43678. serialize(serializationObject: any): void;
  43679. /**
  43680. * Adds all the elements from the container to the scene
  43681. * @param container the container holding the elements
  43682. */
  43683. addFromContainer(container: AbstractScene): void;
  43684. /**
  43685. * Removes all the elements in the container from the scene
  43686. * @param container contains the elements to remove
  43687. * @param dispose if the removed element should be disposed (default: false)
  43688. */
  43689. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43690. /**
  43691. * Disposes the component and the associated ressources.
  43692. */
  43693. dispose(): void;
  43694. /**
  43695. * Disables audio in the associated scene.
  43696. */
  43697. disableAudio(): void;
  43698. /**
  43699. * Enables audio in the associated scene.
  43700. */
  43701. enableAudio(): void;
  43702. /**
  43703. * Switch audio to headphone output.
  43704. */
  43705. switchAudioModeForHeadphones(): void;
  43706. /**
  43707. * Switch audio to normal speakers.
  43708. */
  43709. switchAudioModeForNormalSpeakers(): void;
  43710. private _cachedCameraDirection;
  43711. private _cachedCameraPosition;
  43712. private _lastCheck;
  43713. private _afterRender;
  43714. }
  43715. }
  43716. declare module "babylonjs/Audio/weightedsound" {
  43717. import { Sound } from "babylonjs/Audio/sound";
  43718. /**
  43719. * Wraps one or more Sound objects and selects one with random weight for playback.
  43720. */
  43721. export class WeightedSound {
  43722. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43723. loop: boolean;
  43724. private _coneInnerAngle;
  43725. private _coneOuterAngle;
  43726. private _volume;
  43727. /** A Sound is currently playing. */
  43728. isPlaying: boolean;
  43729. /** A Sound is currently paused. */
  43730. isPaused: boolean;
  43731. private _sounds;
  43732. private _weights;
  43733. private _currentIndex?;
  43734. /**
  43735. * Creates a new WeightedSound from the list of sounds given.
  43736. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43737. * @param sounds Array of Sounds that will be selected from.
  43738. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43739. */
  43740. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43741. /**
  43742. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43743. */
  43744. get directionalConeInnerAngle(): number;
  43745. /**
  43746. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43747. */
  43748. set directionalConeInnerAngle(value: number);
  43749. /**
  43750. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43751. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43752. */
  43753. get directionalConeOuterAngle(): number;
  43754. /**
  43755. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43756. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43757. */
  43758. set directionalConeOuterAngle(value: number);
  43759. /**
  43760. * Playback volume.
  43761. */
  43762. get volume(): number;
  43763. /**
  43764. * Playback volume.
  43765. */
  43766. set volume(value: number);
  43767. private _onended;
  43768. /**
  43769. * Suspend playback
  43770. */
  43771. pause(): void;
  43772. /**
  43773. * Stop playback
  43774. */
  43775. stop(): void;
  43776. /**
  43777. * Start playback.
  43778. * @param startOffset Position the clip head at a specific time in seconds.
  43779. */
  43780. play(startOffset?: number): void;
  43781. }
  43782. }
  43783. declare module "babylonjs/Audio/index" {
  43784. export * from "babylonjs/Audio/analyser";
  43785. export * from "babylonjs/Audio/audioEngine";
  43786. export * from "babylonjs/Audio/audioSceneComponent";
  43787. export * from "babylonjs/Audio/sound";
  43788. export * from "babylonjs/Audio/soundTrack";
  43789. export * from "babylonjs/Audio/weightedsound";
  43790. }
  43791. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43792. import { Behavior } from "babylonjs/Behaviors/behavior";
  43793. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43794. import { BackEase } from "babylonjs/Animations/easing";
  43795. /**
  43796. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43797. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43798. */
  43799. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43800. /**
  43801. * Gets the name of the behavior.
  43802. */
  43803. get name(): string;
  43804. /**
  43805. * The easing function used by animations
  43806. */
  43807. static EasingFunction: BackEase;
  43808. /**
  43809. * The easing mode used by animations
  43810. */
  43811. static EasingMode: number;
  43812. /**
  43813. * The duration of the animation, in milliseconds
  43814. */
  43815. transitionDuration: number;
  43816. /**
  43817. * Length of the distance animated by the transition when lower radius is reached
  43818. */
  43819. lowerRadiusTransitionRange: number;
  43820. /**
  43821. * Length of the distance animated by the transition when upper radius is reached
  43822. */
  43823. upperRadiusTransitionRange: number;
  43824. private _autoTransitionRange;
  43825. /**
  43826. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43827. */
  43828. get autoTransitionRange(): boolean;
  43829. /**
  43830. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43831. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43832. */
  43833. set autoTransitionRange(value: boolean);
  43834. private _attachedCamera;
  43835. private _onAfterCheckInputsObserver;
  43836. private _onMeshTargetChangedObserver;
  43837. /**
  43838. * Initializes the behavior.
  43839. */
  43840. init(): void;
  43841. /**
  43842. * Attaches the behavior to its arc rotate camera.
  43843. * @param camera Defines the camera to attach the behavior to
  43844. */
  43845. attach(camera: ArcRotateCamera): void;
  43846. /**
  43847. * Detaches the behavior from its current arc rotate camera.
  43848. */
  43849. detach(): void;
  43850. private _radiusIsAnimating;
  43851. private _radiusBounceTransition;
  43852. private _animatables;
  43853. private _cachedWheelPrecision;
  43854. /**
  43855. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43856. * @param radiusLimit The limit to check against.
  43857. * @return Bool to indicate if at limit.
  43858. */
  43859. private _isRadiusAtLimit;
  43860. /**
  43861. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43862. * @param radiusDelta The delta by which to animate to. Can be negative.
  43863. */
  43864. private _applyBoundRadiusAnimation;
  43865. /**
  43866. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43867. */
  43868. protected _clearAnimationLocks(): void;
  43869. /**
  43870. * Stops and removes all animations that have been applied to the camera
  43871. */
  43872. stopAllAnimations(): void;
  43873. }
  43874. }
  43875. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43876. import { Behavior } from "babylonjs/Behaviors/behavior";
  43877. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43878. import { ExponentialEase } from "babylonjs/Animations/easing";
  43879. import { Nullable } from "babylonjs/types";
  43880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43881. import { Vector3 } from "babylonjs/Maths/math.vector";
  43882. /**
  43883. * 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.
  43884. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43885. */
  43886. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43887. /**
  43888. * Gets the name of the behavior.
  43889. */
  43890. get name(): string;
  43891. private _mode;
  43892. private _radiusScale;
  43893. private _positionScale;
  43894. private _defaultElevation;
  43895. private _elevationReturnTime;
  43896. private _elevationReturnWaitTime;
  43897. private _zoomStopsAnimation;
  43898. private _framingTime;
  43899. /**
  43900. * The easing function used by animations
  43901. */
  43902. static EasingFunction: ExponentialEase;
  43903. /**
  43904. * The easing mode used by animations
  43905. */
  43906. static EasingMode: number;
  43907. /**
  43908. * Sets the current mode used by the behavior
  43909. */
  43910. set mode(mode: number);
  43911. /**
  43912. * Gets current mode used by the behavior.
  43913. */
  43914. get mode(): number;
  43915. /**
  43916. * Sets the scale applied to the radius (1 by default)
  43917. */
  43918. set radiusScale(radius: number);
  43919. /**
  43920. * Gets the scale applied to the radius
  43921. */
  43922. get radiusScale(): number;
  43923. /**
  43924. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43925. */
  43926. set positionScale(scale: number);
  43927. /**
  43928. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43929. */
  43930. get positionScale(): number;
  43931. /**
  43932. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43933. * behaviour is triggered, in radians.
  43934. */
  43935. set defaultElevation(elevation: number);
  43936. /**
  43937. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43938. * behaviour is triggered, in radians.
  43939. */
  43940. get defaultElevation(): number;
  43941. /**
  43942. * Sets the time (in milliseconds) taken to return to the default beta position.
  43943. * Negative value indicates camera should not return to default.
  43944. */
  43945. set elevationReturnTime(speed: number);
  43946. /**
  43947. * Gets the time (in milliseconds) taken to return to the default beta position.
  43948. * Negative value indicates camera should not return to default.
  43949. */
  43950. get elevationReturnTime(): number;
  43951. /**
  43952. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43953. */
  43954. set elevationReturnWaitTime(time: number);
  43955. /**
  43956. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43957. */
  43958. get elevationReturnWaitTime(): number;
  43959. /**
  43960. * Sets the flag that indicates if user zooming should stop animation.
  43961. */
  43962. set zoomStopsAnimation(flag: boolean);
  43963. /**
  43964. * Gets the flag that indicates if user zooming should stop animation.
  43965. */
  43966. get zoomStopsAnimation(): boolean;
  43967. /**
  43968. * Sets the transition time when framing the mesh, in milliseconds
  43969. */
  43970. set framingTime(time: number);
  43971. /**
  43972. * Gets the transition time when framing the mesh, in milliseconds
  43973. */
  43974. get framingTime(): number;
  43975. /**
  43976. * Define if the behavior should automatically change the configured
  43977. * camera limits and sensibilities.
  43978. */
  43979. autoCorrectCameraLimitsAndSensibility: boolean;
  43980. private _onPrePointerObservableObserver;
  43981. private _onAfterCheckInputsObserver;
  43982. private _onMeshTargetChangedObserver;
  43983. private _attachedCamera;
  43984. private _isPointerDown;
  43985. private _lastInteractionTime;
  43986. /**
  43987. * Initializes the behavior.
  43988. */
  43989. init(): void;
  43990. /**
  43991. * Attaches the behavior to its arc rotate camera.
  43992. * @param camera Defines the camera to attach the behavior to
  43993. */
  43994. attach(camera: ArcRotateCamera): void;
  43995. /**
  43996. * Detaches the behavior from its current arc rotate camera.
  43997. */
  43998. detach(): void;
  43999. private _animatables;
  44000. private _betaIsAnimating;
  44001. private _betaTransition;
  44002. private _radiusTransition;
  44003. private _vectorTransition;
  44004. /**
  44005. * Targets the given mesh and updates zoom level accordingly.
  44006. * @param mesh The mesh to target.
  44007. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44008. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44009. */
  44010. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44011. /**
  44012. * Targets the given mesh with its children and updates zoom level accordingly.
  44013. * @param mesh The mesh to target.
  44014. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44015. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44016. */
  44017. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44018. /**
  44019. * Targets the given meshes with their children and updates zoom level accordingly.
  44020. * @param meshes The mesh to target.
  44021. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44022. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44023. */
  44024. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44025. /**
  44026. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  44027. * @param minimumWorld Determines the smaller position of the bounding box extend
  44028. * @param maximumWorld Determines the bigger position of the bounding box extend
  44029. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44030. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44031. */
  44032. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44033. /**
  44034. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  44035. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  44036. * frustum width.
  44037. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  44038. * to fully enclose the mesh in the viewing frustum.
  44039. */
  44040. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  44041. /**
  44042. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  44043. * is automatically returned to its default position (expected to be above ground plane).
  44044. */
  44045. private _maintainCameraAboveGround;
  44046. /**
  44047. * Returns the frustum slope based on the canvas ratio and camera FOV
  44048. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  44049. */
  44050. private _getFrustumSlope;
  44051. /**
  44052. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  44053. */
  44054. private _clearAnimationLocks;
  44055. /**
  44056. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44057. */
  44058. private _applyUserInteraction;
  44059. /**
  44060. * Stops and removes all animations that have been applied to the camera
  44061. */
  44062. stopAllAnimations(): void;
  44063. /**
  44064. * Gets a value indicating if the user is moving the camera
  44065. */
  44066. get isUserIsMoving(): boolean;
  44067. /**
  44068. * The camera can move all the way towards the mesh.
  44069. */
  44070. static IgnoreBoundsSizeMode: number;
  44071. /**
  44072. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  44073. */
  44074. static FitFrustumSidesMode: number;
  44075. }
  44076. }
  44077. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  44078. import { Nullable } from "babylonjs/types";
  44079. import { Camera } from "babylonjs/Cameras/camera";
  44080. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44081. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44082. /**
  44083. * Base class for Camera Pointer Inputs.
  44084. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  44085. * for example usage.
  44086. */
  44087. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  44088. /**
  44089. * Defines the camera the input is attached to.
  44090. */
  44091. abstract camera: Camera;
  44092. /**
  44093. * Whether keyboard modifier keys are pressed at time of last mouse event.
  44094. */
  44095. protected _altKey: boolean;
  44096. protected _ctrlKey: boolean;
  44097. protected _metaKey: boolean;
  44098. protected _shiftKey: boolean;
  44099. /**
  44100. * Which mouse buttons were pressed at time of last mouse event.
  44101. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  44102. */
  44103. protected _buttonsPressed: number;
  44104. /**
  44105. * Defines the buttons associated with the input to handle camera move.
  44106. */
  44107. buttons: number[];
  44108. /**
  44109. * Attach the input controls to a specific dom element to get the input from.
  44110. * @param element Defines the element the controls should be listened from
  44111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44112. */
  44113. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44114. /**
  44115. * Detach the current controls from the specified dom element.
  44116. * @param element Defines the element to stop listening the inputs from
  44117. */
  44118. detachControl(element: Nullable<HTMLElement>): void;
  44119. /**
  44120. * Gets the class name of the current input.
  44121. * @returns the class name
  44122. */
  44123. getClassName(): string;
  44124. /**
  44125. * Get the friendly name associated with the input class.
  44126. * @returns the input friendly name
  44127. */
  44128. getSimpleName(): string;
  44129. /**
  44130. * Called on pointer POINTERDOUBLETAP event.
  44131. * Override this method to provide functionality on POINTERDOUBLETAP event.
  44132. */
  44133. protected onDoubleTap(type: string): void;
  44134. /**
  44135. * Called on pointer POINTERMOVE event if only a single touch is active.
  44136. * Override this method to provide functionality.
  44137. */
  44138. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44139. /**
  44140. * Called on pointer POINTERMOVE event if multiple touches are active.
  44141. * Override this method to provide functionality.
  44142. */
  44143. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44144. /**
  44145. * Called on JS contextmenu event.
  44146. * Override this method to provide functionality.
  44147. */
  44148. protected onContextMenu(evt: PointerEvent): void;
  44149. /**
  44150. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44151. * press.
  44152. * Override this method to provide functionality.
  44153. */
  44154. protected onButtonDown(evt: PointerEvent): void;
  44155. /**
  44156. * Called each time a new POINTERUP event occurs. Ie, for each button
  44157. * release.
  44158. * Override this method to provide functionality.
  44159. */
  44160. protected onButtonUp(evt: PointerEvent): void;
  44161. /**
  44162. * Called when window becomes inactive.
  44163. * Override this method to provide functionality.
  44164. */
  44165. protected onLostFocus(): void;
  44166. private _pointerInput;
  44167. private _observer;
  44168. private _onLostFocus;
  44169. private pointA;
  44170. private pointB;
  44171. }
  44172. }
  44173. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  44174. import { Nullable } from "babylonjs/types";
  44175. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44176. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44177. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44178. /**
  44179. * Manage the pointers inputs to control an arc rotate camera.
  44180. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44181. */
  44182. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  44183. /**
  44184. * Defines the camera the input is attached to.
  44185. */
  44186. camera: ArcRotateCamera;
  44187. /**
  44188. * Gets the class name of the current input.
  44189. * @returns the class name
  44190. */
  44191. getClassName(): string;
  44192. /**
  44193. * Defines the buttons associated with the input to handle camera move.
  44194. */
  44195. buttons: number[];
  44196. /**
  44197. * Defines the pointer angular sensibility along the X axis or how fast is
  44198. * the camera rotating.
  44199. */
  44200. angularSensibilityX: number;
  44201. /**
  44202. * Defines the pointer angular sensibility along the Y axis or how fast is
  44203. * the camera rotating.
  44204. */
  44205. angularSensibilityY: number;
  44206. /**
  44207. * Defines the pointer pinch precision or how fast is the camera zooming.
  44208. */
  44209. pinchPrecision: number;
  44210. /**
  44211. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44212. * from 0.
  44213. * It defines the percentage of current camera.radius to use as delta when
  44214. * pinch zoom is used.
  44215. */
  44216. pinchDeltaPercentage: number;
  44217. /**
  44218. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44219. * that any object in the plane at the camera's target point will scale
  44220. * perfectly with finger motion.
  44221. * Overrides pinchDeltaPercentage and pinchPrecision.
  44222. */
  44223. useNaturalPinchZoom: boolean;
  44224. /**
  44225. * Defines the pointer panning sensibility or how fast is the camera moving.
  44226. */
  44227. panningSensibility: number;
  44228. /**
  44229. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  44230. */
  44231. multiTouchPanning: boolean;
  44232. /**
  44233. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  44234. * zoom (pinch) through multitouch.
  44235. */
  44236. multiTouchPanAndZoom: boolean;
  44237. /**
  44238. * Revers pinch action direction.
  44239. */
  44240. pinchInwards: boolean;
  44241. private _isPanClick;
  44242. private _twoFingerActivityCount;
  44243. private _isPinching;
  44244. /**
  44245. * Called on pointer POINTERMOVE event if only a single touch is active.
  44246. */
  44247. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44248. /**
  44249. * Called on pointer POINTERDOUBLETAP event.
  44250. */
  44251. protected onDoubleTap(type: string): void;
  44252. /**
  44253. * Called on pointer POINTERMOVE event if multiple touches are active.
  44254. */
  44255. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44256. /**
  44257. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44258. * press.
  44259. */
  44260. protected onButtonDown(evt: PointerEvent): void;
  44261. /**
  44262. * Called each time a new POINTERUP event occurs. Ie, for each button
  44263. * release.
  44264. */
  44265. protected onButtonUp(evt: PointerEvent): void;
  44266. /**
  44267. * Called when window becomes inactive.
  44268. */
  44269. protected onLostFocus(): void;
  44270. }
  44271. }
  44272. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44273. import { Nullable } from "babylonjs/types";
  44274. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44275. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44276. /**
  44277. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44278. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44279. */
  44280. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44281. /**
  44282. * Defines the camera the input is attached to.
  44283. */
  44284. camera: ArcRotateCamera;
  44285. /**
  44286. * Defines the list of key codes associated with the up action (increase alpha)
  44287. */
  44288. keysUp: number[];
  44289. /**
  44290. * Defines the list of key codes associated with the down action (decrease alpha)
  44291. */
  44292. keysDown: number[];
  44293. /**
  44294. * Defines the list of key codes associated with the left action (increase beta)
  44295. */
  44296. keysLeft: number[];
  44297. /**
  44298. * Defines the list of key codes associated with the right action (decrease beta)
  44299. */
  44300. keysRight: number[];
  44301. /**
  44302. * Defines the list of key codes associated with the reset action.
  44303. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44304. */
  44305. keysReset: number[];
  44306. /**
  44307. * Defines the panning sensibility of the inputs.
  44308. * (How fast is the camera panning)
  44309. */
  44310. panningSensibility: number;
  44311. /**
  44312. * Defines the zooming sensibility of the inputs.
  44313. * (How fast is the camera zooming)
  44314. */
  44315. zoomingSensibility: number;
  44316. /**
  44317. * Defines whether maintaining the alt key down switch the movement mode from
  44318. * orientation to zoom.
  44319. */
  44320. useAltToZoom: boolean;
  44321. /**
  44322. * Rotation speed of the camera
  44323. */
  44324. angularSpeed: number;
  44325. private _keys;
  44326. private _ctrlPressed;
  44327. private _altPressed;
  44328. private _onCanvasBlurObserver;
  44329. private _onKeyboardObserver;
  44330. private _engine;
  44331. private _scene;
  44332. /**
  44333. * Attach the input controls to a specific dom element to get the input from.
  44334. * @param element Defines the element the controls should be listened from
  44335. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44336. */
  44337. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44338. /**
  44339. * Detach the current controls from the specified dom element.
  44340. * @param element Defines the element to stop listening the inputs from
  44341. */
  44342. detachControl(element: Nullable<HTMLElement>): void;
  44343. /**
  44344. * Update the current camera state depending on the inputs that have been used this frame.
  44345. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44346. */
  44347. checkInputs(): void;
  44348. /**
  44349. * Gets the class name of the current intput.
  44350. * @returns the class name
  44351. */
  44352. getClassName(): string;
  44353. /**
  44354. * Get the friendly name associated with the input class.
  44355. * @returns the input friendly name
  44356. */
  44357. getSimpleName(): string;
  44358. }
  44359. }
  44360. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44361. import { Nullable } from "babylonjs/types";
  44362. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44363. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44364. /**
  44365. * Manage the mouse wheel inputs to control an arc rotate camera.
  44366. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44367. */
  44368. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44369. /**
  44370. * Defines the camera the input is attached to.
  44371. */
  44372. camera: ArcRotateCamera;
  44373. /**
  44374. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44375. */
  44376. wheelPrecision: number;
  44377. /**
  44378. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44379. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44380. */
  44381. wheelDeltaPercentage: number;
  44382. private _wheel;
  44383. private _observer;
  44384. private computeDeltaFromMouseWheelLegacyEvent;
  44385. /**
  44386. * Attach the input controls to a specific dom element to get the input from.
  44387. * @param element Defines the element the controls should be listened from
  44388. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44389. */
  44390. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44391. /**
  44392. * Detach the current controls from the specified dom element.
  44393. * @param element Defines the element to stop listening the inputs from
  44394. */
  44395. detachControl(element: Nullable<HTMLElement>): void;
  44396. /**
  44397. * Gets the class name of the current intput.
  44398. * @returns the class name
  44399. */
  44400. getClassName(): string;
  44401. /**
  44402. * Get the friendly name associated with the input class.
  44403. * @returns the input friendly name
  44404. */
  44405. getSimpleName(): string;
  44406. }
  44407. }
  44408. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44409. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44410. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44411. /**
  44412. * Default Inputs manager for the ArcRotateCamera.
  44413. * It groups all the default supported inputs for ease of use.
  44414. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44415. */
  44416. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44417. /**
  44418. * Instantiates a new ArcRotateCameraInputsManager.
  44419. * @param camera Defines the camera the inputs belong to
  44420. */
  44421. constructor(camera: ArcRotateCamera);
  44422. /**
  44423. * Add mouse wheel input support to the input manager.
  44424. * @returns the current input manager
  44425. */
  44426. addMouseWheel(): ArcRotateCameraInputsManager;
  44427. /**
  44428. * Add pointers input support to the input manager.
  44429. * @returns the current input manager
  44430. */
  44431. addPointers(): ArcRotateCameraInputsManager;
  44432. /**
  44433. * Add keyboard input support to the input manager.
  44434. * @returns the current input manager
  44435. */
  44436. addKeyboard(): ArcRotateCameraInputsManager;
  44437. }
  44438. }
  44439. declare module "babylonjs/Cameras/arcRotateCamera" {
  44440. import { Observable } from "babylonjs/Misc/observable";
  44441. import { Nullable } from "babylonjs/types";
  44442. import { Scene } from "babylonjs/scene";
  44443. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44445. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44446. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44447. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44448. import { Camera } from "babylonjs/Cameras/camera";
  44449. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44450. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44451. import { Collider } from "babylonjs/Collisions/collider";
  44452. /**
  44453. * This represents an orbital type of camera.
  44454. *
  44455. * 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.
  44456. * 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.
  44457. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44458. */
  44459. export class ArcRotateCamera extends TargetCamera {
  44460. /**
  44461. * Defines the rotation angle of the camera along the longitudinal axis.
  44462. */
  44463. alpha: number;
  44464. /**
  44465. * Defines the rotation angle of the camera along the latitudinal axis.
  44466. */
  44467. beta: number;
  44468. /**
  44469. * Defines the radius of the camera from it s target point.
  44470. */
  44471. radius: number;
  44472. protected _target: Vector3;
  44473. protected _targetHost: Nullable<AbstractMesh>;
  44474. /**
  44475. * Defines the target point of the camera.
  44476. * The camera looks towards it form the radius distance.
  44477. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44478. */
  44479. get target(): Vector3;
  44480. set target(value: Vector3);
  44481. /**
  44482. * Define the current local position of the camera in the scene
  44483. */
  44484. get position(): Vector3;
  44485. set position(newPosition: Vector3);
  44486. protected _upToYMatrix: Matrix;
  44487. protected _YToUpMatrix: Matrix;
  44488. /**
  44489. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44490. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44491. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44492. */
  44493. set upVector(vec: Vector3);
  44494. get upVector(): Vector3;
  44495. /**
  44496. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44497. */
  44498. setMatUp(): void;
  44499. /**
  44500. * Current inertia value on the longitudinal axis.
  44501. * The bigger this number the longer it will take for the camera to stop.
  44502. */
  44503. inertialAlphaOffset: number;
  44504. /**
  44505. * Current inertia value on the latitudinal axis.
  44506. * The bigger this number the longer it will take for the camera to stop.
  44507. */
  44508. inertialBetaOffset: number;
  44509. /**
  44510. * Current inertia value on the radius axis.
  44511. * The bigger this number the longer it will take for the camera to stop.
  44512. */
  44513. inertialRadiusOffset: number;
  44514. /**
  44515. * Minimum allowed angle on the longitudinal axis.
  44516. * This can help limiting how the Camera is able to move in the scene.
  44517. */
  44518. lowerAlphaLimit: Nullable<number>;
  44519. /**
  44520. * Maximum allowed angle on the longitudinal axis.
  44521. * This can help limiting how the Camera is able to move in the scene.
  44522. */
  44523. upperAlphaLimit: Nullable<number>;
  44524. /**
  44525. * Minimum allowed angle on the latitudinal axis.
  44526. * This can help limiting how the Camera is able to move in the scene.
  44527. */
  44528. lowerBetaLimit: number;
  44529. /**
  44530. * Maximum allowed angle on the latitudinal axis.
  44531. * This can help limiting how the Camera is able to move in the scene.
  44532. */
  44533. upperBetaLimit: number;
  44534. /**
  44535. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44536. * This can help limiting how the Camera is able to move in the scene.
  44537. */
  44538. lowerRadiusLimit: Nullable<number>;
  44539. /**
  44540. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44541. * This can help limiting how the Camera is able to move in the scene.
  44542. */
  44543. upperRadiusLimit: Nullable<number>;
  44544. /**
  44545. * Defines the current inertia value used during panning of the camera along the X axis.
  44546. */
  44547. inertialPanningX: number;
  44548. /**
  44549. * Defines the current inertia value used during panning of the camera along the Y axis.
  44550. */
  44551. inertialPanningY: number;
  44552. /**
  44553. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44554. * Basically if your fingers moves away from more than this distance you will be considered
  44555. * in pinch mode.
  44556. */
  44557. pinchToPanMaxDistance: number;
  44558. /**
  44559. * Defines the maximum distance the camera can pan.
  44560. * This could help keeping the cammera always in your scene.
  44561. */
  44562. panningDistanceLimit: Nullable<number>;
  44563. /**
  44564. * Defines the target of the camera before paning.
  44565. */
  44566. panningOriginTarget: Vector3;
  44567. /**
  44568. * Defines the value of the inertia used during panning.
  44569. * 0 would mean stop inertia and one would mean no decelleration at all.
  44570. */
  44571. panningInertia: number;
  44572. /**
  44573. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44574. */
  44575. get angularSensibilityX(): number;
  44576. set angularSensibilityX(value: number);
  44577. /**
  44578. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44579. */
  44580. get angularSensibilityY(): number;
  44581. set angularSensibilityY(value: number);
  44582. /**
  44583. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44584. */
  44585. get pinchPrecision(): number;
  44586. set pinchPrecision(value: number);
  44587. /**
  44588. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44589. * It will be used instead of pinchDeltaPrecision if different from 0.
  44590. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44591. */
  44592. get pinchDeltaPercentage(): number;
  44593. set pinchDeltaPercentage(value: number);
  44594. /**
  44595. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44596. * and pinch delta percentage.
  44597. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44598. * that any object in the plane at the camera's target point will scale
  44599. * perfectly with finger motion.
  44600. */
  44601. get useNaturalPinchZoom(): boolean;
  44602. set useNaturalPinchZoom(value: boolean);
  44603. /**
  44604. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44605. */
  44606. get panningSensibility(): number;
  44607. set panningSensibility(value: number);
  44608. /**
  44609. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44610. */
  44611. get keysUp(): number[];
  44612. set keysUp(value: number[]);
  44613. /**
  44614. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44615. */
  44616. get keysDown(): number[];
  44617. set keysDown(value: number[]);
  44618. /**
  44619. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44620. */
  44621. get keysLeft(): number[];
  44622. set keysLeft(value: number[]);
  44623. /**
  44624. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44625. */
  44626. get keysRight(): number[];
  44627. set keysRight(value: number[]);
  44628. /**
  44629. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44630. */
  44631. get wheelPrecision(): number;
  44632. set wheelPrecision(value: number);
  44633. /**
  44634. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44635. * It will be used instead of pinchDeltaPrecision if different from 0.
  44636. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44637. */
  44638. get wheelDeltaPercentage(): number;
  44639. set wheelDeltaPercentage(value: number);
  44640. /**
  44641. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44642. */
  44643. zoomOnFactor: number;
  44644. /**
  44645. * Defines a screen offset for the camera position.
  44646. */
  44647. targetScreenOffset: Vector2;
  44648. /**
  44649. * Allows the camera to be completely reversed.
  44650. * If false the camera can not arrive upside down.
  44651. */
  44652. allowUpsideDown: boolean;
  44653. /**
  44654. * Define if double tap/click is used to restore the previously saved state of the camera.
  44655. */
  44656. useInputToRestoreState: boolean;
  44657. /** @hidden */
  44658. _viewMatrix: Matrix;
  44659. /** @hidden */
  44660. _useCtrlForPanning: boolean;
  44661. /** @hidden */
  44662. _panningMouseButton: number;
  44663. /**
  44664. * Defines the input associated to the camera.
  44665. */
  44666. inputs: ArcRotateCameraInputsManager;
  44667. /** @hidden */
  44668. _reset: () => void;
  44669. /**
  44670. * Defines the allowed panning axis.
  44671. */
  44672. panningAxis: Vector3;
  44673. protected _localDirection: Vector3;
  44674. protected _transformedDirection: Vector3;
  44675. private _bouncingBehavior;
  44676. /**
  44677. * Gets the bouncing behavior of the camera if it has been enabled.
  44678. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44679. */
  44680. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44681. /**
  44682. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44683. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44684. */
  44685. get useBouncingBehavior(): boolean;
  44686. set useBouncingBehavior(value: boolean);
  44687. private _framingBehavior;
  44688. /**
  44689. * Gets the framing behavior of the camera if it has been enabled.
  44690. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44691. */
  44692. get framingBehavior(): Nullable<FramingBehavior>;
  44693. /**
  44694. * Defines if the framing behavior of the camera is enabled on the camera.
  44695. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44696. */
  44697. get useFramingBehavior(): boolean;
  44698. set useFramingBehavior(value: boolean);
  44699. private _autoRotationBehavior;
  44700. /**
  44701. * Gets the auto rotation behavior of the camera if it has been enabled.
  44702. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44703. */
  44704. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44705. /**
  44706. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44707. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44708. */
  44709. get useAutoRotationBehavior(): boolean;
  44710. set useAutoRotationBehavior(value: boolean);
  44711. /**
  44712. * Observable triggered when the mesh target has been changed on the camera.
  44713. */
  44714. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44715. /**
  44716. * Event raised when the camera is colliding with a mesh.
  44717. */
  44718. onCollide: (collidedMesh: AbstractMesh) => void;
  44719. /**
  44720. * Defines whether the camera should check collision with the objects oh the scene.
  44721. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44722. */
  44723. checkCollisions: boolean;
  44724. /**
  44725. * Defines the collision radius of the camera.
  44726. * This simulates a sphere around the camera.
  44727. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44728. */
  44729. collisionRadius: Vector3;
  44730. protected _collider: Collider;
  44731. protected _previousPosition: Vector3;
  44732. protected _collisionVelocity: Vector3;
  44733. protected _newPosition: Vector3;
  44734. protected _previousAlpha: number;
  44735. protected _previousBeta: number;
  44736. protected _previousRadius: number;
  44737. protected _collisionTriggered: boolean;
  44738. protected _targetBoundingCenter: Nullable<Vector3>;
  44739. private _computationVector;
  44740. /**
  44741. * Instantiates a new ArcRotateCamera in a given scene
  44742. * @param name Defines the name of the camera
  44743. * @param alpha Defines the camera rotation along the logitudinal axis
  44744. * @param beta Defines the camera rotation along the latitudinal axis
  44745. * @param radius Defines the camera distance from its target
  44746. * @param target Defines the camera target
  44747. * @param scene Defines the scene the camera belongs to
  44748. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44749. */
  44750. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44751. /** @hidden */
  44752. _initCache(): void;
  44753. /** @hidden */
  44754. _updateCache(ignoreParentClass?: boolean): void;
  44755. protected _getTargetPosition(): Vector3;
  44756. private _storedAlpha;
  44757. private _storedBeta;
  44758. private _storedRadius;
  44759. private _storedTarget;
  44760. private _storedTargetScreenOffset;
  44761. /**
  44762. * Stores the current state of the camera (alpha, beta, radius and target)
  44763. * @returns the camera itself
  44764. */
  44765. storeState(): Camera;
  44766. /**
  44767. * @hidden
  44768. * Restored camera state. You must call storeState() first
  44769. */
  44770. _restoreStateValues(): boolean;
  44771. /** @hidden */
  44772. _isSynchronizedViewMatrix(): boolean;
  44773. /**
  44774. * Attached controls to the current camera.
  44775. * @param element Defines the element the controls should be listened from
  44776. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44777. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44778. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44779. */
  44780. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44781. /**
  44782. * Detach the current controls from the camera.
  44783. * The camera will stop reacting to inputs.
  44784. * @param element Defines the element to stop listening the inputs from
  44785. */
  44786. detachControl(element: HTMLElement): void;
  44787. /** @hidden */
  44788. _checkInputs(): void;
  44789. protected _checkLimits(): void;
  44790. /**
  44791. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44792. */
  44793. rebuildAnglesAndRadius(): void;
  44794. /**
  44795. * Use a position to define the current camera related information like alpha, beta and radius
  44796. * @param position Defines the position to set the camera at
  44797. */
  44798. setPosition(position: Vector3): void;
  44799. /**
  44800. * Defines the target the camera should look at.
  44801. * This will automatically adapt alpha beta and radius to fit within the new target.
  44802. * @param target Defines the new target as a Vector or a mesh
  44803. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44804. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44805. */
  44806. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44807. /** @hidden */
  44808. _getViewMatrix(): Matrix;
  44809. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44810. /**
  44811. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44812. * @param meshes Defines the mesh to zoom on
  44813. * @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)
  44814. */
  44815. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44816. /**
  44817. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44818. * The target will be changed but the radius
  44819. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44820. * @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)
  44821. */
  44822. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44823. min: Vector3;
  44824. max: Vector3;
  44825. distance: number;
  44826. }, doNotUpdateMaxZ?: boolean): void;
  44827. /**
  44828. * @override
  44829. * Override Camera.createRigCamera
  44830. */
  44831. createRigCamera(name: string, cameraIndex: number): Camera;
  44832. /**
  44833. * @hidden
  44834. * @override
  44835. * Override Camera._updateRigCameras
  44836. */
  44837. _updateRigCameras(): void;
  44838. /**
  44839. * Destroy the camera and release the current resources hold by it.
  44840. */
  44841. dispose(): void;
  44842. /**
  44843. * Gets the current object class name.
  44844. * @return the class name
  44845. */
  44846. getClassName(): string;
  44847. }
  44848. }
  44849. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44850. import { Behavior } from "babylonjs/Behaviors/behavior";
  44851. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44852. /**
  44853. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44854. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44855. */
  44856. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44857. /**
  44858. * Gets the name of the behavior.
  44859. */
  44860. get name(): string;
  44861. private _zoomStopsAnimation;
  44862. private _idleRotationSpeed;
  44863. private _idleRotationWaitTime;
  44864. private _idleRotationSpinupTime;
  44865. /**
  44866. * Sets the flag that indicates if user zooming should stop animation.
  44867. */
  44868. set zoomStopsAnimation(flag: boolean);
  44869. /**
  44870. * Gets the flag that indicates if user zooming should stop animation.
  44871. */
  44872. get zoomStopsAnimation(): boolean;
  44873. /**
  44874. * Sets the default speed at which the camera rotates around the model.
  44875. */
  44876. set idleRotationSpeed(speed: number);
  44877. /**
  44878. * Gets the default speed at which the camera rotates around the model.
  44879. */
  44880. get idleRotationSpeed(): number;
  44881. /**
  44882. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44883. */
  44884. set idleRotationWaitTime(time: number);
  44885. /**
  44886. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44887. */
  44888. get idleRotationWaitTime(): number;
  44889. /**
  44890. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44891. */
  44892. set idleRotationSpinupTime(time: number);
  44893. /**
  44894. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44895. */
  44896. get idleRotationSpinupTime(): number;
  44897. /**
  44898. * Gets a value indicating if the camera is currently rotating because of this behavior
  44899. */
  44900. get rotationInProgress(): boolean;
  44901. private _onPrePointerObservableObserver;
  44902. private _onAfterCheckInputsObserver;
  44903. private _attachedCamera;
  44904. private _isPointerDown;
  44905. private _lastFrameTime;
  44906. private _lastInteractionTime;
  44907. private _cameraRotationSpeed;
  44908. /**
  44909. * Initializes the behavior.
  44910. */
  44911. init(): void;
  44912. /**
  44913. * Attaches the behavior to its arc rotate camera.
  44914. * @param camera Defines the camera to attach the behavior to
  44915. */
  44916. attach(camera: ArcRotateCamera): void;
  44917. /**
  44918. * Detaches the behavior from its current arc rotate camera.
  44919. */
  44920. detach(): void;
  44921. /**
  44922. * Returns true if user is scrolling.
  44923. * @return true if user is scrolling.
  44924. */
  44925. private _userIsZooming;
  44926. private _lastFrameRadius;
  44927. private _shouldAnimationStopForInteraction;
  44928. /**
  44929. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44930. */
  44931. private _applyUserInteraction;
  44932. private _userIsMoving;
  44933. }
  44934. }
  44935. declare module "babylonjs/Behaviors/Cameras/index" {
  44936. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44937. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44938. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44939. }
  44940. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44941. import { Mesh } from "babylonjs/Meshes/mesh";
  44942. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44943. import { Behavior } from "babylonjs/Behaviors/behavior";
  44944. /**
  44945. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44946. */
  44947. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44948. private ui;
  44949. /**
  44950. * The name of the behavior
  44951. */
  44952. name: string;
  44953. /**
  44954. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44955. */
  44956. distanceAwayFromFace: number;
  44957. /**
  44958. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44959. */
  44960. distanceAwayFromBottomOfFace: number;
  44961. private _faceVectors;
  44962. private _target;
  44963. private _scene;
  44964. private _onRenderObserver;
  44965. private _tmpMatrix;
  44966. private _tmpVector;
  44967. /**
  44968. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44969. * @param ui The transform node that should be attched to the mesh
  44970. */
  44971. constructor(ui: TransformNode);
  44972. /**
  44973. * Initializes the behavior
  44974. */
  44975. init(): void;
  44976. private _closestFace;
  44977. private _zeroVector;
  44978. private _lookAtTmpMatrix;
  44979. private _lookAtToRef;
  44980. /**
  44981. * Attaches the AttachToBoxBehavior to the passed in mesh
  44982. * @param target The mesh that the specified node will be attached to
  44983. */
  44984. attach(target: Mesh): void;
  44985. /**
  44986. * Detaches the behavior from the mesh
  44987. */
  44988. detach(): void;
  44989. }
  44990. }
  44991. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44992. import { Behavior } from "babylonjs/Behaviors/behavior";
  44993. import { Mesh } from "babylonjs/Meshes/mesh";
  44994. /**
  44995. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44996. */
  44997. export class FadeInOutBehavior implements Behavior<Mesh> {
  44998. /**
  44999. * Time in milliseconds to delay before fading in (Default: 0)
  45000. */
  45001. delay: number;
  45002. /**
  45003. * Time in milliseconds for the mesh to fade in (Default: 300)
  45004. */
  45005. fadeInTime: number;
  45006. private _millisecondsPerFrame;
  45007. private _hovered;
  45008. private _hoverValue;
  45009. private _ownerNode;
  45010. /**
  45011. * Instatiates the FadeInOutBehavior
  45012. */
  45013. constructor();
  45014. /**
  45015. * The name of the behavior
  45016. */
  45017. get name(): string;
  45018. /**
  45019. * Initializes the behavior
  45020. */
  45021. init(): void;
  45022. /**
  45023. * Attaches the fade behavior on the passed in mesh
  45024. * @param ownerNode The mesh that will be faded in/out once attached
  45025. */
  45026. attach(ownerNode: Mesh): void;
  45027. /**
  45028. * Detaches the behavior from the mesh
  45029. */
  45030. detach(): void;
  45031. /**
  45032. * Triggers the mesh to begin fading in or out
  45033. * @param value if the object should fade in or out (true to fade in)
  45034. */
  45035. fadeIn(value: boolean): void;
  45036. private _update;
  45037. private _setAllVisibility;
  45038. }
  45039. }
  45040. declare module "babylonjs/Misc/pivotTools" {
  45041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45042. /**
  45043. * Class containing a set of static utilities functions for managing Pivots
  45044. * @hidden
  45045. */
  45046. export class PivotTools {
  45047. private static _PivotCached;
  45048. private static _OldPivotPoint;
  45049. private static _PivotTranslation;
  45050. private static _PivotTmpVector;
  45051. private static _PivotPostMultiplyPivotMatrix;
  45052. /** @hidden */
  45053. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  45054. /** @hidden */
  45055. static _RestorePivotPoint(mesh: AbstractMesh): void;
  45056. }
  45057. }
  45058. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  45059. import { Scene } from "babylonjs/scene";
  45060. import { Vector4 } from "babylonjs/Maths/math.vector";
  45061. import { Mesh } from "babylonjs/Meshes/mesh";
  45062. import { Nullable } from "babylonjs/types";
  45063. import { Plane } from "babylonjs/Maths/math.plane";
  45064. /**
  45065. * Class containing static functions to help procedurally build meshes
  45066. */
  45067. export class PlaneBuilder {
  45068. /**
  45069. * Creates a plane mesh
  45070. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  45071. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  45072. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  45073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45074. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45076. * @param name defines the name of the mesh
  45077. * @param options defines the options used to create the mesh
  45078. * @param scene defines the hosting scene
  45079. * @returns the plane mesh
  45080. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  45081. */
  45082. static CreatePlane(name: string, options: {
  45083. size?: number;
  45084. width?: number;
  45085. height?: number;
  45086. sideOrientation?: number;
  45087. frontUVs?: Vector4;
  45088. backUVs?: Vector4;
  45089. updatable?: boolean;
  45090. sourcePlane?: Plane;
  45091. }, scene?: Nullable<Scene>): Mesh;
  45092. }
  45093. }
  45094. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  45095. import { Behavior } from "babylonjs/Behaviors/behavior";
  45096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45097. import { Observable } from "babylonjs/Misc/observable";
  45098. import { Vector3 } from "babylonjs/Maths/math.vector";
  45099. import { Ray } from "babylonjs/Culling/ray";
  45100. import "babylonjs/Meshes/Builders/planeBuilder";
  45101. /**
  45102. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  45103. */
  45104. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  45105. private static _AnyMouseID;
  45106. /**
  45107. * Abstract mesh the behavior is set on
  45108. */
  45109. attachedNode: AbstractMesh;
  45110. private _dragPlane;
  45111. private _scene;
  45112. private _pointerObserver;
  45113. private _beforeRenderObserver;
  45114. private static _planeScene;
  45115. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  45116. /**
  45117. * 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)
  45118. */
  45119. maxDragAngle: number;
  45120. /**
  45121. * @hidden
  45122. */
  45123. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  45124. /**
  45125. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45126. */
  45127. currentDraggingPointerID: number;
  45128. /**
  45129. * The last position where the pointer hit the drag plane in world space
  45130. */
  45131. lastDragPosition: Vector3;
  45132. /**
  45133. * If the behavior is currently in a dragging state
  45134. */
  45135. dragging: boolean;
  45136. /**
  45137. * 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)
  45138. */
  45139. dragDeltaRatio: number;
  45140. /**
  45141. * If the drag plane orientation should be updated during the dragging (Default: true)
  45142. */
  45143. updateDragPlane: boolean;
  45144. private _debugMode;
  45145. private _moving;
  45146. /**
  45147. * Fires each time the attached mesh is dragged with the pointer
  45148. * * delta between last drag position and current drag position in world space
  45149. * * dragDistance along the drag axis
  45150. * * dragPlaneNormal normal of the current drag plane used during the drag
  45151. * * dragPlanePoint in world space where the drag intersects the drag plane
  45152. */
  45153. onDragObservable: Observable<{
  45154. delta: Vector3;
  45155. dragPlanePoint: Vector3;
  45156. dragPlaneNormal: Vector3;
  45157. dragDistance: number;
  45158. pointerId: number;
  45159. }>;
  45160. /**
  45161. * Fires each time a drag begins (eg. mouse down on mesh)
  45162. */
  45163. onDragStartObservable: Observable<{
  45164. dragPlanePoint: Vector3;
  45165. pointerId: number;
  45166. }>;
  45167. /**
  45168. * Fires each time a drag ends (eg. mouse release after drag)
  45169. */
  45170. onDragEndObservable: Observable<{
  45171. dragPlanePoint: Vector3;
  45172. pointerId: number;
  45173. }>;
  45174. /**
  45175. * If the attached mesh should be moved when dragged
  45176. */
  45177. moveAttached: boolean;
  45178. /**
  45179. * If the drag behavior will react to drag events (Default: true)
  45180. */
  45181. enabled: boolean;
  45182. /**
  45183. * If pointer events should start and release the drag (Default: true)
  45184. */
  45185. startAndReleaseDragOnPointerEvents: boolean;
  45186. /**
  45187. * If camera controls should be detached during the drag
  45188. */
  45189. detachCameraControls: boolean;
  45190. /**
  45191. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  45192. */
  45193. useObjectOrientationForDragging: boolean;
  45194. private _options;
  45195. /**
  45196. * Gets the options used by the behavior
  45197. */
  45198. get options(): {
  45199. dragAxis?: Vector3;
  45200. dragPlaneNormal?: Vector3;
  45201. };
  45202. /**
  45203. * Sets the options used by the behavior
  45204. */
  45205. set options(options: {
  45206. dragAxis?: Vector3;
  45207. dragPlaneNormal?: Vector3;
  45208. });
  45209. /**
  45210. * Creates a pointer drag behavior that can be attached to a mesh
  45211. * @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)
  45212. */
  45213. constructor(options?: {
  45214. dragAxis?: Vector3;
  45215. dragPlaneNormal?: Vector3;
  45216. });
  45217. /**
  45218. * Predicate to determine if it is valid to move the object to a new position when it is moved
  45219. */
  45220. validateDrag: (targetPosition: Vector3) => boolean;
  45221. /**
  45222. * The name of the behavior
  45223. */
  45224. get name(): string;
  45225. /**
  45226. * Initializes the behavior
  45227. */
  45228. init(): void;
  45229. private _tmpVector;
  45230. private _alternatePickedPoint;
  45231. private _worldDragAxis;
  45232. private _targetPosition;
  45233. private _attachedElement;
  45234. /**
  45235. * Attaches the drag behavior the passed in mesh
  45236. * @param ownerNode The mesh that will be dragged around once attached
  45237. * @param predicate Predicate to use for pick filtering
  45238. */
  45239. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  45240. /**
  45241. * Force relase the drag action by code.
  45242. */
  45243. releaseDrag(): void;
  45244. private _startDragRay;
  45245. private _lastPointerRay;
  45246. /**
  45247. * Simulates the start of a pointer drag event on the behavior
  45248. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45249. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45250. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45251. */
  45252. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45253. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45254. private _dragDelta;
  45255. protected _moveDrag(ray: Ray): void;
  45256. private _pickWithRayOnDragPlane;
  45257. private _pointA;
  45258. private _pointC;
  45259. private _localAxis;
  45260. private _lookAt;
  45261. private _updateDragPlanePosition;
  45262. /**
  45263. * Detaches the behavior from the mesh
  45264. */
  45265. detach(): void;
  45266. }
  45267. }
  45268. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45269. import { Mesh } from "babylonjs/Meshes/mesh";
  45270. import { Behavior } from "babylonjs/Behaviors/behavior";
  45271. /**
  45272. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45273. */
  45274. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45275. private _dragBehaviorA;
  45276. private _dragBehaviorB;
  45277. private _startDistance;
  45278. private _initialScale;
  45279. private _targetScale;
  45280. private _ownerNode;
  45281. private _sceneRenderObserver;
  45282. /**
  45283. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45284. */
  45285. constructor();
  45286. /**
  45287. * The name of the behavior
  45288. */
  45289. get name(): string;
  45290. /**
  45291. * Initializes the behavior
  45292. */
  45293. init(): void;
  45294. private _getCurrentDistance;
  45295. /**
  45296. * Attaches the scale behavior the passed in mesh
  45297. * @param ownerNode The mesh that will be scaled around once attached
  45298. */
  45299. attach(ownerNode: Mesh): void;
  45300. /**
  45301. * Detaches the behavior from the mesh
  45302. */
  45303. detach(): void;
  45304. }
  45305. }
  45306. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45307. import { Behavior } from "babylonjs/Behaviors/behavior";
  45308. import { Mesh } from "babylonjs/Meshes/mesh";
  45309. import { Observable } from "babylonjs/Misc/observable";
  45310. /**
  45311. * 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
  45312. */
  45313. export class SixDofDragBehavior implements Behavior<Mesh> {
  45314. private static _virtualScene;
  45315. private _ownerNode;
  45316. private _sceneRenderObserver;
  45317. private _scene;
  45318. private _targetPosition;
  45319. private _virtualOriginMesh;
  45320. private _virtualDragMesh;
  45321. private _pointerObserver;
  45322. private _moving;
  45323. private _startingOrientation;
  45324. private _attachedElement;
  45325. /**
  45326. * 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)
  45327. */
  45328. private zDragFactor;
  45329. /**
  45330. * If the object should rotate to face the drag origin
  45331. */
  45332. rotateDraggedObject: boolean;
  45333. /**
  45334. * If the behavior is currently in a dragging state
  45335. */
  45336. dragging: boolean;
  45337. /**
  45338. * 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)
  45339. */
  45340. dragDeltaRatio: number;
  45341. /**
  45342. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45343. */
  45344. currentDraggingPointerID: number;
  45345. /**
  45346. * If camera controls should be detached during the drag
  45347. */
  45348. detachCameraControls: boolean;
  45349. /**
  45350. * Fires each time a drag starts
  45351. */
  45352. onDragStartObservable: Observable<{}>;
  45353. /**
  45354. * Fires each time a drag ends (eg. mouse release after drag)
  45355. */
  45356. onDragEndObservable: Observable<{}>;
  45357. /**
  45358. * 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
  45359. */
  45360. constructor();
  45361. /**
  45362. * The name of the behavior
  45363. */
  45364. get name(): string;
  45365. /**
  45366. * Initializes the behavior
  45367. */
  45368. init(): void;
  45369. /**
  45370. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45371. */
  45372. private get _pointerCamera();
  45373. /**
  45374. * Attaches the scale behavior the passed in mesh
  45375. * @param ownerNode The mesh that will be scaled around once attached
  45376. */
  45377. attach(ownerNode: Mesh): void;
  45378. /**
  45379. * Detaches the behavior from the mesh
  45380. */
  45381. detach(): void;
  45382. }
  45383. }
  45384. declare module "babylonjs/Behaviors/Meshes/index" {
  45385. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45386. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45387. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45388. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45389. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45390. }
  45391. declare module "babylonjs/Behaviors/index" {
  45392. export * from "babylonjs/Behaviors/behavior";
  45393. export * from "babylonjs/Behaviors/Cameras/index";
  45394. export * from "babylonjs/Behaviors/Meshes/index";
  45395. }
  45396. declare module "babylonjs/Bones/boneIKController" {
  45397. import { Bone } from "babylonjs/Bones/bone";
  45398. import { Vector3 } from "babylonjs/Maths/math.vector";
  45399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45400. import { Nullable } from "babylonjs/types";
  45401. /**
  45402. * Class used to apply inverse kinematics to bones
  45403. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45404. */
  45405. export class BoneIKController {
  45406. private static _tmpVecs;
  45407. private static _tmpQuat;
  45408. private static _tmpMats;
  45409. /**
  45410. * Gets or sets the target mesh
  45411. */
  45412. targetMesh: AbstractMesh;
  45413. /** Gets or sets the mesh used as pole */
  45414. poleTargetMesh: AbstractMesh;
  45415. /**
  45416. * Gets or sets the bone used as pole
  45417. */
  45418. poleTargetBone: Nullable<Bone>;
  45419. /**
  45420. * Gets or sets the target position
  45421. */
  45422. targetPosition: Vector3;
  45423. /**
  45424. * Gets or sets the pole target position
  45425. */
  45426. poleTargetPosition: Vector3;
  45427. /**
  45428. * Gets or sets the pole target local offset
  45429. */
  45430. poleTargetLocalOffset: Vector3;
  45431. /**
  45432. * Gets or sets the pole angle
  45433. */
  45434. poleAngle: number;
  45435. /**
  45436. * Gets or sets the mesh associated with the controller
  45437. */
  45438. mesh: AbstractMesh;
  45439. /**
  45440. * 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)
  45441. */
  45442. slerpAmount: number;
  45443. private _bone1Quat;
  45444. private _bone1Mat;
  45445. private _bone2Ang;
  45446. private _bone1;
  45447. private _bone2;
  45448. private _bone1Length;
  45449. private _bone2Length;
  45450. private _maxAngle;
  45451. private _maxReach;
  45452. private _rightHandedSystem;
  45453. private _bendAxis;
  45454. private _slerping;
  45455. private _adjustRoll;
  45456. /**
  45457. * Gets or sets maximum allowed angle
  45458. */
  45459. get maxAngle(): number;
  45460. set maxAngle(value: number);
  45461. /**
  45462. * Creates a new BoneIKController
  45463. * @param mesh defines the mesh to control
  45464. * @param bone defines the bone to control
  45465. * @param options defines options to set up the controller
  45466. */
  45467. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45468. targetMesh?: AbstractMesh;
  45469. poleTargetMesh?: AbstractMesh;
  45470. poleTargetBone?: Bone;
  45471. poleTargetLocalOffset?: Vector3;
  45472. poleAngle?: number;
  45473. bendAxis?: Vector3;
  45474. maxAngle?: number;
  45475. slerpAmount?: number;
  45476. });
  45477. private _setMaxAngle;
  45478. /**
  45479. * Force the controller to update the bones
  45480. */
  45481. update(): void;
  45482. }
  45483. }
  45484. declare module "babylonjs/Bones/boneLookController" {
  45485. import { Vector3 } from "babylonjs/Maths/math.vector";
  45486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45487. import { Bone } from "babylonjs/Bones/bone";
  45488. import { Space } from "babylonjs/Maths/math.axis";
  45489. /**
  45490. * Class used to make a bone look toward a point in space
  45491. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45492. */
  45493. export class BoneLookController {
  45494. private static _tmpVecs;
  45495. private static _tmpQuat;
  45496. private static _tmpMats;
  45497. /**
  45498. * The target Vector3 that the bone will look at
  45499. */
  45500. target: Vector3;
  45501. /**
  45502. * The mesh that the bone is attached to
  45503. */
  45504. mesh: AbstractMesh;
  45505. /**
  45506. * The bone that will be looking to the target
  45507. */
  45508. bone: Bone;
  45509. /**
  45510. * The up axis of the coordinate system that is used when the bone is rotated
  45511. */
  45512. upAxis: Vector3;
  45513. /**
  45514. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45515. */
  45516. upAxisSpace: Space;
  45517. /**
  45518. * Used to make an adjustment to the yaw of the bone
  45519. */
  45520. adjustYaw: number;
  45521. /**
  45522. * Used to make an adjustment to the pitch of the bone
  45523. */
  45524. adjustPitch: number;
  45525. /**
  45526. * Used to make an adjustment to the roll of the bone
  45527. */
  45528. adjustRoll: number;
  45529. /**
  45530. * 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)
  45531. */
  45532. slerpAmount: number;
  45533. private _minYaw;
  45534. private _maxYaw;
  45535. private _minPitch;
  45536. private _maxPitch;
  45537. private _minYawSin;
  45538. private _minYawCos;
  45539. private _maxYawSin;
  45540. private _maxYawCos;
  45541. private _midYawConstraint;
  45542. private _minPitchTan;
  45543. private _maxPitchTan;
  45544. private _boneQuat;
  45545. private _slerping;
  45546. private _transformYawPitch;
  45547. private _transformYawPitchInv;
  45548. private _firstFrameSkipped;
  45549. private _yawRange;
  45550. private _fowardAxis;
  45551. /**
  45552. * Gets or sets the minimum yaw angle that the bone can look to
  45553. */
  45554. get minYaw(): number;
  45555. set minYaw(value: number);
  45556. /**
  45557. * Gets or sets the maximum yaw angle that the bone can look to
  45558. */
  45559. get maxYaw(): number;
  45560. set maxYaw(value: number);
  45561. /**
  45562. * Gets or sets the minimum pitch angle that the bone can look to
  45563. */
  45564. get minPitch(): number;
  45565. set minPitch(value: number);
  45566. /**
  45567. * Gets or sets the maximum pitch angle that the bone can look to
  45568. */
  45569. get maxPitch(): number;
  45570. set maxPitch(value: number);
  45571. /**
  45572. * Create a BoneLookController
  45573. * @param mesh the mesh that the bone belongs to
  45574. * @param bone the bone that will be looking to the target
  45575. * @param target the target Vector3 to look at
  45576. * @param options optional settings:
  45577. * * maxYaw: the maximum angle the bone will yaw to
  45578. * * minYaw: the minimum angle the bone will yaw to
  45579. * * maxPitch: the maximum angle the bone will pitch to
  45580. * * minPitch: the minimum angle the bone will yaw to
  45581. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45582. * * upAxis: the up axis of the coordinate system
  45583. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45584. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45585. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45586. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45587. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45588. * * adjustRoll: used to make an adjustment to the roll of the bone
  45589. **/
  45590. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45591. maxYaw?: number;
  45592. minYaw?: number;
  45593. maxPitch?: number;
  45594. minPitch?: number;
  45595. slerpAmount?: number;
  45596. upAxis?: Vector3;
  45597. upAxisSpace?: Space;
  45598. yawAxis?: Vector3;
  45599. pitchAxis?: Vector3;
  45600. adjustYaw?: number;
  45601. adjustPitch?: number;
  45602. adjustRoll?: number;
  45603. });
  45604. /**
  45605. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45606. */
  45607. update(): void;
  45608. private _getAngleDiff;
  45609. private _getAngleBetween;
  45610. private _isAngleBetween;
  45611. }
  45612. }
  45613. declare module "babylonjs/Bones/index" {
  45614. export * from "babylonjs/Bones/bone";
  45615. export * from "babylonjs/Bones/boneIKController";
  45616. export * from "babylonjs/Bones/boneLookController";
  45617. export * from "babylonjs/Bones/skeleton";
  45618. }
  45619. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45620. import { Nullable } from "babylonjs/types";
  45621. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45622. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45623. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45624. /**
  45625. * Manage the gamepad inputs to control an arc rotate camera.
  45626. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45627. */
  45628. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45629. /**
  45630. * Defines the camera the input is attached to.
  45631. */
  45632. camera: ArcRotateCamera;
  45633. /**
  45634. * Defines the gamepad the input is gathering event from.
  45635. */
  45636. gamepad: Nullable<Gamepad>;
  45637. /**
  45638. * Defines the gamepad rotation sensiblity.
  45639. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45640. */
  45641. gamepadRotationSensibility: number;
  45642. /**
  45643. * Defines the gamepad move sensiblity.
  45644. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45645. */
  45646. gamepadMoveSensibility: number;
  45647. private _yAxisScale;
  45648. /**
  45649. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45650. */
  45651. get invertYAxis(): boolean;
  45652. set invertYAxis(value: boolean);
  45653. private _onGamepadConnectedObserver;
  45654. private _onGamepadDisconnectedObserver;
  45655. /**
  45656. * Attach the input controls to a specific dom element to get the input from.
  45657. * @param element Defines the element the controls should be listened from
  45658. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45659. */
  45660. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45661. /**
  45662. * Detach the current controls from the specified dom element.
  45663. * @param element Defines the element to stop listening the inputs from
  45664. */
  45665. detachControl(element: Nullable<HTMLElement>): void;
  45666. /**
  45667. * Update the current camera state depending on the inputs that have been used this frame.
  45668. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45669. */
  45670. checkInputs(): void;
  45671. /**
  45672. * Gets the class name of the current intput.
  45673. * @returns the class name
  45674. */
  45675. getClassName(): string;
  45676. /**
  45677. * Get the friendly name associated with the input class.
  45678. * @returns the input friendly name
  45679. */
  45680. getSimpleName(): string;
  45681. }
  45682. }
  45683. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45684. import { Nullable } from "babylonjs/types";
  45685. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45686. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45687. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45688. interface ArcRotateCameraInputsManager {
  45689. /**
  45690. * Add orientation input support to the input manager.
  45691. * @returns the current input manager
  45692. */
  45693. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45694. }
  45695. }
  45696. /**
  45697. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45698. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45699. */
  45700. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45701. /**
  45702. * Defines the camera the input is attached to.
  45703. */
  45704. camera: ArcRotateCamera;
  45705. /**
  45706. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45707. */
  45708. alphaCorrection: number;
  45709. /**
  45710. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45711. */
  45712. gammaCorrection: number;
  45713. private _alpha;
  45714. private _gamma;
  45715. private _dirty;
  45716. private _deviceOrientationHandler;
  45717. /**
  45718. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45719. */
  45720. constructor();
  45721. /**
  45722. * Attach the input controls to a specific dom element to get the input from.
  45723. * @param element Defines the element the controls should be listened from
  45724. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45725. */
  45726. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45727. /** @hidden */
  45728. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45729. /**
  45730. * Update the current camera state depending on the inputs that have been used this frame.
  45731. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45732. */
  45733. checkInputs(): void;
  45734. /**
  45735. * Detach the current controls from the specified dom element.
  45736. * @param element Defines the element to stop listening the inputs from
  45737. */
  45738. detachControl(element: Nullable<HTMLElement>): void;
  45739. /**
  45740. * Gets the class name of the current intput.
  45741. * @returns the class name
  45742. */
  45743. getClassName(): string;
  45744. /**
  45745. * Get the friendly name associated with the input class.
  45746. * @returns the input friendly name
  45747. */
  45748. getSimpleName(): string;
  45749. }
  45750. }
  45751. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45752. import { Nullable } from "babylonjs/types";
  45753. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45754. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45755. /**
  45756. * Listen to mouse events to control the camera.
  45757. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45758. */
  45759. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45760. /**
  45761. * Defines the camera the input is attached to.
  45762. */
  45763. camera: FlyCamera;
  45764. /**
  45765. * Defines if touch is enabled. (Default is true.)
  45766. */
  45767. touchEnabled: boolean;
  45768. /**
  45769. * Defines the buttons associated with the input to handle camera rotation.
  45770. */
  45771. buttons: number[];
  45772. /**
  45773. * Assign buttons for Yaw control.
  45774. */
  45775. buttonsYaw: number[];
  45776. /**
  45777. * Assign buttons for Pitch control.
  45778. */
  45779. buttonsPitch: number[];
  45780. /**
  45781. * Assign buttons for Roll control.
  45782. */
  45783. buttonsRoll: number[];
  45784. /**
  45785. * Detect if any button is being pressed while mouse is moved.
  45786. * -1 = Mouse locked.
  45787. * 0 = Left button.
  45788. * 1 = Middle Button.
  45789. * 2 = Right Button.
  45790. */
  45791. activeButton: number;
  45792. /**
  45793. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45794. * Higher values reduce its sensitivity.
  45795. */
  45796. angularSensibility: number;
  45797. private _mousemoveCallback;
  45798. private _observer;
  45799. private _rollObserver;
  45800. private previousPosition;
  45801. private noPreventDefault;
  45802. private element;
  45803. /**
  45804. * Listen to mouse events to control the camera.
  45805. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45806. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45807. */
  45808. constructor(touchEnabled?: boolean);
  45809. /**
  45810. * Attach the mouse control to the HTML DOM element.
  45811. * @param element Defines the element that listens to the input events.
  45812. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45813. */
  45814. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45815. /**
  45816. * Detach the current controls from the specified dom element.
  45817. * @param element Defines the element to stop listening the inputs from
  45818. */
  45819. detachControl(element: Nullable<HTMLElement>): void;
  45820. /**
  45821. * Gets the class name of the current input.
  45822. * @returns the class name.
  45823. */
  45824. getClassName(): string;
  45825. /**
  45826. * Get the friendly name associated with the input class.
  45827. * @returns the input's friendly name.
  45828. */
  45829. getSimpleName(): string;
  45830. private _pointerInput;
  45831. private _onMouseMove;
  45832. /**
  45833. * Rotate camera by mouse offset.
  45834. */
  45835. private rotateCamera;
  45836. }
  45837. }
  45838. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45839. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45840. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45841. /**
  45842. * Default Inputs manager for the FlyCamera.
  45843. * It groups all the default supported inputs for ease of use.
  45844. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45845. */
  45846. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45847. /**
  45848. * Instantiates a new FlyCameraInputsManager.
  45849. * @param camera Defines the camera the inputs belong to.
  45850. */
  45851. constructor(camera: FlyCamera);
  45852. /**
  45853. * Add keyboard input support to the input manager.
  45854. * @returns the new FlyCameraKeyboardMoveInput().
  45855. */
  45856. addKeyboard(): FlyCameraInputsManager;
  45857. /**
  45858. * Add mouse input support to the input manager.
  45859. * @param touchEnabled Enable touch screen support.
  45860. * @returns the new FlyCameraMouseInput().
  45861. */
  45862. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45863. }
  45864. }
  45865. declare module "babylonjs/Cameras/flyCamera" {
  45866. import { Scene } from "babylonjs/scene";
  45867. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45869. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45870. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45871. /**
  45872. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45873. * such as in a 3D Space Shooter or a Flight Simulator.
  45874. */
  45875. export class FlyCamera extends TargetCamera {
  45876. /**
  45877. * Define the collision ellipsoid of the camera.
  45878. * This is helpful for simulating a camera body, like a player's body.
  45879. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45880. */
  45881. ellipsoid: Vector3;
  45882. /**
  45883. * Define an offset for the position of the ellipsoid around the camera.
  45884. * This can be helpful if the camera is attached away from the player's body center,
  45885. * such as at its head.
  45886. */
  45887. ellipsoidOffset: Vector3;
  45888. /**
  45889. * Enable or disable collisions of the camera with the rest of the scene objects.
  45890. */
  45891. checkCollisions: boolean;
  45892. /**
  45893. * Enable or disable gravity on the camera.
  45894. */
  45895. applyGravity: boolean;
  45896. /**
  45897. * Define the current direction the camera is moving to.
  45898. */
  45899. cameraDirection: Vector3;
  45900. /**
  45901. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45902. * This overrides and empties cameraRotation.
  45903. */
  45904. rotationQuaternion: Quaternion;
  45905. /**
  45906. * Track Roll to maintain the wanted Rolling when looking around.
  45907. */
  45908. _trackRoll: number;
  45909. /**
  45910. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45911. */
  45912. rollCorrect: number;
  45913. /**
  45914. * Mimic a banked turn, Rolling the camera when Yawing.
  45915. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45916. */
  45917. bankedTurn: boolean;
  45918. /**
  45919. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45920. */
  45921. bankedTurnLimit: number;
  45922. /**
  45923. * Value of 0 disables the banked Roll.
  45924. * Value of 1 is equal to the Yaw angle in radians.
  45925. */
  45926. bankedTurnMultiplier: number;
  45927. /**
  45928. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45929. */
  45930. inputs: FlyCameraInputsManager;
  45931. /**
  45932. * Gets the input sensibility for mouse input.
  45933. * Higher values reduce sensitivity.
  45934. */
  45935. get angularSensibility(): number;
  45936. /**
  45937. * Sets the input sensibility for a mouse input.
  45938. * Higher values reduce sensitivity.
  45939. */
  45940. set angularSensibility(value: number);
  45941. /**
  45942. * Get the keys for camera movement forward.
  45943. */
  45944. get keysForward(): number[];
  45945. /**
  45946. * Set the keys for camera movement forward.
  45947. */
  45948. set keysForward(value: number[]);
  45949. /**
  45950. * Get the keys for camera movement backward.
  45951. */
  45952. get keysBackward(): number[];
  45953. set keysBackward(value: number[]);
  45954. /**
  45955. * Get the keys for camera movement up.
  45956. */
  45957. get keysUp(): number[];
  45958. /**
  45959. * Set the keys for camera movement up.
  45960. */
  45961. set keysUp(value: number[]);
  45962. /**
  45963. * Get the keys for camera movement down.
  45964. */
  45965. get keysDown(): number[];
  45966. /**
  45967. * Set the keys for camera movement down.
  45968. */
  45969. set keysDown(value: number[]);
  45970. /**
  45971. * Get the keys for camera movement left.
  45972. */
  45973. get keysLeft(): number[];
  45974. /**
  45975. * Set the keys for camera movement left.
  45976. */
  45977. set keysLeft(value: number[]);
  45978. /**
  45979. * Set the keys for camera movement right.
  45980. */
  45981. get keysRight(): number[];
  45982. /**
  45983. * Set the keys for camera movement right.
  45984. */
  45985. set keysRight(value: number[]);
  45986. /**
  45987. * Event raised when the camera collides with a mesh in the scene.
  45988. */
  45989. onCollide: (collidedMesh: AbstractMesh) => void;
  45990. private _collider;
  45991. private _needMoveForGravity;
  45992. private _oldPosition;
  45993. private _diffPosition;
  45994. private _newPosition;
  45995. /** @hidden */
  45996. _localDirection: Vector3;
  45997. /** @hidden */
  45998. _transformedDirection: Vector3;
  45999. /**
  46000. * Instantiates a FlyCamera.
  46001. * This is a flying camera, designed for 3D movement and rotation in all directions,
  46002. * such as in a 3D Space Shooter or a Flight Simulator.
  46003. * @param name Define the name of the camera in the scene.
  46004. * @param position Define the starting position of the camera in the scene.
  46005. * @param scene Define the scene the camera belongs to.
  46006. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  46007. */
  46008. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46009. /**
  46010. * Attach a control to the HTML DOM element.
  46011. * @param element Defines the element that listens to the input events.
  46012. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  46013. */
  46014. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46015. /**
  46016. * Detach a control from the HTML DOM element.
  46017. * The camera will stop reacting to that input.
  46018. * @param element Defines the element that listens to the input events.
  46019. */
  46020. detachControl(element: HTMLElement): void;
  46021. private _collisionMask;
  46022. /**
  46023. * Get the mask that the camera ignores in collision events.
  46024. */
  46025. get collisionMask(): number;
  46026. /**
  46027. * Set the mask that the camera ignores in collision events.
  46028. */
  46029. set collisionMask(mask: number);
  46030. /** @hidden */
  46031. _collideWithWorld(displacement: Vector3): void;
  46032. /** @hidden */
  46033. private _onCollisionPositionChange;
  46034. /** @hidden */
  46035. _checkInputs(): void;
  46036. /** @hidden */
  46037. _decideIfNeedsToMove(): boolean;
  46038. /** @hidden */
  46039. _updatePosition(): void;
  46040. /**
  46041. * Restore the Roll to its target value at the rate specified.
  46042. * @param rate - Higher means slower restoring.
  46043. * @hidden
  46044. */
  46045. restoreRoll(rate: number): void;
  46046. /**
  46047. * Destroy the camera and release the current resources held by it.
  46048. */
  46049. dispose(): void;
  46050. /**
  46051. * Get the current object class name.
  46052. * @returns the class name.
  46053. */
  46054. getClassName(): string;
  46055. }
  46056. }
  46057. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  46058. import { Nullable } from "babylonjs/types";
  46059. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46060. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  46061. /**
  46062. * Listen to keyboard events to control the camera.
  46063. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46064. */
  46065. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  46066. /**
  46067. * Defines the camera the input is attached to.
  46068. */
  46069. camera: FlyCamera;
  46070. /**
  46071. * The list of keyboard keys used to control the forward move of the camera.
  46072. */
  46073. keysForward: number[];
  46074. /**
  46075. * The list of keyboard keys used to control the backward move of the camera.
  46076. */
  46077. keysBackward: number[];
  46078. /**
  46079. * The list of keyboard keys used to control the forward move of the camera.
  46080. */
  46081. keysUp: number[];
  46082. /**
  46083. * The list of keyboard keys used to control the backward move of the camera.
  46084. */
  46085. keysDown: number[];
  46086. /**
  46087. * The list of keyboard keys used to control the right strafe move of the camera.
  46088. */
  46089. keysRight: number[];
  46090. /**
  46091. * The list of keyboard keys used to control the left strafe move of the camera.
  46092. */
  46093. keysLeft: number[];
  46094. private _keys;
  46095. private _onCanvasBlurObserver;
  46096. private _onKeyboardObserver;
  46097. private _engine;
  46098. private _scene;
  46099. /**
  46100. * Attach the input controls to a specific dom element to get the input from.
  46101. * @param element Defines the element the controls should be listened from
  46102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46103. */
  46104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46105. /**
  46106. * Detach the current controls from the specified dom element.
  46107. * @param element Defines the element to stop listening the inputs from
  46108. */
  46109. detachControl(element: Nullable<HTMLElement>): void;
  46110. /**
  46111. * Gets the class name of the current intput.
  46112. * @returns the class name
  46113. */
  46114. getClassName(): string;
  46115. /** @hidden */
  46116. _onLostFocus(e: FocusEvent): void;
  46117. /**
  46118. * Get the friendly name associated with the input class.
  46119. * @returns the input friendly name
  46120. */
  46121. getSimpleName(): string;
  46122. /**
  46123. * Update the current camera state depending on the inputs that have been used this frame.
  46124. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46125. */
  46126. checkInputs(): void;
  46127. }
  46128. }
  46129. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  46130. import { Nullable } from "babylonjs/types";
  46131. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46132. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46133. /**
  46134. * Manage the mouse wheel inputs to control a follow camera.
  46135. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46136. */
  46137. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  46138. /**
  46139. * Defines the camera the input is attached to.
  46140. */
  46141. camera: FollowCamera;
  46142. /**
  46143. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  46144. */
  46145. axisControlRadius: boolean;
  46146. /**
  46147. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  46148. */
  46149. axisControlHeight: boolean;
  46150. /**
  46151. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  46152. */
  46153. axisControlRotation: boolean;
  46154. /**
  46155. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  46156. * relation to mouseWheel events.
  46157. */
  46158. wheelPrecision: number;
  46159. /**
  46160. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46161. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46162. */
  46163. wheelDeltaPercentage: number;
  46164. private _wheel;
  46165. private _observer;
  46166. /**
  46167. * Attach the input controls to a specific dom element to get the input from.
  46168. * @param element Defines the element the controls should be listened from
  46169. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46170. */
  46171. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46172. /**
  46173. * Detach the current controls from the specified dom element.
  46174. * @param element Defines the element to stop listening the inputs from
  46175. */
  46176. detachControl(element: Nullable<HTMLElement>): void;
  46177. /**
  46178. * Gets the class name of the current intput.
  46179. * @returns the class name
  46180. */
  46181. getClassName(): string;
  46182. /**
  46183. * Get the friendly name associated with the input class.
  46184. * @returns the input friendly name
  46185. */
  46186. getSimpleName(): string;
  46187. }
  46188. }
  46189. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  46190. import { Nullable } from "babylonjs/types";
  46191. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46192. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  46193. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  46194. /**
  46195. * Manage the pointers inputs to control an follow camera.
  46196. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46197. */
  46198. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  46199. /**
  46200. * Defines the camera the input is attached to.
  46201. */
  46202. camera: FollowCamera;
  46203. /**
  46204. * Gets the class name of the current input.
  46205. * @returns the class name
  46206. */
  46207. getClassName(): string;
  46208. /**
  46209. * Defines the pointer angular sensibility along the X axis or how fast is
  46210. * the camera rotating.
  46211. * A negative number will reverse the axis direction.
  46212. */
  46213. angularSensibilityX: number;
  46214. /**
  46215. * Defines the pointer angular sensibility along the Y axis or how fast is
  46216. * the camera rotating.
  46217. * A negative number will reverse the axis direction.
  46218. */
  46219. angularSensibilityY: number;
  46220. /**
  46221. * Defines the pointer pinch precision or how fast is the camera zooming.
  46222. * A negative number will reverse the axis direction.
  46223. */
  46224. pinchPrecision: number;
  46225. /**
  46226. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46227. * from 0.
  46228. * It defines the percentage of current camera.radius to use as delta when
  46229. * pinch zoom is used.
  46230. */
  46231. pinchDeltaPercentage: number;
  46232. /**
  46233. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  46234. */
  46235. axisXControlRadius: boolean;
  46236. /**
  46237. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  46238. */
  46239. axisXControlHeight: boolean;
  46240. /**
  46241. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  46242. */
  46243. axisXControlRotation: boolean;
  46244. /**
  46245. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46246. */
  46247. axisYControlRadius: boolean;
  46248. /**
  46249. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46250. */
  46251. axisYControlHeight: boolean;
  46252. /**
  46253. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46254. */
  46255. axisYControlRotation: boolean;
  46256. /**
  46257. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46258. */
  46259. axisPinchControlRadius: boolean;
  46260. /**
  46261. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46262. */
  46263. axisPinchControlHeight: boolean;
  46264. /**
  46265. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46266. */
  46267. axisPinchControlRotation: boolean;
  46268. /**
  46269. * Log error messages if basic misconfiguration has occurred.
  46270. */
  46271. warningEnable: boolean;
  46272. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46273. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46274. private _warningCounter;
  46275. private _warning;
  46276. }
  46277. }
  46278. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46279. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46280. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46281. /**
  46282. * Default Inputs manager for the FollowCamera.
  46283. * It groups all the default supported inputs for ease of use.
  46284. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46285. */
  46286. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46287. /**
  46288. * Instantiates a new FollowCameraInputsManager.
  46289. * @param camera Defines the camera the inputs belong to
  46290. */
  46291. constructor(camera: FollowCamera);
  46292. /**
  46293. * Add keyboard input support to the input manager.
  46294. * @returns the current input manager
  46295. */
  46296. addKeyboard(): FollowCameraInputsManager;
  46297. /**
  46298. * Add mouse wheel input support to the input manager.
  46299. * @returns the current input manager
  46300. */
  46301. addMouseWheel(): FollowCameraInputsManager;
  46302. /**
  46303. * Add pointers input support to the input manager.
  46304. * @returns the current input manager
  46305. */
  46306. addPointers(): FollowCameraInputsManager;
  46307. /**
  46308. * Add orientation input support to the input manager.
  46309. * @returns the current input manager
  46310. */
  46311. addVRDeviceOrientation(): FollowCameraInputsManager;
  46312. }
  46313. }
  46314. declare module "babylonjs/Cameras/followCamera" {
  46315. import { Nullable } from "babylonjs/types";
  46316. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46317. import { Scene } from "babylonjs/scene";
  46318. import { Vector3 } from "babylonjs/Maths/math.vector";
  46319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46320. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46321. /**
  46322. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46323. * an arc rotate version arcFollowCamera are available.
  46324. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46325. */
  46326. export class FollowCamera extends TargetCamera {
  46327. /**
  46328. * Distance the follow camera should follow an object at
  46329. */
  46330. radius: number;
  46331. /**
  46332. * Minimum allowed distance of the camera to the axis of rotation
  46333. * (The camera can not get closer).
  46334. * This can help limiting how the Camera is able to move in the scene.
  46335. */
  46336. lowerRadiusLimit: Nullable<number>;
  46337. /**
  46338. * Maximum allowed distance of the camera to the axis of rotation
  46339. * (The camera can not get further).
  46340. * This can help limiting how the Camera is able to move in the scene.
  46341. */
  46342. upperRadiusLimit: Nullable<number>;
  46343. /**
  46344. * Define a rotation offset between the camera and the object it follows
  46345. */
  46346. rotationOffset: number;
  46347. /**
  46348. * Minimum allowed angle to camera position relative to target object.
  46349. * This can help limiting how the Camera is able to move in the scene.
  46350. */
  46351. lowerRotationOffsetLimit: Nullable<number>;
  46352. /**
  46353. * Maximum allowed angle to camera position relative to target object.
  46354. * This can help limiting how the Camera is able to move in the scene.
  46355. */
  46356. upperRotationOffsetLimit: Nullable<number>;
  46357. /**
  46358. * Define a height offset between the camera and the object it follows.
  46359. * It can help following an object from the top (like a car chaing a plane)
  46360. */
  46361. heightOffset: number;
  46362. /**
  46363. * Minimum allowed height of camera position relative to target object.
  46364. * This can help limiting how the Camera is able to move in the scene.
  46365. */
  46366. lowerHeightOffsetLimit: Nullable<number>;
  46367. /**
  46368. * Maximum allowed height of camera position relative to target object.
  46369. * This can help limiting how the Camera is able to move in the scene.
  46370. */
  46371. upperHeightOffsetLimit: Nullable<number>;
  46372. /**
  46373. * Define how fast the camera can accelerate to follow it s target.
  46374. */
  46375. cameraAcceleration: number;
  46376. /**
  46377. * Define the speed limit of the camera following an object.
  46378. */
  46379. maxCameraSpeed: number;
  46380. /**
  46381. * Define the target of the camera.
  46382. */
  46383. lockedTarget: Nullable<AbstractMesh>;
  46384. /**
  46385. * Defines the input associated with the camera.
  46386. */
  46387. inputs: FollowCameraInputsManager;
  46388. /**
  46389. * Instantiates the follow camera.
  46390. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46391. * @param name Define the name of the camera in the scene
  46392. * @param position Define the position of the camera
  46393. * @param scene Define the scene the camera belong to
  46394. * @param lockedTarget Define the target of the camera
  46395. */
  46396. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46397. private _follow;
  46398. /**
  46399. * Attached controls to the current camera.
  46400. * @param element Defines the element the controls should be listened from
  46401. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46402. */
  46403. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46404. /**
  46405. * Detach the current controls from the camera.
  46406. * The camera will stop reacting to inputs.
  46407. * @param element Defines the element to stop listening the inputs from
  46408. */
  46409. detachControl(element: HTMLElement): void;
  46410. /** @hidden */
  46411. _checkInputs(): void;
  46412. private _checkLimits;
  46413. /**
  46414. * Gets the camera class name.
  46415. * @returns the class name
  46416. */
  46417. getClassName(): string;
  46418. }
  46419. /**
  46420. * Arc Rotate version of the follow camera.
  46421. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46422. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46423. */
  46424. export class ArcFollowCamera extends TargetCamera {
  46425. /** The longitudinal angle of the camera */
  46426. alpha: number;
  46427. /** The latitudinal angle of the camera */
  46428. beta: number;
  46429. /** The radius of the camera from its target */
  46430. radius: number;
  46431. private _cartesianCoordinates;
  46432. /** Define the camera target (the mesh it should follow) */
  46433. private _meshTarget;
  46434. /**
  46435. * Instantiates a new ArcFollowCamera
  46436. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46437. * @param name Define the name of the camera
  46438. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46439. * @param beta Define the rotation angle of the camera around the elevation axis
  46440. * @param radius Define the radius of the camera from its target point
  46441. * @param target Define the target of the camera
  46442. * @param scene Define the scene the camera belongs to
  46443. */
  46444. constructor(name: string,
  46445. /** The longitudinal angle of the camera */
  46446. alpha: number,
  46447. /** The latitudinal angle of the camera */
  46448. beta: number,
  46449. /** The radius of the camera from its target */
  46450. radius: number,
  46451. /** Define the camera target (the mesh it should follow) */
  46452. target: Nullable<AbstractMesh>, scene: Scene);
  46453. private _follow;
  46454. /** @hidden */
  46455. _checkInputs(): void;
  46456. /**
  46457. * Returns the class name of the object.
  46458. * It is mostly used internally for serialization purposes.
  46459. */
  46460. getClassName(): string;
  46461. }
  46462. }
  46463. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46464. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46465. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46466. import { Nullable } from "babylonjs/types";
  46467. /**
  46468. * Manage the keyboard inputs to control the movement of a follow camera.
  46469. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46470. */
  46471. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46472. /**
  46473. * Defines the camera the input is attached to.
  46474. */
  46475. camera: FollowCamera;
  46476. /**
  46477. * Defines the list of key codes associated with the up action (increase heightOffset)
  46478. */
  46479. keysHeightOffsetIncr: number[];
  46480. /**
  46481. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46482. */
  46483. keysHeightOffsetDecr: number[];
  46484. /**
  46485. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46486. */
  46487. keysHeightOffsetModifierAlt: boolean;
  46488. /**
  46489. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46490. */
  46491. keysHeightOffsetModifierCtrl: boolean;
  46492. /**
  46493. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46494. */
  46495. keysHeightOffsetModifierShift: boolean;
  46496. /**
  46497. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46498. */
  46499. keysRotationOffsetIncr: number[];
  46500. /**
  46501. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46502. */
  46503. keysRotationOffsetDecr: number[];
  46504. /**
  46505. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46506. */
  46507. keysRotationOffsetModifierAlt: boolean;
  46508. /**
  46509. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46510. */
  46511. keysRotationOffsetModifierCtrl: boolean;
  46512. /**
  46513. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46514. */
  46515. keysRotationOffsetModifierShift: boolean;
  46516. /**
  46517. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46518. */
  46519. keysRadiusIncr: number[];
  46520. /**
  46521. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46522. */
  46523. keysRadiusDecr: number[];
  46524. /**
  46525. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46526. */
  46527. keysRadiusModifierAlt: boolean;
  46528. /**
  46529. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46530. */
  46531. keysRadiusModifierCtrl: boolean;
  46532. /**
  46533. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46534. */
  46535. keysRadiusModifierShift: boolean;
  46536. /**
  46537. * Defines the rate of change of heightOffset.
  46538. */
  46539. heightSensibility: number;
  46540. /**
  46541. * Defines the rate of change of rotationOffset.
  46542. */
  46543. rotationSensibility: number;
  46544. /**
  46545. * Defines the rate of change of radius.
  46546. */
  46547. radiusSensibility: number;
  46548. private _keys;
  46549. private _ctrlPressed;
  46550. private _altPressed;
  46551. private _shiftPressed;
  46552. private _onCanvasBlurObserver;
  46553. private _onKeyboardObserver;
  46554. private _engine;
  46555. private _scene;
  46556. /**
  46557. * Attach the input controls to a specific dom element to get the input from.
  46558. * @param element Defines the element the controls should be listened from
  46559. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46560. */
  46561. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46562. /**
  46563. * Detach the current controls from the specified dom element.
  46564. * @param element Defines the element to stop listening the inputs from
  46565. */
  46566. detachControl(element: Nullable<HTMLElement>): void;
  46567. /**
  46568. * Update the current camera state depending on the inputs that have been used this frame.
  46569. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46570. */
  46571. checkInputs(): void;
  46572. /**
  46573. * Gets the class name of the current input.
  46574. * @returns the class name
  46575. */
  46576. getClassName(): string;
  46577. /**
  46578. * Get the friendly name associated with the input class.
  46579. * @returns the input friendly name
  46580. */
  46581. getSimpleName(): string;
  46582. /**
  46583. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46584. * allow modification of the heightOffset value.
  46585. */
  46586. private _modifierHeightOffset;
  46587. /**
  46588. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46589. * allow modification of the rotationOffset value.
  46590. */
  46591. private _modifierRotationOffset;
  46592. /**
  46593. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46594. * allow modification of the radius value.
  46595. */
  46596. private _modifierRadius;
  46597. }
  46598. }
  46599. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46600. import { Nullable } from "babylonjs/types";
  46601. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46602. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46603. import { Observable } from "babylonjs/Misc/observable";
  46604. module "babylonjs/Cameras/freeCameraInputsManager" {
  46605. interface FreeCameraInputsManager {
  46606. /**
  46607. * @hidden
  46608. */
  46609. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46610. /**
  46611. * Add orientation input support to the input manager.
  46612. * @returns the current input manager
  46613. */
  46614. addDeviceOrientation(): FreeCameraInputsManager;
  46615. }
  46616. }
  46617. /**
  46618. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46619. * Screen rotation is taken into account.
  46620. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46621. */
  46622. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46623. private _camera;
  46624. private _screenOrientationAngle;
  46625. private _constantTranform;
  46626. private _screenQuaternion;
  46627. private _alpha;
  46628. private _beta;
  46629. private _gamma;
  46630. /**
  46631. * Can be used to detect if a device orientation sensor is available on a device
  46632. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46633. * @returns a promise that will resolve on orientation change
  46634. */
  46635. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46636. /**
  46637. * @hidden
  46638. */
  46639. _onDeviceOrientationChangedObservable: Observable<void>;
  46640. /**
  46641. * Instantiates a new input
  46642. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46643. */
  46644. constructor();
  46645. /**
  46646. * Define the camera controlled by the input.
  46647. */
  46648. get camera(): FreeCamera;
  46649. set camera(camera: FreeCamera);
  46650. /**
  46651. * Attach the input controls to a specific dom element to get the input from.
  46652. * @param element Defines the element the controls should be listened from
  46653. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46654. */
  46655. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46656. private _orientationChanged;
  46657. private _deviceOrientation;
  46658. /**
  46659. * Detach the current controls from the specified dom element.
  46660. * @param element Defines the element to stop listening the inputs from
  46661. */
  46662. detachControl(element: Nullable<HTMLElement>): void;
  46663. /**
  46664. * Update the current camera state depending on the inputs that have been used this frame.
  46665. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46666. */
  46667. checkInputs(): void;
  46668. /**
  46669. * Gets the class name of the current intput.
  46670. * @returns the class name
  46671. */
  46672. getClassName(): string;
  46673. /**
  46674. * Get the friendly name associated with the input class.
  46675. * @returns the input friendly name
  46676. */
  46677. getSimpleName(): string;
  46678. }
  46679. }
  46680. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46681. import { Nullable } from "babylonjs/types";
  46682. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46683. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46684. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46685. /**
  46686. * Manage the gamepad inputs to control a free camera.
  46687. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46688. */
  46689. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46690. /**
  46691. * Define the camera the input is attached to.
  46692. */
  46693. camera: FreeCamera;
  46694. /**
  46695. * Define the Gamepad controlling the input
  46696. */
  46697. gamepad: Nullable<Gamepad>;
  46698. /**
  46699. * Defines the gamepad rotation sensiblity.
  46700. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46701. */
  46702. gamepadAngularSensibility: number;
  46703. /**
  46704. * Defines the gamepad move sensiblity.
  46705. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46706. */
  46707. gamepadMoveSensibility: number;
  46708. private _yAxisScale;
  46709. /**
  46710. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46711. */
  46712. get invertYAxis(): boolean;
  46713. set invertYAxis(value: boolean);
  46714. private _onGamepadConnectedObserver;
  46715. private _onGamepadDisconnectedObserver;
  46716. private _cameraTransform;
  46717. private _deltaTransform;
  46718. private _vector3;
  46719. private _vector2;
  46720. /**
  46721. * Attach the input controls to a specific dom element to get the input from.
  46722. * @param element Defines the element the controls should be listened from
  46723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46724. */
  46725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46726. /**
  46727. * Detach the current controls from the specified dom element.
  46728. * @param element Defines the element to stop listening the inputs from
  46729. */
  46730. detachControl(element: Nullable<HTMLElement>): void;
  46731. /**
  46732. * Update the current camera state depending on the inputs that have been used this frame.
  46733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46734. */
  46735. checkInputs(): void;
  46736. /**
  46737. * Gets the class name of the current intput.
  46738. * @returns the class name
  46739. */
  46740. getClassName(): string;
  46741. /**
  46742. * Get the friendly name associated with the input class.
  46743. * @returns the input friendly name
  46744. */
  46745. getSimpleName(): string;
  46746. }
  46747. }
  46748. declare module "babylonjs/Misc/virtualJoystick" {
  46749. import { Nullable } from "babylonjs/types";
  46750. import { Vector3 } from "babylonjs/Maths/math.vector";
  46751. /**
  46752. * Defines the potential axis of a Joystick
  46753. */
  46754. export enum JoystickAxis {
  46755. /** X axis */
  46756. X = 0,
  46757. /** Y axis */
  46758. Y = 1,
  46759. /** Z axis */
  46760. Z = 2
  46761. }
  46762. /**
  46763. * Represents the different customization options available
  46764. * for VirtualJoystick
  46765. */
  46766. interface VirtualJoystickCustomizations {
  46767. /**
  46768. * Size of the joystick's puck
  46769. */
  46770. puckSize: number;
  46771. /**
  46772. * Size of the joystick's container
  46773. */
  46774. containerSize: number;
  46775. /**
  46776. * Color of the joystick && puck
  46777. */
  46778. color: string;
  46779. /**
  46780. * Image URL for the joystick's puck
  46781. */
  46782. puckImage?: string;
  46783. /**
  46784. * Image URL for the joystick's container
  46785. */
  46786. containerImage?: string;
  46787. /**
  46788. * Defines the unmoving position of the joystick container
  46789. */
  46790. position?: {
  46791. x: number;
  46792. y: number;
  46793. };
  46794. /**
  46795. * Defines whether or not the joystick container is always visible
  46796. */
  46797. alwaysVisible: boolean;
  46798. /**
  46799. * Defines whether or not to limit the movement of the puck to the joystick's container
  46800. */
  46801. limitToContainer: boolean;
  46802. }
  46803. /**
  46804. * Class used to define virtual joystick (used in touch mode)
  46805. */
  46806. export class VirtualJoystick {
  46807. /**
  46808. * Gets or sets a boolean indicating that left and right values must be inverted
  46809. */
  46810. reverseLeftRight: boolean;
  46811. /**
  46812. * Gets or sets a boolean indicating that up and down values must be inverted
  46813. */
  46814. reverseUpDown: boolean;
  46815. /**
  46816. * Gets the offset value for the position (ie. the change of the position value)
  46817. */
  46818. deltaPosition: Vector3;
  46819. /**
  46820. * Gets a boolean indicating if the virtual joystick was pressed
  46821. */
  46822. pressed: boolean;
  46823. /**
  46824. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46825. */
  46826. static Canvas: Nullable<HTMLCanvasElement>;
  46827. /**
  46828. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46829. */
  46830. limitToContainer: boolean;
  46831. private static _globalJoystickIndex;
  46832. private static _alwaysVisibleSticks;
  46833. private static vjCanvasContext;
  46834. private static vjCanvasWidth;
  46835. private static vjCanvasHeight;
  46836. private static halfWidth;
  46837. private static _GetDefaultOptions;
  46838. private _action;
  46839. private _axisTargetedByLeftAndRight;
  46840. private _axisTargetedByUpAndDown;
  46841. private _joystickSensibility;
  46842. private _inversedSensibility;
  46843. private _joystickPointerID;
  46844. private _joystickColor;
  46845. private _joystickPointerPos;
  46846. private _joystickPreviousPointerPos;
  46847. private _joystickPointerStartPos;
  46848. private _deltaJoystickVector;
  46849. private _leftJoystick;
  46850. private _touches;
  46851. private _joystickPosition;
  46852. private _alwaysVisible;
  46853. private _puckImage;
  46854. private _containerImage;
  46855. private _joystickPuckSize;
  46856. private _joystickContainerSize;
  46857. private _clearPuckSize;
  46858. private _clearContainerSize;
  46859. private _clearPuckSizeOffset;
  46860. private _clearContainerSizeOffset;
  46861. private _onPointerDownHandlerRef;
  46862. private _onPointerMoveHandlerRef;
  46863. private _onPointerUpHandlerRef;
  46864. private _onResize;
  46865. /**
  46866. * Creates a new virtual joystick
  46867. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46868. * @param customizations Defines the options we want to customize the VirtualJoystick
  46869. */
  46870. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46871. /**
  46872. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46873. * @param newJoystickSensibility defines the new sensibility
  46874. */
  46875. setJoystickSensibility(newJoystickSensibility: number): void;
  46876. private _onPointerDown;
  46877. private _onPointerMove;
  46878. private _onPointerUp;
  46879. /**
  46880. * Change the color of the virtual joystick
  46881. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46882. */
  46883. setJoystickColor(newColor: string): void;
  46884. /**
  46885. * Size of the joystick's container
  46886. */
  46887. set containerSize(newSize: number);
  46888. get containerSize(): number;
  46889. /**
  46890. * Size of the joystick's puck
  46891. */
  46892. set puckSize(newSize: number);
  46893. get puckSize(): number;
  46894. /**
  46895. * Clears the set position of the joystick
  46896. */
  46897. clearPosition(): void;
  46898. /**
  46899. * Defines whether or not the joystick container is always visible
  46900. */
  46901. set alwaysVisible(value: boolean);
  46902. get alwaysVisible(): boolean;
  46903. /**
  46904. * Sets the constant position of the Joystick container
  46905. * @param x X axis coordinate
  46906. * @param y Y axis coordinate
  46907. */
  46908. setPosition(x: number, y: number): void;
  46909. /**
  46910. * Defines a callback to call when the joystick is touched
  46911. * @param action defines the callback
  46912. */
  46913. setActionOnTouch(action: () => any): void;
  46914. /**
  46915. * Defines which axis you'd like to control for left & right
  46916. * @param axis defines the axis to use
  46917. */
  46918. setAxisForLeftRight(axis: JoystickAxis): void;
  46919. /**
  46920. * Defines which axis you'd like to control for up & down
  46921. * @param axis defines the axis to use
  46922. */
  46923. setAxisForUpDown(axis: JoystickAxis): void;
  46924. /**
  46925. * Clears the canvas from the previous puck / container draw
  46926. */
  46927. private _clearPreviousDraw;
  46928. /**
  46929. * Loads `urlPath` to be used for the container's image
  46930. * @param urlPath defines the urlPath of an image to use
  46931. */
  46932. setContainerImage(urlPath: string): void;
  46933. /**
  46934. * Loads `urlPath` to be used for the puck's image
  46935. * @param urlPath defines the urlPath of an image to use
  46936. */
  46937. setPuckImage(urlPath: string): void;
  46938. /**
  46939. * Draws the Virtual Joystick's container
  46940. */
  46941. private _drawContainer;
  46942. /**
  46943. * Draws the Virtual Joystick's puck
  46944. */
  46945. private _drawPuck;
  46946. private _drawVirtualJoystick;
  46947. /**
  46948. * Release internal HTML canvas
  46949. */
  46950. releaseCanvas(): void;
  46951. }
  46952. }
  46953. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46954. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46955. import { Nullable } from "babylonjs/types";
  46956. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46957. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46958. module "babylonjs/Cameras/freeCameraInputsManager" {
  46959. interface FreeCameraInputsManager {
  46960. /**
  46961. * Add virtual joystick input support to the input manager.
  46962. * @returns the current input manager
  46963. */
  46964. addVirtualJoystick(): FreeCameraInputsManager;
  46965. }
  46966. }
  46967. /**
  46968. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46969. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46970. */
  46971. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46972. /**
  46973. * Defines the camera the input is attached to.
  46974. */
  46975. camera: FreeCamera;
  46976. private _leftjoystick;
  46977. private _rightjoystick;
  46978. /**
  46979. * Gets the left stick of the virtual joystick.
  46980. * @returns The virtual Joystick
  46981. */
  46982. getLeftJoystick(): VirtualJoystick;
  46983. /**
  46984. * Gets the right stick of the virtual joystick.
  46985. * @returns The virtual Joystick
  46986. */
  46987. getRightJoystick(): VirtualJoystick;
  46988. /**
  46989. * Update the current camera state depending on the inputs that have been used this frame.
  46990. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46991. */
  46992. checkInputs(): void;
  46993. /**
  46994. * Attach the input controls to a specific dom element to get the input from.
  46995. * @param element Defines the element the controls should be listened from
  46996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46997. */
  46998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46999. /**
  47000. * Detach the current controls from the specified dom element.
  47001. * @param element Defines the element to stop listening the inputs from
  47002. */
  47003. detachControl(element: Nullable<HTMLElement>): void;
  47004. /**
  47005. * Gets the class name of the current intput.
  47006. * @returns the class name
  47007. */
  47008. getClassName(): string;
  47009. /**
  47010. * Get the friendly name associated with the input class.
  47011. * @returns the input friendly name
  47012. */
  47013. getSimpleName(): string;
  47014. }
  47015. }
  47016. declare module "babylonjs/Cameras/Inputs/index" {
  47017. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  47018. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  47019. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  47020. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  47021. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47022. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  47023. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  47024. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  47025. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  47026. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  47027. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47028. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  47029. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  47030. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  47031. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  47032. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47033. }
  47034. declare module "babylonjs/Cameras/touchCamera" {
  47035. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47036. import { Scene } from "babylonjs/scene";
  47037. import { Vector3 } from "babylonjs/Maths/math.vector";
  47038. /**
  47039. * This represents a FPS type of camera controlled by touch.
  47040. * This is like a universal camera minus the Gamepad controls.
  47041. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47042. */
  47043. export class TouchCamera extends FreeCamera {
  47044. /**
  47045. * Defines the touch sensibility for rotation.
  47046. * The higher the faster.
  47047. */
  47048. get touchAngularSensibility(): number;
  47049. set touchAngularSensibility(value: number);
  47050. /**
  47051. * Defines the touch sensibility for move.
  47052. * The higher the faster.
  47053. */
  47054. get touchMoveSensibility(): number;
  47055. set touchMoveSensibility(value: number);
  47056. /**
  47057. * Instantiates a new touch camera.
  47058. * This represents a FPS type of camera controlled by touch.
  47059. * This is like a universal camera minus the Gamepad controls.
  47060. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47061. * @param name Define the name of the camera in the scene
  47062. * @param position Define the start position of the camera in the scene
  47063. * @param scene Define the scene the camera belongs to
  47064. */
  47065. constructor(name: string, position: Vector3, scene: Scene);
  47066. /**
  47067. * Gets the current object class name.
  47068. * @return the class name
  47069. */
  47070. getClassName(): string;
  47071. /** @hidden */
  47072. _setupInputs(): void;
  47073. }
  47074. }
  47075. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  47076. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47077. import { Scene } from "babylonjs/scene";
  47078. import { Vector3 } from "babylonjs/Maths/math.vector";
  47079. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47080. import { Axis } from "babylonjs/Maths/math.axis";
  47081. /**
  47082. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  47083. * being tilted forward or back and left or right.
  47084. */
  47085. export class DeviceOrientationCamera extends FreeCamera {
  47086. private _initialQuaternion;
  47087. private _quaternionCache;
  47088. private _tmpDragQuaternion;
  47089. private _disablePointerInputWhenUsingDeviceOrientation;
  47090. /**
  47091. * Creates a new device orientation camera
  47092. * @param name The name of the camera
  47093. * @param position The start position camera
  47094. * @param scene The scene the camera belongs to
  47095. */
  47096. constructor(name: string, position: Vector3, scene: Scene);
  47097. /**
  47098. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  47099. */
  47100. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  47101. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  47102. private _dragFactor;
  47103. /**
  47104. * Enabled turning on the y axis when the orientation sensor is active
  47105. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  47106. */
  47107. enableHorizontalDragging(dragFactor?: number): void;
  47108. /**
  47109. * Gets the current instance class name ("DeviceOrientationCamera").
  47110. * This helps avoiding instanceof at run time.
  47111. * @returns the class name
  47112. */
  47113. getClassName(): string;
  47114. /**
  47115. * @hidden
  47116. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  47117. */
  47118. _checkInputs(): void;
  47119. /**
  47120. * Reset the camera to its default orientation on the specified axis only.
  47121. * @param axis The axis to reset
  47122. */
  47123. resetToCurrentRotation(axis?: Axis): void;
  47124. }
  47125. }
  47126. declare module "babylonjs/Gamepads/xboxGamepad" {
  47127. import { Observable } from "babylonjs/Misc/observable";
  47128. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47129. /**
  47130. * Defines supported buttons for XBox360 compatible gamepads
  47131. */
  47132. export enum Xbox360Button {
  47133. /** A */
  47134. A = 0,
  47135. /** B */
  47136. B = 1,
  47137. /** X */
  47138. X = 2,
  47139. /** Y */
  47140. Y = 3,
  47141. /** Left button */
  47142. LB = 4,
  47143. /** Right button */
  47144. RB = 5,
  47145. /** Back */
  47146. Back = 8,
  47147. /** Start */
  47148. Start = 9,
  47149. /** Left stick */
  47150. LeftStick = 10,
  47151. /** Right stick */
  47152. RightStick = 11
  47153. }
  47154. /** Defines values for XBox360 DPad */
  47155. export enum Xbox360Dpad {
  47156. /** Up */
  47157. Up = 12,
  47158. /** Down */
  47159. Down = 13,
  47160. /** Left */
  47161. Left = 14,
  47162. /** Right */
  47163. Right = 15
  47164. }
  47165. /**
  47166. * Defines a XBox360 gamepad
  47167. */
  47168. export class Xbox360Pad extends Gamepad {
  47169. private _leftTrigger;
  47170. private _rightTrigger;
  47171. private _onlefttriggerchanged;
  47172. private _onrighttriggerchanged;
  47173. private _onbuttondown;
  47174. private _onbuttonup;
  47175. private _ondpaddown;
  47176. private _ondpadup;
  47177. /** Observable raised when a button is pressed */
  47178. onButtonDownObservable: Observable<Xbox360Button>;
  47179. /** Observable raised when a button is released */
  47180. onButtonUpObservable: Observable<Xbox360Button>;
  47181. /** Observable raised when a pad is pressed */
  47182. onPadDownObservable: Observable<Xbox360Dpad>;
  47183. /** Observable raised when a pad is released */
  47184. onPadUpObservable: Observable<Xbox360Dpad>;
  47185. private _buttonA;
  47186. private _buttonB;
  47187. private _buttonX;
  47188. private _buttonY;
  47189. private _buttonBack;
  47190. private _buttonStart;
  47191. private _buttonLB;
  47192. private _buttonRB;
  47193. private _buttonLeftStick;
  47194. private _buttonRightStick;
  47195. private _dPadUp;
  47196. private _dPadDown;
  47197. private _dPadLeft;
  47198. private _dPadRight;
  47199. private _isXboxOnePad;
  47200. /**
  47201. * Creates a new XBox360 gamepad object
  47202. * @param id defines the id of this gamepad
  47203. * @param index defines its index
  47204. * @param gamepad defines the internal HTML gamepad object
  47205. * @param xboxOne defines if it is a XBox One gamepad
  47206. */
  47207. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  47208. /**
  47209. * Defines the callback to call when left trigger is pressed
  47210. * @param callback defines the callback to use
  47211. */
  47212. onlefttriggerchanged(callback: (value: number) => void): void;
  47213. /**
  47214. * Defines the callback to call when right trigger is pressed
  47215. * @param callback defines the callback to use
  47216. */
  47217. onrighttriggerchanged(callback: (value: number) => void): void;
  47218. /**
  47219. * Gets the left trigger value
  47220. */
  47221. get leftTrigger(): number;
  47222. /**
  47223. * Sets the left trigger value
  47224. */
  47225. set leftTrigger(newValue: number);
  47226. /**
  47227. * Gets the right trigger value
  47228. */
  47229. get rightTrigger(): number;
  47230. /**
  47231. * Sets the right trigger value
  47232. */
  47233. set rightTrigger(newValue: number);
  47234. /**
  47235. * Defines the callback to call when a button is pressed
  47236. * @param callback defines the callback to use
  47237. */
  47238. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  47239. /**
  47240. * Defines the callback to call when a button is released
  47241. * @param callback defines the callback to use
  47242. */
  47243. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47244. /**
  47245. * Defines the callback to call when a pad is pressed
  47246. * @param callback defines the callback to use
  47247. */
  47248. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47249. /**
  47250. * Defines the callback to call when a pad is released
  47251. * @param callback defines the callback to use
  47252. */
  47253. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47254. private _setButtonValue;
  47255. private _setDPadValue;
  47256. /**
  47257. * Gets the value of the `A` button
  47258. */
  47259. get buttonA(): number;
  47260. /**
  47261. * Sets the value of the `A` button
  47262. */
  47263. set buttonA(value: number);
  47264. /**
  47265. * Gets the value of the `B` button
  47266. */
  47267. get buttonB(): number;
  47268. /**
  47269. * Sets the value of the `B` button
  47270. */
  47271. set buttonB(value: number);
  47272. /**
  47273. * Gets the value of the `X` button
  47274. */
  47275. get buttonX(): number;
  47276. /**
  47277. * Sets the value of the `X` button
  47278. */
  47279. set buttonX(value: number);
  47280. /**
  47281. * Gets the value of the `Y` button
  47282. */
  47283. get buttonY(): number;
  47284. /**
  47285. * Sets the value of the `Y` button
  47286. */
  47287. set buttonY(value: number);
  47288. /**
  47289. * Gets the value of the `Start` button
  47290. */
  47291. get buttonStart(): number;
  47292. /**
  47293. * Sets the value of the `Start` button
  47294. */
  47295. set buttonStart(value: number);
  47296. /**
  47297. * Gets the value of the `Back` button
  47298. */
  47299. get buttonBack(): number;
  47300. /**
  47301. * Sets the value of the `Back` button
  47302. */
  47303. set buttonBack(value: number);
  47304. /**
  47305. * Gets the value of the `Left` button
  47306. */
  47307. get buttonLB(): number;
  47308. /**
  47309. * Sets the value of the `Left` button
  47310. */
  47311. set buttonLB(value: number);
  47312. /**
  47313. * Gets the value of the `Right` button
  47314. */
  47315. get buttonRB(): number;
  47316. /**
  47317. * Sets the value of the `Right` button
  47318. */
  47319. set buttonRB(value: number);
  47320. /**
  47321. * Gets the value of the Left joystick
  47322. */
  47323. get buttonLeftStick(): number;
  47324. /**
  47325. * Sets the value of the Left joystick
  47326. */
  47327. set buttonLeftStick(value: number);
  47328. /**
  47329. * Gets the value of the Right joystick
  47330. */
  47331. get buttonRightStick(): number;
  47332. /**
  47333. * Sets the value of the Right joystick
  47334. */
  47335. set buttonRightStick(value: number);
  47336. /**
  47337. * Gets the value of D-pad up
  47338. */
  47339. get dPadUp(): number;
  47340. /**
  47341. * Sets the value of D-pad up
  47342. */
  47343. set dPadUp(value: number);
  47344. /**
  47345. * Gets the value of D-pad down
  47346. */
  47347. get dPadDown(): number;
  47348. /**
  47349. * Sets the value of D-pad down
  47350. */
  47351. set dPadDown(value: number);
  47352. /**
  47353. * Gets the value of D-pad left
  47354. */
  47355. get dPadLeft(): number;
  47356. /**
  47357. * Sets the value of D-pad left
  47358. */
  47359. set dPadLeft(value: number);
  47360. /**
  47361. * Gets the value of D-pad right
  47362. */
  47363. get dPadRight(): number;
  47364. /**
  47365. * Sets the value of D-pad right
  47366. */
  47367. set dPadRight(value: number);
  47368. /**
  47369. * Force the gamepad to synchronize with device values
  47370. */
  47371. update(): void;
  47372. /**
  47373. * Disposes the gamepad
  47374. */
  47375. dispose(): void;
  47376. }
  47377. }
  47378. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47379. import { Observable } from "babylonjs/Misc/observable";
  47380. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47381. /**
  47382. * Defines supported buttons for DualShock compatible gamepads
  47383. */
  47384. export enum DualShockButton {
  47385. /** Cross */
  47386. Cross = 0,
  47387. /** Circle */
  47388. Circle = 1,
  47389. /** Square */
  47390. Square = 2,
  47391. /** Triangle */
  47392. Triangle = 3,
  47393. /** L1 */
  47394. L1 = 4,
  47395. /** R1 */
  47396. R1 = 5,
  47397. /** Share */
  47398. Share = 8,
  47399. /** Options */
  47400. Options = 9,
  47401. /** Left stick */
  47402. LeftStick = 10,
  47403. /** Right stick */
  47404. RightStick = 11
  47405. }
  47406. /** Defines values for DualShock DPad */
  47407. export enum DualShockDpad {
  47408. /** Up */
  47409. Up = 12,
  47410. /** Down */
  47411. Down = 13,
  47412. /** Left */
  47413. Left = 14,
  47414. /** Right */
  47415. Right = 15
  47416. }
  47417. /**
  47418. * Defines a DualShock gamepad
  47419. */
  47420. export class DualShockPad extends Gamepad {
  47421. private _leftTrigger;
  47422. private _rightTrigger;
  47423. private _onlefttriggerchanged;
  47424. private _onrighttriggerchanged;
  47425. private _onbuttondown;
  47426. private _onbuttonup;
  47427. private _ondpaddown;
  47428. private _ondpadup;
  47429. /** Observable raised when a button is pressed */
  47430. onButtonDownObservable: Observable<DualShockButton>;
  47431. /** Observable raised when a button is released */
  47432. onButtonUpObservable: Observable<DualShockButton>;
  47433. /** Observable raised when a pad is pressed */
  47434. onPadDownObservable: Observable<DualShockDpad>;
  47435. /** Observable raised when a pad is released */
  47436. onPadUpObservable: Observable<DualShockDpad>;
  47437. private _buttonCross;
  47438. private _buttonCircle;
  47439. private _buttonSquare;
  47440. private _buttonTriangle;
  47441. private _buttonShare;
  47442. private _buttonOptions;
  47443. private _buttonL1;
  47444. private _buttonR1;
  47445. private _buttonLeftStick;
  47446. private _buttonRightStick;
  47447. private _dPadUp;
  47448. private _dPadDown;
  47449. private _dPadLeft;
  47450. private _dPadRight;
  47451. /**
  47452. * Creates a new DualShock gamepad object
  47453. * @param id defines the id of this gamepad
  47454. * @param index defines its index
  47455. * @param gamepad defines the internal HTML gamepad object
  47456. */
  47457. constructor(id: string, index: number, gamepad: any);
  47458. /**
  47459. * Defines the callback to call when left trigger is pressed
  47460. * @param callback defines the callback to use
  47461. */
  47462. onlefttriggerchanged(callback: (value: number) => void): void;
  47463. /**
  47464. * Defines the callback to call when right trigger is pressed
  47465. * @param callback defines the callback to use
  47466. */
  47467. onrighttriggerchanged(callback: (value: number) => void): void;
  47468. /**
  47469. * Gets the left trigger value
  47470. */
  47471. get leftTrigger(): number;
  47472. /**
  47473. * Sets the left trigger value
  47474. */
  47475. set leftTrigger(newValue: number);
  47476. /**
  47477. * Gets the right trigger value
  47478. */
  47479. get rightTrigger(): number;
  47480. /**
  47481. * Sets the right trigger value
  47482. */
  47483. set rightTrigger(newValue: number);
  47484. /**
  47485. * Defines the callback to call when a button is pressed
  47486. * @param callback defines the callback to use
  47487. */
  47488. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47489. /**
  47490. * Defines the callback to call when a button is released
  47491. * @param callback defines the callback to use
  47492. */
  47493. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47494. /**
  47495. * Defines the callback to call when a pad is pressed
  47496. * @param callback defines the callback to use
  47497. */
  47498. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47499. /**
  47500. * Defines the callback to call when a pad is released
  47501. * @param callback defines the callback to use
  47502. */
  47503. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47504. private _setButtonValue;
  47505. private _setDPadValue;
  47506. /**
  47507. * Gets the value of the `Cross` button
  47508. */
  47509. get buttonCross(): number;
  47510. /**
  47511. * Sets the value of the `Cross` button
  47512. */
  47513. set buttonCross(value: number);
  47514. /**
  47515. * Gets the value of the `Circle` button
  47516. */
  47517. get buttonCircle(): number;
  47518. /**
  47519. * Sets the value of the `Circle` button
  47520. */
  47521. set buttonCircle(value: number);
  47522. /**
  47523. * Gets the value of the `Square` button
  47524. */
  47525. get buttonSquare(): number;
  47526. /**
  47527. * Sets the value of the `Square` button
  47528. */
  47529. set buttonSquare(value: number);
  47530. /**
  47531. * Gets the value of the `Triangle` button
  47532. */
  47533. get buttonTriangle(): number;
  47534. /**
  47535. * Sets the value of the `Triangle` button
  47536. */
  47537. set buttonTriangle(value: number);
  47538. /**
  47539. * Gets the value of the `Options` button
  47540. */
  47541. get buttonOptions(): number;
  47542. /**
  47543. * Sets the value of the `Options` button
  47544. */
  47545. set buttonOptions(value: number);
  47546. /**
  47547. * Gets the value of the `Share` button
  47548. */
  47549. get buttonShare(): number;
  47550. /**
  47551. * Sets the value of the `Share` button
  47552. */
  47553. set buttonShare(value: number);
  47554. /**
  47555. * Gets the value of the `L1` button
  47556. */
  47557. get buttonL1(): number;
  47558. /**
  47559. * Sets the value of the `L1` button
  47560. */
  47561. set buttonL1(value: number);
  47562. /**
  47563. * Gets the value of the `R1` button
  47564. */
  47565. get buttonR1(): number;
  47566. /**
  47567. * Sets the value of the `R1` button
  47568. */
  47569. set buttonR1(value: number);
  47570. /**
  47571. * Gets the value of the Left joystick
  47572. */
  47573. get buttonLeftStick(): number;
  47574. /**
  47575. * Sets the value of the Left joystick
  47576. */
  47577. set buttonLeftStick(value: number);
  47578. /**
  47579. * Gets the value of the Right joystick
  47580. */
  47581. get buttonRightStick(): number;
  47582. /**
  47583. * Sets the value of the Right joystick
  47584. */
  47585. set buttonRightStick(value: number);
  47586. /**
  47587. * Gets the value of D-pad up
  47588. */
  47589. get dPadUp(): number;
  47590. /**
  47591. * Sets the value of D-pad up
  47592. */
  47593. set dPadUp(value: number);
  47594. /**
  47595. * Gets the value of D-pad down
  47596. */
  47597. get dPadDown(): number;
  47598. /**
  47599. * Sets the value of D-pad down
  47600. */
  47601. set dPadDown(value: number);
  47602. /**
  47603. * Gets the value of D-pad left
  47604. */
  47605. get dPadLeft(): number;
  47606. /**
  47607. * Sets the value of D-pad left
  47608. */
  47609. set dPadLeft(value: number);
  47610. /**
  47611. * Gets the value of D-pad right
  47612. */
  47613. get dPadRight(): number;
  47614. /**
  47615. * Sets the value of D-pad right
  47616. */
  47617. set dPadRight(value: number);
  47618. /**
  47619. * Force the gamepad to synchronize with device values
  47620. */
  47621. update(): void;
  47622. /**
  47623. * Disposes the gamepad
  47624. */
  47625. dispose(): void;
  47626. }
  47627. }
  47628. declare module "babylonjs/Gamepads/gamepadManager" {
  47629. import { Observable } from "babylonjs/Misc/observable";
  47630. import { Nullable } from "babylonjs/types";
  47631. import { Scene } from "babylonjs/scene";
  47632. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47633. /**
  47634. * Manager for handling gamepads
  47635. */
  47636. export class GamepadManager {
  47637. private _scene?;
  47638. private _babylonGamepads;
  47639. private _oneGamepadConnected;
  47640. /** @hidden */
  47641. _isMonitoring: boolean;
  47642. private _gamepadEventSupported;
  47643. private _gamepadSupport?;
  47644. /**
  47645. * observable to be triggered when the gamepad controller has been connected
  47646. */
  47647. onGamepadConnectedObservable: Observable<Gamepad>;
  47648. /**
  47649. * observable to be triggered when the gamepad controller has been disconnected
  47650. */
  47651. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47652. private _onGamepadConnectedEvent;
  47653. private _onGamepadDisconnectedEvent;
  47654. /**
  47655. * Initializes the gamepad manager
  47656. * @param _scene BabylonJS scene
  47657. */
  47658. constructor(_scene?: Scene | undefined);
  47659. /**
  47660. * The gamepads in the game pad manager
  47661. */
  47662. get gamepads(): Gamepad[];
  47663. /**
  47664. * Get the gamepad controllers based on type
  47665. * @param type The type of gamepad controller
  47666. * @returns Nullable gamepad
  47667. */
  47668. getGamepadByType(type?: number): Nullable<Gamepad>;
  47669. /**
  47670. * Disposes the gamepad manager
  47671. */
  47672. dispose(): void;
  47673. private _addNewGamepad;
  47674. private _startMonitoringGamepads;
  47675. private _stopMonitoringGamepads;
  47676. /** @hidden */
  47677. _checkGamepadsStatus(): void;
  47678. private _updateGamepadObjects;
  47679. }
  47680. }
  47681. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47682. import { Nullable } from "babylonjs/types";
  47683. import { Scene } from "babylonjs/scene";
  47684. import { ISceneComponent } from "babylonjs/sceneComponent";
  47685. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47686. module "babylonjs/scene" {
  47687. interface Scene {
  47688. /** @hidden */
  47689. _gamepadManager: Nullable<GamepadManager>;
  47690. /**
  47691. * Gets the gamepad manager associated with the scene
  47692. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47693. */
  47694. gamepadManager: GamepadManager;
  47695. }
  47696. }
  47697. module "babylonjs/Cameras/freeCameraInputsManager" {
  47698. /**
  47699. * Interface representing a free camera inputs manager
  47700. */
  47701. interface FreeCameraInputsManager {
  47702. /**
  47703. * Adds gamepad input support to the FreeCameraInputsManager.
  47704. * @returns the FreeCameraInputsManager
  47705. */
  47706. addGamepad(): FreeCameraInputsManager;
  47707. }
  47708. }
  47709. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47710. /**
  47711. * Interface representing an arc rotate camera inputs manager
  47712. */
  47713. interface ArcRotateCameraInputsManager {
  47714. /**
  47715. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47716. * @returns the camera inputs manager
  47717. */
  47718. addGamepad(): ArcRotateCameraInputsManager;
  47719. }
  47720. }
  47721. /**
  47722. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47723. */
  47724. export class GamepadSystemSceneComponent implements ISceneComponent {
  47725. /**
  47726. * The component name helpfull to identify the component in the list of scene components.
  47727. */
  47728. readonly name: string;
  47729. /**
  47730. * The scene the component belongs to.
  47731. */
  47732. scene: Scene;
  47733. /**
  47734. * Creates a new instance of the component for the given scene
  47735. * @param scene Defines the scene to register the component in
  47736. */
  47737. constructor(scene: Scene);
  47738. /**
  47739. * Registers the component in a given scene
  47740. */
  47741. register(): void;
  47742. /**
  47743. * Rebuilds the elements related to this component in case of
  47744. * context lost for instance.
  47745. */
  47746. rebuild(): void;
  47747. /**
  47748. * Disposes the component and the associated ressources
  47749. */
  47750. dispose(): void;
  47751. private _beforeCameraUpdate;
  47752. }
  47753. }
  47754. declare module "babylonjs/Cameras/universalCamera" {
  47755. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47756. import { Scene } from "babylonjs/scene";
  47757. import { Vector3 } from "babylonjs/Maths/math.vector";
  47758. import "babylonjs/Gamepads/gamepadSceneComponent";
  47759. /**
  47760. * 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,
  47761. * which still works and will still be found in many Playgrounds.
  47762. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47763. */
  47764. export class UniversalCamera extends TouchCamera {
  47765. /**
  47766. * Defines the gamepad rotation sensiblity.
  47767. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47768. */
  47769. get gamepadAngularSensibility(): number;
  47770. set gamepadAngularSensibility(value: number);
  47771. /**
  47772. * Defines the gamepad move sensiblity.
  47773. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47774. */
  47775. get gamepadMoveSensibility(): number;
  47776. set gamepadMoveSensibility(value: number);
  47777. /**
  47778. * 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,
  47779. * which still works and will still be found in many Playgrounds.
  47780. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47781. * @param name Define the name of the camera in the scene
  47782. * @param position Define the start position of the camera in the scene
  47783. * @param scene Define the scene the camera belongs to
  47784. */
  47785. constructor(name: string, position: Vector3, scene: Scene);
  47786. /**
  47787. * Gets the current object class name.
  47788. * @return the class name
  47789. */
  47790. getClassName(): string;
  47791. }
  47792. }
  47793. declare module "babylonjs/Cameras/gamepadCamera" {
  47794. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47795. import { Scene } from "babylonjs/scene";
  47796. import { Vector3 } from "babylonjs/Maths/math.vector";
  47797. /**
  47798. * This represents a FPS type of camera. This is only here for back compat purpose.
  47799. * Please use the UniversalCamera instead as both are identical.
  47800. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47801. */
  47802. export class GamepadCamera extends UniversalCamera {
  47803. /**
  47804. * Instantiates a new Gamepad Camera
  47805. * This represents a FPS type of camera. This is only here for back compat purpose.
  47806. * Please use the UniversalCamera instead as both are identical.
  47807. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47808. * @param name Define the name of the camera in the scene
  47809. * @param position Define the start position of the camera in the scene
  47810. * @param scene Define the scene the camera belongs to
  47811. */
  47812. constructor(name: string, position: Vector3, scene: Scene);
  47813. /**
  47814. * Gets the current object class name.
  47815. * @return the class name
  47816. */
  47817. getClassName(): string;
  47818. }
  47819. }
  47820. declare module "babylonjs/Shaders/pass.fragment" {
  47821. /** @hidden */
  47822. export var passPixelShader: {
  47823. name: string;
  47824. shader: string;
  47825. };
  47826. }
  47827. declare module "babylonjs/Shaders/passCube.fragment" {
  47828. /** @hidden */
  47829. export var passCubePixelShader: {
  47830. name: string;
  47831. shader: string;
  47832. };
  47833. }
  47834. declare module "babylonjs/PostProcesses/passPostProcess" {
  47835. import { Nullable } from "babylonjs/types";
  47836. import { Camera } from "babylonjs/Cameras/camera";
  47837. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47838. import { Engine } from "babylonjs/Engines/engine";
  47839. import "babylonjs/Shaders/pass.fragment";
  47840. import "babylonjs/Shaders/passCube.fragment";
  47841. import { Scene } from "babylonjs/scene";
  47842. /**
  47843. * PassPostProcess which produces an output the same as it's input
  47844. */
  47845. export class PassPostProcess extends PostProcess {
  47846. /**
  47847. * Gets a string identifying the name of the class
  47848. * @returns "PassPostProcess" string
  47849. */
  47850. getClassName(): string;
  47851. /**
  47852. * Creates the PassPostProcess
  47853. * @param name The name of the effect.
  47854. * @param options The required width/height ratio to downsize to before computing the render pass.
  47855. * @param camera The camera to apply the render pass to.
  47856. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47857. * @param engine The engine which the post process will be applied. (default: current engine)
  47858. * @param reusable If the post process can be reused on the same frame. (default: false)
  47859. * @param textureType The type of texture to be used when performing the post processing.
  47860. * @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)
  47861. */
  47862. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47863. /** @hidden */
  47864. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  47865. }
  47866. /**
  47867. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47868. */
  47869. export class PassCubePostProcess extends PostProcess {
  47870. private _face;
  47871. /**
  47872. * Gets or sets the cube face to display.
  47873. * * 0 is +X
  47874. * * 1 is -X
  47875. * * 2 is +Y
  47876. * * 3 is -Y
  47877. * * 4 is +Z
  47878. * * 5 is -Z
  47879. */
  47880. get face(): number;
  47881. set face(value: number);
  47882. /**
  47883. * Gets a string identifying the name of the class
  47884. * @returns "PassCubePostProcess" string
  47885. */
  47886. getClassName(): string;
  47887. /**
  47888. * Creates the PassCubePostProcess
  47889. * @param name The name of the effect.
  47890. * @param options The required width/height ratio to downsize to before computing the render pass.
  47891. * @param camera The camera to apply the render pass to.
  47892. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47893. * @param engine The engine which the post process will be applied. (default: current engine)
  47894. * @param reusable If the post process can be reused on the same frame. (default: false)
  47895. * @param textureType The type of texture to be used when performing the post processing.
  47896. * @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)
  47897. */
  47898. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47899. /** @hidden */
  47900. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  47901. }
  47902. }
  47903. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47904. /** @hidden */
  47905. export var anaglyphPixelShader: {
  47906. name: string;
  47907. shader: string;
  47908. };
  47909. }
  47910. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47911. import { Engine } from "babylonjs/Engines/engine";
  47912. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47913. import { Camera } from "babylonjs/Cameras/camera";
  47914. import "babylonjs/Shaders/anaglyph.fragment";
  47915. /**
  47916. * Postprocess used to generate anaglyphic rendering
  47917. */
  47918. export class AnaglyphPostProcess extends PostProcess {
  47919. private _passedProcess;
  47920. /**
  47921. * Gets a string identifying the name of the class
  47922. * @returns "AnaglyphPostProcess" string
  47923. */
  47924. getClassName(): string;
  47925. /**
  47926. * Creates a new AnaglyphPostProcess
  47927. * @param name defines postprocess name
  47928. * @param options defines creation options or target ratio scale
  47929. * @param rigCameras defines cameras using this postprocess
  47930. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47931. * @param engine defines hosting engine
  47932. * @param reusable defines if the postprocess will be reused multiple times per frame
  47933. */
  47934. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47935. }
  47936. }
  47937. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47938. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47939. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47940. import { Scene } from "babylonjs/scene";
  47941. import { Vector3 } from "babylonjs/Maths/math.vector";
  47942. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47943. /**
  47944. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47945. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47946. */
  47947. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47948. /**
  47949. * Creates a new AnaglyphArcRotateCamera
  47950. * @param name defines camera name
  47951. * @param alpha defines alpha angle (in radians)
  47952. * @param beta defines beta angle (in radians)
  47953. * @param radius defines radius
  47954. * @param target defines camera target
  47955. * @param interaxialDistance defines distance between each color axis
  47956. * @param scene defines the hosting scene
  47957. */
  47958. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47959. /**
  47960. * Gets camera class name
  47961. * @returns AnaglyphArcRotateCamera
  47962. */
  47963. getClassName(): string;
  47964. }
  47965. }
  47966. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47967. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47968. import { Scene } from "babylonjs/scene";
  47969. import { Vector3 } from "babylonjs/Maths/math.vector";
  47970. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47971. /**
  47972. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47973. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47974. */
  47975. export class AnaglyphFreeCamera extends FreeCamera {
  47976. /**
  47977. * Creates a new AnaglyphFreeCamera
  47978. * @param name defines camera name
  47979. * @param position defines initial position
  47980. * @param interaxialDistance defines distance between each color axis
  47981. * @param scene defines the hosting scene
  47982. */
  47983. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47984. /**
  47985. * Gets camera class name
  47986. * @returns AnaglyphFreeCamera
  47987. */
  47988. getClassName(): string;
  47989. }
  47990. }
  47991. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47992. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47993. import { Scene } from "babylonjs/scene";
  47994. import { Vector3 } from "babylonjs/Maths/math.vector";
  47995. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47996. /**
  47997. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47998. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47999. */
  48000. export class AnaglyphGamepadCamera extends GamepadCamera {
  48001. /**
  48002. * Creates a new AnaglyphGamepadCamera
  48003. * @param name defines camera name
  48004. * @param position defines initial position
  48005. * @param interaxialDistance defines distance between each color axis
  48006. * @param scene defines the hosting scene
  48007. */
  48008. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48009. /**
  48010. * Gets camera class name
  48011. * @returns AnaglyphGamepadCamera
  48012. */
  48013. getClassName(): string;
  48014. }
  48015. }
  48016. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  48017. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48018. import { Scene } from "babylonjs/scene";
  48019. import { Vector3 } from "babylonjs/Maths/math.vector";
  48020. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48021. /**
  48022. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  48023. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48024. */
  48025. export class AnaglyphUniversalCamera extends UniversalCamera {
  48026. /**
  48027. * Creates a new AnaglyphUniversalCamera
  48028. * @param name defines camera name
  48029. * @param position defines initial position
  48030. * @param interaxialDistance defines distance between each color axis
  48031. * @param scene defines the hosting scene
  48032. */
  48033. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48034. /**
  48035. * Gets camera class name
  48036. * @returns AnaglyphUniversalCamera
  48037. */
  48038. getClassName(): string;
  48039. }
  48040. }
  48041. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  48042. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  48043. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48044. import { Scene } from "babylonjs/scene";
  48045. import { Vector3 } from "babylonjs/Maths/math.vector";
  48046. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48047. /**
  48048. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  48049. * @see https://doc.babylonjs.com/features/cameras
  48050. */
  48051. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  48052. /**
  48053. * Creates a new StereoscopicArcRotateCamera
  48054. * @param name defines camera name
  48055. * @param alpha defines alpha angle (in radians)
  48056. * @param beta defines beta angle (in radians)
  48057. * @param radius defines radius
  48058. * @param target defines camera target
  48059. * @param interaxialDistance defines distance between each color axis
  48060. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48061. * @param scene defines the hosting scene
  48062. */
  48063. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48064. /**
  48065. * Gets camera class name
  48066. * @returns StereoscopicArcRotateCamera
  48067. */
  48068. getClassName(): string;
  48069. }
  48070. }
  48071. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  48072. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48073. import { Scene } from "babylonjs/scene";
  48074. import { Vector3 } from "babylonjs/Maths/math.vector";
  48075. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48076. /**
  48077. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  48078. * @see https://doc.babylonjs.com/features/cameras
  48079. */
  48080. export class StereoscopicFreeCamera extends FreeCamera {
  48081. /**
  48082. * Creates a new StereoscopicFreeCamera
  48083. * @param name defines camera name
  48084. * @param position defines initial position
  48085. * @param interaxialDistance defines distance between each color axis
  48086. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48087. * @param scene defines the hosting scene
  48088. */
  48089. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48090. /**
  48091. * Gets camera class name
  48092. * @returns StereoscopicFreeCamera
  48093. */
  48094. getClassName(): string;
  48095. }
  48096. }
  48097. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  48098. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  48099. import { Scene } from "babylonjs/scene";
  48100. import { Vector3 } from "babylonjs/Maths/math.vector";
  48101. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48102. /**
  48103. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  48104. * @see https://doc.babylonjs.com/features/cameras
  48105. */
  48106. export class StereoscopicGamepadCamera extends GamepadCamera {
  48107. /**
  48108. * Creates a new StereoscopicGamepadCamera
  48109. * @param name defines camera name
  48110. * @param position defines initial position
  48111. * @param interaxialDistance defines distance between each color axis
  48112. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48113. * @param scene defines the hosting scene
  48114. */
  48115. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48116. /**
  48117. * Gets camera class name
  48118. * @returns StereoscopicGamepadCamera
  48119. */
  48120. getClassName(): string;
  48121. }
  48122. }
  48123. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  48124. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48125. import { Scene } from "babylonjs/scene";
  48126. import { Vector3 } from "babylonjs/Maths/math.vector";
  48127. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48128. /**
  48129. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  48130. * @see https://doc.babylonjs.com/features/cameras
  48131. */
  48132. export class StereoscopicUniversalCamera extends UniversalCamera {
  48133. /**
  48134. * Creates a new StereoscopicUniversalCamera
  48135. * @param name defines camera name
  48136. * @param position defines initial position
  48137. * @param interaxialDistance defines distance between each color axis
  48138. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48139. * @param scene defines the hosting scene
  48140. */
  48141. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48142. /**
  48143. * Gets camera class name
  48144. * @returns StereoscopicUniversalCamera
  48145. */
  48146. getClassName(): string;
  48147. }
  48148. }
  48149. declare module "babylonjs/Cameras/Stereoscopic/index" {
  48150. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  48151. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  48152. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  48153. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  48154. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  48155. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  48156. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  48157. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  48158. }
  48159. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  48160. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48161. import { Scene } from "babylonjs/scene";
  48162. import { Vector3 } from "babylonjs/Maths/math.vector";
  48163. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  48164. /**
  48165. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  48166. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48167. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48168. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48169. */
  48170. export class VirtualJoysticksCamera extends FreeCamera {
  48171. /**
  48172. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  48173. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48174. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48175. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48176. * @param name Define the name of the camera in the scene
  48177. * @param position Define the start position of the camera in the scene
  48178. * @param scene Define the scene the camera belongs to
  48179. */
  48180. constructor(name: string, position: Vector3, scene: Scene);
  48181. /**
  48182. * Gets the current object class name.
  48183. * @return the class name
  48184. */
  48185. getClassName(): string;
  48186. }
  48187. }
  48188. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  48189. import { Matrix } from "babylonjs/Maths/math.vector";
  48190. /**
  48191. * This represents all the required metrics to create a VR camera.
  48192. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  48193. */
  48194. export class VRCameraMetrics {
  48195. /**
  48196. * Define the horizontal resolution off the screen.
  48197. */
  48198. hResolution: number;
  48199. /**
  48200. * Define the vertical resolution off the screen.
  48201. */
  48202. vResolution: number;
  48203. /**
  48204. * Define the horizontal screen size.
  48205. */
  48206. hScreenSize: number;
  48207. /**
  48208. * Define the vertical screen size.
  48209. */
  48210. vScreenSize: number;
  48211. /**
  48212. * Define the vertical screen center position.
  48213. */
  48214. vScreenCenter: number;
  48215. /**
  48216. * Define the distance of the eyes to the screen.
  48217. */
  48218. eyeToScreenDistance: number;
  48219. /**
  48220. * Define the distance between both lenses
  48221. */
  48222. lensSeparationDistance: number;
  48223. /**
  48224. * Define the distance between both viewer's eyes.
  48225. */
  48226. interpupillaryDistance: number;
  48227. /**
  48228. * Define the distortion factor of the VR postprocess.
  48229. * Please, touch with care.
  48230. */
  48231. distortionK: number[];
  48232. /**
  48233. * Define the chromatic aberration correction factors for the VR post process.
  48234. */
  48235. chromaAbCorrection: number[];
  48236. /**
  48237. * Define the scale factor of the post process.
  48238. * The smaller the better but the slower.
  48239. */
  48240. postProcessScaleFactor: number;
  48241. /**
  48242. * Define an offset for the lens center.
  48243. */
  48244. lensCenterOffset: number;
  48245. /**
  48246. * Define if the current vr camera should compensate the distortion of the lense or not.
  48247. */
  48248. compensateDistortion: boolean;
  48249. /**
  48250. * Defines if multiview should be enabled when rendering (Default: false)
  48251. */
  48252. multiviewEnabled: boolean;
  48253. /**
  48254. * Gets the rendering aspect ratio based on the provided resolutions.
  48255. */
  48256. get aspectRatio(): number;
  48257. /**
  48258. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  48259. */
  48260. get aspectRatioFov(): number;
  48261. /**
  48262. * @hidden
  48263. */
  48264. get leftHMatrix(): Matrix;
  48265. /**
  48266. * @hidden
  48267. */
  48268. get rightHMatrix(): Matrix;
  48269. /**
  48270. * @hidden
  48271. */
  48272. get leftPreViewMatrix(): Matrix;
  48273. /**
  48274. * @hidden
  48275. */
  48276. get rightPreViewMatrix(): Matrix;
  48277. /**
  48278. * Get the default VRMetrics based on the most generic setup.
  48279. * @returns the default vr metrics
  48280. */
  48281. static GetDefault(): VRCameraMetrics;
  48282. }
  48283. }
  48284. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48285. /** @hidden */
  48286. export var vrDistortionCorrectionPixelShader: {
  48287. name: string;
  48288. shader: string;
  48289. };
  48290. }
  48291. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48292. import { Camera } from "babylonjs/Cameras/camera";
  48293. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48294. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48295. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48296. /**
  48297. * VRDistortionCorrectionPostProcess used for mobile VR
  48298. */
  48299. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48300. private _isRightEye;
  48301. private _distortionFactors;
  48302. private _postProcessScaleFactor;
  48303. private _lensCenterOffset;
  48304. private _scaleIn;
  48305. private _scaleFactor;
  48306. private _lensCenter;
  48307. /**
  48308. * Gets a string identifying the name of the class
  48309. * @returns "VRDistortionCorrectionPostProcess" string
  48310. */
  48311. getClassName(): string;
  48312. /**
  48313. * Initializes the VRDistortionCorrectionPostProcess
  48314. * @param name The name of the effect.
  48315. * @param camera The camera to apply the render pass to.
  48316. * @param isRightEye If this is for the right eye distortion
  48317. * @param vrMetrics All the required metrics for the VR camera
  48318. */
  48319. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48320. }
  48321. }
  48322. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48323. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48324. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48325. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48326. import { Scene } from "babylonjs/scene";
  48327. import { Vector3 } from "babylonjs/Maths/math.vector";
  48328. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48329. import "babylonjs/Cameras/RigModes/vrRigMode";
  48330. /**
  48331. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48332. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48333. */
  48334. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48335. /**
  48336. * Creates a new VRDeviceOrientationArcRotateCamera
  48337. * @param name defines camera name
  48338. * @param alpha defines the camera rotation along the logitudinal axis
  48339. * @param beta defines the camera rotation along the latitudinal axis
  48340. * @param radius defines the camera distance from its target
  48341. * @param target defines the camera target
  48342. * @param scene defines the scene the camera belongs to
  48343. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48344. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48345. */
  48346. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48347. /**
  48348. * Gets camera class name
  48349. * @returns VRDeviceOrientationArcRotateCamera
  48350. */
  48351. getClassName(): string;
  48352. }
  48353. }
  48354. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48355. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48356. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48357. import { Scene } from "babylonjs/scene";
  48358. import { Vector3 } from "babylonjs/Maths/math.vector";
  48359. import "babylonjs/Cameras/RigModes/vrRigMode";
  48360. /**
  48361. * Camera used to simulate VR rendering (based on FreeCamera)
  48362. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48363. */
  48364. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48365. /**
  48366. * Creates a new VRDeviceOrientationFreeCamera
  48367. * @param name defines camera name
  48368. * @param position defines the start position of the camera
  48369. * @param scene defines the scene the camera belongs to
  48370. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48371. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48372. */
  48373. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48374. /**
  48375. * Gets camera class name
  48376. * @returns VRDeviceOrientationFreeCamera
  48377. */
  48378. getClassName(): string;
  48379. }
  48380. }
  48381. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48382. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48383. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48384. import { Scene } from "babylonjs/scene";
  48385. import { Vector3 } from "babylonjs/Maths/math.vector";
  48386. import "babylonjs/Gamepads/gamepadSceneComponent";
  48387. /**
  48388. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48389. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48390. */
  48391. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48392. /**
  48393. * Creates a new VRDeviceOrientationGamepadCamera
  48394. * @param name defines camera name
  48395. * @param position defines the start position of the camera
  48396. * @param scene defines the scene the camera belongs to
  48397. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48398. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48399. */
  48400. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48401. /**
  48402. * Gets camera class name
  48403. * @returns VRDeviceOrientationGamepadCamera
  48404. */
  48405. getClassName(): string;
  48406. }
  48407. }
  48408. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48409. import { Scene } from "babylonjs/scene";
  48410. import { Texture } from "babylonjs/Materials/Textures/texture";
  48411. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48412. /**
  48413. * A class extending Texture allowing drawing on a texture
  48414. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48415. */
  48416. export class DynamicTexture extends Texture {
  48417. private _generateMipMaps;
  48418. private _canvas;
  48419. private _context;
  48420. /**
  48421. * Creates a DynamicTexture
  48422. * @param name defines the name of the texture
  48423. * @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
  48424. * @param scene defines the scene where you want the texture
  48425. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48426. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48427. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48428. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  48429. */
  48430. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  48431. /**
  48432. * Get the current class name of the texture useful for serialization or dynamic coding.
  48433. * @returns "DynamicTexture"
  48434. */
  48435. getClassName(): string;
  48436. /**
  48437. * Gets the current state of canRescale
  48438. */
  48439. get canRescale(): boolean;
  48440. private _recreate;
  48441. /**
  48442. * Scales the texture
  48443. * @param ratio the scale factor to apply to both width and height
  48444. */
  48445. scale(ratio: number): void;
  48446. /**
  48447. * Resizes the texture
  48448. * @param width the new width
  48449. * @param height the new height
  48450. */
  48451. scaleTo(width: number, height: number): void;
  48452. /**
  48453. * Gets the context of the canvas used by the texture
  48454. * @returns the canvas context of the dynamic texture
  48455. */
  48456. getContext(): CanvasRenderingContext2D;
  48457. /**
  48458. * Clears the texture
  48459. */
  48460. clear(): void;
  48461. /**
  48462. * Updates the texture
  48463. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48464. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48465. */
  48466. update(invertY?: boolean, premulAlpha?: boolean): void;
  48467. /**
  48468. * Draws text onto the texture
  48469. * @param text defines the text to be drawn
  48470. * @param x defines the placement of the text from the left
  48471. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48472. * @param font defines the font to be used with font-style, font-size, font-name
  48473. * @param color defines the color used for the text
  48474. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48475. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48476. * @param update defines whether texture is immediately update (default is true)
  48477. */
  48478. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48479. /**
  48480. * Clones the texture
  48481. * @returns the clone of the texture.
  48482. */
  48483. clone(): DynamicTexture;
  48484. /**
  48485. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48486. * @returns a serialized dynamic texture object
  48487. */
  48488. serialize(): any;
  48489. private _IsCanvasElement;
  48490. /** @hidden */
  48491. _rebuild(): void;
  48492. }
  48493. }
  48494. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48495. import { Scene } from "babylonjs/scene";
  48496. import { Color3 } from "babylonjs/Maths/math.color";
  48497. import { Mesh } from "babylonjs/Meshes/mesh";
  48498. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48499. import { Nullable } from "babylonjs/types";
  48500. /**
  48501. * Class containing static functions to help procedurally build meshes
  48502. */
  48503. export class GroundBuilder {
  48504. /**
  48505. * Creates a ground mesh
  48506. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48507. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48509. * @param name defines the name of the mesh
  48510. * @param options defines the options used to create the mesh
  48511. * @param scene defines the hosting scene
  48512. * @returns the ground mesh
  48513. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48514. */
  48515. static CreateGround(name: string, options: {
  48516. width?: number;
  48517. height?: number;
  48518. subdivisions?: number;
  48519. subdivisionsX?: number;
  48520. subdivisionsY?: number;
  48521. updatable?: boolean;
  48522. }, scene: any): Mesh;
  48523. /**
  48524. * Creates a tiled ground mesh
  48525. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48526. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48527. * * 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
  48528. * * 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
  48529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48530. * @param name defines the name of the mesh
  48531. * @param options defines the options used to create the mesh
  48532. * @param scene defines the hosting scene
  48533. * @returns the tiled ground mesh
  48534. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48535. */
  48536. static CreateTiledGround(name: string, options: {
  48537. xmin: number;
  48538. zmin: number;
  48539. xmax: number;
  48540. zmax: number;
  48541. subdivisions?: {
  48542. w: number;
  48543. h: number;
  48544. };
  48545. precision?: {
  48546. w: number;
  48547. h: number;
  48548. };
  48549. updatable?: boolean;
  48550. }, scene?: Nullable<Scene>): Mesh;
  48551. /**
  48552. * Creates a ground mesh from a height map
  48553. * * The parameter `url` sets the URL of the height map image resource.
  48554. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48555. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48556. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48557. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48558. * * 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.
  48559. * * 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).
  48560. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48562. * @param name defines the name of the mesh
  48563. * @param url defines the url to the height map
  48564. * @param options defines the options used to create the mesh
  48565. * @param scene defines the hosting scene
  48566. * @returns the ground mesh
  48567. * @see https://doc.babylonjs.com/babylon101/height_map
  48568. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48569. */
  48570. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48571. width?: number;
  48572. height?: number;
  48573. subdivisions?: number;
  48574. minHeight?: number;
  48575. maxHeight?: number;
  48576. colorFilter?: Color3;
  48577. alphaFilter?: number;
  48578. updatable?: boolean;
  48579. onReady?: (mesh: GroundMesh) => void;
  48580. }, scene?: Nullable<Scene>): GroundMesh;
  48581. }
  48582. }
  48583. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48584. import { Vector4 } from "babylonjs/Maths/math.vector";
  48585. import { Mesh } from "babylonjs/Meshes/mesh";
  48586. /**
  48587. * Class containing static functions to help procedurally build meshes
  48588. */
  48589. export class TorusBuilder {
  48590. /**
  48591. * Creates a torus mesh
  48592. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48593. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48594. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48598. * @param name defines the name of the mesh
  48599. * @param options defines the options used to create the mesh
  48600. * @param scene defines the hosting scene
  48601. * @returns the torus mesh
  48602. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48603. */
  48604. static CreateTorus(name: string, options: {
  48605. diameter?: number;
  48606. thickness?: number;
  48607. tessellation?: number;
  48608. updatable?: boolean;
  48609. sideOrientation?: number;
  48610. frontUVs?: Vector4;
  48611. backUVs?: Vector4;
  48612. }, scene: any): Mesh;
  48613. }
  48614. }
  48615. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48616. import { Vector4 } from "babylonjs/Maths/math.vector";
  48617. import { Color4 } from "babylonjs/Maths/math.color";
  48618. import { Mesh } from "babylonjs/Meshes/mesh";
  48619. /**
  48620. * Class containing static functions to help procedurally build meshes
  48621. */
  48622. export class CylinderBuilder {
  48623. /**
  48624. * Creates a cylinder or a cone mesh
  48625. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48626. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48627. * * 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.
  48628. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48629. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48630. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48631. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48632. * * 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).
  48633. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48634. * * 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).
  48635. * * 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
  48636. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48637. * * 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
  48638. * * 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.
  48639. * * If `enclose` is false, a ring surface is one element.
  48640. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48641. * * 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
  48642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48643. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48645. * @param name defines the name of the mesh
  48646. * @param options defines the options used to create the mesh
  48647. * @param scene defines the hosting scene
  48648. * @returns the cylinder mesh
  48649. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48650. */
  48651. static CreateCylinder(name: string, options: {
  48652. height?: number;
  48653. diameterTop?: number;
  48654. diameterBottom?: number;
  48655. diameter?: number;
  48656. tessellation?: number;
  48657. subdivisions?: number;
  48658. arc?: number;
  48659. faceColors?: Color4[];
  48660. faceUV?: Vector4[];
  48661. updatable?: boolean;
  48662. hasRings?: boolean;
  48663. enclose?: boolean;
  48664. cap?: number;
  48665. sideOrientation?: number;
  48666. frontUVs?: Vector4;
  48667. backUVs?: Vector4;
  48668. }, scene: any): Mesh;
  48669. }
  48670. }
  48671. declare module "babylonjs/XR/webXRTypes" {
  48672. import { Nullable } from "babylonjs/types";
  48673. import { IDisposable } from "babylonjs/scene";
  48674. /**
  48675. * States of the webXR experience
  48676. */
  48677. export enum WebXRState {
  48678. /**
  48679. * Transitioning to being in XR mode
  48680. */
  48681. ENTERING_XR = 0,
  48682. /**
  48683. * Transitioning to non XR mode
  48684. */
  48685. EXITING_XR = 1,
  48686. /**
  48687. * In XR mode and presenting
  48688. */
  48689. IN_XR = 2,
  48690. /**
  48691. * Not entered XR mode
  48692. */
  48693. NOT_IN_XR = 3
  48694. }
  48695. /**
  48696. * Abstraction of the XR render target
  48697. */
  48698. export interface WebXRRenderTarget extends IDisposable {
  48699. /**
  48700. * xrpresent context of the canvas which can be used to display/mirror xr content
  48701. */
  48702. canvasContext: WebGLRenderingContext;
  48703. /**
  48704. * xr layer for the canvas
  48705. */
  48706. xrLayer: Nullable<XRWebGLLayer>;
  48707. /**
  48708. * Initializes the xr layer for the session
  48709. * @param xrSession xr session
  48710. * @returns a promise that will resolve once the XR Layer has been created
  48711. */
  48712. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48713. }
  48714. }
  48715. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48716. import { Nullable } from "babylonjs/types";
  48717. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  48718. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48719. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48720. import { Observable } from "babylonjs/Misc/observable";
  48721. /**
  48722. * COnfiguration object for WebXR output canvas
  48723. */
  48724. export class WebXRManagedOutputCanvasOptions {
  48725. /**
  48726. * An optional canvas in case you wish to create it yourself and provide it here.
  48727. * If not provided, a new canvas will be created
  48728. */
  48729. canvasElement?: HTMLCanvasElement;
  48730. /**
  48731. * Options for this XR Layer output
  48732. */
  48733. canvasOptions?: XRWebGLLayerOptions;
  48734. /**
  48735. * CSS styling for a newly created canvas (if not provided)
  48736. */
  48737. newCanvasCssStyle?: string;
  48738. /**
  48739. * Get the default values of the configuration object
  48740. * @param engine defines the engine to use (can be null)
  48741. * @returns default values of this configuration object
  48742. */
  48743. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  48744. }
  48745. /**
  48746. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48747. */
  48748. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48749. private _options;
  48750. private _canvas;
  48751. private _engine;
  48752. private _originalCanvasSize;
  48753. /**
  48754. * Rendering context of the canvas which can be used to display/mirror xr content
  48755. */
  48756. canvasContext: WebGLRenderingContext;
  48757. /**
  48758. * xr layer for the canvas
  48759. */
  48760. xrLayer: Nullable<XRWebGLLayer>;
  48761. /**
  48762. * Obseervers registered here will be triggered when the xr layer was initialized
  48763. */
  48764. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48765. /**
  48766. * Initializes the canvas to be added/removed upon entering/exiting xr
  48767. * @param _xrSessionManager The XR Session manager
  48768. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48769. */
  48770. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48771. /**
  48772. * Disposes of the object
  48773. */
  48774. dispose(): void;
  48775. /**
  48776. * Initializes the xr layer for the session
  48777. * @param xrSession xr session
  48778. * @returns a promise that will resolve once the XR Layer has been created
  48779. */
  48780. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48781. private _addCanvas;
  48782. private _removeCanvas;
  48783. private _setCanvasSize;
  48784. private _setManagedOutputCanvas;
  48785. }
  48786. }
  48787. declare module "babylonjs/XR/webXRSessionManager" {
  48788. import { Observable } from "babylonjs/Misc/observable";
  48789. import { Nullable } from "babylonjs/types";
  48790. import { IDisposable, Scene } from "babylonjs/scene";
  48791. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48792. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48793. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48794. /**
  48795. * Manages an XRSession to work with Babylon's engine
  48796. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48797. */
  48798. export class WebXRSessionManager implements IDisposable {
  48799. /** The scene which the session should be created for */
  48800. scene: Scene;
  48801. private _referenceSpace;
  48802. private _rttProvider;
  48803. private _sessionEnded;
  48804. private _xrNavigator;
  48805. private baseLayer;
  48806. /**
  48807. * The base reference space from which the session started. good if you want to reset your
  48808. * reference space
  48809. */
  48810. baseReferenceSpace: XRReferenceSpace;
  48811. /**
  48812. * Current XR frame
  48813. */
  48814. currentFrame: Nullable<XRFrame>;
  48815. /** WebXR timestamp updated every frame */
  48816. currentTimestamp: number;
  48817. /**
  48818. * Used just in case of a failure to initialize an immersive session.
  48819. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48820. */
  48821. defaultHeightCompensation: number;
  48822. /**
  48823. * Fires every time a new xrFrame arrives which can be used to update the camera
  48824. */
  48825. onXRFrameObservable: Observable<XRFrame>;
  48826. /**
  48827. * Fires when the reference space changed
  48828. */
  48829. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48830. /**
  48831. * Fires when the xr session is ended either by the device or manually done
  48832. */
  48833. onXRSessionEnded: Observable<any>;
  48834. /**
  48835. * Fires when the xr session is ended either by the device or manually done
  48836. */
  48837. onXRSessionInit: Observable<XRSession>;
  48838. /**
  48839. * Underlying xr session
  48840. */
  48841. session: XRSession;
  48842. /**
  48843. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48844. * or get the offset the player is currently at.
  48845. */
  48846. viewerReferenceSpace: XRReferenceSpace;
  48847. /**
  48848. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48849. * @param scene The scene which the session should be created for
  48850. */
  48851. constructor(
  48852. /** The scene which the session should be created for */
  48853. scene: Scene);
  48854. /**
  48855. * The current reference space used in this session. This reference space can constantly change!
  48856. * It is mainly used to offset the camera's position.
  48857. */
  48858. get referenceSpace(): XRReferenceSpace;
  48859. /**
  48860. * Set a new reference space and triggers the observable
  48861. */
  48862. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48863. /**
  48864. * Disposes of the session manager
  48865. */
  48866. dispose(): void;
  48867. /**
  48868. * Stops the xrSession and restores the render loop
  48869. * @returns Promise which resolves after it exits XR
  48870. */
  48871. exitXRAsync(): Promise<void>;
  48872. /**
  48873. * Gets the correct render target texture to be rendered this frame for this eye
  48874. * @param eye the eye for which to get the render target
  48875. * @returns the render target for the specified eye
  48876. */
  48877. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48878. /**
  48879. * Creates a WebXRRenderTarget object for the XR session
  48880. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48881. * @param options optional options to provide when creating a new render target
  48882. * @returns a WebXR render target to which the session can render
  48883. */
  48884. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48885. /**
  48886. * Initializes the manager
  48887. * After initialization enterXR can be called to start an XR session
  48888. * @returns Promise which resolves after it is initialized
  48889. */
  48890. initializeAsync(): Promise<void>;
  48891. /**
  48892. * Initializes an xr session
  48893. * @param xrSessionMode mode to initialize
  48894. * @param xrSessionInit defines optional and required values to pass to the session builder
  48895. * @returns a promise which will resolve once the session has been initialized
  48896. */
  48897. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48898. /**
  48899. * Checks if a session would be supported for the creation options specified
  48900. * @param sessionMode session mode to check if supported eg. immersive-vr
  48901. * @returns A Promise that resolves to true if supported and false if not
  48902. */
  48903. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48904. /**
  48905. * Resets the reference space to the one started the session
  48906. */
  48907. resetReferenceSpace(): void;
  48908. /**
  48909. * Starts rendering to the xr layer
  48910. */
  48911. runXRRenderLoop(): void;
  48912. /**
  48913. * Sets the reference space on the xr session
  48914. * @param referenceSpaceType space to set
  48915. * @returns a promise that will resolve once the reference space has been set
  48916. */
  48917. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48918. /**
  48919. * Updates the render state of the session
  48920. * @param state state to set
  48921. * @returns a promise that resolves once the render state has been updated
  48922. */
  48923. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48924. /**
  48925. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48926. * @param sessionMode defines the session to test
  48927. * @returns a promise with boolean as final value
  48928. */
  48929. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48930. private _createRenderTargetTexture;
  48931. }
  48932. }
  48933. declare module "babylonjs/XR/webXRCamera" {
  48934. import { Vector3 } from "babylonjs/Maths/math.vector";
  48935. import { Scene } from "babylonjs/scene";
  48936. import { Camera } from "babylonjs/Cameras/camera";
  48937. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48938. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48939. import { Observable } from "babylonjs/Misc/observable";
  48940. /**
  48941. * WebXR Camera which holds the views for the xrSession
  48942. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48943. */
  48944. export class WebXRCamera extends FreeCamera {
  48945. private _xrSessionManager;
  48946. private _firstFrame;
  48947. private _referenceQuaternion;
  48948. private _referencedPosition;
  48949. private _xrInvPositionCache;
  48950. private _xrInvQuaternionCache;
  48951. /**
  48952. * Observable raised before camera teleportation
  48953. */
  48954. onBeforeCameraTeleport: Observable<Vector3>;
  48955. /**
  48956. * Observable raised after camera teleportation
  48957. */
  48958. onAfterCameraTeleport: Observable<Vector3>;
  48959. /**
  48960. * Should position compensation execute on first frame.
  48961. * This is used when copying the position from a native (non XR) camera
  48962. */
  48963. compensateOnFirstFrame: boolean;
  48964. /**
  48965. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48966. * @param name the name of the camera
  48967. * @param scene the scene to add the camera to
  48968. * @param _xrSessionManager a constructed xr session manager
  48969. */
  48970. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48971. /**
  48972. * Return the user's height, unrelated to the current ground.
  48973. * This will be the y position of this camera, when ground level is 0.
  48974. */
  48975. get realWorldHeight(): number;
  48976. /** @hidden */
  48977. _updateForDualEyeDebugging(): void;
  48978. /**
  48979. * Sets this camera's transformation based on a non-vr camera
  48980. * @param otherCamera the non-vr camera to copy the transformation from
  48981. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48982. */
  48983. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48984. /**
  48985. * Gets the current instance class name ("WebXRCamera").
  48986. * @returns the class name
  48987. */
  48988. getClassName(): string;
  48989. private _rotate180;
  48990. private _updateFromXRSession;
  48991. private _updateNumberOfRigCameras;
  48992. private _updateReferenceSpace;
  48993. private _updateReferenceSpaceOffset;
  48994. }
  48995. }
  48996. declare module "babylonjs/XR/webXRFeaturesManager" {
  48997. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48998. import { IDisposable } from "babylonjs/scene";
  48999. /**
  49000. * Defining the interface required for a (webxr) feature
  49001. */
  49002. export interface IWebXRFeature extends IDisposable {
  49003. /**
  49004. * Is this feature attached
  49005. */
  49006. attached: boolean;
  49007. /**
  49008. * Should auto-attach be disabled?
  49009. */
  49010. disableAutoAttach: boolean;
  49011. /**
  49012. * Attach the feature to the session
  49013. * Will usually be called by the features manager
  49014. *
  49015. * @param force should attachment be forced (even when already attached)
  49016. * @returns true if successful.
  49017. */
  49018. attach(force?: boolean): boolean;
  49019. /**
  49020. * Detach the feature from the session
  49021. * Will usually be called by the features manager
  49022. *
  49023. * @returns true if successful.
  49024. */
  49025. detach(): boolean;
  49026. /**
  49027. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  49028. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  49029. *
  49030. * @returns whether or not the feature is compatible in this environment
  49031. */
  49032. isCompatible(): boolean;
  49033. /**
  49034. * Was this feature disposed;
  49035. */
  49036. isDisposed: boolean;
  49037. /**
  49038. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  49039. */
  49040. xrNativeFeatureName?: string;
  49041. /**
  49042. * A list of (Babylon WebXR) features this feature depends on
  49043. */
  49044. dependsOn?: string[];
  49045. }
  49046. /**
  49047. * A list of the currently available features without referencing them
  49048. */
  49049. export class WebXRFeatureName {
  49050. /**
  49051. * The name of the anchor system feature
  49052. */
  49053. static readonly ANCHOR_SYSTEM: string;
  49054. /**
  49055. * The name of the background remover feature
  49056. */
  49057. static readonly BACKGROUND_REMOVER: string;
  49058. /**
  49059. * The name of the hit test feature
  49060. */
  49061. static readonly HIT_TEST: string;
  49062. /**
  49063. * physics impostors for xr controllers feature
  49064. */
  49065. static readonly PHYSICS_CONTROLLERS: string;
  49066. /**
  49067. * The name of the plane detection feature
  49068. */
  49069. static readonly PLANE_DETECTION: string;
  49070. /**
  49071. * The name of the pointer selection feature
  49072. */
  49073. static readonly POINTER_SELECTION: string;
  49074. /**
  49075. * The name of the teleportation feature
  49076. */
  49077. static readonly TELEPORTATION: string;
  49078. /**
  49079. * The name of the feature points feature.
  49080. */
  49081. static readonly FEATURE_POINTS: string;
  49082. /**
  49083. * The name of the hand tracking feature.
  49084. */
  49085. static readonly HAND_TRACKING: string;
  49086. }
  49087. /**
  49088. * Defining the constructor of a feature. Used to register the modules.
  49089. */
  49090. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  49091. /**
  49092. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  49093. * It is mainly used in AR sessions.
  49094. *
  49095. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  49096. */
  49097. export class WebXRFeaturesManager implements IDisposable {
  49098. private _xrSessionManager;
  49099. private static readonly _AvailableFeatures;
  49100. private _features;
  49101. /**
  49102. * constructs a new features manages.
  49103. *
  49104. * @param _xrSessionManager an instance of WebXRSessionManager
  49105. */
  49106. constructor(_xrSessionManager: WebXRSessionManager);
  49107. /**
  49108. * Used to register a module. After calling this function a developer can use this feature in the scene.
  49109. * Mainly used internally.
  49110. *
  49111. * @param featureName the name of the feature to register
  49112. * @param constructorFunction the function used to construct the module
  49113. * @param version the (babylon) version of the module
  49114. * @param stable is that a stable version of this module
  49115. */
  49116. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  49117. /**
  49118. * Returns a constructor of a specific feature.
  49119. *
  49120. * @param featureName the name of the feature to construct
  49121. * @param version the version of the feature to load
  49122. * @param xrSessionManager the xrSessionManager. Used to construct the module
  49123. * @param options optional options provided to the module.
  49124. * @returns a function that, when called, will return a new instance of this feature
  49125. */
  49126. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  49127. /**
  49128. * Can be used to return the list of features currently registered
  49129. *
  49130. * @returns an Array of available features
  49131. */
  49132. static GetAvailableFeatures(): string[];
  49133. /**
  49134. * Gets the versions available for a specific feature
  49135. * @param featureName the name of the feature
  49136. * @returns an array with the available versions
  49137. */
  49138. static GetAvailableVersions(featureName: string): string[];
  49139. /**
  49140. * Return the latest unstable version of this feature
  49141. * @param featureName the name of the feature to search
  49142. * @returns the version number. if not found will return -1
  49143. */
  49144. static GetLatestVersionOfFeature(featureName: string): number;
  49145. /**
  49146. * Return the latest stable version of this feature
  49147. * @param featureName the name of the feature to search
  49148. * @returns the version number. if not found will return -1
  49149. */
  49150. static GetStableVersionOfFeature(featureName: string): number;
  49151. /**
  49152. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  49153. * Can be used during a session to start a feature
  49154. * @param featureName the name of feature to attach
  49155. */
  49156. attachFeature(featureName: string): void;
  49157. /**
  49158. * Can be used inside a session or when the session ends to detach a specific feature
  49159. * @param featureName the name of the feature to detach
  49160. */
  49161. detachFeature(featureName: string): void;
  49162. /**
  49163. * Used to disable an already-enabled feature
  49164. * The feature will be disposed and will be recreated once enabled.
  49165. * @param featureName the feature to disable
  49166. * @returns true if disable was successful
  49167. */
  49168. disableFeature(featureName: string | {
  49169. Name: string;
  49170. }): boolean;
  49171. /**
  49172. * dispose this features manager
  49173. */
  49174. dispose(): void;
  49175. /**
  49176. * 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.
  49177. * 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.
  49178. *
  49179. * @param featureName the name of the feature to load or the class of the feature
  49180. * @param version optional version to load. if not provided the latest version will be enabled
  49181. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  49182. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  49183. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  49184. * @returns a new constructed feature or throws an error if feature not found.
  49185. */
  49186. enableFeature(featureName: string | {
  49187. Name: string;
  49188. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  49189. /**
  49190. * get the implementation of an enabled feature.
  49191. * @param featureName the name of the feature to load
  49192. * @returns the feature class, if found
  49193. */
  49194. getEnabledFeature(featureName: string): IWebXRFeature;
  49195. /**
  49196. * Get the list of enabled features
  49197. * @returns an array of enabled features
  49198. */
  49199. getEnabledFeatures(): string[];
  49200. /**
  49201. * This function will exten the session creation configuration object with enabled features.
  49202. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  49203. * according to the defined "required" variable, provided during enableFeature call
  49204. * @param xrSessionInit the xr Session init object to extend
  49205. *
  49206. * @returns an extended XRSessionInit object
  49207. */
  49208. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  49209. }
  49210. }
  49211. declare module "babylonjs/XR/webXRExperienceHelper" {
  49212. import { Observable } from "babylonjs/Misc/observable";
  49213. import { IDisposable, Scene } from "babylonjs/scene";
  49214. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49215. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49216. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49217. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  49218. /**
  49219. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  49220. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  49221. */
  49222. export class WebXRExperienceHelper implements IDisposable {
  49223. private scene;
  49224. private _nonVRCamera;
  49225. private _originalSceneAutoClear;
  49226. private _supported;
  49227. /**
  49228. * Camera used to render xr content
  49229. */
  49230. camera: WebXRCamera;
  49231. /** A features manager for this xr session */
  49232. featuresManager: WebXRFeaturesManager;
  49233. /**
  49234. * Observers registered here will be triggered after the camera's initial transformation is set
  49235. * This can be used to set a different ground level or an extra rotation.
  49236. *
  49237. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  49238. * to the position set after this observable is done executing.
  49239. */
  49240. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  49241. /**
  49242. * Fires when the state of the experience helper has changed
  49243. */
  49244. onStateChangedObservable: Observable<WebXRState>;
  49245. /** Session manager used to keep track of xr session */
  49246. sessionManager: WebXRSessionManager;
  49247. /**
  49248. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  49249. */
  49250. state: WebXRState;
  49251. /**
  49252. * Creates a WebXRExperienceHelper
  49253. * @param scene The scene the helper should be created in
  49254. */
  49255. private constructor();
  49256. /**
  49257. * Creates the experience helper
  49258. * @param scene the scene to attach the experience helper to
  49259. * @returns a promise for the experience helper
  49260. */
  49261. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  49262. /**
  49263. * Disposes of the experience helper
  49264. */
  49265. dispose(): void;
  49266. /**
  49267. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  49268. * @param sessionMode options for the XR session
  49269. * @param referenceSpaceType frame of reference of the XR session
  49270. * @param renderTarget the output canvas that will be used to enter XR mode
  49271. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  49272. * @returns promise that resolves after xr mode has entered
  49273. */
  49274. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  49275. /**
  49276. * Exits XR mode and returns the scene to its original state
  49277. * @returns promise that resolves after xr mode has exited
  49278. */
  49279. exitXRAsync(): Promise<void>;
  49280. private _nonXRToXRCamera;
  49281. private _setState;
  49282. }
  49283. }
  49284. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  49285. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49286. import { Observable } from "babylonjs/Misc/observable";
  49287. import { IDisposable } from "babylonjs/scene";
  49288. /**
  49289. * X-Y values for axes in WebXR
  49290. */
  49291. export interface IWebXRMotionControllerAxesValue {
  49292. /**
  49293. * The value of the x axis
  49294. */
  49295. x: number;
  49296. /**
  49297. * The value of the y-axis
  49298. */
  49299. y: number;
  49300. }
  49301. /**
  49302. * changed / previous values for the values of this component
  49303. */
  49304. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49305. /**
  49306. * current (this frame) value
  49307. */
  49308. current: T;
  49309. /**
  49310. * previous (last change) value
  49311. */
  49312. previous: T;
  49313. }
  49314. /**
  49315. * Represents changes in the component between current frame and last values recorded
  49316. */
  49317. export interface IWebXRMotionControllerComponentChanges {
  49318. /**
  49319. * will be populated with previous and current values if axes changed
  49320. */
  49321. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49322. /**
  49323. * will be populated with previous and current values if pressed changed
  49324. */
  49325. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49326. /**
  49327. * will be populated with previous and current values if touched changed
  49328. */
  49329. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49330. /**
  49331. * will be populated with previous and current values if value changed
  49332. */
  49333. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49334. }
  49335. /**
  49336. * This class represents a single component (for example button or thumbstick) of a motion controller
  49337. */
  49338. export class WebXRControllerComponent implements IDisposable {
  49339. /**
  49340. * the id of this component
  49341. */
  49342. id: string;
  49343. /**
  49344. * the type of the component
  49345. */
  49346. type: MotionControllerComponentType;
  49347. private _buttonIndex;
  49348. private _axesIndices;
  49349. private _axes;
  49350. private _changes;
  49351. private _currentValue;
  49352. private _hasChanges;
  49353. private _pressed;
  49354. private _touched;
  49355. /**
  49356. * button component type
  49357. */
  49358. static BUTTON_TYPE: MotionControllerComponentType;
  49359. /**
  49360. * squeeze component type
  49361. */
  49362. static SQUEEZE_TYPE: MotionControllerComponentType;
  49363. /**
  49364. * Thumbstick component type
  49365. */
  49366. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49367. /**
  49368. * Touchpad component type
  49369. */
  49370. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49371. /**
  49372. * trigger component type
  49373. */
  49374. static TRIGGER_TYPE: MotionControllerComponentType;
  49375. /**
  49376. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49377. * the axes data changes
  49378. */
  49379. onAxisValueChangedObservable: Observable<{
  49380. x: number;
  49381. y: number;
  49382. }>;
  49383. /**
  49384. * Observers registered here will be triggered when the state of a button changes
  49385. * State change is either pressed / touched / value
  49386. */
  49387. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49388. /**
  49389. * Creates a new component for a motion controller.
  49390. * It is created by the motion controller itself
  49391. *
  49392. * @param id the id of this component
  49393. * @param type the type of the component
  49394. * @param _buttonIndex index in the buttons array of the gamepad
  49395. * @param _axesIndices indices of the values in the axes array of the gamepad
  49396. */
  49397. constructor(
  49398. /**
  49399. * the id of this component
  49400. */
  49401. id: string,
  49402. /**
  49403. * the type of the component
  49404. */
  49405. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49406. /**
  49407. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49408. */
  49409. get axes(): IWebXRMotionControllerAxesValue;
  49410. /**
  49411. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49412. */
  49413. get changes(): IWebXRMotionControllerComponentChanges;
  49414. /**
  49415. * Return whether or not the component changed the last frame
  49416. */
  49417. get hasChanges(): boolean;
  49418. /**
  49419. * is the button currently pressed
  49420. */
  49421. get pressed(): boolean;
  49422. /**
  49423. * is the button currently touched
  49424. */
  49425. get touched(): boolean;
  49426. /**
  49427. * Get the current value of this component
  49428. */
  49429. get value(): number;
  49430. /**
  49431. * Dispose this component
  49432. */
  49433. dispose(): void;
  49434. /**
  49435. * Are there axes correlating to this component
  49436. * @return true is axes data is available
  49437. */
  49438. isAxes(): boolean;
  49439. /**
  49440. * Is this component a button (hence - pressable)
  49441. * @returns true if can be pressed
  49442. */
  49443. isButton(): boolean;
  49444. /**
  49445. * update this component using the gamepad object it is in. Called on every frame
  49446. * @param nativeController the native gamepad controller object
  49447. */
  49448. update(nativeController: IMinimalMotionControllerObject): void;
  49449. }
  49450. }
  49451. declare module "babylonjs/Loading/sceneLoader" {
  49452. import { Observable } from "babylonjs/Misc/observable";
  49453. import { Nullable } from "babylonjs/types";
  49454. import { Scene } from "babylonjs/scene";
  49455. import { Engine } from "babylonjs/Engines/engine";
  49456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49457. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49458. import { AssetContainer } from "babylonjs/assetContainer";
  49459. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49460. import { Skeleton } from "babylonjs/Bones/skeleton";
  49461. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49462. import { WebRequest } from "babylonjs/Misc/webRequest";
  49463. /**
  49464. * Interface used to represent data loading progression
  49465. */
  49466. export interface ISceneLoaderProgressEvent {
  49467. /**
  49468. * Defines if data length to load can be evaluated
  49469. */
  49470. readonly lengthComputable: boolean;
  49471. /**
  49472. * Defines the loaded data length
  49473. */
  49474. readonly loaded: number;
  49475. /**
  49476. * Defines the data length to load
  49477. */
  49478. readonly total: number;
  49479. }
  49480. /**
  49481. * Interface used by SceneLoader plugins to define supported file extensions
  49482. */
  49483. export interface ISceneLoaderPluginExtensions {
  49484. /**
  49485. * Defines the list of supported extensions
  49486. */
  49487. [extension: string]: {
  49488. isBinary: boolean;
  49489. };
  49490. }
  49491. /**
  49492. * Interface used by SceneLoader plugin factory
  49493. */
  49494. export interface ISceneLoaderPluginFactory {
  49495. /**
  49496. * Defines the name of the factory
  49497. */
  49498. name: string;
  49499. /**
  49500. * Function called to create a new plugin
  49501. * @return the new plugin
  49502. */
  49503. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49504. /**
  49505. * The callback that returns true if the data can be directly loaded.
  49506. * @param data string containing the file data
  49507. * @returns if the data can be loaded directly
  49508. */
  49509. canDirectLoad?(data: string): boolean;
  49510. }
  49511. /**
  49512. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49513. */
  49514. export interface ISceneLoaderPluginBase {
  49515. /**
  49516. * The friendly name of this plugin.
  49517. */
  49518. name: string;
  49519. /**
  49520. * The file extensions supported by this plugin.
  49521. */
  49522. extensions: string | ISceneLoaderPluginExtensions;
  49523. /**
  49524. * The callback called when loading from a url.
  49525. * @param scene scene loading this url
  49526. * @param url url to load
  49527. * @param onSuccess callback called when the file successfully loads
  49528. * @param onProgress callback called while file is loading (if the server supports this mode)
  49529. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49530. * @param onError callback called when the file fails to load
  49531. * @returns a file request object
  49532. */
  49533. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49534. /**
  49535. * The callback called when loading from a file object.
  49536. * @param scene scene loading this file
  49537. * @param file defines the file to load
  49538. * @param onSuccess defines the callback to call when data is loaded
  49539. * @param onProgress defines the callback to call during loading process
  49540. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49541. * @param onError defines the callback to call when an error occurs
  49542. * @returns a file request object
  49543. */
  49544. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49545. /**
  49546. * The callback that returns true if the data can be directly loaded.
  49547. * @param data string containing the file data
  49548. * @returns if the data can be loaded directly
  49549. */
  49550. canDirectLoad?(data: string): boolean;
  49551. /**
  49552. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49553. * @param scene scene loading this data
  49554. * @param data string containing the data
  49555. * @returns data to pass to the plugin
  49556. */
  49557. directLoad?(scene: Scene, data: string): any;
  49558. /**
  49559. * The callback that allows custom handling of the root url based on the response url.
  49560. * @param rootUrl the original root url
  49561. * @param responseURL the response url if available
  49562. * @returns the new root url
  49563. */
  49564. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49565. }
  49566. /**
  49567. * Interface used to define a SceneLoader plugin
  49568. */
  49569. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49570. /**
  49571. * Import meshes into a scene.
  49572. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49573. * @param scene The scene to import into
  49574. * @param data The data to import
  49575. * @param rootUrl The root url for scene and resources
  49576. * @param meshes The meshes array to import into
  49577. * @param particleSystems The particle systems array to import into
  49578. * @param skeletons The skeletons array to import into
  49579. * @param onError The callback when import fails
  49580. * @returns True if successful or false otherwise
  49581. */
  49582. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49583. /**
  49584. * Load into a scene.
  49585. * @param scene The scene to load into
  49586. * @param data The data to import
  49587. * @param rootUrl The root url for scene and resources
  49588. * @param onError The callback when import fails
  49589. * @returns True if successful or false otherwise
  49590. */
  49591. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49592. /**
  49593. * Load into an asset container.
  49594. * @param scene The scene to load into
  49595. * @param data The data to import
  49596. * @param rootUrl The root url for scene and resources
  49597. * @param onError The callback when import fails
  49598. * @returns The loaded asset container
  49599. */
  49600. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49601. }
  49602. /**
  49603. * Interface used to define an async SceneLoader plugin
  49604. */
  49605. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49606. /**
  49607. * Import meshes into a scene.
  49608. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49609. * @param scene The scene to import into
  49610. * @param data The data to import
  49611. * @param rootUrl The root url for scene and resources
  49612. * @param onProgress The callback when the load progresses
  49613. * @param fileName Defines the name of the file to load
  49614. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49615. */
  49616. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49617. meshes: AbstractMesh[];
  49618. particleSystems: IParticleSystem[];
  49619. skeletons: Skeleton[];
  49620. animationGroups: AnimationGroup[];
  49621. }>;
  49622. /**
  49623. * Load into a scene.
  49624. * @param scene The scene to load into
  49625. * @param data The data to import
  49626. * @param rootUrl The root url for scene and resources
  49627. * @param onProgress The callback when the load progresses
  49628. * @param fileName Defines the name of the file to load
  49629. * @returns Nothing
  49630. */
  49631. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49632. /**
  49633. * Load into an asset container.
  49634. * @param scene The scene to load into
  49635. * @param data The data to import
  49636. * @param rootUrl The root url for scene and resources
  49637. * @param onProgress The callback when the load progresses
  49638. * @param fileName Defines the name of the file to load
  49639. * @returns The loaded asset container
  49640. */
  49641. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49642. }
  49643. /**
  49644. * Mode that determines how to handle old animation groups before loading new ones.
  49645. */
  49646. export enum SceneLoaderAnimationGroupLoadingMode {
  49647. /**
  49648. * Reset all old animations to initial state then dispose them.
  49649. */
  49650. Clean = 0,
  49651. /**
  49652. * Stop all old animations.
  49653. */
  49654. Stop = 1,
  49655. /**
  49656. * Restart old animations from first frame.
  49657. */
  49658. Sync = 2,
  49659. /**
  49660. * Old animations remains untouched.
  49661. */
  49662. NoSync = 3
  49663. }
  49664. /**
  49665. * Defines a plugin registered by the SceneLoader
  49666. */
  49667. interface IRegisteredPlugin {
  49668. /**
  49669. * Defines the plugin to use
  49670. */
  49671. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49672. /**
  49673. * Defines if the plugin supports binary data
  49674. */
  49675. isBinary: boolean;
  49676. }
  49677. /**
  49678. * Class used to load scene from various file formats using registered plugins
  49679. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49680. */
  49681. export class SceneLoader {
  49682. /**
  49683. * No logging while loading
  49684. */
  49685. static readonly NO_LOGGING: number;
  49686. /**
  49687. * Minimal logging while loading
  49688. */
  49689. static readonly MINIMAL_LOGGING: number;
  49690. /**
  49691. * Summary logging while loading
  49692. */
  49693. static readonly SUMMARY_LOGGING: number;
  49694. /**
  49695. * Detailled logging while loading
  49696. */
  49697. static readonly DETAILED_LOGGING: number;
  49698. /**
  49699. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49700. */
  49701. static get ForceFullSceneLoadingForIncremental(): boolean;
  49702. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49703. /**
  49704. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49705. */
  49706. static get ShowLoadingScreen(): boolean;
  49707. static set ShowLoadingScreen(value: boolean);
  49708. /**
  49709. * Defines the current logging level (while loading the scene)
  49710. * @ignorenaming
  49711. */
  49712. static get loggingLevel(): number;
  49713. static set loggingLevel(value: number);
  49714. /**
  49715. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49716. */
  49717. static get CleanBoneMatrixWeights(): boolean;
  49718. static set CleanBoneMatrixWeights(value: boolean);
  49719. /**
  49720. * Event raised when a plugin is used to load a scene
  49721. */
  49722. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49723. private static _registeredPlugins;
  49724. private static _showingLoadingScreen;
  49725. /**
  49726. * Gets the default plugin (used to load Babylon files)
  49727. * @returns the .babylon plugin
  49728. */
  49729. static GetDefaultPlugin(): IRegisteredPlugin;
  49730. private static _GetPluginForExtension;
  49731. private static _GetPluginForDirectLoad;
  49732. private static _GetPluginForFilename;
  49733. private static _GetDirectLoad;
  49734. private static _LoadData;
  49735. private static _GetFileInfo;
  49736. /**
  49737. * Gets a plugin that can load the given extension
  49738. * @param extension defines the extension to load
  49739. * @returns a plugin or null if none works
  49740. */
  49741. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49742. /**
  49743. * Gets a boolean indicating that the given extension can be loaded
  49744. * @param extension defines the extension to load
  49745. * @returns true if the extension is supported
  49746. */
  49747. static IsPluginForExtensionAvailable(extension: string): boolean;
  49748. /**
  49749. * Adds a new plugin to the list of registered plugins
  49750. * @param plugin defines the plugin to add
  49751. */
  49752. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49753. /**
  49754. * Import meshes into a scene
  49755. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49756. * @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)
  49757. * @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)
  49758. * @param scene the instance of BABYLON.Scene to append to
  49759. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  49760. * @param onProgress a callback with a progress event for each file being loaded
  49761. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49762. * @param pluginExtension the extension used to determine the plugin
  49763. * @returns The loaded plugin
  49764. */
  49765. 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>;
  49766. /**
  49767. * Import meshes into a scene
  49768. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49769. * @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)
  49770. * @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)
  49771. * @param scene the instance of BABYLON.Scene to append to
  49772. * @param onProgress a callback with a progress event for each file being loaded
  49773. * @param pluginExtension the extension used to determine the plugin
  49774. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49775. */
  49776. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49777. meshes: AbstractMesh[];
  49778. particleSystems: IParticleSystem[];
  49779. skeletons: Skeleton[];
  49780. animationGroups: AnimationGroup[];
  49781. }>;
  49782. /**
  49783. * Load a scene
  49784. * @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)
  49785. * @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)
  49786. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49787. * @param onSuccess a callback with the scene when import succeeds
  49788. * @param onProgress a callback with a progress event for each file being loaded
  49789. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49790. * @param pluginExtension the extension used to determine the plugin
  49791. * @returns The loaded plugin
  49792. */
  49793. 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>;
  49794. /**
  49795. * Load a scene
  49796. * @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)
  49797. * @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)
  49798. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49799. * @param onProgress a callback with a progress event for each file being loaded
  49800. * @param pluginExtension the extension used to determine the plugin
  49801. * @returns The loaded scene
  49802. */
  49803. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49804. /**
  49805. * Append a scene
  49806. * @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)
  49807. * @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)
  49808. * @param scene is the instance of BABYLON.Scene to append to
  49809. * @param onSuccess a callback with the scene when import succeeds
  49810. * @param onProgress a callback with a progress event for each file being loaded
  49811. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49812. * @param pluginExtension the extension used to determine the plugin
  49813. * @returns The loaded plugin
  49814. */
  49815. 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>;
  49816. /**
  49817. * Append a scene
  49818. * @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)
  49819. * @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)
  49820. * @param scene is the instance of BABYLON.Scene to append to
  49821. * @param onProgress a callback with a progress event for each file being loaded
  49822. * @param pluginExtension the extension used to determine the plugin
  49823. * @returns The given scene
  49824. */
  49825. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49826. /**
  49827. * Load a scene into an asset container
  49828. * @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)
  49829. * @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)
  49830. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49831. * @param onSuccess a callback with the scene when import succeeds
  49832. * @param onProgress a callback with a progress event for each file being loaded
  49833. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49834. * @param pluginExtension the extension used to determine the plugin
  49835. * @returns The loaded plugin
  49836. */
  49837. 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>;
  49838. /**
  49839. * Load a scene into an asset container
  49840. * @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)
  49841. * @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)
  49842. * @param scene is the instance of Scene to append to
  49843. * @param onProgress a callback with a progress event for each file being loaded
  49844. * @param pluginExtension the extension used to determine the plugin
  49845. * @returns The loaded asset container
  49846. */
  49847. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49848. /**
  49849. * Import animations from a file into a scene
  49850. * @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)
  49851. * @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)
  49852. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49853. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49854. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49855. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49856. * @param onSuccess a callback with the scene when import succeeds
  49857. * @param onProgress a callback with a progress event for each file being loaded
  49858. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49859. * @param pluginExtension the extension used to determine the plugin
  49860. */
  49861. 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;
  49862. /**
  49863. * Import animations from a file into a scene
  49864. * @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)
  49865. * @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)
  49866. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49867. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49868. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49869. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49870. * @param onSuccess a callback with the scene when import succeeds
  49871. * @param onProgress a callback with a progress event for each file being loaded
  49872. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49873. * @param pluginExtension the extension used to determine the plugin
  49874. * @returns the updated scene with imported animations
  49875. */
  49876. 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>;
  49877. }
  49878. }
  49879. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49880. import { IDisposable, Scene } from "babylonjs/scene";
  49881. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49882. import { Observable } from "babylonjs/Misc/observable";
  49883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49884. import { Nullable } from "babylonjs/types";
  49885. /**
  49886. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49887. */
  49888. export type MotionControllerHandedness = "none" | "left" | "right";
  49889. /**
  49890. * The type of components available in motion controllers.
  49891. * This is not the name of the component.
  49892. */
  49893. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49894. /**
  49895. * The state of a controller component
  49896. */
  49897. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49898. /**
  49899. * The schema of motion controller layout.
  49900. * No object will be initialized using this interface
  49901. * This is used just to define the profile.
  49902. */
  49903. export interface IMotionControllerLayout {
  49904. /**
  49905. * Path to load the assets. Usually relative to the base path
  49906. */
  49907. assetPath: string;
  49908. /**
  49909. * Available components (unsorted)
  49910. */
  49911. components: {
  49912. /**
  49913. * A map of component Ids
  49914. */
  49915. [componentId: string]: {
  49916. /**
  49917. * The type of input the component outputs
  49918. */
  49919. type: MotionControllerComponentType;
  49920. /**
  49921. * The indices of this component in the gamepad object
  49922. */
  49923. gamepadIndices: {
  49924. /**
  49925. * Index of button
  49926. */
  49927. button?: number;
  49928. /**
  49929. * If available, index of x-axis
  49930. */
  49931. xAxis?: number;
  49932. /**
  49933. * If available, index of y-axis
  49934. */
  49935. yAxis?: number;
  49936. };
  49937. /**
  49938. * The mesh's root node name
  49939. */
  49940. rootNodeName: string;
  49941. /**
  49942. * Animation definitions for this model
  49943. */
  49944. visualResponses: {
  49945. [stateKey: string]: {
  49946. /**
  49947. * What property will be animated
  49948. */
  49949. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49950. /**
  49951. * What states influence this visual response
  49952. */
  49953. states: MotionControllerComponentStateType[];
  49954. /**
  49955. * Type of animation - movement or visibility
  49956. */
  49957. valueNodeProperty: "transform" | "visibility";
  49958. /**
  49959. * Base node name to move. Its position will be calculated according to the min and max nodes
  49960. */
  49961. valueNodeName?: string;
  49962. /**
  49963. * Minimum movement node
  49964. */
  49965. minNodeName?: string;
  49966. /**
  49967. * Max movement node
  49968. */
  49969. maxNodeName?: string;
  49970. };
  49971. };
  49972. /**
  49973. * If touch enabled, what is the name of node to display user feedback
  49974. */
  49975. touchPointNodeName?: string;
  49976. };
  49977. };
  49978. /**
  49979. * Is it xr standard mapping or not
  49980. */
  49981. gamepadMapping: "" | "xr-standard";
  49982. /**
  49983. * Base root node of this entire model
  49984. */
  49985. rootNodeName: string;
  49986. /**
  49987. * Defines the main button component id
  49988. */
  49989. selectComponentId: string;
  49990. }
  49991. /**
  49992. * A definition for the layout map in the input profile
  49993. */
  49994. export interface IMotionControllerLayoutMap {
  49995. /**
  49996. * Layouts with handedness type as a key
  49997. */
  49998. [handedness: string]: IMotionControllerLayout;
  49999. }
  50000. /**
  50001. * The XR Input profile schema
  50002. * Profiles can be found here:
  50003. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  50004. */
  50005. export interface IMotionControllerProfile {
  50006. /**
  50007. * fallback profiles for this profileId
  50008. */
  50009. fallbackProfileIds: string[];
  50010. /**
  50011. * The layout map, with handedness as key
  50012. */
  50013. layouts: IMotionControllerLayoutMap;
  50014. /**
  50015. * The id of this profile
  50016. * correlates to the profile(s) in the xrInput.profiles array
  50017. */
  50018. profileId: string;
  50019. }
  50020. /**
  50021. * A helper-interface for the 3 meshes needed for controller button animation
  50022. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  50023. */
  50024. export interface IMotionControllerButtonMeshMap {
  50025. /**
  50026. * the mesh that defines the pressed value mesh position.
  50027. * This is used to find the max-position of this button
  50028. */
  50029. pressedMesh: AbstractMesh;
  50030. /**
  50031. * the mesh that defines the unpressed value mesh position.
  50032. * This is used to find the min (or initial) position of this button
  50033. */
  50034. unpressedMesh: AbstractMesh;
  50035. /**
  50036. * The mesh that will be changed when value changes
  50037. */
  50038. valueMesh: AbstractMesh;
  50039. }
  50040. /**
  50041. * A helper-interface for the 3 meshes needed for controller axis animation.
  50042. * This will be expanded when touchpad animations are fully supported
  50043. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  50044. */
  50045. export interface IMotionControllerMeshMap {
  50046. /**
  50047. * the mesh that defines the maximum value mesh position.
  50048. */
  50049. maxMesh?: AbstractMesh;
  50050. /**
  50051. * the mesh that defines the minimum value mesh position.
  50052. */
  50053. minMesh?: AbstractMesh;
  50054. /**
  50055. * The mesh that will be changed when axis value changes
  50056. */
  50057. valueMesh?: AbstractMesh;
  50058. }
  50059. /**
  50060. * The elements needed for change-detection of the gamepad objects in motion controllers
  50061. */
  50062. export interface IMinimalMotionControllerObject {
  50063. /**
  50064. * Available axes of this controller
  50065. */
  50066. axes: number[];
  50067. /**
  50068. * An array of available buttons
  50069. */
  50070. buttons: Array<{
  50071. /**
  50072. * Value of the button/trigger
  50073. */
  50074. value: number;
  50075. /**
  50076. * If the button/trigger is currently touched
  50077. */
  50078. touched: boolean;
  50079. /**
  50080. * If the button/trigger is currently pressed
  50081. */
  50082. pressed: boolean;
  50083. }>;
  50084. /**
  50085. * EXPERIMENTAL haptic support.
  50086. */
  50087. hapticActuators?: Array<{
  50088. pulse: (value: number, duration: number) => Promise<boolean>;
  50089. }>;
  50090. }
  50091. /**
  50092. * An Abstract Motion controller
  50093. * This class receives an xrInput and a profile layout and uses those to initialize the components
  50094. * Each component has an observable to check for changes in value and state
  50095. */
  50096. export abstract class WebXRAbstractMotionController implements IDisposable {
  50097. protected scene: Scene;
  50098. protected layout: IMotionControllerLayout;
  50099. /**
  50100. * The gamepad object correlating to this controller
  50101. */
  50102. gamepadObject: IMinimalMotionControllerObject;
  50103. /**
  50104. * handedness (left/right/none) of this controller
  50105. */
  50106. handedness: MotionControllerHandedness;
  50107. private _initComponent;
  50108. private _modelReady;
  50109. /**
  50110. * A map of components (WebXRControllerComponent) in this motion controller
  50111. * Components have a ComponentType and can also have both button and axis definitions
  50112. */
  50113. readonly components: {
  50114. [id: string]: WebXRControllerComponent;
  50115. };
  50116. /**
  50117. * Disable the model's animation. Can be set at any time.
  50118. */
  50119. disableAnimation: boolean;
  50120. /**
  50121. * Observers registered here will be triggered when the model of this controller is done loading
  50122. */
  50123. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  50124. /**
  50125. * The profile id of this motion controller
  50126. */
  50127. abstract profileId: string;
  50128. /**
  50129. * The root mesh of the model. It is null if the model was not yet initialized
  50130. */
  50131. rootMesh: Nullable<AbstractMesh>;
  50132. /**
  50133. * constructs a new abstract motion controller
  50134. * @param scene the scene to which the model of the controller will be added
  50135. * @param layout The profile layout to load
  50136. * @param gamepadObject The gamepad object correlating to this controller
  50137. * @param handedness handedness (left/right/none) of this controller
  50138. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  50139. */
  50140. constructor(scene: Scene, layout: IMotionControllerLayout,
  50141. /**
  50142. * The gamepad object correlating to this controller
  50143. */
  50144. gamepadObject: IMinimalMotionControllerObject,
  50145. /**
  50146. * handedness (left/right/none) of this controller
  50147. */
  50148. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  50149. /**
  50150. * Dispose this controller, the model mesh and all its components
  50151. */
  50152. dispose(): void;
  50153. /**
  50154. * Returns all components of specific type
  50155. * @param type the type to search for
  50156. * @return an array of components with this type
  50157. */
  50158. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  50159. /**
  50160. * get a component based an its component id as defined in layout.components
  50161. * @param id the id of the component
  50162. * @returns the component correlates to the id or undefined if not found
  50163. */
  50164. getComponent(id: string): WebXRControllerComponent;
  50165. /**
  50166. * Get the list of components available in this motion controller
  50167. * @returns an array of strings correlating to available components
  50168. */
  50169. getComponentIds(): string[];
  50170. /**
  50171. * Get the first component of specific type
  50172. * @param type type of component to find
  50173. * @return a controller component or null if not found
  50174. */
  50175. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  50176. /**
  50177. * Get the main (Select) component of this controller as defined in the layout
  50178. * @returns the main component of this controller
  50179. */
  50180. getMainComponent(): WebXRControllerComponent;
  50181. /**
  50182. * Loads the model correlating to this controller
  50183. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  50184. * @returns A promise fulfilled with the result of the model loading
  50185. */
  50186. loadModel(): Promise<boolean>;
  50187. /**
  50188. * Update this model using the current XRFrame
  50189. * @param xrFrame the current xr frame to use and update the model
  50190. */
  50191. updateFromXRFrame(xrFrame: XRFrame): void;
  50192. /**
  50193. * Backwards compatibility due to a deeply-integrated typo
  50194. */
  50195. get handness(): XREye;
  50196. /**
  50197. * Pulse (vibrate) this controller
  50198. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  50199. * Consecutive calls to this function will cancel the last pulse call
  50200. *
  50201. * @param value the strength of the pulse in 0.0...1.0 range
  50202. * @param duration Duration of the pulse in milliseconds
  50203. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  50204. * @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
  50205. */
  50206. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  50207. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50208. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50209. /**
  50210. * Moves the axis on the controller mesh based on its current state
  50211. * @param axis the index of the axis
  50212. * @param axisValue the value of the axis which determines the meshes new position
  50213. * @hidden
  50214. */
  50215. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  50216. /**
  50217. * Update the model itself with the current frame data
  50218. * @param xrFrame the frame to use for updating the model mesh
  50219. */
  50220. protected updateModel(xrFrame: XRFrame): void;
  50221. /**
  50222. * Get the filename and path for this controller's model
  50223. * @returns a map of filename and path
  50224. */
  50225. protected abstract _getFilenameAndPath(): {
  50226. filename: string;
  50227. path: string;
  50228. };
  50229. /**
  50230. * This function is called before the mesh is loaded. It checks for loading constraints.
  50231. * For example, this function can check if the GLB loader is available
  50232. * If this function returns false, the generic controller will be loaded instead
  50233. * @returns Is the client ready to load the mesh
  50234. */
  50235. protected abstract _getModelLoadingConstraints(): boolean;
  50236. /**
  50237. * This function will be called after the model was successfully loaded and can be used
  50238. * for mesh transformations before it is available for the user
  50239. * @param meshes the loaded meshes
  50240. */
  50241. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  50242. /**
  50243. * Set the root mesh for this controller. Important for the WebXR controller class
  50244. * @param meshes the loaded meshes
  50245. */
  50246. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  50247. /**
  50248. * A function executed each frame that updates the mesh (if needed)
  50249. * @param xrFrame the current xrFrame
  50250. */
  50251. protected abstract _updateModel(xrFrame: XRFrame): void;
  50252. private _getGenericFilenameAndPath;
  50253. private _getGenericParentMesh;
  50254. }
  50255. }
  50256. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  50257. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50259. import { Scene } from "babylonjs/scene";
  50260. /**
  50261. * A generic trigger-only motion controller for WebXR
  50262. */
  50263. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  50264. /**
  50265. * Static version of the profile id of this controller
  50266. */
  50267. static ProfileId: string;
  50268. profileId: string;
  50269. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  50270. protected _getFilenameAndPath(): {
  50271. filename: string;
  50272. path: string;
  50273. };
  50274. protected _getModelLoadingConstraints(): boolean;
  50275. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  50276. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50277. protected _updateModel(): void;
  50278. }
  50279. }
  50280. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  50281. import { Vector4 } from "babylonjs/Maths/math.vector";
  50282. import { Mesh } from "babylonjs/Meshes/mesh";
  50283. import { Scene } from "babylonjs/scene";
  50284. import { Nullable } from "babylonjs/types";
  50285. /**
  50286. * Class containing static functions to help procedurally build meshes
  50287. */
  50288. export class SphereBuilder {
  50289. /**
  50290. * Creates a sphere mesh
  50291. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50292. * * 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`)
  50293. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50294. * * 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
  50295. * * 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)
  50296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50297. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50299. * @param name defines the name of the mesh
  50300. * @param options defines the options used to create the mesh
  50301. * @param scene defines the hosting scene
  50302. * @returns the sphere mesh
  50303. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50304. */
  50305. static CreateSphere(name: string, options: {
  50306. segments?: number;
  50307. diameter?: number;
  50308. diameterX?: number;
  50309. diameterY?: number;
  50310. diameterZ?: number;
  50311. arc?: number;
  50312. slice?: number;
  50313. sideOrientation?: number;
  50314. frontUVs?: Vector4;
  50315. backUVs?: Vector4;
  50316. updatable?: boolean;
  50317. }, scene?: Nullable<Scene>): Mesh;
  50318. }
  50319. }
  50320. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50322. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50323. import { Scene } from "babylonjs/scene";
  50324. /**
  50325. * A profiled motion controller has its profile loaded from an online repository.
  50326. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50327. */
  50328. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50329. private _repositoryUrl;
  50330. private _buttonMeshMapping;
  50331. private _touchDots;
  50332. /**
  50333. * The profile ID of this controller. Will be populated when the controller initializes.
  50334. */
  50335. profileId: string;
  50336. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50337. dispose(): void;
  50338. protected _getFilenameAndPath(): {
  50339. filename: string;
  50340. path: string;
  50341. };
  50342. protected _getModelLoadingConstraints(): boolean;
  50343. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50344. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50345. protected _updateModel(_xrFrame: XRFrame): void;
  50346. }
  50347. }
  50348. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50349. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50350. import { Scene } from "babylonjs/scene";
  50351. /**
  50352. * A construction function type to create a new controller based on an xrInput object
  50353. */
  50354. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50355. /**
  50356. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50357. *
  50358. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50359. * it should be replaced with auto-loaded controllers.
  50360. *
  50361. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50362. */
  50363. export class WebXRMotionControllerManager {
  50364. private static _AvailableControllers;
  50365. private static _Fallbacks;
  50366. private static _ProfileLoadingPromises;
  50367. private static _ProfilesList;
  50368. /**
  50369. * The base URL of the online controller repository. Can be changed at any time.
  50370. */
  50371. static BaseRepositoryUrl: string;
  50372. /**
  50373. * Which repository gets priority - local or online
  50374. */
  50375. static PrioritizeOnlineRepository: boolean;
  50376. /**
  50377. * Use the online repository, or use only locally-defined controllers
  50378. */
  50379. static UseOnlineRepository: boolean;
  50380. /**
  50381. * Clear the cache used for profile loading and reload when requested again
  50382. */
  50383. static ClearProfilesCache(): void;
  50384. /**
  50385. * Register the default fallbacks.
  50386. * This function is called automatically when this file is imported.
  50387. */
  50388. static DefaultFallbacks(): void;
  50389. /**
  50390. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50391. * @param profileId the profile to which a fallback needs to be found
  50392. * @return an array with corresponding fallback profiles
  50393. */
  50394. static FindFallbackWithProfileId(profileId: string): string[];
  50395. /**
  50396. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50397. * The order of search:
  50398. *
  50399. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50400. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50401. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50402. * 4) return the generic trigger controller if none were found
  50403. *
  50404. * @param xrInput the xrInput to which a new controller is initialized
  50405. * @param scene the scene to which the model will be added
  50406. * @param forceProfile force a certain profile for this controller
  50407. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50408. */
  50409. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50410. /**
  50411. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50412. *
  50413. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50414. *
  50415. * @param type the profile type to register
  50416. * @param constructFunction the function to be called when loading this profile
  50417. */
  50418. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50419. /**
  50420. * Register a fallback to a specific profile.
  50421. * @param profileId the profileId that will receive the fallbacks
  50422. * @param fallbacks A list of fallback profiles
  50423. */
  50424. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50425. /**
  50426. * Will update the list of profiles available in the repository
  50427. * @return a promise that resolves to a map of profiles available online
  50428. */
  50429. static UpdateProfilesList(): Promise<{
  50430. [profile: string]: string;
  50431. }>;
  50432. private static _LoadProfileFromRepository;
  50433. private static _LoadProfilesFromAvailableControllers;
  50434. }
  50435. }
  50436. declare module "babylonjs/XR/webXRInputSource" {
  50437. import { Observable } from "babylonjs/Misc/observable";
  50438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50439. import { Ray } from "babylonjs/Culling/ray";
  50440. import { Scene } from "babylonjs/scene";
  50441. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50442. /**
  50443. * Configuration options for the WebXR controller creation
  50444. */
  50445. export interface IWebXRControllerOptions {
  50446. /**
  50447. * Should the controller mesh be animated when a user interacts with it
  50448. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50449. */
  50450. disableMotionControllerAnimation?: boolean;
  50451. /**
  50452. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50453. */
  50454. doNotLoadControllerMesh?: boolean;
  50455. /**
  50456. * Force a specific controller type for this controller.
  50457. * This can be used when creating your own profile or when testing different controllers
  50458. */
  50459. forceControllerProfile?: string;
  50460. /**
  50461. * Defines a rendering group ID for meshes that will be loaded.
  50462. * This is for the default controllers only.
  50463. */
  50464. renderingGroupId?: number;
  50465. }
  50466. /**
  50467. * Represents an XR controller
  50468. */
  50469. export class WebXRInputSource {
  50470. private _scene;
  50471. /** The underlying input source for the controller */
  50472. inputSource: XRInputSource;
  50473. private _options;
  50474. private _tmpVector;
  50475. private _uniqueId;
  50476. private _disposed;
  50477. /**
  50478. * 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
  50479. */
  50480. grip?: AbstractMesh;
  50481. /**
  50482. * If available, this is the gamepad object related to this controller.
  50483. * Using this object it is possible to get click events and trackpad changes of the
  50484. * webxr controller that is currently being used.
  50485. */
  50486. motionController?: WebXRAbstractMotionController;
  50487. /**
  50488. * Event that fires when the controller is removed/disposed.
  50489. * The object provided as event data is this controller, after associated assets were disposed.
  50490. * uniqueId is still available.
  50491. */
  50492. onDisposeObservable: Observable<WebXRInputSource>;
  50493. /**
  50494. * Will be triggered when the mesh associated with the motion controller is done loading.
  50495. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50496. * A shortened version of controller -> motion controller -> on mesh loaded.
  50497. */
  50498. onMeshLoadedObservable: Observable<AbstractMesh>;
  50499. /**
  50500. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50501. */
  50502. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50503. /**
  50504. * Pointer which can be used to select objects or attach a visible laser to
  50505. */
  50506. pointer: AbstractMesh;
  50507. /**
  50508. * Creates the input source object
  50509. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50510. * @param _scene the scene which the controller should be associated to
  50511. * @param inputSource the underlying input source for the controller
  50512. * @param _options options for this controller creation
  50513. */
  50514. constructor(_scene: Scene,
  50515. /** The underlying input source for the controller */
  50516. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50517. /**
  50518. * Get this controllers unique id
  50519. */
  50520. get uniqueId(): string;
  50521. /**
  50522. * Disposes of the object
  50523. */
  50524. dispose(): void;
  50525. /**
  50526. * Gets a world space ray coming from the pointer or grip
  50527. * @param result the resulting ray
  50528. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50529. */
  50530. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50531. /**
  50532. * Updates the controller pose based on the given XRFrame
  50533. * @param xrFrame xr frame to update the pose with
  50534. * @param referenceSpace reference space to use
  50535. */
  50536. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50537. }
  50538. }
  50539. declare module "babylonjs/XR/webXRInput" {
  50540. import { Observable } from "babylonjs/Misc/observable";
  50541. import { IDisposable } from "babylonjs/scene";
  50542. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50543. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50544. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50545. /**
  50546. * The schema for initialization options of the XR Input class
  50547. */
  50548. export interface IWebXRInputOptions {
  50549. /**
  50550. * If set to true no model will be automatically loaded
  50551. */
  50552. doNotLoadControllerMeshes?: boolean;
  50553. /**
  50554. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50555. * If not found, the xr input profile data will be used.
  50556. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50557. */
  50558. forceInputProfile?: string;
  50559. /**
  50560. * Do not send a request to the controller repository to load the profile.
  50561. *
  50562. * Instead, use the controllers available in babylon itself.
  50563. */
  50564. disableOnlineControllerRepository?: boolean;
  50565. /**
  50566. * A custom URL for the controllers repository
  50567. */
  50568. customControllersRepositoryURL?: string;
  50569. /**
  50570. * Should the controller model's components not move according to the user input
  50571. */
  50572. disableControllerAnimation?: boolean;
  50573. /**
  50574. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50575. */
  50576. controllerOptions?: IWebXRControllerOptions;
  50577. }
  50578. /**
  50579. * XR input used to track XR inputs such as controllers/rays
  50580. */
  50581. export class WebXRInput implements IDisposable {
  50582. /**
  50583. * the xr session manager for this session
  50584. */
  50585. xrSessionManager: WebXRSessionManager;
  50586. /**
  50587. * the WebXR camera for this session. Mainly used for teleportation
  50588. */
  50589. xrCamera: WebXRCamera;
  50590. private readonly options;
  50591. /**
  50592. * XR controllers being tracked
  50593. */
  50594. controllers: Array<WebXRInputSource>;
  50595. private _frameObserver;
  50596. private _sessionEndedObserver;
  50597. private _sessionInitObserver;
  50598. /**
  50599. * Event when a controller has been connected/added
  50600. */
  50601. onControllerAddedObservable: Observable<WebXRInputSource>;
  50602. /**
  50603. * Event when a controller has been removed/disconnected
  50604. */
  50605. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50606. /**
  50607. * Initializes the WebXRInput
  50608. * @param xrSessionManager the xr session manager for this session
  50609. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50610. * @param options = initialization options for this xr input
  50611. */
  50612. constructor(
  50613. /**
  50614. * the xr session manager for this session
  50615. */
  50616. xrSessionManager: WebXRSessionManager,
  50617. /**
  50618. * the WebXR camera for this session. Mainly used for teleportation
  50619. */
  50620. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50621. private _onInputSourcesChange;
  50622. private _addAndRemoveControllers;
  50623. /**
  50624. * Disposes of the object
  50625. */
  50626. dispose(): void;
  50627. }
  50628. }
  50629. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50630. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50631. import { Observable, EventState } from "babylonjs/Misc/observable";
  50632. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50633. /**
  50634. * This is the base class for all WebXR features.
  50635. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50636. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50637. */
  50638. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50639. protected _xrSessionManager: WebXRSessionManager;
  50640. private _attached;
  50641. private _removeOnDetach;
  50642. /**
  50643. * Is this feature disposed?
  50644. */
  50645. isDisposed: boolean;
  50646. /**
  50647. * Should auto-attach be disabled?
  50648. */
  50649. disableAutoAttach: boolean;
  50650. /**
  50651. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50652. */
  50653. xrNativeFeatureName: string;
  50654. /**
  50655. * Construct a new (abstract) WebXR feature
  50656. * @param _xrSessionManager the xr session manager for this feature
  50657. */
  50658. constructor(_xrSessionManager: WebXRSessionManager);
  50659. /**
  50660. * Is this feature attached
  50661. */
  50662. get attached(): boolean;
  50663. /**
  50664. * attach this feature
  50665. *
  50666. * @param force should attachment be forced (even when already attached)
  50667. * @returns true if successful, false is failed or already attached
  50668. */
  50669. attach(force?: boolean): boolean;
  50670. /**
  50671. * detach this feature.
  50672. *
  50673. * @returns true if successful, false if failed or already detached
  50674. */
  50675. detach(): boolean;
  50676. /**
  50677. * Dispose this feature and all of the resources attached
  50678. */
  50679. dispose(): void;
  50680. /**
  50681. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50682. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50683. *
  50684. * @returns whether or not the feature is compatible in this environment
  50685. */
  50686. isCompatible(): boolean;
  50687. /**
  50688. * This is used to register callbacks that will automatically be removed when detach is called.
  50689. * @param observable the observable to which the observer will be attached
  50690. * @param callback the callback to register
  50691. */
  50692. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50693. /**
  50694. * Code in this function will be executed on each xrFrame received from the browser.
  50695. * This function will not execute after the feature is detached.
  50696. * @param _xrFrame the current frame
  50697. */
  50698. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50699. }
  50700. }
  50701. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50702. import { IDisposable, Scene } from "babylonjs/scene";
  50703. import { Nullable } from "babylonjs/types";
  50704. import { Observable } from "babylonjs/Misc/observable";
  50705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50706. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50707. import { Camera } from "babylonjs/Cameras/camera";
  50708. /**
  50709. * Renders a layer on top of an existing scene
  50710. */
  50711. export class UtilityLayerRenderer implements IDisposable {
  50712. /** the original scene that will be rendered on top of */
  50713. originalScene: Scene;
  50714. private _pointerCaptures;
  50715. private _lastPointerEvents;
  50716. private static _DefaultUtilityLayer;
  50717. private static _DefaultKeepDepthUtilityLayer;
  50718. private _sharedGizmoLight;
  50719. private _renderCamera;
  50720. /**
  50721. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50722. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50723. * @returns the camera that is used when rendering the utility layer
  50724. */
  50725. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50726. /**
  50727. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50728. * @param cam the camera that should be used when rendering the utility layer
  50729. */
  50730. setRenderCamera(cam: Nullable<Camera>): void;
  50731. /**
  50732. * @hidden
  50733. * Light which used by gizmos to get light shading
  50734. */
  50735. _getSharedGizmoLight(): HemisphericLight;
  50736. /**
  50737. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50738. */
  50739. pickUtilitySceneFirst: boolean;
  50740. /**
  50741. * 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)
  50742. */
  50743. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50744. /**
  50745. * 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)
  50746. */
  50747. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50748. /**
  50749. * The scene that is rendered on top of the original scene
  50750. */
  50751. utilityLayerScene: Scene;
  50752. /**
  50753. * If the utility layer should automatically be rendered on top of existing scene
  50754. */
  50755. shouldRender: boolean;
  50756. /**
  50757. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50758. */
  50759. onlyCheckPointerDownEvents: boolean;
  50760. /**
  50761. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50762. */
  50763. processAllEvents: boolean;
  50764. /**
  50765. * Observable raised when the pointer move from the utility layer scene to the main scene
  50766. */
  50767. onPointerOutObservable: Observable<number>;
  50768. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50769. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50770. private _afterRenderObserver;
  50771. private _sceneDisposeObserver;
  50772. private _originalPointerObserver;
  50773. /**
  50774. * Instantiates a UtilityLayerRenderer
  50775. * @param originalScene the original scene that will be rendered on top of
  50776. * @param handleEvents boolean indicating if the utility layer should handle events
  50777. */
  50778. constructor(
  50779. /** the original scene that will be rendered on top of */
  50780. originalScene: Scene, handleEvents?: boolean);
  50781. private _notifyObservers;
  50782. /**
  50783. * Renders the utility layers scene on top of the original scene
  50784. */
  50785. render(): void;
  50786. /**
  50787. * Disposes of the renderer
  50788. */
  50789. dispose(): void;
  50790. private _updateCamera;
  50791. }
  50792. }
  50793. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50794. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50796. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50797. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50798. import { Scene } from "babylonjs/scene";
  50799. import { Nullable } from "babylonjs/types";
  50800. import { Color3 } from "babylonjs/Maths/math.color";
  50801. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50802. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50803. /**
  50804. * Options interface for the pointer selection module
  50805. */
  50806. export interface IWebXRControllerPointerSelectionOptions {
  50807. /**
  50808. * if provided, this scene will be used to render meshes.
  50809. */
  50810. customUtilityLayerScene?: Scene;
  50811. /**
  50812. * 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)
  50813. * If not disabled, the last picked point will be used to execute a pointer up event
  50814. * If disabled, pointer up event will be triggered right after the pointer down event.
  50815. * Used in screen and gaze target ray mode only
  50816. */
  50817. disablePointerUpOnTouchOut: boolean;
  50818. /**
  50819. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50820. */
  50821. forceGazeMode: boolean;
  50822. /**
  50823. * 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
  50824. * to start a new countdown to the pointer down event.
  50825. * Defaults to 1.
  50826. */
  50827. gazeModePointerMovedFactor?: number;
  50828. /**
  50829. * Different button type to use instead of the main component
  50830. */
  50831. overrideButtonId?: string;
  50832. /**
  50833. * use this rendering group id for the meshes (optional)
  50834. */
  50835. renderingGroupId?: number;
  50836. /**
  50837. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50838. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50839. * 3000 means 3 seconds between pointing at something and selecting it
  50840. */
  50841. timeToSelect?: number;
  50842. /**
  50843. * Should meshes created here be added to a utility layer or the main scene
  50844. */
  50845. useUtilityLayer?: boolean;
  50846. /**
  50847. * Optional WebXR camera to be used for gaze selection
  50848. */
  50849. gazeCamera?: WebXRCamera;
  50850. /**
  50851. * the xr input to use with this pointer selection
  50852. */
  50853. xrInput: WebXRInput;
  50854. }
  50855. /**
  50856. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50857. */
  50858. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50859. private readonly _options;
  50860. private static _idCounter;
  50861. private _attachController;
  50862. private _controllers;
  50863. private _scene;
  50864. private _tmpVectorForPickCompare;
  50865. /**
  50866. * The module's name
  50867. */
  50868. static readonly Name: string;
  50869. /**
  50870. * The (Babylon) version of this module.
  50871. * This is an integer representing the implementation version.
  50872. * This number does not correspond to the WebXR specs version
  50873. */
  50874. static readonly Version: number;
  50875. /**
  50876. * Disable lighting on the laser pointer (so it will always be visible)
  50877. */
  50878. disablePointerLighting: boolean;
  50879. /**
  50880. * Disable lighting on the selection mesh (so it will always be visible)
  50881. */
  50882. disableSelectionMeshLighting: boolean;
  50883. /**
  50884. * Should the laser pointer be displayed
  50885. */
  50886. displayLaserPointer: boolean;
  50887. /**
  50888. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50889. */
  50890. displaySelectionMesh: boolean;
  50891. /**
  50892. * This color will be set to the laser pointer when selection is triggered
  50893. */
  50894. laserPointerPickedColor: Color3;
  50895. /**
  50896. * Default color of the laser pointer
  50897. */
  50898. laserPointerDefaultColor: Color3;
  50899. /**
  50900. * default color of the selection ring
  50901. */
  50902. selectionMeshDefaultColor: Color3;
  50903. /**
  50904. * This color will be applied to the selection ring when selection is triggered
  50905. */
  50906. selectionMeshPickedColor: Color3;
  50907. /**
  50908. * Optional filter to be used for ray selection. This predicate shares behavior with
  50909. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50910. */
  50911. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50912. /**
  50913. * constructs a new background remover module
  50914. * @param _xrSessionManager the session manager for this module
  50915. * @param _options read-only options to be used in this module
  50916. */
  50917. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50918. /**
  50919. * attach this feature
  50920. * Will usually be called by the features manager
  50921. *
  50922. * @returns true if successful.
  50923. */
  50924. attach(): boolean;
  50925. /**
  50926. * detach this feature.
  50927. * Will usually be called by the features manager
  50928. *
  50929. * @returns true if successful.
  50930. */
  50931. detach(): boolean;
  50932. /**
  50933. * Will get the mesh under a specific pointer.
  50934. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50935. * @param controllerId the controllerId to check
  50936. * @returns The mesh under pointer or null if no mesh is under the pointer
  50937. */
  50938. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50939. /**
  50940. * Get the xr controller that correlates to the pointer id in the pointer event
  50941. *
  50942. * @param id the pointer id to search for
  50943. * @returns the controller that correlates to this id or null if not found
  50944. */
  50945. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50946. protected _onXRFrame(_xrFrame: XRFrame): void;
  50947. private _attachGazeMode;
  50948. private _attachScreenRayMode;
  50949. private _attachTrackedPointerRayMode;
  50950. private _convertNormalToDirectionOfRay;
  50951. private _detachController;
  50952. private _generateNewMeshPair;
  50953. private _pickingMoved;
  50954. private _updatePointerDistance;
  50955. /** @hidden */
  50956. get lasterPointerDefaultColor(): Color3;
  50957. }
  50958. }
  50959. declare module "babylonjs/XR/webXREnterExitUI" {
  50960. import { Nullable } from "babylonjs/types";
  50961. import { Observable } from "babylonjs/Misc/observable";
  50962. import { IDisposable, Scene } from "babylonjs/scene";
  50963. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50964. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50965. /**
  50966. * Button which can be used to enter a different mode of XR
  50967. */
  50968. export class WebXREnterExitUIButton {
  50969. /** button element */
  50970. element: HTMLElement;
  50971. /** XR initialization options for the button */
  50972. sessionMode: XRSessionMode;
  50973. /** Reference space type */
  50974. referenceSpaceType: XRReferenceSpaceType;
  50975. /**
  50976. * Creates a WebXREnterExitUIButton
  50977. * @param element button element
  50978. * @param sessionMode XR initialization session mode
  50979. * @param referenceSpaceType the type of reference space to be used
  50980. */
  50981. constructor(
  50982. /** button element */
  50983. element: HTMLElement,
  50984. /** XR initialization options for the button */
  50985. sessionMode: XRSessionMode,
  50986. /** Reference space type */
  50987. referenceSpaceType: XRReferenceSpaceType);
  50988. /**
  50989. * Extendable function which can be used to update the button's visuals when the state changes
  50990. * @param activeButton the current active button in the UI
  50991. */
  50992. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50993. }
  50994. /**
  50995. * Options to create the webXR UI
  50996. */
  50997. export class WebXREnterExitUIOptions {
  50998. /**
  50999. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  51000. */
  51001. customButtons?: Array<WebXREnterExitUIButton>;
  51002. /**
  51003. * A reference space type to use when creating the default button.
  51004. * Default is local-floor
  51005. */
  51006. referenceSpaceType?: XRReferenceSpaceType;
  51007. /**
  51008. * Context to enter xr with
  51009. */
  51010. renderTarget?: Nullable<WebXRRenderTarget>;
  51011. /**
  51012. * A session mode to use when creating the default button.
  51013. * Default is immersive-vr
  51014. */
  51015. sessionMode?: XRSessionMode;
  51016. /**
  51017. * A list of optional features to init the session with
  51018. */
  51019. optionalFeatures?: string[];
  51020. /**
  51021. * A list of optional features to init the session with
  51022. */
  51023. requiredFeatures?: string[];
  51024. }
  51025. /**
  51026. * UI to allow the user to enter/exit XR mode
  51027. */
  51028. export class WebXREnterExitUI implements IDisposable {
  51029. private scene;
  51030. /** version of the options passed to this UI */
  51031. options: WebXREnterExitUIOptions;
  51032. private _activeButton;
  51033. private _buttons;
  51034. /**
  51035. * The HTML Div Element to which buttons are added.
  51036. */
  51037. readonly overlay: HTMLDivElement;
  51038. /**
  51039. * Fired every time the active button is changed.
  51040. *
  51041. * When xr is entered via a button that launches xr that button will be the callback parameter
  51042. *
  51043. * When exiting xr the callback parameter will be null)
  51044. */
  51045. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  51046. /**
  51047. *
  51048. * @param scene babylon scene object to use
  51049. * @param options (read-only) version of the options passed to this UI
  51050. */
  51051. private constructor();
  51052. /**
  51053. * Creates UI to allow the user to enter/exit XR mode
  51054. * @param scene the scene to add the ui to
  51055. * @param helper the xr experience helper to enter/exit xr with
  51056. * @param options options to configure the UI
  51057. * @returns the created ui
  51058. */
  51059. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  51060. /**
  51061. * Disposes of the XR UI component
  51062. */
  51063. dispose(): void;
  51064. private _updateButtons;
  51065. }
  51066. }
  51067. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  51068. import { Vector3 } from "babylonjs/Maths/math.vector";
  51069. import { Color4 } from "babylonjs/Maths/math.color";
  51070. import { Nullable } from "babylonjs/types";
  51071. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51072. import { Scene } from "babylonjs/scene";
  51073. /**
  51074. * Class containing static functions to help procedurally build meshes
  51075. */
  51076. export class LinesBuilder {
  51077. /**
  51078. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51079. * * 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
  51080. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51081. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51082. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51083. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51084. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51085. * * 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
  51086. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51088. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51089. * @param name defines the name of the new line system
  51090. * @param options defines the options used to create the line system
  51091. * @param scene defines the hosting scene
  51092. * @returns a new line system mesh
  51093. */
  51094. static CreateLineSystem(name: string, options: {
  51095. lines: Vector3[][];
  51096. updatable?: boolean;
  51097. instance?: Nullable<LinesMesh>;
  51098. colors?: Nullable<Color4[][]>;
  51099. useVertexAlpha?: boolean;
  51100. }, scene: Nullable<Scene>): LinesMesh;
  51101. /**
  51102. * Creates a line mesh
  51103. * 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
  51104. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51105. * * The parameter `points` is an array successive Vector3
  51106. * * 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
  51107. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51108. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51109. * * When updating an instance, remember that only point positions can change, not the number of points
  51110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51111. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51112. * @param name defines the name of the new line system
  51113. * @param options defines the options used to create the line system
  51114. * @param scene defines the hosting scene
  51115. * @returns a new line mesh
  51116. */
  51117. static CreateLines(name: string, options: {
  51118. points: Vector3[];
  51119. updatable?: boolean;
  51120. instance?: Nullable<LinesMesh>;
  51121. colors?: Color4[];
  51122. useVertexAlpha?: boolean;
  51123. }, scene?: Nullable<Scene>): LinesMesh;
  51124. /**
  51125. * Creates a dashed line mesh
  51126. * * 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
  51127. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51128. * * The parameter `points` is an array successive Vector3
  51129. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51130. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51131. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51132. * * 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
  51133. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51134. * * When updating an instance, remember that only point positions can change, not the number of points
  51135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51136. * @param name defines the name of the mesh
  51137. * @param options defines the options used to create the mesh
  51138. * @param scene defines the hosting scene
  51139. * @returns the dashed line mesh
  51140. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51141. */
  51142. static CreateDashedLines(name: string, options: {
  51143. points: Vector3[];
  51144. dashSize?: number;
  51145. gapSize?: number;
  51146. dashNb?: number;
  51147. updatable?: boolean;
  51148. instance?: LinesMesh;
  51149. useVertexAlpha?: boolean;
  51150. }, scene?: Nullable<Scene>): LinesMesh;
  51151. }
  51152. }
  51153. declare module "babylonjs/Misc/timer" {
  51154. import { Observable, Observer } from "babylonjs/Misc/observable";
  51155. import { Nullable } from "babylonjs/types";
  51156. import { IDisposable } from "babylonjs/scene";
  51157. /**
  51158. * Construction options for a timer
  51159. */
  51160. export interface ITimerOptions<T> {
  51161. /**
  51162. * Time-to-end
  51163. */
  51164. timeout: number;
  51165. /**
  51166. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  51167. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  51168. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  51169. */
  51170. contextObservable: Observable<T>;
  51171. /**
  51172. * Optional parameters when adding an observer to the observable
  51173. */
  51174. observableParameters?: {
  51175. mask?: number;
  51176. insertFirst?: boolean;
  51177. scope?: any;
  51178. };
  51179. /**
  51180. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  51181. */
  51182. breakCondition?: (data?: ITimerData<T>) => boolean;
  51183. /**
  51184. * Will be triggered when the time condition has met
  51185. */
  51186. onEnded?: (data: ITimerData<any>) => void;
  51187. /**
  51188. * Will be triggered when the break condition has met (prematurely ended)
  51189. */
  51190. onAborted?: (data: ITimerData<any>) => void;
  51191. /**
  51192. * Optional function to execute on each tick (or count)
  51193. */
  51194. onTick?: (data: ITimerData<any>) => void;
  51195. }
  51196. /**
  51197. * An interface defining the data sent by the timer
  51198. */
  51199. export interface ITimerData<T> {
  51200. /**
  51201. * When did it start
  51202. */
  51203. startTime: number;
  51204. /**
  51205. * Time now
  51206. */
  51207. currentTime: number;
  51208. /**
  51209. * Time passed since started
  51210. */
  51211. deltaTime: number;
  51212. /**
  51213. * How much is completed, in [0.0...1.0].
  51214. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  51215. */
  51216. completeRate: number;
  51217. /**
  51218. * What the registered observable sent in the last count
  51219. */
  51220. payload: T;
  51221. }
  51222. /**
  51223. * The current state of the timer
  51224. */
  51225. export enum TimerState {
  51226. /**
  51227. * Timer initialized, not yet started
  51228. */
  51229. INIT = 0,
  51230. /**
  51231. * Timer started and counting
  51232. */
  51233. STARTED = 1,
  51234. /**
  51235. * Timer ended (whether aborted or time reached)
  51236. */
  51237. ENDED = 2
  51238. }
  51239. /**
  51240. * A simple version of the timer. Will take options and start the timer immediately after calling it
  51241. *
  51242. * @param options options with which to initialize this timer
  51243. */
  51244. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  51245. /**
  51246. * An advanced implementation of a timer class
  51247. */
  51248. export class AdvancedTimer<T = any> implements IDisposable {
  51249. /**
  51250. * Will notify each time the timer calculates the remaining time
  51251. */
  51252. onEachCountObservable: Observable<ITimerData<T>>;
  51253. /**
  51254. * Will trigger when the timer was aborted due to the break condition
  51255. */
  51256. onTimerAbortedObservable: Observable<ITimerData<T>>;
  51257. /**
  51258. * Will trigger when the timer ended successfully
  51259. */
  51260. onTimerEndedObservable: Observable<ITimerData<T>>;
  51261. /**
  51262. * Will trigger when the timer state has changed
  51263. */
  51264. onStateChangedObservable: Observable<TimerState>;
  51265. private _observer;
  51266. private _contextObservable;
  51267. private _observableParameters;
  51268. private _startTime;
  51269. private _timer;
  51270. private _state;
  51271. private _breakCondition;
  51272. private _timeToEnd;
  51273. private _breakOnNextTick;
  51274. /**
  51275. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  51276. * @param options construction options for this advanced timer
  51277. */
  51278. constructor(options: ITimerOptions<T>);
  51279. /**
  51280. * set a breaking condition for this timer. Default is to never break during count
  51281. * @param predicate the new break condition. Returns true to break, false otherwise
  51282. */
  51283. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  51284. /**
  51285. * Reset ALL associated observables in this advanced timer
  51286. */
  51287. clearObservables(): void;
  51288. /**
  51289. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  51290. *
  51291. * @param timeToEnd how much time to measure until timer ended
  51292. */
  51293. start(timeToEnd?: number): void;
  51294. /**
  51295. * Will force a stop on the next tick.
  51296. */
  51297. stop(): void;
  51298. /**
  51299. * Dispose this timer, clearing all resources
  51300. */
  51301. dispose(): void;
  51302. private _setState;
  51303. private _tick;
  51304. private _stop;
  51305. }
  51306. }
  51307. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51308. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51309. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51310. import { Nullable } from "babylonjs/types";
  51311. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51313. import { Vector3 } from "babylonjs/Maths/math.vector";
  51314. import { Material } from "babylonjs/Materials/material";
  51315. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51316. import { Scene } from "babylonjs/scene";
  51317. /**
  51318. * The options container for the teleportation module
  51319. */
  51320. export interface IWebXRTeleportationOptions {
  51321. /**
  51322. * if provided, this scene will be used to render meshes.
  51323. */
  51324. customUtilityLayerScene?: Scene;
  51325. /**
  51326. * Values to configure the default target mesh
  51327. */
  51328. defaultTargetMeshOptions?: {
  51329. /**
  51330. * Fill color of the teleportation area
  51331. */
  51332. teleportationFillColor?: string;
  51333. /**
  51334. * Border color for the teleportation area
  51335. */
  51336. teleportationBorderColor?: string;
  51337. /**
  51338. * Disable the mesh's animation sequence
  51339. */
  51340. disableAnimation?: boolean;
  51341. /**
  51342. * Disable lighting on the material or the ring and arrow
  51343. */
  51344. disableLighting?: boolean;
  51345. /**
  51346. * Override the default material of the torus and arrow
  51347. */
  51348. torusArrowMaterial?: Material;
  51349. };
  51350. /**
  51351. * A list of meshes to use as floor meshes.
  51352. * Meshes can be added and removed after initializing the feature using the
  51353. * addFloorMesh and removeFloorMesh functions
  51354. * If empty, rotation will still work
  51355. */
  51356. floorMeshes?: AbstractMesh[];
  51357. /**
  51358. * use this rendering group id for the meshes (optional)
  51359. */
  51360. renderingGroupId?: number;
  51361. /**
  51362. * Should teleportation move only to snap points
  51363. */
  51364. snapPointsOnly?: boolean;
  51365. /**
  51366. * An array of points to which the teleportation will snap to.
  51367. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51368. */
  51369. snapPositions?: Vector3[];
  51370. /**
  51371. * How close should the teleportation ray be in order to snap to position.
  51372. * Default to 0.8 units (meters)
  51373. */
  51374. snapToPositionRadius?: number;
  51375. /**
  51376. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51377. * If you want to support rotation, make sure your mesh has a direction indicator.
  51378. *
  51379. * When left untouched, the default mesh will be initialized.
  51380. */
  51381. teleportationTargetMesh?: AbstractMesh;
  51382. /**
  51383. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51384. */
  51385. timeToTeleport?: number;
  51386. /**
  51387. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51388. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51389. */
  51390. useMainComponentOnly?: boolean;
  51391. /**
  51392. * Should meshes created here be added to a utility layer or the main scene
  51393. */
  51394. useUtilityLayer?: boolean;
  51395. /**
  51396. * Babylon XR Input class for controller
  51397. */
  51398. xrInput: WebXRInput;
  51399. /**
  51400. * Meshes that the teleportation ray cannot go through
  51401. */
  51402. pickBlockerMeshes?: AbstractMesh[];
  51403. }
  51404. /**
  51405. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51406. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51407. * the input of the attached controllers.
  51408. */
  51409. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51410. private _options;
  51411. private _controllers;
  51412. private _currentTeleportationControllerId;
  51413. private _floorMeshes;
  51414. private _quadraticBezierCurve;
  51415. private _selectionFeature;
  51416. private _snapToPositions;
  51417. private _snappedToPoint;
  51418. private _teleportationRingMaterial?;
  51419. private _tmpRay;
  51420. private _tmpVector;
  51421. private _tmpQuaternion;
  51422. /**
  51423. * The module's name
  51424. */
  51425. static readonly Name: string;
  51426. /**
  51427. * The (Babylon) version of this module.
  51428. * This is an integer representing the implementation version.
  51429. * This number does not correspond to the webxr specs version
  51430. */
  51431. static readonly Version: number;
  51432. /**
  51433. * Is movement backwards enabled
  51434. */
  51435. backwardsMovementEnabled: boolean;
  51436. /**
  51437. * Distance to travel when moving backwards
  51438. */
  51439. backwardsTeleportationDistance: number;
  51440. /**
  51441. * The distance from the user to the inspection point in the direction of the controller
  51442. * A higher number will allow the user to move further
  51443. * defaults to 5 (meters, in xr units)
  51444. */
  51445. parabolicCheckRadius: number;
  51446. /**
  51447. * Should the module support parabolic ray on top of direct ray
  51448. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51449. * Very helpful when moving between floors / different heights
  51450. */
  51451. parabolicRayEnabled: boolean;
  51452. /**
  51453. * How much rotation should be applied when rotating right and left
  51454. */
  51455. rotationAngle: number;
  51456. /**
  51457. * Is rotation enabled when moving forward?
  51458. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51459. */
  51460. rotationEnabled: boolean;
  51461. /**
  51462. * constructs a new anchor system
  51463. * @param _xrSessionManager an instance of WebXRSessionManager
  51464. * @param _options configuration object for this feature
  51465. */
  51466. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51467. /**
  51468. * Get the snapPointsOnly flag
  51469. */
  51470. get snapPointsOnly(): boolean;
  51471. /**
  51472. * Sets the snapPointsOnly flag
  51473. * @param snapToPoints should teleportation be exclusively to snap points
  51474. */
  51475. set snapPointsOnly(snapToPoints: boolean);
  51476. /**
  51477. * Add a new mesh to the floor meshes array
  51478. * @param mesh the mesh to use as floor mesh
  51479. */
  51480. addFloorMesh(mesh: AbstractMesh): void;
  51481. /**
  51482. * Add a new snap-to point to fix teleportation to this position
  51483. * @param newSnapPoint The new Snap-To point
  51484. */
  51485. addSnapPoint(newSnapPoint: Vector3): void;
  51486. attach(): boolean;
  51487. detach(): boolean;
  51488. dispose(): void;
  51489. /**
  51490. * Remove a mesh from the floor meshes array
  51491. * @param mesh the mesh to remove
  51492. */
  51493. removeFloorMesh(mesh: AbstractMesh): void;
  51494. /**
  51495. * Remove a mesh from the floor meshes array using its name
  51496. * @param name the mesh name to remove
  51497. */
  51498. removeFloorMeshByName(name: string): void;
  51499. /**
  51500. * 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
  51501. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51502. * @returns was the point found and removed or not
  51503. */
  51504. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51505. /**
  51506. * This function sets a selection feature that will be disabled when
  51507. * the forward ray is shown and will be reattached when hidden.
  51508. * This is used to remove the selection rays when moving.
  51509. * @param selectionFeature the feature to disable when forward movement is enabled
  51510. */
  51511. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  51512. protected _onXRFrame(_xrFrame: XRFrame): void;
  51513. private _attachController;
  51514. private _createDefaultTargetMesh;
  51515. private _detachController;
  51516. private _findClosestSnapPointWithRadius;
  51517. private _setTargetMeshPosition;
  51518. private _setTargetMeshVisibility;
  51519. private _showParabolicPath;
  51520. private _teleportForward;
  51521. }
  51522. }
  51523. declare module "babylonjs/XR/webXRDefaultExperience" {
  51524. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51525. import { Scene } from "babylonjs/scene";
  51526. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51527. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51528. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51529. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51531. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51532. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51533. /**
  51534. * Options for the default xr helper
  51535. */
  51536. export class WebXRDefaultExperienceOptions {
  51537. /**
  51538. * Enable or disable default UI to enter XR
  51539. */
  51540. disableDefaultUI?: boolean;
  51541. /**
  51542. * Should teleportation not initialize. defaults to false.
  51543. */
  51544. disableTeleportation?: boolean;
  51545. /**
  51546. * Floor meshes that will be used for teleport
  51547. */
  51548. floorMeshes?: Array<AbstractMesh>;
  51549. /**
  51550. * If set to true, the first frame will not be used to reset position
  51551. * The first frame is mainly used when copying transformation from the old camera
  51552. * Mainly used in AR
  51553. */
  51554. ignoreNativeCameraTransformation?: boolean;
  51555. /**
  51556. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51557. */
  51558. inputOptions?: IWebXRInputOptions;
  51559. /**
  51560. * optional configuration for the output canvas
  51561. */
  51562. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51563. /**
  51564. * optional UI options. This can be used among other to change session mode and reference space type
  51565. */
  51566. uiOptions?: WebXREnterExitUIOptions;
  51567. /**
  51568. * When loading teleportation and pointer select, use stable versions instead of latest.
  51569. */
  51570. useStablePlugins?: boolean;
  51571. /**
  51572. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51573. */
  51574. renderingGroupId?: number;
  51575. /**
  51576. * A list of optional features to init the session with
  51577. * If set to true, all features we support will be added
  51578. */
  51579. optionalFeatures?: boolean | string[];
  51580. }
  51581. /**
  51582. * Default experience which provides a similar setup to the previous webVRExperience
  51583. */
  51584. export class WebXRDefaultExperience {
  51585. /**
  51586. * Base experience
  51587. */
  51588. baseExperience: WebXRExperienceHelper;
  51589. /**
  51590. * Enables ui for entering/exiting xr
  51591. */
  51592. enterExitUI: WebXREnterExitUI;
  51593. /**
  51594. * Input experience extension
  51595. */
  51596. input: WebXRInput;
  51597. /**
  51598. * Enables laser pointer and selection
  51599. */
  51600. pointerSelection: WebXRControllerPointerSelection;
  51601. /**
  51602. * Default target xr should render to
  51603. */
  51604. renderTarget: WebXRRenderTarget;
  51605. /**
  51606. * Enables teleportation
  51607. */
  51608. teleportation: WebXRMotionControllerTeleportation;
  51609. private constructor();
  51610. /**
  51611. * Creates the default xr experience
  51612. * @param scene scene
  51613. * @param options options for basic configuration
  51614. * @returns resulting WebXRDefaultExperience
  51615. */
  51616. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51617. /**
  51618. * DIsposes of the experience helper
  51619. */
  51620. dispose(): void;
  51621. }
  51622. }
  51623. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51624. import { Observable } from "babylonjs/Misc/observable";
  51625. import { Nullable } from "babylonjs/types";
  51626. import { Camera } from "babylonjs/Cameras/camera";
  51627. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51628. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51629. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51630. import { Scene } from "babylonjs/scene";
  51631. import { Vector3 } from "babylonjs/Maths/math.vector";
  51632. import { Color3 } from "babylonjs/Maths/math.color";
  51633. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51635. import { Mesh } from "babylonjs/Meshes/mesh";
  51636. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51637. import { EasingFunction } from "babylonjs/Animations/easing";
  51638. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51639. import "babylonjs/Meshes/Builders/groundBuilder";
  51640. import "babylonjs/Meshes/Builders/torusBuilder";
  51641. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51642. import "babylonjs/Gamepads/gamepadSceneComponent";
  51643. import "babylonjs/Animations/animatable";
  51644. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51645. /**
  51646. * Options to modify the vr teleportation behavior.
  51647. */
  51648. export interface VRTeleportationOptions {
  51649. /**
  51650. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51651. */
  51652. floorMeshName?: string;
  51653. /**
  51654. * A list of meshes to be used as the teleportation floor. (default: empty)
  51655. */
  51656. floorMeshes?: Mesh[];
  51657. /**
  51658. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51659. */
  51660. teleportationMode?: number;
  51661. /**
  51662. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51663. */
  51664. teleportationTime?: number;
  51665. /**
  51666. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51667. */
  51668. teleportationSpeed?: number;
  51669. /**
  51670. * The easing function used in the animation or null for Linear. (default CircleEase)
  51671. */
  51672. easingFunction?: EasingFunction;
  51673. }
  51674. /**
  51675. * Options to modify the vr experience helper's behavior.
  51676. */
  51677. export interface VRExperienceHelperOptions extends WebVROptions {
  51678. /**
  51679. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51680. */
  51681. createDeviceOrientationCamera?: boolean;
  51682. /**
  51683. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51684. */
  51685. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51686. /**
  51687. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51688. */
  51689. laserToggle?: boolean;
  51690. /**
  51691. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51692. */
  51693. floorMeshes?: Mesh[];
  51694. /**
  51695. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51696. */
  51697. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51698. /**
  51699. * Defines if WebXR should be used instead of WebVR (if available)
  51700. */
  51701. useXR?: boolean;
  51702. }
  51703. /**
  51704. * Event containing information after VR has been entered
  51705. */
  51706. export class OnAfterEnteringVRObservableEvent {
  51707. /**
  51708. * If entering vr was successful
  51709. */
  51710. success: boolean;
  51711. }
  51712. /**
  51713. * Helps to quickly add VR support to an existing scene.
  51714. * See https://doc.babylonjs.com/how_to/webvr_helper
  51715. */
  51716. export class VRExperienceHelper {
  51717. /** Options to modify the vr experience helper's behavior. */
  51718. webVROptions: VRExperienceHelperOptions;
  51719. private _scene;
  51720. private _position;
  51721. private _btnVR;
  51722. private _btnVRDisplayed;
  51723. private _webVRsupported;
  51724. private _webVRready;
  51725. private _webVRrequesting;
  51726. private _webVRpresenting;
  51727. private _hasEnteredVR;
  51728. private _fullscreenVRpresenting;
  51729. private _inputElement;
  51730. private _webVRCamera;
  51731. private _vrDeviceOrientationCamera;
  51732. private _deviceOrientationCamera;
  51733. private _existingCamera;
  51734. private _onKeyDown;
  51735. private _onVrDisplayPresentChange;
  51736. private _onVRDisplayChanged;
  51737. private _onVRRequestPresentStart;
  51738. private _onVRRequestPresentComplete;
  51739. /**
  51740. * 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)
  51741. */
  51742. enableGazeEvenWhenNoPointerLock: boolean;
  51743. /**
  51744. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51745. */
  51746. exitVROnDoubleTap: boolean;
  51747. /**
  51748. * Observable raised right before entering VR.
  51749. */
  51750. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51751. /**
  51752. * Observable raised when entering VR has completed.
  51753. */
  51754. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51755. /**
  51756. * Observable raised when exiting VR.
  51757. */
  51758. onExitingVRObservable: Observable<VRExperienceHelper>;
  51759. /**
  51760. * Observable raised when controller mesh is loaded.
  51761. */
  51762. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51763. /** Return this.onEnteringVRObservable
  51764. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51765. */
  51766. get onEnteringVR(): Observable<VRExperienceHelper>;
  51767. /** Return this.onExitingVRObservable
  51768. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51769. */
  51770. get onExitingVR(): Observable<VRExperienceHelper>;
  51771. /** Return this.onControllerMeshLoadedObservable
  51772. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51773. */
  51774. get onControllerMeshLoaded(): Observable<WebVRController>;
  51775. private _rayLength;
  51776. private _useCustomVRButton;
  51777. private _teleportationRequested;
  51778. private _teleportActive;
  51779. private _floorMeshName;
  51780. private _floorMeshesCollection;
  51781. private _teleportationMode;
  51782. private _teleportationTime;
  51783. private _teleportationSpeed;
  51784. private _teleportationEasing;
  51785. private _rotationAllowed;
  51786. private _teleportBackwardsVector;
  51787. private _teleportationTarget;
  51788. private _isDefaultTeleportationTarget;
  51789. private _postProcessMove;
  51790. private _teleportationFillColor;
  51791. private _teleportationBorderColor;
  51792. private _rotationAngle;
  51793. private _haloCenter;
  51794. private _cameraGazer;
  51795. private _padSensibilityUp;
  51796. private _padSensibilityDown;
  51797. private _leftController;
  51798. private _rightController;
  51799. private _gazeColor;
  51800. private _laserColor;
  51801. private _pickedLaserColor;
  51802. private _pickedGazeColor;
  51803. /**
  51804. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51805. */
  51806. onNewMeshSelected: Observable<AbstractMesh>;
  51807. /**
  51808. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51809. * This observable will provide the mesh and the controller used to select the mesh
  51810. */
  51811. onMeshSelectedWithController: Observable<{
  51812. mesh: AbstractMesh;
  51813. controller: WebVRController;
  51814. }>;
  51815. /**
  51816. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51817. */
  51818. onNewMeshPicked: Observable<PickingInfo>;
  51819. private _circleEase;
  51820. /**
  51821. * Observable raised before camera teleportation
  51822. */
  51823. onBeforeCameraTeleport: Observable<Vector3>;
  51824. /**
  51825. * Observable raised after camera teleportation
  51826. */
  51827. onAfterCameraTeleport: Observable<Vector3>;
  51828. /**
  51829. * Observable raised when current selected mesh gets unselected
  51830. */
  51831. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51832. private _raySelectionPredicate;
  51833. /**
  51834. * To be optionaly changed by user to define custom ray selection
  51835. */
  51836. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51837. /**
  51838. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51839. */
  51840. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51841. /**
  51842. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51843. */
  51844. teleportationEnabled: boolean;
  51845. private _defaultHeight;
  51846. private _teleportationInitialized;
  51847. private _interactionsEnabled;
  51848. private _interactionsRequested;
  51849. private _displayGaze;
  51850. private _displayLaserPointer;
  51851. /**
  51852. * The mesh used to display where the user is going to teleport.
  51853. */
  51854. get teleportationTarget(): Mesh;
  51855. /**
  51856. * Sets the mesh to be used to display where the user is going to teleport.
  51857. */
  51858. set teleportationTarget(value: Mesh);
  51859. /**
  51860. * 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
  51861. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51862. * See https://doc.babylonjs.com/resources/baking_transformations
  51863. */
  51864. get gazeTrackerMesh(): Mesh;
  51865. set gazeTrackerMesh(value: Mesh);
  51866. /**
  51867. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51868. */
  51869. updateGazeTrackerScale: boolean;
  51870. /**
  51871. * If the gaze trackers color should be updated when selecting meshes
  51872. */
  51873. updateGazeTrackerColor: boolean;
  51874. /**
  51875. * If the controller laser color should be updated when selecting meshes
  51876. */
  51877. updateControllerLaserColor: boolean;
  51878. /**
  51879. * The gaze tracking mesh corresponding to the left controller
  51880. */
  51881. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51882. /**
  51883. * The gaze tracking mesh corresponding to the right controller
  51884. */
  51885. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51886. /**
  51887. * If the ray of the gaze should be displayed.
  51888. */
  51889. get displayGaze(): boolean;
  51890. /**
  51891. * Sets if the ray of the gaze should be displayed.
  51892. */
  51893. set displayGaze(value: boolean);
  51894. /**
  51895. * If the ray of the LaserPointer should be displayed.
  51896. */
  51897. get displayLaserPointer(): boolean;
  51898. /**
  51899. * Sets if the ray of the LaserPointer should be displayed.
  51900. */
  51901. set displayLaserPointer(value: boolean);
  51902. /**
  51903. * The deviceOrientationCamera used as the camera when not in VR.
  51904. */
  51905. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51906. /**
  51907. * Based on the current WebVR support, returns the current VR camera used.
  51908. */
  51909. get currentVRCamera(): Nullable<Camera>;
  51910. /**
  51911. * The webVRCamera which is used when in VR.
  51912. */
  51913. get webVRCamera(): WebVRFreeCamera;
  51914. /**
  51915. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51916. */
  51917. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51918. /**
  51919. * The html button that is used to trigger entering into VR.
  51920. */
  51921. get vrButton(): Nullable<HTMLButtonElement>;
  51922. private get _teleportationRequestInitiated();
  51923. /**
  51924. * Defines whether or not Pointer lock should be requested when switching to
  51925. * full screen.
  51926. */
  51927. requestPointerLockOnFullScreen: boolean;
  51928. /**
  51929. * If asking to force XR, this will be populated with the default xr experience
  51930. */
  51931. xr: WebXRDefaultExperience;
  51932. /**
  51933. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51934. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51935. */
  51936. xrTestDone: boolean;
  51937. /**
  51938. * Instantiates a VRExperienceHelper.
  51939. * Helps to quickly add VR support to an existing scene.
  51940. * @param scene The scene the VRExperienceHelper belongs to.
  51941. * @param webVROptions Options to modify the vr experience helper's behavior.
  51942. */
  51943. constructor(scene: Scene,
  51944. /** Options to modify the vr experience helper's behavior. */
  51945. webVROptions?: VRExperienceHelperOptions);
  51946. private completeVRInit;
  51947. private _onDefaultMeshLoaded;
  51948. private _onResize;
  51949. private _onFullscreenChange;
  51950. /**
  51951. * Gets a value indicating if we are currently in VR mode.
  51952. */
  51953. get isInVRMode(): boolean;
  51954. private onVrDisplayPresentChange;
  51955. private onVRDisplayChanged;
  51956. private moveButtonToBottomRight;
  51957. private displayVRButton;
  51958. private updateButtonVisibility;
  51959. private _cachedAngularSensibility;
  51960. /**
  51961. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51962. * Otherwise, will use the fullscreen API.
  51963. */
  51964. enterVR(): void;
  51965. /**
  51966. * Attempt to exit VR, or fullscreen.
  51967. */
  51968. exitVR(): void;
  51969. /**
  51970. * The position of the vr experience helper.
  51971. */
  51972. get position(): Vector3;
  51973. /**
  51974. * Sets the position of the vr experience helper.
  51975. */
  51976. set position(value: Vector3);
  51977. /**
  51978. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51979. */
  51980. enableInteractions(): void;
  51981. private get _noControllerIsActive();
  51982. private beforeRender;
  51983. private _isTeleportationFloor;
  51984. /**
  51985. * Adds a floor mesh to be used for teleportation.
  51986. * @param floorMesh the mesh to be used for teleportation.
  51987. */
  51988. addFloorMesh(floorMesh: Mesh): void;
  51989. /**
  51990. * Removes a floor mesh from being used for teleportation.
  51991. * @param floorMesh the mesh to be removed.
  51992. */
  51993. removeFloorMesh(floorMesh: Mesh): void;
  51994. /**
  51995. * Enables interactions and teleportation using the VR controllers and gaze.
  51996. * @param vrTeleportationOptions options to modify teleportation behavior.
  51997. */
  51998. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51999. private _onNewGamepadConnected;
  52000. private _tryEnableInteractionOnController;
  52001. private _onNewGamepadDisconnected;
  52002. private _enableInteractionOnController;
  52003. private _checkTeleportWithRay;
  52004. private _checkRotate;
  52005. private _checkTeleportBackwards;
  52006. private _enableTeleportationOnController;
  52007. private _createTeleportationCircles;
  52008. private _displayTeleportationTarget;
  52009. private _hideTeleportationTarget;
  52010. private _rotateCamera;
  52011. private _moveTeleportationSelectorTo;
  52012. private _workingVector;
  52013. private _workingQuaternion;
  52014. private _workingMatrix;
  52015. /**
  52016. * Time Constant Teleportation Mode
  52017. */
  52018. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  52019. /**
  52020. * Speed Constant Teleportation Mode
  52021. */
  52022. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  52023. /**
  52024. * Teleports the users feet to the desired location
  52025. * @param location The location where the user's feet should be placed
  52026. */
  52027. teleportCamera(location: Vector3): void;
  52028. private _convertNormalToDirectionOfRay;
  52029. private _castRayAndSelectObject;
  52030. private _notifySelectedMeshUnselected;
  52031. /**
  52032. * Permanently set new colors for the laser pointer
  52033. * @param color the new laser color
  52034. * @param pickedColor the new laser color when picked mesh detected
  52035. */
  52036. setLaserColor(color: Color3, pickedColor?: Color3): void;
  52037. /**
  52038. * Set lighting enabled / disabled on the laser pointer of both controllers
  52039. * @param enabled should the lighting be enabled on the laser pointer
  52040. */
  52041. setLaserLightingState(enabled?: boolean): void;
  52042. /**
  52043. * Permanently set new colors for the gaze pointer
  52044. * @param color the new gaze color
  52045. * @param pickedColor the new gaze color when picked mesh detected
  52046. */
  52047. setGazeColor(color: Color3, pickedColor?: Color3): void;
  52048. /**
  52049. * Sets the color of the laser ray from the vr controllers.
  52050. * @param color new color for the ray.
  52051. */
  52052. changeLaserColor(color: Color3): void;
  52053. /**
  52054. * Sets the color of the ray from the vr headsets gaze.
  52055. * @param color new color for the ray.
  52056. */
  52057. changeGazeColor(color: Color3): void;
  52058. /**
  52059. * Exits VR and disposes of the vr experience helper
  52060. */
  52061. dispose(): void;
  52062. /**
  52063. * Gets the name of the VRExperienceHelper class
  52064. * @returns "VRExperienceHelper"
  52065. */
  52066. getClassName(): string;
  52067. }
  52068. }
  52069. declare module "babylonjs/Cameras/VR/index" {
  52070. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  52071. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  52072. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  52073. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  52074. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  52075. export * from "babylonjs/Cameras/VR/webVRCamera";
  52076. }
  52077. declare module "babylonjs/Cameras/RigModes/index" {
  52078. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  52079. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  52080. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  52081. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  52082. }
  52083. declare module "babylonjs/Cameras/index" {
  52084. export * from "babylonjs/Cameras/Inputs/index";
  52085. export * from "babylonjs/Cameras/cameraInputsManager";
  52086. export * from "babylonjs/Cameras/camera";
  52087. export * from "babylonjs/Cameras/targetCamera";
  52088. export * from "babylonjs/Cameras/freeCamera";
  52089. export * from "babylonjs/Cameras/freeCameraInputsManager";
  52090. export * from "babylonjs/Cameras/touchCamera";
  52091. export * from "babylonjs/Cameras/arcRotateCamera";
  52092. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  52093. export * from "babylonjs/Cameras/deviceOrientationCamera";
  52094. export * from "babylonjs/Cameras/flyCamera";
  52095. export * from "babylonjs/Cameras/flyCameraInputsManager";
  52096. export * from "babylonjs/Cameras/followCamera";
  52097. export * from "babylonjs/Cameras/followCameraInputsManager";
  52098. export * from "babylonjs/Cameras/gamepadCamera";
  52099. export * from "babylonjs/Cameras/Stereoscopic/index";
  52100. export * from "babylonjs/Cameras/universalCamera";
  52101. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  52102. export * from "babylonjs/Cameras/VR/index";
  52103. export * from "babylonjs/Cameras/RigModes/index";
  52104. }
  52105. declare module "babylonjs/Collisions/index" {
  52106. export * from "babylonjs/Collisions/collider";
  52107. export * from "babylonjs/Collisions/collisionCoordinator";
  52108. export * from "babylonjs/Collisions/pickingInfo";
  52109. export * from "babylonjs/Collisions/intersectionInfo";
  52110. export * from "babylonjs/Collisions/meshCollisionData";
  52111. }
  52112. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  52113. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  52114. import { Vector3 } from "babylonjs/Maths/math.vector";
  52115. import { Ray } from "babylonjs/Culling/ray";
  52116. import { Plane } from "babylonjs/Maths/math.plane";
  52117. /**
  52118. * Contains an array of blocks representing the octree
  52119. */
  52120. export interface IOctreeContainer<T> {
  52121. /**
  52122. * Blocks within the octree
  52123. */
  52124. blocks: Array<OctreeBlock<T>>;
  52125. }
  52126. /**
  52127. * Class used to store a cell in an octree
  52128. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52129. */
  52130. export class OctreeBlock<T> {
  52131. /**
  52132. * Gets the content of the current block
  52133. */
  52134. entries: T[];
  52135. /**
  52136. * Gets the list of block children
  52137. */
  52138. blocks: Array<OctreeBlock<T>>;
  52139. private _depth;
  52140. private _maxDepth;
  52141. private _capacity;
  52142. private _minPoint;
  52143. private _maxPoint;
  52144. private _boundingVectors;
  52145. private _creationFunc;
  52146. /**
  52147. * Creates a new block
  52148. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  52149. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  52150. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52151. * @param depth defines the current depth of this block in the octree
  52152. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  52153. * @param creationFunc defines a callback to call when an element is added to the block
  52154. */
  52155. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  52156. /**
  52157. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52158. */
  52159. get capacity(): number;
  52160. /**
  52161. * Gets the minimum vector (in world space) of the block's bounding box
  52162. */
  52163. get minPoint(): Vector3;
  52164. /**
  52165. * Gets the maximum vector (in world space) of the block's bounding box
  52166. */
  52167. get maxPoint(): Vector3;
  52168. /**
  52169. * Add a new element to this block
  52170. * @param entry defines the element to add
  52171. */
  52172. addEntry(entry: T): void;
  52173. /**
  52174. * Remove an element from this block
  52175. * @param entry defines the element to remove
  52176. */
  52177. removeEntry(entry: T): void;
  52178. /**
  52179. * Add an array of elements to this block
  52180. * @param entries defines the array of elements to add
  52181. */
  52182. addEntries(entries: T[]): void;
  52183. /**
  52184. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  52185. * @param frustumPlanes defines the frustum planes to test
  52186. * @param selection defines the array to store current content if selection is positive
  52187. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52188. */
  52189. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52190. /**
  52191. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  52192. * @param sphereCenter defines the bounding sphere center
  52193. * @param sphereRadius defines the bounding sphere radius
  52194. * @param selection defines the array to store current content if selection is positive
  52195. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52196. */
  52197. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52198. /**
  52199. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  52200. * @param ray defines the ray to test with
  52201. * @param selection defines the array to store current content if selection is positive
  52202. */
  52203. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  52204. /**
  52205. * Subdivide the content into child blocks (this block will then be empty)
  52206. */
  52207. createInnerBlocks(): void;
  52208. /**
  52209. * @hidden
  52210. */
  52211. 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;
  52212. }
  52213. }
  52214. declare module "babylonjs/Culling/Octrees/octree" {
  52215. import { SmartArray } from "babylonjs/Misc/smartArray";
  52216. import { Vector3 } from "babylonjs/Maths/math.vector";
  52217. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52219. import { Ray } from "babylonjs/Culling/ray";
  52220. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  52221. import { Plane } from "babylonjs/Maths/math.plane";
  52222. /**
  52223. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  52224. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52225. */
  52226. export class Octree<T> {
  52227. /** 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.) */
  52228. maxDepth: number;
  52229. /**
  52230. * Blocks within the octree containing objects
  52231. */
  52232. blocks: Array<OctreeBlock<T>>;
  52233. /**
  52234. * Content stored in the octree
  52235. */
  52236. dynamicContent: T[];
  52237. private _maxBlockCapacity;
  52238. private _selectionContent;
  52239. private _creationFunc;
  52240. /**
  52241. * Creates a octree
  52242. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52243. * @param creationFunc function to be used to instatiate the octree
  52244. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  52245. * @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.)
  52246. */
  52247. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  52248. /** 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.) */
  52249. maxDepth?: number);
  52250. /**
  52251. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  52252. * @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);
  52253. * @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);
  52254. * @param entries meshes to be added to the octree blocks
  52255. */
  52256. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  52257. /**
  52258. * Adds a mesh to the octree
  52259. * @param entry Mesh to add to the octree
  52260. */
  52261. addMesh(entry: T): void;
  52262. /**
  52263. * Remove an element from the octree
  52264. * @param entry defines the element to remove
  52265. */
  52266. removeMesh(entry: T): void;
  52267. /**
  52268. * Selects an array of meshes within the frustum
  52269. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  52270. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  52271. * @returns array of meshes within the frustum
  52272. */
  52273. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  52274. /**
  52275. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  52276. * @param sphereCenter defines the bounding sphere center
  52277. * @param sphereRadius defines the bounding sphere radius
  52278. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52279. * @returns an array of objects that intersect the sphere
  52280. */
  52281. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  52282. /**
  52283. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  52284. * @param ray defines the ray to test with
  52285. * @returns array of intersected objects
  52286. */
  52287. intersectsRay(ray: Ray): SmartArray<T>;
  52288. /**
  52289. * Adds a mesh into the octree block if it intersects the block
  52290. */
  52291. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  52292. /**
  52293. * Adds a submesh into the octree block if it intersects the block
  52294. */
  52295. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  52296. }
  52297. }
  52298. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  52299. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  52300. import { Scene } from "babylonjs/scene";
  52301. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52303. import { Ray } from "babylonjs/Culling/ray";
  52304. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52305. import { Collider } from "babylonjs/Collisions/collider";
  52306. module "babylonjs/scene" {
  52307. interface Scene {
  52308. /**
  52309. * @hidden
  52310. * Backing Filed
  52311. */
  52312. _selectionOctree: Octree<AbstractMesh>;
  52313. /**
  52314. * Gets the octree used to boost mesh selection (picking)
  52315. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52316. */
  52317. selectionOctree: Octree<AbstractMesh>;
  52318. /**
  52319. * Creates or updates the octree used to boost selection (picking)
  52320. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52321. * @param maxCapacity defines the maximum capacity per leaf
  52322. * @param maxDepth defines the maximum depth of the octree
  52323. * @returns an octree of AbstractMesh
  52324. */
  52325. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52326. }
  52327. }
  52328. module "babylonjs/Meshes/abstractMesh" {
  52329. interface AbstractMesh {
  52330. /**
  52331. * @hidden
  52332. * Backing Field
  52333. */
  52334. _submeshesOctree: Octree<SubMesh>;
  52335. /**
  52336. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52337. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52338. * @param maxCapacity defines the maximum size of each block (64 by default)
  52339. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52340. * @returns the new octree
  52341. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52342. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52343. */
  52344. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52345. }
  52346. }
  52347. /**
  52348. * Defines the octree scene component responsible to manage any octrees
  52349. * in a given scene.
  52350. */
  52351. export class OctreeSceneComponent {
  52352. /**
  52353. * The component name help to identify the component in the list of scene components.
  52354. */
  52355. readonly name: string;
  52356. /**
  52357. * The scene the component belongs to.
  52358. */
  52359. scene: Scene;
  52360. /**
  52361. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52362. */
  52363. readonly checksIsEnabled: boolean;
  52364. /**
  52365. * Creates a new instance of the component for the given scene
  52366. * @param scene Defines the scene to register the component in
  52367. */
  52368. constructor(scene: Scene);
  52369. /**
  52370. * Registers the component in a given scene
  52371. */
  52372. register(): void;
  52373. /**
  52374. * Return the list of active meshes
  52375. * @returns the list of active meshes
  52376. */
  52377. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52378. /**
  52379. * Return the list of active sub meshes
  52380. * @param mesh The mesh to get the candidates sub meshes from
  52381. * @returns the list of active sub meshes
  52382. */
  52383. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52384. private _tempRay;
  52385. /**
  52386. * Return the list of sub meshes intersecting with a given local ray
  52387. * @param mesh defines the mesh to find the submesh for
  52388. * @param localRay defines the ray in local space
  52389. * @returns the list of intersecting sub meshes
  52390. */
  52391. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52392. /**
  52393. * Return the list of sub meshes colliding with a collider
  52394. * @param mesh defines the mesh to find the submesh for
  52395. * @param collider defines the collider to evaluate the collision against
  52396. * @returns the list of colliding sub meshes
  52397. */
  52398. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52399. /**
  52400. * Rebuilds the elements related to this component in case of
  52401. * context lost for instance.
  52402. */
  52403. rebuild(): void;
  52404. /**
  52405. * Disposes the component and the associated ressources.
  52406. */
  52407. dispose(): void;
  52408. }
  52409. }
  52410. declare module "babylonjs/Culling/Octrees/index" {
  52411. export * from "babylonjs/Culling/Octrees/octree";
  52412. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52413. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52414. }
  52415. declare module "babylonjs/Culling/index" {
  52416. export * from "babylonjs/Culling/boundingBox";
  52417. export * from "babylonjs/Culling/boundingInfo";
  52418. export * from "babylonjs/Culling/boundingSphere";
  52419. export * from "babylonjs/Culling/Octrees/index";
  52420. export * from "babylonjs/Culling/ray";
  52421. }
  52422. declare module "babylonjs/Gizmos/gizmo" {
  52423. import { Nullable } from "babylonjs/types";
  52424. import { IDisposable } from "babylonjs/scene";
  52425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52426. import { Mesh } from "babylonjs/Meshes/mesh";
  52427. import { Node } from "babylonjs/node";
  52428. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52429. /**
  52430. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52431. */
  52432. export class Gizmo implements IDisposable {
  52433. /** The utility layer the gizmo will be added to */
  52434. gizmoLayer: UtilityLayerRenderer;
  52435. /**
  52436. * The root mesh of the gizmo
  52437. */
  52438. _rootMesh: Mesh;
  52439. private _attachedMesh;
  52440. private _attachedNode;
  52441. /**
  52442. * Ratio for the scale of the gizmo (Default: 1)
  52443. */
  52444. protected _scaleRatio: number;
  52445. /**
  52446. * boolean updated by pointermove when a gizmo mesh is hovered
  52447. */
  52448. protected _isHovered: boolean;
  52449. /**
  52450. * Ratio for the scale of the gizmo (Default: 1)
  52451. */
  52452. set scaleRatio(value: number);
  52453. get scaleRatio(): number;
  52454. /**
  52455. * True when the mouse pointer is hovered a gizmo mesh
  52456. */
  52457. get isHovered(): boolean;
  52458. /**
  52459. * If a custom mesh has been set (Default: false)
  52460. */
  52461. protected _customMeshSet: boolean;
  52462. /**
  52463. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52464. * * When set, interactions will be enabled
  52465. */
  52466. get attachedMesh(): Nullable<AbstractMesh>;
  52467. set attachedMesh(value: Nullable<AbstractMesh>);
  52468. /**
  52469. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52470. * * When set, interactions will be enabled
  52471. */
  52472. get attachedNode(): Nullable<Node>;
  52473. set attachedNode(value: Nullable<Node>);
  52474. /**
  52475. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52476. * @param mesh The mesh to replace the default mesh of the gizmo
  52477. */
  52478. setCustomMesh(mesh: Mesh): void;
  52479. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  52480. /**
  52481. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52482. */
  52483. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52484. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52485. /**
  52486. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52487. */
  52488. updateGizmoPositionToMatchAttachedMesh: boolean;
  52489. /**
  52490. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52491. */
  52492. updateScale: boolean;
  52493. protected _interactionsEnabled: boolean;
  52494. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52495. private _beforeRenderObserver;
  52496. private _tempQuaternion;
  52497. private _tempVector;
  52498. private _tempVector2;
  52499. private _tempMatrix1;
  52500. private _tempMatrix2;
  52501. private _rightHandtoLeftHandMatrix;
  52502. /**
  52503. * Creates a gizmo
  52504. * @param gizmoLayer The utility layer the gizmo will be added to
  52505. */
  52506. constructor(
  52507. /** The utility layer the gizmo will be added to */
  52508. gizmoLayer?: UtilityLayerRenderer);
  52509. /**
  52510. * Updates the gizmo to match the attached mesh's position/rotation
  52511. */
  52512. protected _update(): void;
  52513. /**
  52514. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52515. * @param value Node, TransformNode or mesh
  52516. */
  52517. protected _matrixChanged(): void;
  52518. /**
  52519. * Disposes of the gizmo
  52520. */
  52521. dispose(): void;
  52522. }
  52523. }
  52524. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52525. import { Observable } from "babylonjs/Misc/observable";
  52526. import { Nullable } from "babylonjs/types";
  52527. import { Vector3 } from "babylonjs/Maths/math.vector";
  52528. import { Color3 } from "babylonjs/Maths/math.color";
  52529. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52530. import { Node } from "babylonjs/node";
  52531. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52532. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52533. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52534. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52535. import { Scene } from "babylonjs/scene";
  52536. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52537. /**
  52538. * Single plane drag gizmo
  52539. */
  52540. export class PlaneDragGizmo extends Gizmo {
  52541. /**
  52542. * Drag behavior responsible for the gizmos dragging interactions
  52543. */
  52544. dragBehavior: PointerDragBehavior;
  52545. private _pointerObserver;
  52546. /**
  52547. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52548. */
  52549. snapDistance: number;
  52550. /**
  52551. * Event that fires each time the gizmo snaps to a new location.
  52552. * * snapDistance is the the change in distance
  52553. */
  52554. onSnapObservable: Observable<{
  52555. snapDistance: number;
  52556. }>;
  52557. private _plane;
  52558. private _coloredMaterial;
  52559. private _hoverMaterial;
  52560. private _isEnabled;
  52561. private _parent;
  52562. /** @hidden */
  52563. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52564. /** @hidden */
  52565. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52566. /**
  52567. * Creates a PlaneDragGizmo
  52568. * @param gizmoLayer The utility layer the gizmo will be added to
  52569. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52570. * @param color The color of the gizmo
  52571. */
  52572. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52573. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52574. /**
  52575. * If the gizmo is enabled
  52576. */
  52577. set isEnabled(value: boolean);
  52578. get isEnabled(): boolean;
  52579. /**
  52580. * Disposes of the gizmo
  52581. */
  52582. dispose(): void;
  52583. }
  52584. }
  52585. declare module "babylonjs/Gizmos/positionGizmo" {
  52586. import { Observable } from "babylonjs/Misc/observable";
  52587. import { Nullable } from "babylonjs/types";
  52588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52589. import { Node } from "babylonjs/node";
  52590. import { Mesh } from "babylonjs/Meshes/mesh";
  52591. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52592. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52593. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52594. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52595. /**
  52596. * Gizmo that enables dragging a mesh along 3 axis
  52597. */
  52598. export class PositionGizmo extends Gizmo {
  52599. /**
  52600. * Internal gizmo used for interactions on the x axis
  52601. */
  52602. xGizmo: AxisDragGizmo;
  52603. /**
  52604. * Internal gizmo used for interactions on the y axis
  52605. */
  52606. yGizmo: AxisDragGizmo;
  52607. /**
  52608. * Internal gizmo used for interactions on the z axis
  52609. */
  52610. zGizmo: AxisDragGizmo;
  52611. /**
  52612. * Internal gizmo used for interactions on the yz plane
  52613. */
  52614. xPlaneGizmo: PlaneDragGizmo;
  52615. /**
  52616. * Internal gizmo used for interactions on the xz plane
  52617. */
  52618. yPlaneGizmo: PlaneDragGizmo;
  52619. /**
  52620. * Internal gizmo used for interactions on the xy plane
  52621. */
  52622. zPlaneGizmo: PlaneDragGizmo;
  52623. /**
  52624. * private variables
  52625. */
  52626. private _meshAttached;
  52627. private _nodeAttached;
  52628. private _snapDistance;
  52629. /** Fires an event when any of it's sub gizmos are dragged */
  52630. onDragStartObservable: Observable<unknown>;
  52631. /** Fires an event when any of it's sub gizmos are released from dragging */
  52632. onDragEndObservable: Observable<unknown>;
  52633. /**
  52634. * If set to true, planar drag is enabled
  52635. */
  52636. private _planarGizmoEnabled;
  52637. get attachedMesh(): Nullable<AbstractMesh>;
  52638. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52639. get attachedNode(): Nullable<Node>;
  52640. set attachedNode(node: Nullable<Node>);
  52641. /**
  52642. * True when the mouse pointer is hovering a gizmo mesh
  52643. */
  52644. get isHovered(): boolean;
  52645. /**
  52646. * Creates a PositionGizmo
  52647. * @param gizmoLayer The utility layer the gizmo will be added to
  52648. @param thickness display gizmo axis thickness
  52649. */
  52650. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52651. /**
  52652. * If the planar drag gizmo is enabled
  52653. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52654. */
  52655. set planarGizmoEnabled(value: boolean);
  52656. get planarGizmoEnabled(): boolean;
  52657. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52658. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52659. /**
  52660. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52661. */
  52662. set snapDistance(value: number);
  52663. get snapDistance(): number;
  52664. /**
  52665. * Ratio for the scale of the gizmo (Default: 1)
  52666. */
  52667. set scaleRatio(value: number);
  52668. get scaleRatio(): number;
  52669. /**
  52670. * Disposes of the gizmo
  52671. */
  52672. dispose(): void;
  52673. /**
  52674. * CustomMeshes are not supported by this gizmo
  52675. * @param mesh The mesh to replace the default mesh of the gizmo
  52676. */
  52677. setCustomMesh(mesh: Mesh): void;
  52678. }
  52679. }
  52680. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52681. import { Observable } from "babylonjs/Misc/observable";
  52682. import { Nullable } from "babylonjs/types";
  52683. import { Vector3 } from "babylonjs/Maths/math.vector";
  52684. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52685. import { Node } from "babylonjs/node";
  52686. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52687. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52688. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52689. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52690. import { Scene } from "babylonjs/scene";
  52691. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52692. import { Color3 } from "babylonjs/Maths/math.color";
  52693. /**
  52694. * Single axis drag gizmo
  52695. */
  52696. export class AxisDragGizmo extends Gizmo {
  52697. /**
  52698. * Drag behavior responsible for the gizmos dragging interactions
  52699. */
  52700. dragBehavior: PointerDragBehavior;
  52701. private _pointerObserver;
  52702. /**
  52703. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52704. */
  52705. snapDistance: number;
  52706. /**
  52707. * Event that fires each time the gizmo snaps to a new location.
  52708. * * snapDistance is the the change in distance
  52709. */
  52710. onSnapObservable: Observable<{
  52711. snapDistance: number;
  52712. }>;
  52713. private _isEnabled;
  52714. private _parent;
  52715. private _arrow;
  52716. private _coloredMaterial;
  52717. private _hoverMaterial;
  52718. /** @hidden */
  52719. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52720. /** @hidden */
  52721. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52722. /**
  52723. * Creates an AxisDragGizmo
  52724. * @param gizmoLayer The utility layer the gizmo will be added to
  52725. * @param dragAxis The axis which the gizmo will be able to drag on
  52726. * @param color The color of the gizmo
  52727. * @param thickness display gizmo axis thickness
  52728. */
  52729. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52730. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52731. /**
  52732. * If the gizmo is enabled
  52733. */
  52734. set isEnabled(value: boolean);
  52735. get isEnabled(): boolean;
  52736. /**
  52737. * Disposes of the gizmo
  52738. */
  52739. dispose(): void;
  52740. }
  52741. }
  52742. declare module "babylonjs/Debug/axesViewer" {
  52743. import { Vector3 } from "babylonjs/Maths/math.vector";
  52744. import { Nullable } from "babylonjs/types";
  52745. import { Scene } from "babylonjs/scene";
  52746. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52747. /**
  52748. * The Axes viewer will show 3 axes in a specific point in space
  52749. */
  52750. export class AxesViewer {
  52751. private _xAxis;
  52752. private _yAxis;
  52753. private _zAxis;
  52754. private _scaleLinesFactor;
  52755. private _instanced;
  52756. /**
  52757. * Gets the hosting scene
  52758. */
  52759. scene: Nullable<Scene>;
  52760. /**
  52761. * Gets or sets a number used to scale line length
  52762. */
  52763. scaleLines: number;
  52764. /** Gets the node hierarchy used to render x-axis */
  52765. get xAxis(): TransformNode;
  52766. /** Gets the node hierarchy used to render y-axis */
  52767. get yAxis(): TransformNode;
  52768. /** Gets the node hierarchy used to render z-axis */
  52769. get zAxis(): TransformNode;
  52770. /**
  52771. * Creates a new AxesViewer
  52772. * @param scene defines the hosting scene
  52773. * @param scaleLines defines a number used to scale line length (1 by default)
  52774. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52775. * @param xAxis defines the node hierarchy used to render the x-axis
  52776. * @param yAxis defines the node hierarchy used to render the y-axis
  52777. * @param zAxis defines the node hierarchy used to render the z-axis
  52778. */
  52779. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52780. /**
  52781. * Force the viewer to update
  52782. * @param position defines the position of the viewer
  52783. * @param xaxis defines the x axis of the viewer
  52784. * @param yaxis defines the y axis of the viewer
  52785. * @param zaxis defines the z axis of the viewer
  52786. */
  52787. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52788. /**
  52789. * Creates an instance of this axes viewer.
  52790. * @returns a new axes viewer with instanced meshes
  52791. */
  52792. createInstance(): AxesViewer;
  52793. /** Releases resources */
  52794. dispose(): void;
  52795. private static _SetRenderingGroupId;
  52796. }
  52797. }
  52798. declare module "babylonjs/Debug/boneAxesViewer" {
  52799. import { Nullable } from "babylonjs/types";
  52800. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52801. import { Vector3 } from "babylonjs/Maths/math.vector";
  52802. import { Mesh } from "babylonjs/Meshes/mesh";
  52803. import { Bone } from "babylonjs/Bones/bone";
  52804. import { Scene } from "babylonjs/scene";
  52805. /**
  52806. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52807. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52808. */
  52809. export class BoneAxesViewer extends AxesViewer {
  52810. /**
  52811. * Gets or sets the target mesh where to display the axes viewer
  52812. */
  52813. mesh: Nullable<Mesh>;
  52814. /**
  52815. * Gets or sets the target bone where to display the axes viewer
  52816. */
  52817. bone: Nullable<Bone>;
  52818. /** Gets current position */
  52819. pos: Vector3;
  52820. /** Gets direction of X axis */
  52821. xaxis: Vector3;
  52822. /** Gets direction of Y axis */
  52823. yaxis: Vector3;
  52824. /** Gets direction of Z axis */
  52825. zaxis: Vector3;
  52826. /**
  52827. * Creates a new BoneAxesViewer
  52828. * @param scene defines the hosting scene
  52829. * @param bone defines the target bone
  52830. * @param mesh defines the target mesh
  52831. * @param scaleLines defines a scaling factor for line length (1 by default)
  52832. */
  52833. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52834. /**
  52835. * Force the viewer to update
  52836. */
  52837. update(): void;
  52838. /** Releases resources */
  52839. dispose(): void;
  52840. }
  52841. }
  52842. declare module "babylonjs/Debug/debugLayer" {
  52843. import { Scene } from "babylonjs/scene";
  52844. /**
  52845. * Interface used to define scene explorer extensibility option
  52846. */
  52847. export interface IExplorerExtensibilityOption {
  52848. /**
  52849. * Define the option label
  52850. */
  52851. label: string;
  52852. /**
  52853. * Defines the action to execute on click
  52854. */
  52855. action: (entity: any) => void;
  52856. }
  52857. /**
  52858. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52859. */
  52860. export interface IExplorerExtensibilityGroup {
  52861. /**
  52862. * Defines a predicate to test if a given type mut be extended
  52863. */
  52864. predicate: (entity: any) => boolean;
  52865. /**
  52866. * Gets the list of options added to a type
  52867. */
  52868. entries: IExplorerExtensibilityOption[];
  52869. }
  52870. /**
  52871. * Interface used to define the options to use to create the Inspector
  52872. */
  52873. export interface IInspectorOptions {
  52874. /**
  52875. * Display in overlay mode (default: false)
  52876. */
  52877. overlay?: boolean;
  52878. /**
  52879. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52880. */
  52881. globalRoot?: HTMLElement;
  52882. /**
  52883. * Display the Scene explorer
  52884. */
  52885. showExplorer?: boolean;
  52886. /**
  52887. * Display the property inspector
  52888. */
  52889. showInspector?: boolean;
  52890. /**
  52891. * Display in embed mode (both panes on the right)
  52892. */
  52893. embedMode?: boolean;
  52894. /**
  52895. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52896. */
  52897. handleResize?: boolean;
  52898. /**
  52899. * Allow the panes to popup (default: true)
  52900. */
  52901. enablePopup?: boolean;
  52902. /**
  52903. * Allow the panes to be closed by users (default: true)
  52904. */
  52905. enableClose?: boolean;
  52906. /**
  52907. * Optional list of extensibility entries
  52908. */
  52909. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52910. /**
  52911. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52912. */
  52913. inspectorURL?: string;
  52914. /**
  52915. * Optional initial tab (default to DebugLayerTab.Properties)
  52916. */
  52917. initialTab?: DebugLayerTab;
  52918. }
  52919. module "babylonjs/scene" {
  52920. interface Scene {
  52921. /**
  52922. * @hidden
  52923. * Backing field
  52924. */
  52925. _debugLayer: DebugLayer;
  52926. /**
  52927. * Gets the debug layer (aka Inspector) associated with the scene
  52928. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52929. */
  52930. debugLayer: DebugLayer;
  52931. }
  52932. }
  52933. /**
  52934. * Enum of inspector action tab
  52935. */
  52936. export enum DebugLayerTab {
  52937. /**
  52938. * Properties tag (default)
  52939. */
  52940. Properties = 0,
  52941. /**
  52942. * Debug tab
  52943. */
  52944. Debug = 1,
  52945. /**
  52946. * Statistics tab
  52947. */
  52948. Statistics = 2,
  52949. /**
  52950. * Tools tab
  52951. */
  52952. Tools = 3,
  52953. /**
  52954. * Settings tab
  52955. */
  52956. Settings = 4
  52957. }
  52958. /**
  52959. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52960. * what is happening in your scene
  52961. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52962. */
  52963. export class DebugLayer {
  52964. /**
  52965. * Define the url to get the inspector script from.
  52966. * By default it uses the babylonjs CDN.
  52967. * @ignoreNaming
  52968. */
  52969. static InspectorURL: string;
  52970. private _scene;
  52971. private BJSINSPECTOR;
  52972. private _onPropertyChangedObservable?;
  52973. /**
  52974. * Observable triggered when a property is changed through the inspector.
  52975. */
  52976. get onPropertyChangedObservable(): any;
  52977. /**
  52978. * Instantiates a new debug layer.
  52979. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52980. * what is happening in your scene
  52981. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52982. * @param scene Defines the scene to inspect
  52983. */
  52984. constructor(scene: Scene);
  52985. /** Creates the inspector window. */
  52986. private _createInspector;
  52987. /**
  52988. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52989. * @param entity defines the entity to select
  52990. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52991. */
  52992. select(entity: any, lineContainerTitles?: string | string[]): void;
  52993. /** Get the inspector from bundle or global */
  52994. private _getGlobalInspector;
  52995. /**
  52996. * Get if the inspector is visible or not.
  52997. * @returns true if visible otherwise, false
  52998. */
  52999. isVisible(): boolean;
  53000. /**
  53001. * Hide the inspector and close its window.
  53002. */
  53003. hide(): void;
  53004. /**
  53005. * Update the scene in the inspector
  53006. */
  53007. setAsActiveScene(): void;
  53008. /**
  53009. * Launch the debugLayer.
  53010. * @param config Define the configuration of the inspector
  53011. * @return a promise fulfilled when the debug layer is visible
  53012. */
  53013. show(config?: IInspectorOptions): Promise<DebugLayer>;
  53014. }
  53015. }
  53016. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  53017. import { Nullable } from "babylonjs/types";
  53018. import { Scene } from "babylonjs/scene";
  53019. import { Vector4 } from "babylonjs/Maths/math.vector";
  53020. import { Color4 } from "babylonjs/Maths/math.color";
  53021. import { Mesh } from "babylonjs/Meshes/mesh";
  53022. /**
  53023. * Class containing static functions to help procedurally build meshes
  53024. */
  53025. export class BoxBuilder {
  53026. /**
  53027. * Creates a box mesh
  53028. * * The parameter `size` sets the size (float) of each box side (default 1)
  53029. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53030. * * 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)
  53031. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53033. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53035. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53036. * @param name defines the name of the mesh
  53037. * @param options defines the options used to create the mesh
  53038. * @param scene defines the hosting scene
  53039. * @returns the box mesh
  53040. */
  53041. static CreateBox(name: string, options: {
  53042. size?: number;
  53043. width?: number;
  53044. height?: number;
  53045. depth?: number;
  53046. faceUV?: Vector4[];
  53047. faceColors?: Color4[];
  53048. sideOrientation?: number;
  53049. frontUVs?: Vector4;
  53050. backUVs?: Vector4;
  53051. wrap?: boolean;
  53052. topBaseAt?: number;
  53053. bottomBaseAt?: number;
  53054. updatable?: boolean;
  53055. }, scene?: Nullable<Scene>): Mesh;
  53056. }
  53057. }
  53058. declare module "babylonjs/Debug/physicsViewer" {
  53059. import { Nullable } from "babylonjs/types";
  53060. import { Scene } from "babylonjs/scene";
  53061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53062. import { Mesh } from "babylonjs/Meshes/mesh";
  53063. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53064. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53065. /**
  53066. * Used to show the physics impostor around the specific mesh
  53067. */
  53068. export class PhysicsViewer {
  53069. /** @hidden */
  53070. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  53071. /** @hidden */
  53072. protected _meshes: Array<Nullable<AbstractMesh>>;
  53073. /** @hidden */
  53074. protected _scene: Nullable<Scene>;
  53075. /** @hidden */
  53076. protected _numMeshes: number;
  53077. /** @hidden */
  53078. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  53079. private _renderFunction;
  53080. private _utilityLayer;
  53081. private _debugBoxMesh;
  53082. private _debugSphereMesh;
  53083. private _debugCylinderMesh;
  53084. private _debugMaterial;
  53085. private _debugMeshMeshes;
  53086. /**
  53087. * Creates a new PhysicsViewer
  53088. * @param scene defines the hosting scene
  53089. */
  53090. constructor(scene: Scene);
  53091. /** @hidden */
  53092. protected _updateDebugMeshes(): void;
  53093. /**
  53094. * Renders a specified physic impostor
  53095. * @param impostor defines the impostor to render
  53096. * @param targetMesh defines the mesh represented by the impostor
  53097. * @returns the new debug mesh used to render the impostor
  53098. */
  53099. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  53100. /**
  53101. * Hides a specified physic impostor
  53102. * @param impostor defines the impostor to hide
  53103. */
  53104. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  53105. private _getDebugMaterial;
  53106. private _getDebugBoxMesh;
  53107. private _getDebugSphereMesh;
  53108. private _getDebugCylinderMesh;
  53109. private _getDebugMeshMesh;
  53110. private _getDebugMesh;
  53111. /** Releases all resources */
  53112. dispose(): void;
  53113. }
  53114. }
  53115. declare module "babylonjs/Debug/rayHelper" {
  53116. import { Nullable } from "babylonjs/types";
  53117. import { Ray } from "babylonjs/Culling/ray";
  53118. import { Vector3 } from "babylonjs/Maths/math.vector";
  53119. import { Color3 } from "babylonjs/Maths/math.color";
  53120. import { Scene } from "babylonjs/scene";
  53121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53122. import "babylonjs/Meshes/Builders/linesBuilder";
  53123. /**
  53124. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53125. * in order to better appreciate the issue one might have.
  53126. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53127. */
  53128. export class RayHelper {
  53129. /**
  53130. * Defines the ray we are currently tryin to visualize.
  53131. */
  53132. ray: Nullable<Ray>;
  53133. private _renderPoints;
  53134. private _renderLine;
  53135. private _renderFunction;
  53136. private _scene;
  53137. private _onAfterRenderObserver;
  53138. private _onAfterStepObserver;
  53139. private _attachedToMesh;
  53140. private _meshSpaceDirection;
  53141. private _meshSpaceOrigin;
  53142. /**
  53143. * Helper function to create a colored helper in a scene in one line.
  53144. * @param ray Defines the ray we are currently tryin to visualize
  53145. * @param scene Defines the scene the ray is used in
  53146. * @param color Defines the color we want to see the ray in
  53147. * @returns The newly created ray helper.
  53148. */
  53149. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  53150. /**
  53151. * Instantiate a new ray helper.
  53152. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53153. * in order to better appreciate the issue one might have.
  53154. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53155. * @param ray Defines the ray we are currently tryin to visualize
  53156. */
  53157. constructor(ray: Ray);
  53158. /**
  53159. * Shows the ray we are willing to debug.
  53160. * @param scene Defines the scene the ray needs to be rendered in
  53161. * @param color Defines the color the ray needs to be rendered in
  53162. */
  53163. show(scene: Scene, color?: Color3): void;
  53164. /**
  53165. * Hides the ray we are debugging.
  53166. */
  53167. hide(): void;
  53168. private _render;
  53169. /**
  53170. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  53171. * @param mesh Defines the mesh we want the helper attached to
  53172. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  53173. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  53174. * @param length Defines the length of the ray
  53175. */
  53176. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  53177. /**
  53178. * Detach the ray helper from the mesh it has previously been attached to.
  53179. */
  53180. detachFromMesh(): void;
  53181. private _updateToMesh;
  53182. /**
  53183. * Dispose the helper and release its associated resources.
  53184. */
  53185. dispose(): void;
  53186. }
  53187. }
  53188. declare module "babylonjs/Debug/ISkeletonViewer" {
  53189. import { Skeleton } from "babylonjs/Bones/skeleton";
  53190. import { Color3 } from "babylonjs/Maths/math.color";
  53191. /**
  53192. * Defines the options associated with the creation of a SkeletonViewer.
  53193. */
  53194. export interface ISkeletonViewerOptions {
  53195. /** Should the system pause animations before building the Viewer? */
  53196. pauseAnimations: boolean;
  53197. /** Should the system return the skeleton to rest before building? */
  53198. returnToRest: boolean;
  53199. /** public Display Mode of the Viewer */
  53200. displayMode: number;
  53201. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53202. displayOptions: ISkeletonViewerDisplayOptions;
  53203. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53204. computeBonesUsingShaders: boolean;
  53205. /** Flag ignore non weighted bones */
  53206. useAllBones: boolean;
  53207. }
  53208. /**
  53209. * Defines how to display the various bone meshes for the viewer.
  53210. */
  53211. export interface ISkeletonViewerDisplayOptions {
  53212. /** How far down to start tapering the bone spurs */
  53213. midStep?: number;
  53214. /** How big is the midStep? */
  53215. midStepFactor?: number;
  53216. /** Base for the Sphere Size */
  53217. sphereBaseSize?: number;
  53218. /** The ratio of the sphere to the longest bone in units */
  53219. sphereScaleUnit?: number;
  53220. /** Ratio for the Sphere Size */
  53221. sphereFactor?: number;
  53222. /** Whether a spur should attach its far end to the child bone position */
  53223. spurFollowsChild?: boolean;
  53224. /** Whether to show local axes or not */
  53225. showLocalAxes?: boolean;
  53226. /** Length of each local axis */
  53227. localAxesSize?: number;
  53228. }
  53229. /**
  53230. * Defines the constructor options for the BoneWeight Shader.
  53231. */
  53232. export interface IBoneWeightShaderOptions {
  53233. /** Skeleton to Map */
  53234. skeleton: Skeleton;
  53235. /** Colors for Uninfluenced bones */
  53236. colorBase?: Color3;
  53237. /** Colors for 0.0-0.25 Weight bones */
  53238. colorZero?: Color3;
  53239. /** Color for 0.25-0.5 Weight Influence */
  53240. colorQuarter?: Color3;
  53241. /** Color for 0.5-0.75 Weight Influence */
  53242. colorHalf?: Color3;
  53243. /** Color for 0.75-1 Weight Influence */
  53244. colorFull?: Color3;
  53245. /** Color for Zero Weight Influence */
  53246. targetBoneIndex?: number;
  53247. }
  53248. /**
  53249. * Simple structure of the gradient steps for the Color Map.
  53250. */
  53251. export interface ISkeletonMapShaderColorMapKnot {
  53252. /** Color of the Knot */
  53253. color: Color3;
  53254. /** Location of the Knot */
  53255. location: number;
  53256. }
  53257. /**
  53258. * Defines the constructor options for the SkeletonMap Shader.
  53259. */
  53260. export interface ISkeletonMapShaderOptions {
  53261. /** Skeleton to Map */
  53262. skeleton: Skeleton;
  53263. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  53264. colorMap?: ISkeletonMapShaderColorMapKnot[];
  53265. }
  53266. }
  53267. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53268. import { Nullable } from "babylonjs/types";
  53269. import { Scene } from "babylonjs/scene";
  53270. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53271. import { Color4 } from "babylonjs/Maths/math.color";
  53272. import { Mesh } from "babylonjs/Meshes/mesh";
  53273. /**
  53274. * Class containing static functions to help procedurally build meshes
  53275. */
  53276. export class RibbonBuilder {
  53277. /**
  53278. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53279. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53280. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53281. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53282. * * 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
  53283. * * 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
  53284. * * 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
  53285. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53286. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53287. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53288. * * 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
  53289. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53290. * * 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
  53291. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53293. * @param name defines the name of the mesh
  53294. * @param options defines the options used to create the mesh
  53295. * @param scene defines the hosting scene
  53296. * @returns the ribbon mesh
  53297. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53298. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53299. */
  53300. static CreateRibbon(name: string, options: {
  53301. pathArray: Vector3[][];
  53302. closeArray?: boolean;
  53303. closePath?: boolean;
  53304. offset?: number;
  53305. updatable?: boolean;
  53306. sideOrientation?: number;
  53307. frontUVs?: Vector4;
  53308. backUVs?: Vector4;
  53309. instance?: Mesh;
  53310. invertUV?: boolean;
  53311. uvs?: Vector2[];
  53312. colors?: Color4[];
  53313. }, scene?: Nullable<Scene>): Mesh;
  53314. }
  53315. }
  53316. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53317. import { Nullable } from "babylonjs/types";
  53318. import { Scene } from "babylonjs/scene";
  53319. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53320. import { Mesh } from "babylonjs/Meshes/mesh";
  53321. /**
  53322. * Class containing static functions to help procedurally build meshes
  53323. */
  53324. export class ShapeBuilder {
  53325. /**
  53326. * 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.
  53327. * * 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.
  53328. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53329. * * 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.
  53330. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53331. * * 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
  53332. * * 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
  53333. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53335. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53336. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53338. * @param name defines the name of the mesh
  53339. * @param options defines the options used to create the mesh
  53340. * @param scene defines the hosting scene
  53341. * @returns the extruded shape mesh
  53342. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53343. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53344. */
  53345. static ExtrudeShape(name: string, options: {
  53346. shape: Vector3[];
  53347. path: Vector3[];
  53348. scale?: number;
  53349. rotation?: number;
  53350. cap?: number;
  53351. updatable?: boolean;
  53352. sideOrientation?: number;
  53353. frontUVs?: Vector4;
  53354. backUVs?: Vector4;
  53355. instance?: Mesh;
  53356. invertUV?: boolean;
  53357. }, scene?: Nullable<Scene>): Mesh;
  53358. /**
  53359. * Creates an custom extruded shape mesh.
  53360. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53361. * * 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.
  53362. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53363. * * 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
  53364. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53365. * * 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
  53366. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53367. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53368. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53369. * * 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
  53370. * * 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
  53371. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53373. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53374. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53376. * @param name defines the name of the mesh
  53377. * @param options defines the options used to create the mesh
  53378. * @param scene defines the hosting scene
  53379. * @returns the custom extruded shape mesh
  53380. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53381. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53382. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53383. */
  53384. static ExtrudeShapeCustom(name: string, options: {
  53385. shape: Vector3[];
  53386. path: Vector3[];
  53387. scaleFunction?: any;
  53388. rotationFunction?: any;
  53389. ribbonCloseArray?: boolean;
  53390. ribbonClosePath?: boolean;
  53391. cap?: number;
  53392. updatable?: boolean;
  53393. sideOrientation?: number;
  53394. frontUVs?: Vector4;
  53395. backUVs?: Vector4;
  53396. instance?: Mesh;
  53397. invertUV?: boolean;
  53398. }, scene?: Nullable<Scene>): Mesh;
  53399. private static _ExtrudeShapeGeneric;
  53400. }
  53401. }
  53402. declare module "babylonjs/Debug/skeletonViewer" {
  53403. import { Color3 } from "babylonjs/Maths/math.color";
  53404. import { Scene } from "babylonjs/scene";
  53405. import { Nullable } from "babylonjs/types";
  53406. import { Skeleton } from "babylonjs/Bones/skeleton";
  53407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53408. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53409. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53410. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  53411. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  53412. /**
  53413. * Class used to render a debug view of a given skeleton
  53414. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53415. */
  53416. export class SkeletonViewer {
  53417. /** defines the skeleton to render */
  53418. skeleton: Skeleton;
  53419. /** defines the mesh attached to the skeleton */
  53420. mesh: AbstractMesh;
  53421. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53422. autoUpdateBonesMatrices: boolean;
  53423. /** defines the rendering group id to use with the viewer */
  53424. renderingGroupId: number;
  53425. /** is the options for the viewer */
  53426. options: Partial<ISkeletonViewerOptions>;
  53427. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53428. static readonly DISPLAY_LINES: number;
  53429. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53430. static readonly DISPLAY_SPHERES: number;
  53431. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53432. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53433. /** public static method to create a BoneWeight Shader
  53434. * @param options The constructor options
  53435. * @param scene The scene that the shader is scoped to
  53436. * @returns The created ShaderMaterial
  53437. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  53438. */
  53439. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  53440. /** public static method to create a BoneWeight Shader
  53441. * @param options The constructor options
  53442. * @param scene The scene that the shader is scoped to
  53443. * @returns The created ShaderMaterial
  53444. */
  53445. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  53446. /** private static method to create a BoneWeight Shader
  53447. * @param size The size of the buffer to create (usually the bone count)
  53448. * @param colorMap The gradient data to generate
  53449. * @param scene The scene that the shader is scoped to
  53450. * @returns an Array of floats from the color gradient values
  53451. */
  53452. private static _CreateBoneMapColorBuffer;
  53453. /** If SkeletonViewer scene scope. */
  53454. private _scene;
  53455. /** Gets or sets the color used to render the skeleton */
  53456. color: Color3;
  53457. /** Array of the points of the skeleton fo the line view. */
  53458. private _debugLines;
  53459. /** The SkeletonViewers Mesh. */
  53460. private _debugMesh;
  53461. /** The local axes Meshes. */
  53462. private _localAxes;
  53463. /** If SkeletonViewer is enabled. */
  53464. private _isEnabled;
  53465. /** If SkeletonViewer is ready. */
  53466. private _ready;
  53467. /** SkeletonViewer render observable. */
  53468. private _obs;
  53469. /** The Utility Layer to render the gizmos in. */
  53470. private _utilityLayer;
  53471. private _boneIndices;
  53472. /** Gets the Scene. */
  53473. get scene(): Scene;
  53474. /** Gets the utilityLayer. */
  53475. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53476. /** Checks Ready Status. */
  53477. get isReady(): Boolean;
  53478. /** Sets Ready Status. */
  53479. set ready(value: boolean);
  53480. /** Gets the debugMesh */
  53481. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53482. /** Sets the debugMesh */
  53483. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53484. /** Gets the displayMode */
  53485. get displayMode(): number;
  53486. /** Sets the displayMode */
  53487. set displayMode(value: number);
  53488. /**
  53489. * Creates a new SkeletonViewer
  53490. * @param skeleton defines the skeleton to render
  53491. * @param mesh defines the mesh attached to the skeleton
  53492. * @param scene defines the hosting scene
  53493. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53494. * @param renderingGroupId defines the rendering group id to use with the viewer
  53495. * @param options All of the extra constructor options for the SkeletonViewer
  53496. */
  53497. constructor(
  53498. /** defines the skeleton to render */
  53499. skeleton: Skeleton,
  53500. /** defines the mesh attached to the skeleton */
  53501. mesh: AbstractMesh,
  53502. /** The Scene scope*/
  53503. scene: Scene,
  53504. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53505. autoUpdateBonesMatrices?: boolean,
  53506. /** defines the rendering group id to use with the viewer */
  53507. renderingGroupId?: number,
  53508. /** is the options for the viewer */
  53509. options?: Partial<ISkeletonViewerOptions>);
  53510. /** The Dynamic bindings for the update functions */
  53511. private _bindObs;
  53512. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53513. update(): void;
  53514. /** Gets or sets a boolean indicating if the viewer is enabled */
  53515. set isEnabled(value: boolean);
  53516. get isEnabled(): boolean;
  53517. private _getBonePosition;
  53518. private _getLinesForBonesWithLength;
  53519. private _getLinesForBonesNoLength;
  53520. /** function to revert the mesh and scene back to the initial state. */
  53521. private _revert;
  53522. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  53523. private _getAbsoluteBindPoseToRef;
  53524. /** function to build and bind sphere joint points and spur bone representations. */
  53525. private _buildSpheresAndSpurs;
  53526. private _buildLocalAxes;
  53527. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53528. private _displayLinesUpdate;
  53529. /** Changes the displayMode of the skeleton viewer
  53530. * @param mode The displayMode numerical value
  53531. */
  53532. changeDisplayMode(mode: number): void;
  53533. /** Sets a display option of the skeleton viewer
  53534. *
  53535. * | Option | Type | Default | Description |
  53536. * | ---------------- | ------- | ------- | ----------- |
  53537. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53538. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53539. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53540. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53541. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  53542. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  53543. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  53544. *
  53545. * @param option String of the option name
  53546. * @param value The numerical option value
  53547. */
  53548. changeDisplayOptions(option: string, value: number): void;
  53549. /** Release associated resources */
  53550. dispose(): void;
  53551. }
  53552. }
  53553. declare module "babylonjs/Debug/index" {
  53554. export * from "babylonjs/Debug/axesViewer";
  53555. export * from "babylonjs/Debug/boneAxesViewer";
  53556. export * from "babylonjs/Debug/debugLayer";
  53557. export * from "babylonjs/Debug/physicsViewer";
  53558. export * from "babylonjs/Debug/rayHelper";
  53559. export * from "babylonjs/Debug/skeletonViewer";
  53560. export * from "babylonjs/Debug/ISkeletonViewer";
  53561. }
  53562. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53563. /**
  53564. * Enum for Device Types
  53565. */
  53566. export enum DeviceType {
  53567. /** Generic */
  53568. Generic = 0,
  53569. /** Keyboard */
  53570. Keyboard = 1,
  53571. /** Mouse */
  53572. Mouse = 2,
  53573. /** Touch Pointers */
  53574. Touch = 3,
  53575. /** PS4 Dual Shock */
  53576. DualShock = 4,
  53577. /** Xbox */
  53578. Xbox = 5,
  53579. /** Switch Controller */
  53580. Switch = 6
  53581. }
  53582. /**
  53583. * Enum for All Pointers (Touch/Mouse)
  53584. */
  53585. export enum PointerInput {
  53586. /** Horizontal Axis */
  53587. Horizontal = 0,
  53588. /** Vertical Axis */
  53589. Vertical = 1,
  53590. /** Left Click or Touch */
  53591. LeftClick = 2,
  53592. /** Middle Click */
  53593. MiddleClick = 3,
  53594. /** Right Click */
  53595. RightClick = 4,
  53596. /** Browser Back */
  53597. BrowserBack = 5,
  53598. /** Browser Forward */
  53599. BrowserForward = 6
  53600. }
  53601. /**
  53602. * Enum for Dual Shock Gamepad
  53603. */
  53604. export enum DualShockInput {
  53605. /** Cross */
  53606. Cross = 0,
  53607. /** Circle */
  53608. Circle = 1,
  53609. /** Square */
  53610. Square = 2,
  53611. /** Triangle */
  53612. Triangle = 3,
  53613. /** L1 */
  53614. L1 = 4,
  53615. /** R1 */
  53616. R1 = 5,
  53617. /** L2 */
  53618. L2 = 6,
  53619. /** R2 */
  53620. R2 = 7,
  53621. /** Share */
  53622. Share = 8,
  53623. /** Options */
  53624. Options = 9,
  53625. /** L3 */
  53626. L3 = 10,
  53627. /** R3 */
  53628. R3 = 11,
  53629. /** DPadUp */
  53630. DPadUp = 12,
  53631. /** DPadDown */
  53632. DPadDown = 13,
  53633. /** DPadLeft */
  53634. DPadLeft = 14,
  53635. /** DRight */
  53636. DPadRight = 15,
  53637. /** Home */
  53638. Home = 16,
  53639. /** TouchPad */
  53640. TouchPad = 17,
  53641. /** LStickXAxis */
  53642. LStickXAxis = 18,
  53643. /** LStickYAxis */
  53644. LStickYAxis = 19,
  53645. /** RStickXAxis */
  53646. RStickXAxis = 20,
  53647. /** RStickYAxis */
  53648. RStickYAxis = 21
  53649. }
  53650. /**
  53651. * Enum for Xbox Gamepad
  53652. */
  53653. export enum XboxInput {
  53654. /** A */
  53655. A = 0,
  53656. /** B */
  53657. B = 1,
  53658. /** X */
  53659. X = 2,
  53660. /** Y */
  53661. Y = 3,
  53662. /** LB */
  53663. LB = 4,
  53664. /** RB */
  53665. RB = 5,
  53666. /** LT */
  53667. LT = 6,
  53668. /** RT */
  53669. RT = 7,
  53670. /** Back */
  53671. Back = 8,
  53672. /** Start */
  53673. Start = 9,
  53674. /** LS */
  53675. LS = 10,
  53676. /** RS */
  53677. RS = 11,
  53678. /** DPadUp */
  53679. DPadUp = 12,
  53680. /** DPadDown */
  53681. DPadDown = 13,
  53682. /** DPadLeft */
  53683. DPadLeft = 14,
  53684. /** DRight */
  53685. DPadRight = 15,
  53686. /** Home */
  53687. Home = 16,
  53688. /** LStickXAxis */
  53689. LStickXAxis = 17,
  53690. /** LStickYAxis */
  53691. LStickYAxis = 18,
  53692. /** RStickXAxis */
  53693. RStickXAxis = 19,
  53694. /** RStickYAxis */
  53695. RStickYAxis = 20
  53696. }
  53697. /**
  53698. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53699. */
  53700. export enum SwitchInput {
  53701. /** B */
  53702. B = 0,
  53703. /** A */
  53704. A = 1,
  53705. /** Y */
  53706. Y = 2,
  53707. /** X */
  53708. X = 3,
  53709. /** L */
  53710. L = 4,
  53711. /** R */
  53712. R = 5,
  53713. /** ZL */
  53714. ZL = 6,
  53715. /** ZR */
  53716. ZR = 7,
  53717. /** Minus */
  53718. Minus = 8,
  53719. /** Plus */
  53720. Plus = 9,
  53721. /** LS */
  53722. LS = 10,
  53723. /** RS */
  53724. RS = 11,
  53725. /** DPadUp */
  53726. DPadUp = 12,
  53727. /** DPadDown */
  53728. DPadDown = 13,
  53729. /** DPadLeft */
  53730. DPadLeft = 14,
  53731. /** DRight */
  53732. DPadRight = 15,
  53733. /** Home */
  53734. Home = 16,
  53735. /** Capture */
  53736. Capture = 17,
  53737. /** LStickXAxis */
  53738. LStickXAxis = 18,
  53739. /** LStickYAxis */
  53740. LStickYAxis = 19,
  53741. /** RStickXAxis */
  53742. RStickXAxis = 20,
  53743. /** RStickYAxis */
  53744. RStickYAxis = 21
  53745. }
  53746. }
  53747. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53748. import { Engine } from "babylonjs/Engines/engine";
  53749. import { IDisposable } from "babylonjs/scene";
  53750. import { Nullable } from "babylonjs/types";
  53751. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53752. /**
  53753. * This class will take all inputs from Keyboard, Pointer, and
  53754. * any Gamepads and provide a polling system that all devices
  53755. * will use. This class assumes that there will only be one
  53756. * pointer device and one keyboard.
  53757. */
  53758. export class DeviceInputSystem implements IDisposable {
  53759. /**
  53760. * Callback to be triggered when a device is connected
  53761. */
  53762. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53763. /**
  53764. * Callback to be triggered when a device is disconnected
  53765. */
  53766. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53767. /**
  53768. * Callback to be triggered when event driven input is updated
  53769. */
  53770. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53771. private _inputs;
  53772. private _gamepads;
  53773. private _keyboardActive;
  53774. private _pointerActive;
  53775. private _elementToAttachTo;
  53776. private _keyboardDownEvent;
  53777. private _keyboardUpEvent;
  53778. private _pointerMoveEvent;
  53779. private _pointerDownEvent;
  53780. private _pointerUpEvent;
  53781. private _gamepadConnectedEvent;
  53782. private _gamepadDisconnectedEvent;
  53783. private static _MAX_KEYCODES;
  53784. private static _MAX_POINTER_INPUTS;
  53785. private constructor();
  53786. /**
  53787. * Creates a new DeviceInputSystem instance
  53788. * @param engine Engine to pull input element from
  53789. * @returns The new instance
  53790. */
  53791. static Create(engine: Engine): DeviceInputSystem;
  53792. /**
  53793. * Checks for current device input value, given an id and input index
  53794. * @param deviceName Id of connected device
  53795. * @param inputIndex Index of device input
  53796. * @returns Current value of input
  53797. */
  53798. /**
  53799. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  53800. * @param deviceType Enum specifiying device type
  53801. * @param deviceSlot "Slot" or index that device is referenced in
  53802. * @param inputIndex Id of input to be checked
  53803. * @returns Current value of input
  53804. */
  53805. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  53806. /**
  53807. * Dispose of all the eventlisteners
  53808. */
  53809. dispose(): void;
  53810. /**
  53811. * Add device and inputs to device array
  53812. * @param deviceType Enum specifiying device type
  53813. * @param deviceSlot "Slot" or index that device is referenced in
  53814. * @param numberOfInputs Number of input entries to create for given device
  53815. */
  53816. private _registerDevice;
  53817. /**
  53818. * Given a specific device name, remove that device from the device map
  53819. * @param deviceType Enum specifiying device type
  53820. * @param deviceSlot "Slot" or index that device is referenced in
  53821. */
  53822. private _unregisterDevice;
  53823. /**
  53824. * Handle all actions that come from keyboard interaction
  53825. */
  53826. private _handleKeyActions;
  53827. /**
  53828. * Handle all actions that come from pointer interaction
  53829. */
  53830. private _handlePointerActions;
  53831. /**
  53832. * Handle all actions that come from gamepad interaction
  53833. */
  53834. private _handleGamepadActions;
  53835. /**
  53836. * Update all non-event based devices with each frame
  53837. * @param deviceType Enum specifiying device type
  53838. * @param deviceSlot "Slot" or index that device is referenced in
  53839. * @param inputIndex Id of input to be checked
  53840. */
  53841. private _updateDevice;
  53842. /**
  53843. * Gets DeviceType from the device name
  53844. * @param deviceName Name of Device from DeviceInputSystem
  53845. * @returns DeviceType enum value
  53846. */
  53847. private _getGamepadDeviceType;
  53848. }
  53849. }
  53850. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53851. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53852. /**
  53853. * Type to handle enforcement of inputs
  53854. */
  53855. 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;
  53856. }
  53857. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53858. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53859. import { Engine } from "babylonjs/Engines/engine";
  53860. import { IDisposable } from "babylonjs/scene";
  53861. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53862. import { Nullable } from "babylonjs/types";
  53863. import { Observable } from "babylonjs/Misc/observable";
  53864. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53865. /**
  53866. * Class that handles all input for a specific device
  53867. */
  53868. export class DeviceSource<T extends DeviceType> {
  53869. /** Type of device */
  53870. readonly deviceType: DeviceType;
  53871. /** "Slot" or index that device is referenced in */
  53872. readonly deviceSlot: number;
  53873. /**
  53874. * Observable to handle device input changes per device
  53875. */
  53876. readonly onInputChangedObservable: Observable<{
  53877. inputIndex: DeviceInput<T>;
  53878. previousState: Nullable<number>;
  53879. currentState: Nullable<number>;
  53880. }>;
  53881. private readonly _deviceInputSystem;
  53882. /**
  53883. * Default Constructor
  53884. * @param deviceInputSystem Reference to DeviceInputSystem
  53885. * @param deviceType Type of device
  53886. * @param deviceSlot "Slot" or index that device is referenced in
  53887. */
  53888. constructor(deviceInputSystem: DeviceInputSystem,
  53889. /** Type of device */
  53890. deviceType: DeviceType,
  53891. /** "Slot" or index that device is referenced in */
  53892. deviceSlot?: number);
  53893. /**
  53894. * Get input for specific input
  53895. * @param inputIndex index of specific input on device
  53896. * @returns Input value from DeviceInputSystem
  53897. */
  53898. getInput(inputIndex: DeviceInput<T>): number;
  53899. }
  53900. /**
  53901. * Class to keep track of devices
  53902. */
  53903. export class DeviceSourceManager implements IDisposable {
  53904. /**
  53905. * Observable to be triggered when before a device is connected
  53906. */
  53907. readonly onBeforeDeviceConnectedObservable: Observable<{
  53908. deviceType: DeviceType;
  53909. deviceSlot: number;
  53910. }>;
  53911. /**
  53912. * Observable to be triggered when before a device is disconnected
  53913. */
  53914. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53915. deviceType: DeviceType;
  53916. deviceSlot: number;
  53917. }>;
  53918. /**
  53919. * Observable to be triggered when after a device is connected
  53920. */
  53921. readonly onAfterDeviceConnectedObservable: Observable<{
  53922. deviceType: DeviceType;
  53923. deviceSlot: number;
  53924. }>;
  53925. /**
  53926. * Observable to be triggered when after a device is disconnected
  53927. */
  53928. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53929. deviceType: DeviceType;
  53930. deviceSlot: number;
  53931. }>;
  53932. private readonly _devices;
  53933. private readonly _firstDevice;
  53934. private readonly _deviceInputSystem;
  53935. /**
  53936. * Default Constructor
  53937. * @param engine engine to pull input element from
  53938. */
  53939. constructor(engine: Engine);
  53940. /**
  53941. * Gets a DeviceSource, given a type and slot
  53942. * @param deviceType Enum specifying device type
  53943. * @param deviceSlot "Slot" or index that device is referenced in
  53944. * @returns DeviceSource object
  53945. */
  53946. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53947. /**
  53948. * Gets an array of DeviceSource objects for a given device type
  53949. * @param deviceType Enum specifying device type
  53950. * @returns Array of DeviceSource objects
  53951. */
  53952. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53953. /**
  53954. * Dispose of DeviceInputSystem and other parts
  53955. */
  53956. dispose(): void;
  53957. /**
  53958. * Function to add device name to device list
  53959. * @param deviceType Enum specifying device type
  53960. * @param deviceSlot "Slot" or index that device is referenced in
  53961. */
  53962. private _addDevice;
  53963. /**
  53964. * Function to remove device name to device list
  53965. * @param deviceType Enum specifying device type
  53966. * @param deviceSlot "Slot" or index that device is referenced in
  53967. */
  53968. private _removeDevice;
  53969. /**
  53970. * Updates array storing first connected device of each type
  53971. * @param type Type of Device
  53972. */
  53973. private _updateFirstDevices;
  53974. }
  53975. }
  53976. declare module "babylonjs/DeviceInput/index" {
  53977. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53978. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53979. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53980. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53981. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53982. }
  53983. declare module "babylonjs/Engines/nullEngine" {
  53984. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53985. import { Engine } from "babylonjs/Engines/engine";
  53986. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53987. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53988. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53989. import { Effect } from "babylonjs/Materials/effect";
  53990. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53991. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53992. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53993. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53994. /**
  53995. * Options to create the null engine
  53996. */
  53997. export class NullEngineOptions {
  53998. /**
  53999. * Render width (Default: 512)
  54000. */
  54001. renderWidth: number;
  54002. /**
  54003. * Render height (Default: 256)
  54004. */
  54005. renderHeight: number;
  54006. /**
  54007. * Texture size (Default: 512)
  54008. */
  54009. textureSize: number;
  54010. /**
  54011. * If delta time between frames should be constant
  54012. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54013. */
  54014. deterministicLockstep: boolean;
  54015. /**
  54016. * Maximum about of steps between frames (Default: 4)
  54017. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54018. */
  54019. lockstepMaxSteps: number;
  54020. /**
  54021. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  54022. */
  54023. useHighPrecisionMatrix?: boolean;
  54024. }
  54025. /**
  54026. * The null engine class provides support for headless version of babylon.js.
  54027. * This can be used in server side scenario or for testing purposes
  54028. */
  54029. export class NullEngine extends Engine {
  54030. private _options;
  54031. /**
  54032. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  54033. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54034. * @returns true if engine is in deterministic lock step mode
  54035. */
  54036. isDeterministicLockStep(): boolean;
  54037. /**
  54038. * Gets the max steps when engine is running in deterministic lock step
  54039. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54040. * @returns the max steps
  54041. */
  54042. getLockstepMaxSteps(): number;
  54043. /**
  54044. * Gets the current hardware scaling level.
  54045. * By default the hardware scaling level is computed from the window device ratio.
  54046. * 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.
  54047. * @returns a number indicating the current hardware scaling level
  54048. */
  54049. getHardwareScalingLevel(): number;
  54050. constructor(options?: NullEngineOptions);
  54051. /**
  54052. * Creates a vertex buffer
  54053. * @param vertices the data for the vertex buffer
  54054. * @returns the new WebGL static buffer
  54055. */
  54056. createVertexBuffer(vertices: FloatArray): DataBuffer;
  54057. /**
  54058. * Creates a new index buffer
  54059. * @param indices defines the content of the index buffer
  54060. * @param updatable defines if the index buffer must be updatable
  54061. * @returns a new webGL buffer
  54062. */
  54063. createIndexBuffer(indices: IndicesArray): DataBuffer;
  54064. /**
  54065. * Clear the current render buffer or the current render target (if any is set up)
  54066. * @param color defines the color to use
  54067. * @param backBuffer defines if the back buffer must be cleared
  54068. * @param depth defines if the depth buffer must be cleared
  54069. * @param stencil defines if the stencil buffer must be cleared
  54070. */
  54071. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54072. /**
  54073. * Gets the current render width
  54074. * @param useScreen defines if screen size must be used (or the current render target if any)
  54075. * @returns a number defining the current render width
  54076. */
  54077. getRenderWidth(useScreen?: boolean): number;
  54078. /**
  54079. * Gets the current render height
  54080. * @param useScreen defines if screen size must be used (or the current render target if any)
  54081. * @returns a number defining the current render height
  54082. */
  54083. getRenderHeight(useScreen?: boolean): number;
  54084. /**
  54085. * Set the WebGL's viewport
  54086. * @param viewport defines the viewport element to be used
  54087. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  54088. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  54089. */
  54090. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  54091. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  54092. /**
  54093. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  54094. * @param pipelineContext defines the pipeline context to use
  54095. * @param uniformsNames defines the list of uniform names
  54096. * @returns an array of webGL uniform locations
  54097. */
  54098. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  54099. /**
  54100. * Gets the lsit of active attributes for a given webGL program
  54101. * @param pipelineContext defines the pipeline context to use
  54102. * @param attributesNames defines the list of attribute names to get
  54103. * @returns an array of indices indicating the offset of each attribute
  54104. */
  54105. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54106. /**
  54107. * Binds an effect to the webGL context
  54108. * @param effect defines the effect to bind
  54109. */
  54110. bindSamplers(effect: Effect): void;
  54111. /**
  54112. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  54113. * @param effect defines the effect to activate
  54114. */
  54115. enableEffect(effect: Effect): void;
  54116. /**
  54117. * Set various states to the webGL context
  54118. * @param culling defines backface culling state
  54119. * @param zOffset defines the value to apply to zOffset (0 by default)
  54120. * @param force defines if states must be applied even if cache is up to date
  54121. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  54122. */
  54123. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54124. /**
  54125. * Set the value of an uniform to an array of int32
  54126. * @param uniform defines the webGL uniform location where to store the value
  54127. * @param array defines the array of int32 to store
  54128. * @returns true if value was set
  54129. */
  54130. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54131. /**
  54132. * Set the value of an uniform to an array of int32 (stored as vec2)
  54133. * @param uniform defines the webGL uniform location where to store the value
  54134. * @param array defines the array of int32 to store
  54135. * @returns true if value was set
  54136. */
  54137. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54138. /**
  54139. * Set the value of an uniform to an array of int32 (stored as vec3)
  54140. * @param uniform defines the webGL uniform location where to store the value
  54141. * @param array defines the array of int32 to store
  54142. * @returns true if value was set
  54143. */
  54144. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54145. /**
  54146. * Set the value of an uniform to an array of int32 (stored as vec4)
  54147. * @param uniform defines the webGL uniform location where to store the value
  54148. * @param array defines the array of int32 to store
  54149. * @returns true if value was set
  54150. */
  54151. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54152. /**
  54153. * Set the value of an uniform to an array of float32
  54154. * @param uniform defines the webGL uniform location where to store the value
  54155. * @param array defines the array of float32 to store
  54156. * @returns true if value was set
  54157. */
  54158. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54159. /**
  54160. * Set the value of an uniform to an array of float32 (stored as vec2)
  54161. * @param uniform defines the webGL uniform location where to store the value
  54162. * @param array defines the array of float32 to store
  54163. * @returns true if value was set
  54164. */
  54165. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54166. /**
  54167. * Set the value of an uniform to an array of float32 (stored as vec3)
  54168. * @param uniform defines the webGL uniform location where to store the value
  54169. * @param array defines the array of float32 to store
  54170. * @returns true if value was set
  54171. */
  54172. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54173. /**
  54174. * Set the value of an uniform to an array of float32 (stored as vec4)
  54175. * @param uniform defines the webGL uniform location where to store the value
  54176. * @param array defines the array of float32 to store
  54177. * @returns true if value was set
  54178. */
  54179. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54180. /**
  54181. * Set the value of an uniform to an array of number
  54182. * @param uniform defines the webGL uniform location where to store the value
  54183. * @param array defines the array of number to store
  54184. * @returns true if value was set
  54185. */
  54186. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  54187. /**
  54188. * Set the value of an uniform to an array of number (stored as vec2)
  54189. * @param uniform defines the webGL uniform location where to store the value
  54190. * @param array defines the array of number to store
  54191. * @returns true if value was set
  54192. */
  54193. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  54194. /**
  54195. * Set the value of an uniform to an array of number (stored as vec3)
  54196. * @param uniform defines the webGL uniform location where to store the value
  54197. * @param array defines the array of number to store
  54198. * @returns true if value was set
  54199. */
  54200. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  54201. /**
  54202. * Set the value of an uniform to an array of number (stored as vec4)
  54203. * @param uniform defines the webGL uniform location where to store the value
  54204. * @param array defines the array of number to store
  54205. * @returns true if value was set
  54206. */
  54207. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  54208. /**
  54209. * Set the value of an uniform to an array of float32 (stored as matrices)
  54210. * @param uniform defines the webGL uniform location where to store the value
  54211. * @param matrices defines the array of float32 to store
  54212. * @returns true if value was set
  54213. */
  54214. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  54215. /**
  54216. * Set the value of an uniform to a matrix (3x3)
  54217. * @param uniform defines the webGL uniform location where to store the value
  54218. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  54219. * @returns true if value was set
  54220. */
  54221. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54222. /**
  54223. * Set the value of an uniform to a matrix (2x2)
  54224. * @param uniform defines the webGL uniform location where to store the value
  54225. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  54226. * @returns true if value was set
  54227. */
  54228. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54229. /**
  54230. * Set the value of an uniform to a number (float)
  54231. * @param uniform defines the webGL uniform location where to store the value
  54232. * @param value defines the float number to store
  54233. * @returns true if value was set
  54234. */
  54235. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  54236. /**
  54237. * Set the value of an uniform to a vec2
  54238. * @param uniform defines the webGL uniform location where to store the value
  54239. * @param x defines the 1st component of the value
  54240. * @param y defines the 2nd component of the value
  54241. * @returns true if value was set
  54242. */
  54243. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  54244. /**
  54245. * Set the value of an uniform to a vec3
  54246. * @param uniform defines the webGL uniform location where to store the value
  54247. * @param x defines the 1st component of the value
  54248. * @param y defines the 2nd component of the value
  54249. * @param z defines the 3rd component of the value
  54250. * @returns true if value was set
  54251. */
  54252. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  54253. /**
  54254. * Set the value of an uniform to a boolean
  54255. * @param uniform defines the webGL uniform location where to store the value
  54256. * @param bool defines the boolean to store
  54257. * @returns true if value was set
  54258. */
  54259. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  54260. /**
  54261. * Set the value of an uniform to a vec4
  54262. * @param uniform defines the webGL uniform location where to store the value
  54263. * @param x defines the 1st component of the value
  54264. * @param y defines the 2nd component of the value
  54265. * @param z defines the 3rd component of the value
  54266. * @param w defines the 4th component of the value
  54267. * @returns true if value was set
  54268. */
  54269. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  54270. /**
  54271. * Sets the current alpha mode
  54272. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  54273. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54274. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54275. */
  54276. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54277. /**
  54278. * Bind webGl buffers directly to the webGL context
  54279. * @param vertexBuffers defines the vertex buffer to bind
  54280. * @param indexBuffer defines the index buffer to bind
  54281. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  54282. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  54283. * @param effect defines the effect associated with the vertex buffer
  54284. */
  54285. bindBuffers(vertexBuffers: {
  54286. [key: string]: VertexBuffer;
  54287. }, indexBuffer: DataBuffer, effect: Effect): void;
  54288. /**
  54289. * Force the entire cache to be cleared
  54290. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  54291. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  54292. */
  54293. wipeCaches(bruteForce?: boolean): void;
  54294. /**
  54295. * Send a draw order
  54296. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  54297. * @param indexStart defines the starting index
  54298. * @param indexCount defines the number of index to draw
  54299. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54300. */
  54301. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  54302. /**
  54303. * Draw a list of indexed primitives
  54304. * @param fillMode defines the primitive to use
  54305. * @param indexStart defines the starting index
  54306. * @param indexCount defines the number of index to draw
  54307. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54308. */
  54309. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54310. /**
  54311. * Draw a list of unindexed primitives
  54312. * @param fillMode defines the primitive to use
  54313. * @param verticesStart defines the index of first vertex to draw
  54314. * @param verticesCount defines the count of vertices to draw
  54315. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54316. */
  54317. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54318. /** @hidden */
  54319. _createTexture(): WebGLTexture;
  54320. /** @hidden */
  54321. _releaseTexture(texture: InternalTexture): void;
  54322. /**
  54323. * Usually called from Texture.ts.
  54324. * Passed information to create a WebGLTexture
  54325. * @param urlArg defines a value which contains one of the following:
  54326. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54327. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54328. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54329. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54330. * @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)
  54331. * @param scene needed for loading to the correct scene
  54332. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54333. * @param onLoad optional callback to be called upon successful completion
  54334. * @param onError optional callback to be called upon failure
  54335. * @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
  54336. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54337. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54338. * @param forcedExtension defines the extension to use to pick the right loader
  54339. * @param mimeType defines an optional mime type
  54340. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54341. */
  54342. 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;
  54343. /**
  54344. * Creates a new render target texture
  54345. * @param size defines the size of the texture
  54346. * @param options defines the options used to create the texture
  54347. * @returns a new render target texture stored in an InternalTexture
  54348. */
  54349. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  54350. /**
  54351. * Update the sampling mode of a given texture
  54352. * @param samplingMode defines the required sampling mode
  54353. * @param texture defines the texture to update
  54354. */
  54355. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54356. /**
  54357. * Binds the frame buffer to the specified texture.
  54358. * @param texture The texture to render to or null for the default canvas
  54359. * @param faceIndex The face of the texture to render to in case of cube texture
  54360. * @param requiredWidth The width of the target to render to
  54361. * @param requiredHeight The height of the target to render to
  54362. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  54363. * @param lodLevel defines le lod level to bind to the frame buffer
  54364. */
  54365. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54366. /**
  54367. * Unbind the current render target texture from the webGL context
  54368. * @param texture defines the render target texture to unbind
  54369. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  54370. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  54371. */
  54372. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54373. /**
  54374. * Creates a dynamic vertex buffer
  54375. * @param vertices the data for the dynamic vertex buffer
  54376. * @returns the new WebGL dynamic buffer
  54377. */
  54378. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  54379. /**
  54380. * Update the content of a dynamic texture
  54381. * @param texture defines the texture to update
  54382. * @param canvas defines the canvas containing the source
  54383. * @param invertY defines if data must be stored with Y axis inverted
  54384. * @param premulAlpha defines if alpha is stored as premultiplied
  54385. * @param format defines the format of the data
  54386. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  54387. */
  54388. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  54389. /**
  54390. * Gets a boolean indicating if all created effects are ready
  54391. * @returns true if all effects are ready
  54392. */
  54393. areAllEffectsReady(): boolean;
  54394. /**
  54395. * @hidden
  54396. * Get the current error code of the webGL context
  54397. * @returns the error code
  54398. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  54399. */
  54400. getError(): number;
  54401. /** @hidden */
  54402. _getUnpackAlignement(): number;
  54403. /** @hidden */
  54404. _unpackFlipY(value: boolean): void;
  54405. /**
  54406. * Update a dynamic index buffer
  54407. * @param indexBuffer defines the target index buffer
  54408. * @param indices defines the data to update
  54409. * @param offset defines the offset in the target index buffer where update should start
  54410. */
  54411. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  54412. /**
  54413. * Updates a dynamic vertex buffer.
  54414. * @param vertexBuffer the vertex buffer to update
  54415. * @param vertices the data used to update the vertex buffer
  54416. * @param byteOffset the byte offset of the data (optional)
  54417. * @param byteLength the byte length of the data (optional)
  54418. */
  54419. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54420. /** @hidden */
  54421. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54422. /** @hidden */
  54423. _bindTexture(channel: number, texture: InternalTexture): void;
  54424. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54425. /**
  54426. * 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
  54427. */
  54428. releaseEffects(): void;
  54429. displayLoadingUI(): void;
  54430. hideLoadingUI(): void;
  54431. /** @hidden */
  54432. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54433. /** @hidden */
  54434. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54435. /** @hidden */
  54436. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54437. /** @hidden */
  54438. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54439. }
  54440. }
  54441. declare module "babylonjs/Instrumentation/timeToken" {
  54442. import { Nullable } from "babylonjs/types";
  54443. /**
  54444. * @hidden
  54445. **/
  54446. export class _TimeToken {
  54447. _startTimeQuery: Nullable<WebGLQuery>;
  54448. _endTimeQuery: Nullable<WebGLQuery>;
  54449. _timeElapsedQuery: Nullable<WebGLQuery>;
  54450. _timeElapsedQueryEnded: boolean;
  54451. }
  54452. }
  54453. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54454. import { Nullable, int } from "babylonjs/types";
  54455. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54456. /** @hidden */
  54457. export class _OcclusionDataStorage {
  54458. /** @hidden */
  54459. occlusionInternalRetryCounter: number;
  54460. /** @hidden */
  54461. isOcclusionQueryInProgress: boolean;
  54462. /** @hidden */
  54463. isOccluded: boolean;
  54464. /** @hidden */
  54465. occlusionRetryCount: number;
  54466. /** @hidden */
  54467. occlusionType: number;
  54468. /** @hidden */
  54469. occlusionQueryAlgorithmType: number;
  54470. }
  54471. module "babylonjs/Engines/engine" {
  54472. interface Engine {
  54473. /**
  54474. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54475. * @return the new query
  54476. */
  54477. createQuery(): WebGLQuery;
  54478. /**
  54479. * Delete and release a webGL query
  54480. * @param query defines the query to delete
  54481. * @return the current engine
  54482. */
  54483. deleteQuery(query: WebGLQuery): Engine;
  54484. /**
  54485. * Check if a given query has resolved and got its value
  54486. * @param query defines the query to check
  54487. * @returns true if the query got its value
  54488. */
  54489. isQueryResultAvailable(query: WebGLQuery): boolean;
  54490. /**
  54491. * Gets the value of a given query
  54492. * @param query defines the query to check
  54493. * @returns the value of the query
  54494. */
  54495. getQueryResult(query: WebGLQuery): number;
  54496. /**
  54497. * Initiates an occlusion query
  54498. * @param algorithmType defines the algorithm to use
  54499. * @param query defines the query to use
  54500. * @returns the current engine
  54501. * @see https://doc.babylonjs.com/features/occlusionquery
  54502. */
  54503. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54504. /**
  54505. * Ends an occlusion query
  54506. * @see https://doc.babylonjs.com/features/occlusionquery
  54507. * @param algorithmType defines the algorithm to use
  54508. * @returns the current engine
  54509. */
  54510. endOcclusionQuery(algorithmType: number): Engine;
  54511. /**
  54512. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54513. * Please note that only one query can be issued at a time
  54514. * @returns a time token used to track the time span
  54515. */
  54516. startTimeQuery(): Nullable<_TimeToken>;
  54517. /**
  54518. * Ends a time query
  54519. * @param token defines the token used to measure the time span
  54520. * @returns the time spent (in ns)
  54521. */
  54522. endTimeQuery(token: _TimeToken): int;
  54523. /** @hidden */
  54524. _currentNonTimestampToken: Nullable<_TimeToken>;
  54525. /** @hidden */
  54526. _createTimeQuery(): WebGLQuery;
  54527. /** @hidden */
  54528. _deleteTimeQuery(query: WebGLQuery): void;
  54529. /** @hidden */
  54530. _getGlAlgorithmType(algorithmType: number): number;
  54531. /** @hidden */
  54532. _getTimeQueryResult(query: WebGLQuery): any;
  54533. /** @hidden */
  54534. _getTimeQueryAvailability(query: WebGLQuery): any;
  54535. }
  54536. }
  54537. module "babylonjs/Meshes/abstractMesh" {
  54538. interface AbstractMesh {
  54539. /**
  54540. * Backing filed
  54541. * @hidden
  54542. */
  54543. __occlusionDataStorage: _OcclusionDataStorage;
  54544. /**
  54545. * Access property
  54546. * @hidden
  54547. */
  54548. _occlusionDataStorage: _OcclusionDataStorage;
  54549. /**
  54550. * 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.
  54551. * The default value is -1 which means don't break the query and wait till the result
  54552. * @see https://doc.babylonjs.com/features/occlusionquery
  54553. */
  54554. occlusionRetryCount: number;
  54555. /**
  54556. * 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:
  54557. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54558. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54559. * * 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.
  54560. * @see https://doc.babylonjs.com/features/occlusionquery
  54561. */
  54562. occlusionType: number;
  54563. /**
  54564. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54565. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54566. * * 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.
  54567. * @see https://doc.babylonjs.com/features/occlusionquery
  54568. */
  54569. occlusionQueryAlgorithmType: number;
  54570. /**
  54571. * 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
  54572. * @see https://doc.babylonjs.com/features/occlusionquery
  54573. */
  54574. isOccluded: boolean;
  54575. /**
  54576. * Flag to check the progress status of the query
  54577. * @see https://doc.babylonjs.com/features/occlusionquery
  54578. */
  54579. isOcclusionQueryInProgress: boolean;
  54580. }
  54581. }
  54582. }
  54583. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54584. import { Nullable } from "babylonjs/types";
  54585. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54586. /** @hidden */
  54587. export var _forceTransformFeedbackToBundle: boolean;
  54588. module "babylonjs/Engines/engine" {
  54589. interface Engine {
  54590. /**
  54591. * Creates a webGL transform feedback object
  54592. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54593. * @returns the webGL transform feedback object
  54594. */
  54595. createTransformFeedback(): WebGLTransformFeedback;
  54596. /**
  54597. * Delete a webGL transform feedback object
  54598. * @param value defines the webGL transform feedback object to delete
  54599. */
  54600. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54601. /**
  54602. * Bind a webGL transform feedback object to the webgl context
  54603. * @param value defines the webGL transform feedback object to bind
  54604. */
  54605. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54606. /**
  54607. * Begins a transform feedback operation
  54608. * @param usePoints defines if points or triangles must be used
  54609. */
  54610. beginTransformFeedback(usePoints: boolean): void;
  54611. /**
  54612. * Ends a transform feedback operation
  54613. */
  54614. endTransformFeedback(): void;
  54615. /**
  54616. * Specify the varyings to use with transform feedback
  54617. * @param program defines the associated webGL program
  54618. * @param value defines the list of strings representing the varying names
  54619. */
  54620. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54621. /**
  54622. * Bind a webGL buffer for a transform feedback operation
  54623. * @param value defines the webGL buffer to bind
  54624. */
  54625. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54626. }
  54627. }
  54628. }
  54629. declare module "babylonjs/Engines/Extensions/engine.views" {
  54630. import { Camera } from "babylonjs/Cameras/camera";
  54631. import { Nullable } from "babylonjs/types";
  54632. /**
  54633. * Class used to define an additional view for the engine
  54634. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54635. */
  54636. export class EngineView {
  54637. /** Defines the canvas where to render the view */
  54638. target: HTMLCanvasElement;
  54639. /** Defines an optional camera used to render the view (will use active camera else) */
  54640. camera?: Camera;
  54641. }
  54642. module "babylonjs/Engines/engine" {
  54643. interface Engine {
  54644. /**
  54645. * Gets or sets the HTML element to use for attaching events
  54646. */
  54647. inputElement: Nullable<HTMLElement>;
  54648. /**
  54649. * Gets the current engine view
  54650. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54651. */
  54652. activeView: Nullable<EngineView>;
  54653. /** Gets or sets the list of views */
  54654. views: EngineView[];
  54655. /**
  54656. * Register a new child canvas
  54657. * @param canvas defines the canvas to register
  54658. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54659. * @returns the associated view
  54660. */
  54661. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54662. /**
  54663. * Remove a registered child canvas
  54664. * @param canvas defines the canvas to remove
  54665. * @returns the current engine
  54666. */
  54667. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54668. }
  54669. }
  54670. }
  54671. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54672. import { Nullable } from "babylonjs/types";
  54673. module "babylonjs/Engines/engine" {
  54674. interface Engine {
  54675. /** @hidden */
  54676. _excludedCompressedTextures: string[];
  54677. /** @hidden */
  54678. _textureFormatInUse: string;
  54679. /**
  54680. * Gets the list of texture formats supported
  54681. */
  54682. readonly texturesSupported: Array<string>;
  54683. /**
  54684. * Gets the texture format in use
  54685. */
  54686. readonly textureFormatInUse: Nullable<string>;
  54687. /**
  54688. * Set the compressed texture extensions or file names to skip.
  54689. *
  54690. * @param skippedFiles defines the list of those texture files you want to skip
  54691. * Example: [".dds", ".env", "myfile.png"]
  54692. */
  54693. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54694. /**
  54695. * Set the compressed texture format to use, based on the formats you have, and the formats
  54696. * supported by the hardware / browser.
  54697. *
  54698. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54699. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54700. * to API arguments needed to compressed textures. This puts the burden on the container
  54701. * generator to house the arcane code for determining these for current & future formats.
  54702. *
  54703. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54704. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54705. *
  54706. * Note: The result of this call is not taken into account when a texture is base64.
  54707. *
  54708. * @param formatsAvailable defines the list of those format families you have created
  54709. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54710. *
  54711. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54712. * @returns The extension selected.
  54713. */
  54714. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54715. }
  54716. }
  54717. }
  54718. declare module "babylonjs/Engines/Extensions/index" {
  54719. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54720. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54721. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54722. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54723. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54724. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54725. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54726. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54727. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54728. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54729. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54730. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54731. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54732. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  54733. export * from "babylonjs/Engines/Extensions/engine.views";
  54734. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54735. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54736. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54737. }
  54738. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54739. import { Nullable } from "babylonjs/types";
  54740. /**
  54741. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54742. */
  54743. export interface CubeMapInfo {
  54744. /**
  54745. * The pixel array for the front face.
  54746. * This is stored in format, left to right, up to down format.
  54747. */
  54748. front: Nullable<ArrayBufferView>;
  54749. /**
  54750. * The pixel array for the back face.
  54751. * This is stored in format, left to right, up to down format.
  54752. */
  54753. back: Nullable<ArrayBufferView>;
  54754. /**
  54755. * The pixel array for the left face.
  54756. * This is stored in format, left to right, up to down format.
  54757. */
  54758. left: Nullable<ArrayBufferView>;
  54759. /**
  54760. * The pixel array for the right face.
  54761. * This is stored in format, left to right, up to down format.
  54762. */
  54763. right: Nullable<ArrayBufferView>;
  54764. /**
  54765. * The pixel array for the up face.
  54766. * This is stored in format, left to right, up to down format.
  54767. */
  54768. up: Nullable<ArrayBufferView>;
  54769. /**
  54770. * The pixel array for the down face.
  54771. * This is stored in format, left to right, up to down format.
  54772. */
  54773. down: Nullable<ArrayBufferView>;
  54774. /**
  54775. * The size of the cubemap stored.
  54776. *
  54777. * Each faces will be size * size pixels.
  54778. */
  54779. size: number;
  54780. /**
  54781. * The format of the texture.
  54782. *
  54783. * RGBA, RGB.
  54784. */
  54785. format: number;
  54786. /**
  54787. * The type of the texture data.
  54788. *
  54789. * UNSIGNED_INT, FLOAT.
  54790. */
  54791. type: number;
  54792. /**
  54793. * Specifies whether the texture is in gamma space.
  54794. */
  54795. gammaSpace: boolean;
  54796. }
  54797. /**
  54798. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54799. */
  54800. export class PanoramaToCubeMapTools {
  54801. private static FACE_LEFT;
  54802. private static FACE_RIGHT;
  54803. private static FACE_FRONT;
  54804. private static FACE_BACK;
  54805. private static FACE_DOWN;
  54806. private static FACE_UP;
  54807. /**
  54808. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54809. *
  54810. * @param float32Array The source data.
  54811. * @param inputWidth The width of the input panorama.
  54812. * @param inputHeight The height of the input panorama.
  54813. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54814. * @return The cubemap data
  54815. */
  54816. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54817. private static CreateCubemapTexture;
  54818. private static CalcProjectionSpherical;
  54819. }
  54820. }
  54821. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54822. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54823. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54824. import { Nullable } from "babylonjs/types";
  54825. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54826. /**
  54827. * Helper class dealing with the extraction of spherical polynomial dataArray
  54828. * from a cube map.
  54829. */
  54830. export class CubeMapToSphericalPolynomialTools {
  54831. private static FileFaces;
  54832. /**
  54833. * Converts a texture to the according Spherical Polynomial data.
  54834. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54835. *
  54836. * @param texture The texture to extract the information from.
  54837. * @return The Spherical Polynomial data.
  54838. */
  54839. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54840. /**
  54841. * Converts a cubemap to the according Spherical Polynomial data.
  54842. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54843. *
  54844. * @param cubeInfo The Cube map to extract the information from.
  54845. * @return The Spherical Polynomial data.
  54846. */
  54847. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54848. }
  54849. }
  54850. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54851. import { Nullable } from "babylonjs/types";
  54852. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54853. module "babylonjs/Materials/Textures/baseTexture" {
  54854. interface BaseTexture {
  54855. /**
  54856. * Get the polynomial representation of the texture data.
  54857. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54858. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54859. */
  54860. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54861. }
  54862. }
  54863. }
  54864. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54865. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54866. /** @hidden */
  54867. export var rgbdEncodePixelShader: {
  54868. name: string;
  54869. shader: string;
  54870. };
  54871. }
  54872. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54873. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54874. /** @hidden */
  54875. export var rgbdDecodePixelShader: {
  54876. name: string;
  54877. shader: string;
  54878. };
  54879. }
  54880. declare module "babylonjs/Misc/environmentTextureTools" {
  54881. import { Nullable } from "babylonjs/types";
  54882. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54883. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54884. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54885. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54886. import "babylonjs/Engines/Extensions/engine.readTexture";
  54887. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54888. import "babylonjs/Shaders/rgbdEncode.fragment";
  54889. import "babylonjs/Shaders/rgbdDecode.fragment";
  54890. /**
  54891. * Raw texture data and descriptor sufficient for WebGL texture upload
  54892. */
  54893. export interface EnvironmentTextureInfo {
  54894. /**
  54895. * Version of the environment map
  54896. */
  54897. version: number;
  54898. /**
  54899. * Width of image
  54900. */
  54901. width: number;
  54902. /**
  54903. * Irradiance information stored in the file.
  54904. */
  54905. irradiance: any;
  54906. /**
  54907. * Specular information stored in the file.
  54908. */
  54909. specular: any;
  54910. }
  54911. /**
  54912. * Defines One Image in the file. It requires only the position in the file
  54913. * as well as the length.
  54914. */
  54915. interface BufferImageData {
  54916. /**
  54917. * Length of the image data.
  54918. */
  54919. length: number;
  54920. /**
  54921. * Position of the data from the null terminator delimiting the end of the JSON.
  54922. */
  54923. position: number;
  54924. }
  54925. /**
  54926. * Defines the specular data enclosed in the file.
  54927. * This corresponds to the version 1 of the data.
  54928. */
  54929. export interface EnvironmentTextureSpecularInfoV1 {
  54930. /**
  54931. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54932. */
  54933. specularDataPosition?: number;
  54934. /**
  54935. * This contains all the images data needed to reconstruct the cubemap.
  54936. */
  54937. mipmaps: Array<BufferImageData>;
  54938. /**
  54939. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54940. */
  54941. lodGenerationScale: number;
  54942. }
  54943. /**
  54944. * Sets of helpers addressing the serialization and deserialization of environment texture
  54945. * stored in a BabylonJS env file.
  54946. * Those files are usually stored as .env files.
  54947. */
  54948. export class EnvironmentTextureTools {
  54949. /**
  54950. * Magic number identifying the env file.
  54951. */
  54952. private static _MagicBytes;
  54953. /**
  54954. * Gets the environment info from an env file.
  54955. * @param data The array buffer containing the .env bytes.
  54956. * @returns the environment file info (the json header) if successfully parsed.
  54957. */
  54958. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54959. /**
  54960. * Creates an environment texture from a loaded cube texture.
  54961. * @param texture defines the cube texture to convert in env file
  54962. * @return a promise containing the environment data if succesfull.
  54963. */
  54964. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54965. /**
  54966. * Creates a JSON representation of the spherical data.
  54967. * @param texture defines the texture containing the polynomials
  54968. * @return the JSON representation of the spherical info
  54969. */
  54970. private static _CreateEnvTextureIrradiance;
  54971. /**
  54972. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54973. * @param data the image data
  54974. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54975. * @return the views described by info providing access to the underlying buffer
  54976. */
  54977. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54978. /**
  54979. * Uploads the texture info contained in the env file to the GPU.
  54980. * @param texture defines the internal texture to upload to
  54981. * @param data defines the data to load
  54982. * @param info defines the texture info retrieved through the GetEnvInfo method
  54983. * @returns a promise
  54984. */
  54985. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54986. private static _OnImageReadyAsync;
  54987. /**
  54988. * Uploads the levels of image data to the GPU.
  54989. * @param texture defines the internal texture to upload to
  54990. * @param imageData defines the array buffer views of image data [mipmap][face]
  54991. * @returns a promise
  54992. */
  54993. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54994. /**
  54995. * Uploads spherical polynomials information to the texture.
  54996. * @param texture defines the texture we are trying to upload the information to
  54997. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54998. */
  54999. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  55000. /** @hidden */
  55001. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55002. }
  55003. }
  55004. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  55005. /**
  55006. * Class used to inline functions in shader code
  55007. */
  55008. export class ShaderCodeInliner {
  55009. private static readonly _RegexpFindFunctionNameAndType;
  55010. private _sourceCode;
  55011. private _functionDescr;
  55012. private _numMaxIterations;
  55013. /** Gets or sets the token used to mark the functions to inline */
  55014. inlineToken: string;
  55015. /** Gets or sets the debug mode */
  55016. debug: boolean;
  55017. /** Gets the code after the inlining process */
  55018. get code(): string;
  55019. /**
  55020. * Initializes the inliner
  55021. * @param sourceCode shader code source to inline
  55022. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  55023. */
  55024. constructor(sourceCode: string, numMaxIterations?: number);
  55025. /**
  55026. * Start the processing of the shader code
  55027. */
  55028. processCode(): void;
  55029. private _collectFunctions;
  55030. private _processInlining;
  55031. private _extractBetweenMarkers;
  55032. private _skipWhitespaces;
  55033. private _removeComments;
  55034. private _replaceFunctionCallsByCode;
  55035. private _findBackward;
  55036. private _escapeRegExp;
  55037. private _replaceNames;
  55038. }
  55039. }
  55040. declare module "babylonjs/Engines/nativeEngine" {
  55041. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  55042. import { Engine } from "babylonjs/Engines/engine";
  55043. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  55044. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55045. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55046. import { Effect } from "babylonjs/Materials/effect";
  55047. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  55048. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  55049. import { IColor4Like } from "babylonjs/Maths/math.like";
  55050. import { Scene } from "babylonjs/scene";
  55051. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  55052. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  55053. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  55054. /**
  55055. * Container for accessors for natively-stored mesh data buffers.
  55056. */
  55057. class NativeDataBuffer extends DataBuffer {
  55058. /**
  55059. * Accessor value used to identify/retrieve a natively-stored index buffer.
  55060. */
  55061. nativeIndexBuffer?: any;
  55062. /**
  55063. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  55064. */
  55065. nativeVertexBuffer?: any;
  55066. }
  55067. /** @hidden */
  55068. class NativeTexture extends InternalTexture {
  55069. getInternalTexture(): InternalTexture;
  55070. getViewCount(): number;
  55071. }
  55072. /** @hidden */
  55073. export class NativeEngine extends Engine {
  55074. private readonly _native;
  55075. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  55076. private readonly INVALID_HANDLE;
  55077. private _boundBuffersVertexArray;
  55078. private _currentDepthTest;
  55079. getHardwareScalingLevel(): number;
  55080. constructor();
  55081. dispose(): void;
  55082. /**
  55083. * Can be used to override the current requestAnimationFrame requester.
  55084. * @hidden
  55085. */
  55086. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  55087. /**
  55088. * Override default engine behavior.
  55089. * @param color
  55090. * @param backBuffer
  55091. * @param depth
  55092. * @param stencil
  55093. */
  55094. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  55095. /**
  55096. * Gets host document
  55097. * @returns the host document object
  55098. */
  55099. getHostDocument(): Nullable<Document>;
  55100. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55101. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  55102. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  55103. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  55104. [key: string]: VertexBuffer;
  55105. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55106. bindBuffers(vertexBuffers: {
  55107. [key: string]: VertexBuffer;
  55108. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55109. recordVertexArrayObject(vertexBuffers: {
  55110. [key: string]: VertexBuffer;
  55111. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  55112. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55113. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55114. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55115. /**
  55116. * Draw a list of indexed primitives
  55117. * @param fillMode defines the primitive to use
  55118. * @param indexStart defines the starting index
  55119. * @param indexCount defines the number of index to draw
  55120. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55121. */
  55122. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55123. /**
  55124. * Draw a list of unindexed primitives
  55125. * @param fillMode defines the primitive to use
  55126. * @param verticesStart defines the index of first vertex to draw
  55127. * @param verticesCount defines the count of vertices to draw
  55128. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55129. */
  55130. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55131. createPipelineContext(): IPipelineContext;
  55132. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  55133. /** @hidden */
  55134. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  55135. /** @hidden */
  55136. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  55137. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55138. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55139. protected _setProgram(program: WebGLProgram): void;
  55140. _releaseEffect(effect: Effect): void;
  55141. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  55142. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  55143. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  55144. bindSamplers(effect: Effect): void;
  55145. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  55146. getRenderWidth(useScreen?: boolean): number;
  55147. getRenderHeight(useScreen?: boolean): number;
  55148. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  55149. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55150. /**
  55151. * Set the z offset to apply to current rendering
  55152. * @param value defines the offset to apply
  55153. */
  55154. setZOffset(value: number): void;
  55155. /**
  55156. * Gets the current value of the zOffset
  55157. * @returns the current zOffset state
  55158. */
  55159. getZOffset(): number;
  55160. /**
  55161. * Enable or disable depth buffering
  55162. * @param enable defines the state to set
  55163. */
  55164. setDepthBuffer(enable: boolean): void;
  55165. /**
  55166. * Gets a boolean indicating if depth writing is enabled
  55167. * @returns the current depth writing state
  55168. */
  55169. getDepthWrite(): boolean;
  55170. setDepthFunctionToGreater(): void;
  55171. setDepthFunctionToGreaterOrEqual(): void;
  55172. setDepthFunctionToLess(): void;
  55173. setDepthFunctionToLessOrEqual(): void;
  55174. /**
  55175. * Enable or disable depth writing
  55176. * @param enable defines the state to set
  55177. */
  55178. setDepthWrite(enable: boolean): void;
  55179. /**
  55180. * Enable or disable color writing
  55181. * @param enable defines the state to set
  55182. */
  55183. setColorWrite(enable: boolean): void;
  55184. /**
  55185. * Gets a boolean indicating if color writing is enabled
  55186. * @returns the current color writing state
  55187. */
  55188. getColorWrite(): boolean;
  55189. /**
  55190. * Sets alpha constants used by some alpha blending modes
  55191. * @param r defines the red component
  55192. * @param g defines the green component
  55193. * @param b defines the blue component
  55194. * @param a defines the alpha component
  55195. */
  55196. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55197. /**
  55198. * Sets the current alpha mode
  55199. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55200. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55201. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55202. */
  55203. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55204. /**
  55205. * Gets the current alpha mode
  55206. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55207. * @returns the current alpha mode
  55208. */
  55209. getAlphaMode(): number;
  55210. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  55211. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55212. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55213. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55214. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55215. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55216. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55217. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55218. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55219. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55220. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55221. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55222. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55223. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55224. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55225. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55226. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55227. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55228. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55229. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55230. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  55231. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  55232. wipeCaches(bruteForce?: boolean): void;
  55233. _createTexture(): WebGLTexture;
  55234. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55235. /**
  55236. * Usually called from Texture.ts.
  55237. * Passed information to create a WebGLTexture
  55238. * @param url defines a value which contains one of the following:
  55239. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55240. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55241. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55242. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55243. * @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)
  55244. * @param scene needed for loading to the correct scene
  55245. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55246. * @param onLoad optional callback to be called upon successful completion
  55247. * @param onError optional callback to be called upon failure
  55248. * @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
  55249. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55250. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55251. * @param forcedExtension defines the extension to use to pick the right loader
  55252. * @param mimeType defines an optional mime type
  55253. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55254. */
  55255. 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;
  55256. /**
  55257. * Creates a cube texture
  55258. * @param rootUrl defines the url where the files to load is located
  55259. * @param scene defines the current scene
  55260. * @param files defines the list of files to load (1 per face)
  55261. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55262. * @param onLoad defines an optional callback raised when the texture is loaded
  55263. * @param onError defines an optional callback raised if there is an issue to load the texture
  55264. * @param format defines the format of the data
  55265. * @param forcedExtension defines the extension to use to pick the right loader
  55266. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55267. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55268. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55269. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55270. * @returns the cube texture as an InternalTexture
  55271. */
  55272. 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;
  55273. private _getSamplingFilter;
  55274. private static _GetNativeTextureFormat;
  55275. createRenderTargetTexture(size: number | {
  55276. width: number;
  55277. height: number;
  55278. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55279. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55280. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55281. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55282. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55283. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55284. /**
  55285. * Updates a dynamic vertex buffer.
  55286. * @param vertexBuffer the vertex buffer to update
  55287. * @param data the data used to update the vertex buffer
  55288. * @param byteOffset the byte offset of the data (optional)
  55289. * @param byteLength the byte length of the data (optional)
  55290. */
  55291. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55292. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55293. private _updateAnisotropicLevel;
  55294. private _getAddressMode;
  55295. /** @hidden */
  55296. _bindTexture(channel: number, texture: InternalTexture): void;
  55297. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55298. releaseEffects(): void;
  55299. /** @hidden */
  55300. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55301. /** @hidden */
  55302. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55303. /** @hidden */
  55304. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55305. /** @hidden */
  55306. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55307. }
  55308. }
  55309. declare module "babylonjs/Engines/index" {
  55310. export * from "babylonjs/Engines/constants";
  55311. export * from "babylonjs/Engines/engineCapabilities";
  55312. export * from "babylonjs/Engines/instancingAttributeInfo";
  55313. export * from "babylonjs/Engines/thinEngine";
  55314. export * from "babylonjs/Engines/engine";
  55315. export * from "babylonjs/Engines/engineStore";
  55316. export * from "babylonjs/Engines/nullEngine";
  55317. export * from "babylonjs/Engines/Extensions/index";
  55318. export * from "babylonjs/Engines/IPipelineContext";
  55319. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  55320. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  55321. export * from "babylonjs/Engines/nativeEngine";
  55322. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  55323. export * from "babylonjs/Engines/performanceConfigurator";
  55324. }
  55325. declare module "babylonjs/Events/clipboardEvents" {
  55326. /**
  55327. * Gather the list of clipboard event types as constants.
  55328. */
  55329. export class ClipboardEventTypes {
  55330. /**
  55331. * The clipboard event is fired when a copy command is active (pressed).
  55332. */
  55333. static readonly COPY: number;
  55334. /**
  55335. * The clipboard event is fired when a cut command is active (pressed).
  55336. */
  55337. static readonly CUT: number;
  55338. /**
  55339. * The clipboard event is fired when a paste command is active (pressed).
  55340. */
  55341. static readonly PASTE: number;
  55342. }
  55343. /**
  55344. * This class is used to store clipboard related info for the onClipboardObservable event.
  55345. */
  55346. export class ClipboardInfo {
  55347. /**
  55348. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55349. */
  55350. type: number;
  55351. /**
  55352. * Defines the related dom event
  55353. */
  55354. event: ClipboardEvent;
  55355. /**
  55356. *Creates an instance of ClipboardInfo.
  55357. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55358. * @param event Defines the related dom event
  55359. */
  55360. constructor(
  55361. /**
  55362. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55363. */
  55364. type: number,
  55365. /**
  55366. * Defines the related dom event
  55367. */
  55368. event: ClipboardEvent);
  55369. /**
  55370. * Get the clipboard event's type from the keycode.
  55371. * @param keyCode Defines the keyCode for the current keyboard event.
  55372. * @return {number}
  55373. */
  55374. static GetTypeFromCharacter(keyCode: number): number;
  55375. }
  55376. }
  55377. declare module "babylonjs/Events/index" {
  55378. export * from "babylonjs/Events/keyboardEvents";
  55379. export * from "babylonjs/Events/pointerEvents";
  55380. export * from "babylonjs/Events/clipboardEvents";
  55381. }
  55382. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  55383. import { Scene } from "babylonjs/scene";
  55384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55385. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55386. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55387. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55388. /**
  55389. * Google Daydream controller
  55390. */
  55391. export class DaydreamController extends WebVRController {
  55392. /**
  55393. * Base Url for the controller model.
  55394. */
  55395. static MODEL_BASE_URL: string;
  55396. /**
  55397. * File name for the controller model.
  55398. */
  55399. static MODEL_FILENAME: string;
  55400. /**
  55401. * Gamepad Id prefix used to identify Daydream Controller.
  55402. */
  55403. static readonly GAMEPAD_ID_PREFIX: string;
  55404. /**
  55405. * Creates a new DaydreamController from a gamepad
  55406. * @param vrGamepad the gamepad that the controller should be created from
  55407. */
  55408. constructor(vrGamepad: any);
  55409. /**
  55410. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55411. * @param scene scene in which to add meshes
  55412. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55413. */
  55414. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55415. /**
  55416. * Called once for each button that changed state since the last frame
  55417. * @param buttonIdx Which button index changed
  55418. * @param state New state of the button
  55419. * @param changes Which properties on the state changed since last frame
  55420. */
  55421. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55422. }
  55423. }
  55424. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  55425. import { Scene } from "babylonjs/scene";
  55426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55427. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55428. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55429. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55430. /**
  55431. * Gear VR Controller
  55432. */
  55433. export class GearVRController extends WebVRController {
  55434. /**
  55435. * Base Url for the controller model.
  55436. */
  55437. static MODEL_BASE_URL: string;
  55438. /**
  55439. * File name for the controller model.
  55440. */
  55441. static MODEL_FILENAME: string;
  55442. /**
  55443. * Gamepad Id prefix used to identify this controller.
  55444. */
  55445. static readonly GAMEPAD_ID_PREFIX: string;
  55446. private readonly _buttonIndexToObservableNameMap;
  55447. /**
  55448. * Creates a new GearVRController from a gamepad
  55449. * @param vrGamepad the gamepad that the controller should be created from
  55450. */
  55451. constructor(vrGamepad: any);
  55452. /**
  55453. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55454. * @param scene scene in which to add meshes
  55455. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55456. */
  55457. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55458. /**
  55459. * Called once for each button that changed state since the last frame
  55460. * @param buttonIdx Which button index changed
  55461. * @param state New state of the button
  55462. * @param changes Which properties on the state changed since last frame
  55463. */
  55464. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55465. }
  55466. }
  55467. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55468. import { Scene } from "babylonjs/scene";
  55469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55470. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55471. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55472. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55473. /**
  55474. * Generic Controller
  55475. */
  55476. export class GenericController extends WebVRController {
  55477. /**
  55478. * Base Url for the controller model.
  55479. */
  55480. static readonly MODEL_BASE_URL: string;
  55481. /**
  55482. * File name for the controller model.
  55483. */
  55484. static readonly MODEL_FILENAME: string;
  55485. /**
  55486. * Creates a new GenericController from a gamepad
  55487. * @param vrGamepad the gamepad that the controller should be created from
  55488. */
  55489. constructor(vrGamepad: any);
  55490. /**
  55491. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55492. * @param scene scene in which to add meshes
  55493. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55494. */
  55495. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55496. /**
  55497. * Called once for each button that changed state since the last frame
  55498. * @param buttonIdx Which button index changed
  55499. * @param state New state of the button
  55500. * @param changes Which properties on the state changed since last frame
  55501. */
  55502. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55503. }
  55504. }
  55505. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55506. import { Observable } from "babylonjs/Misc/observable";
  55507. import { Scene } from "babylonjs/scene";
  55508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55509. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55510. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55511. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55512. /**
  55513. * Oculus Touch Controller
  55514. */
  55515. export class OculusTouchController extends WebVRController {
  55516. /**
  55517. * Base Url for the controller model.
  55518. */
  55519. static MODEL_BASE_URL: string;
  55520. /**
  55521. * File name for the left controller model.
  55522. */
  55523. static MODEL_LEFT_FILENAME: string;
  55524. /**
  55525. * File name for the right controller model.
  55526. */
  55527. static MODEL_RIGHT_FILENAME: string;
  55528. /**
  55529. * Base Url for the Quest controller model.
  55530. */
  55531. static QUEST_MODEL_BASE_URL: string;
  55532. /**
  55533. * @hidden
  55534. * If the controllers are running on a device that needs the updated Quest controller models
  55535. */
  55536. static _IsQuest: boolean;
  55537. /**
  55538. * Fired when the secondary trigger on this controller is modified
  55539. */
  55540. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55541. /**
  55542. * Fired when the thumb rest on this controller is modified
  55543. */
  55544. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55545. /**
  55546. * Creates a new OculusTouchController from a gamepad
  55547. * @param vrGamepad the gamepad that the controller should be created from
  55548. */
  55549. constructor(vrGamepad: any);
  55550. /**
  55551. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55552. * @param scene scene in which to add meshes
  55553. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55554. */
  55555. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55556. /**
  55557. * Fired when the A button on this controller is modified
  55558. */
  55559. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55560. /**
  55561. * Fired when the B button on this controller is modified
  55562. */
  55563. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55564. /**
  55565. * Fired when the X button on this controller is modified
  55566. */
  55567. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55568. /**
  55569. * Fired when the Y button on this controller is modified
  55570. */
  55571. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55572. /**
  55573. * Called once for each button that changed state since the last frame
  55574. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55575. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55576. * 2) secondary trigger (same)
  55577. * 3) A (right) X (left), touch, pressed = value
  55578. * 4) B / Y
  55579. * 5) thumb rest
  55580. * @param buttonIdx Which button index changed
  55581. * @param state New state of the button
  55582. * @param changes Which properties on the state changed since last frame
  55583. */
  55584. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55585. }
  55586. }
  55587. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55588. import { Scene } from "babylonjs/scene";
  55589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55590. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55591. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55592. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55593. import { Observable } from "babylonjs/Misc/observable";
  55594. /**
  55595. * Vive Controller
  55596. */
  55597. export class ViveController extends WebVRController {
  55598. /**
  55599. * Base Url for the controller model.
  55600. */
  55601. static MODEL_BASE_URL: string;
  55602. /**
  55603. * File name for the controller model.
  55604. */
  55605. static MODEL_FILENAME: string;
  55606. /**
  55607. * Creates a new ViveController from a gamepad
  55608. * @param vrGamepad the gamepad that the controller should be created from
  55609. */
  55610. constructor(vrGamepad: any);
  55611. /**
  55612. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55613. * @param scene scene in which to add meshes
  55614. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55615. */
  55616. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55617. /**
  55618. * Fired when the left button on this controller is modified
  55619. */
  55620. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55621. /**
  55622. * Fired when the right button on this controller is modified
  55623. */
  55624. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55625. /**
  55626. * Fired when the menu button on this controller is modified
  55627. */
  55628. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55629. /**
  55630. * Called once for each button that changed state since the last frame
  55631. * Vive mapping:
  55632. * 0: touchpad
  55633. * 1: trigger
  55634. * 2: left AND right buttons
  55635. * 3: menu button
  55636. * @param buttonIdx Which button index changed
  55637. * @param state New state of the button
  55638. * @param changes Which properties on the state changed since last frame
  55639. */
  55640. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55641. }
  55642. }
  55643. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55644. import { Observable } from "babylonjs/Misc/observable";
  55645. import { Scene } from "babylonjs/scene";
  55646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55647. import { Ray } from "babylonjs/Culling/ray";
  55648. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55649. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55650. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55651. /**
  55652. * Defines the WindowsMotionController object that the state of the windows motion controller
  55653. */
  55654. export class WindowsMotionController extends WebVRController {
  55655. /**
  55656. * The base url used to load the left and right controller models
  55657. */
  55658. static MODEL_BASE_URL: string;
  55659. /**
  55660. * The name of the left controller model file
  55661. */
  55662. static MODEL_LEFT_FILENAME: string;
  55663. /**
  55664. * The name of the right controller model file
  55665. */
  55666. static MODEL_RIGHT_FILENAME: string;
  55667. /**
  55668. * The controller name prefix for this controller type
  55669. */
  55670. static readonly GAMEPAD_ID_PREFIX: string;
  55671. /**
  55672. * The controller id pattern for this controller type
  55673. */
  55674. private static readonly GAMEPAD_ID_PATTERN;
  55675. private _loadedMeshInfo;
  55676. protected readonly _mapping: {
  55677. buttons: string[];
  55678. buttonMeshNames: {
  55679. trigger: string;
  55680. menu: string;
  55681. grip: string;
  55682. thumbstick: string;
  55683. trackpad: string;
  55684. };
  55685. buttonObservableNames: {
  55686. trigger: string;
  55687. menu: string;
  55688. grip: string;
  55689. thumbstick: string;
  55690. trackpad: string;
  55691. };
  55692. axisMeshNames: string[];
  55693. pointingPoseMeshName: string;
  55694. };
  55695. /**
  55696. * Fired when the trackpad on this controller is clicked
  55697. */
  55698. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55699. /**
  55700. * Fired when the trackpad on this controller is modified
  55701. */
  55702. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55703. /**
  55704. * The current x and y values of this controller's trackpad
  55705. */
  55706. trackpad: StickValues;
  55707. /**
  55708. * Creates a new WindowsMotionController from a gamepad
  55709. * @param vrGamepad the gamepad that the controller should be created from
  55710. */
  55711. constructor(vrGamepad: any);
  55712. /**
  55713. * Fired when the trigger on this controller is modified
  55714. */
  55715. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55716. /**
  55717. * Fired when the menu button on this controller is modified
  55718. */
  55719. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55720. /**
  55721. * Fired when the grip button on this controller is modified
  55722. */
  55723. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55724. /**
  55725. * Fired when the thumbstick button on this controller is modified
  55726. */
  55727. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55728. /**
  55729. * Fired when the touchpad button on this controller is modified
  55730. */
  55731. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55732. /**
  55733. * Fired when the touchpad values on this controller are modified
  55734. */
  55735. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55736. protected _updateTrackpad(): void;
  55737. /**
  55738. * Called once per frame by the engine.
  55739. */
  55740. update(): void;
  55741. /**
  55742. * Called once for each button that changed state since the last frame
  55743. * @param buttonIdx Which button index changed
  55744. * @param state New state of the button
  55745. * @param changes Which properties on the state changed since last frame
  55746. */
  55747. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55748. /**
  55749. * Moves the buttons on the controller mesh based on their current state
  55750. * @param buttonName the name of the button to move
  55751. * @param buttonValue the value of the button which determines the buttons new position
  55752. */
  55753. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55754. /**
  55755. * Moves the axis on the controller mesh based on its current state
  55756. * @param axis the index of the axis
  55757. * @param axisValue the value of the axis which determines the meshes new position
  55758. * @hidden
  55759. */
  55760. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55761. /**
  55762. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55763. * @param scene scene in which to add meshes
  55764. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55765. */
  55766. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55767. /**
  55768. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55769. * can be transformed by button presses and axes values, based on this._mapping.
  55770. *
  55771. * @param scene scene in which the meshes exist
  55772. * @param meshes list of meshes that make up the controller model to process
  55773. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55774. */
  55775. private processModel;
  55776. private createMeshInfo;
  55777. /**
  55778. * Gets the ray of the controller in the direction the controller is pointing
  55779. * @param length the length the resulting ray should be
  55780. * @returns a ray in the direction the controller is pointing
  55781. */
  55782. getForwardRay(length?: number): Ray;
  55783. /**
  55784. * Disposes of the controller
  55785. */
  55786. dispose(): void;
  55787. }
  55788. /**
  55789. * This class represents a new windows motion controller in XR.
  55790. */
  55791. export class XRWindowsMotionController extends WindowsMotionController {
  55792. /**
  55793. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55794. */
  55795. protected readonly _mapping: {
  55796. buttons: string[];
  55797. buttonMeshNames: {
  55798. trigger: string;
  55799. menu: string;
  55800. grip: string;
  55801. thumbstick: string;
  55802. trackpad: string;
  55803. };
  55804. buttonObservableNames: {
  55805. trigger: string;
  55806. menu: string;
  55807. grip: string;
  55808. thumbstick: string;
  55809. trackpad: string;
  55810. };
  55811. axisMeshNames: string[];
  55812. pointingPoseMeshName: string;
  55813. };
  55814. /**
  55815. * Construct a new XR-Based windows motion controller
  55816. *
  55817. * @param gamepadInfo the gamepad object from the browser
  55818. */
  55819. constructor(gamepadInfo: any);
  55820. /**
  55821. * holds the thumbstick values (X,Y)
  55822. */
  55823. thumbstickValues: StickValues;
  55824. /**
  55825. * Fired when the thumbstick on this controller is clicked
  55826. */
  55827. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55828. /**
  55829. * Fired when the thumbstick on this controller is modified
  55830. */
  55831. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55832. /**
  55833. * Fired when the touchpad button on this controller is modified
  55834. */
  55835. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55836. /**
  55837. * Fired when the touchpad values on this controller are modified
  55838. */
  55839. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55840. /**
  55841. * Fired when the thumbstick button on this controller is modified
  55842. * here to prevent breaking changes
  55843. */
  55844. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55845. /**
  55846. * updating the thumbstick(!) and not the trackpad.
  55847. * This is named this way due to the difference between WebVR and XR and to avoid
  55848. * changing the parent class.
  55849. */
  55850. protected _updateTrackpad(): void;
  55851. /**
  55852. * Disposes the class with joy
  55853. */
  55854. dispose(): void;
  55855. }
  55856. }
  55857. declare module "babylonjs/Gamepads/Controllers/index" {
  55858. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55859. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55860. export * from "babylonjs/Gamepads/Controllers/genericController";
  55861. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55862. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55863. export * from "babylonjs/Gamepads/Controllers/viveController";
  55864. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55865. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55866. }
  55867. declare module "babylonjs/Gamepads/index" {
  55868. export * from "babylonjs/Gamepads/Controllers/index";
  55869. export * from "babylonjs/Gamepads/gamepad";
  55870. export * from "babylonjs/Gamepads/gamepadManager";
  55871. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55872. export * from "babylonjs/Gamepads/xboxGamepad";
  55873. export * from "babylonjs/Gamepads/dualShockGamepad";
  55874. }
  55875. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55876. import { Scene } from "babylonjs/scene";
  55877. import { Vector4 } from "babylonjs/Maths/math.vector";
  55878. import { Color4 } from "babylonjs/Maths/math.color";
  55879. import { Mesh } from "babylonjs/Meshes/mesh";
  55880. import { Nullable } from "babylonjs/types";
  55881. /**
  55882. * Class containing static functions to help procedurally build meshes
  55883. */
  55884. export class PolyhedronBuilder {
  55885. /**
  55886. * Creates a polyhedron mesh
  55887. * * 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
  55888. * * The parameter `size` (positive float, default 1) sets the polygon size
  55889. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55890. * * 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`
  55891. * * 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
  55892. * * 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)`)
  55893. * * 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
  55894. * * 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
  55895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55896. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55898. * @param name defines the name of the mesh
  55899. * @param options defines the options used to create the mesh
  55900. * @param scene defines the hosting scene
  55901. * @returns the polyhedron mesh
  55902. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55903. */
  55904. static CreatePolyhedron(name: string, options: {
  55905. type?: number;
  55906. size?: number;
  55907. sizeX?: number;
  55908. sizeY?: number;
  55909. sizeZ?: number;
  55910. custom?: any;
  55911. faceUV?: Vector4[];
  55912. faceColors?: Color4[];
  55913. flat?: boolean;
  55914. updatable?: boolean;
  55915. sideOrientation?: number;
  55916. frontUVs?: Vector4;
  55917. backUVs?: Vector4;
  55918. }, scene?: Nullable<Scene>): Mesh;
  55919. }
  55920. }
  55921. declare module "babylonjs/Gizmos/scaleGizmo" {
  55922. import { Observable } from "babylonjs/Misc/observable";
  55923. import { Nullable } from "babylonjs/types";
  55924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55925. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55926. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55927. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55928. import { Node } from "babylonjs/node";
  55929. /**
  55930. * Gizmo that enables scaling a mesh along 3 axis
  55931. */
  55932. export class ScaleGizmo extends Gizmo {
  55933. /**
  55934. * Internal gizmo used for interactions on the x axis
  55935. */
  55936. xGizmo: AxisScaleGizmo;
  55937. /**
  55938. * Internal gizmo used for interactions on the y axis
  55939. */
  55940. yGizmo: AxisScaleGizmo;
  55941. /**
  55942. * Internal gizmo used for interactions on the z axis
  55943. */
  55944. zGizmo: AxisScaleGizmo;
  55945. /**
  55946. * Internal gizmo used to scale all axis equally
  55947. */
  55948. uniformScaleGizmo: AxisScaleGizmo;
  55949. private _meshAttached;
  55950. private _nodeAttached;
  55951. private _snapDistance;
  55952. private _uniformScalingMesh;
  55953. private _octahedron;
  55954. private _sensitivity;
  55955. /** Fires an event when any of it's sub gizmos are dragged */
  55956. onDragStartObservable: Observable<unknown>;
  55957. /** Fires an event when any of it's sub gizmos are released from dragging */
  55958. onDragEndObservable: Observable<unknown>;
  55959. get attachedMesh(): Nullable<AbstractMesh>;
  55960. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55961. get attachedNode(): Nullable<Node>;
  55962. set attachedNode(node: Nullable<Node>);
  55963. /**
  55964. * True when the mouse pointer is hovering a gizmo mesh
  55965. */
  55966. get isHovered(): boolean;
  55967. /**
  55968. * Creates a ScaleGizmo
  55969. * @param gizmoLayer The utility layer the gizmo will be added to
  55970. * @param thickness display gizmo axis thickness
  55971. */
  55972. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55973. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55974. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55975. /**
  55976. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55977. */
  55978. set snapDistance(value: number);
  55979. get snapDistance(): number;
  55980. /**
  55981. * Ratio for the scale of the gizmo (Default: 1)
  55982. */
  55983. set scaleRatio(value: number);
  55984. get scaleRatio(): number;
  55985. /**
  55986. * Sensitivity factor for dragging (Default: 1)
  55987. */
  55988. set sensitivity(value: number);
  55989. get sensitivity(): number;
  55990. /**
  55991. * Disposes of the gizmo
  55992. */
  55993. dispose(): void;
  55994. }
  55995. }
  55996. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55997. import { Observable } from "babylonjs/Misc/observable";
  55998. import { Nullable } from "babylonjs/types";
  55999. import { Vector3 } from "babylonjs/Maths/math.vector";
  56000. import { Node } from "babylonjs/node";
  56001. import { Mesh } from "babylonjs/Meshes/mesh";
  56002. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56003. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56004. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56005. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56006. import { Color3 } from "babylonjs/Maths/math.color";
  56007. /**
  56008. * Single axis scale gizmo
  56009. */
  56010. export class AxisScaleGizmo extends Gizmo {
  56011. /**
  56012. * Drag behavior responsible for the gizmos dragging interactions
  56013. */
  56014. dragBehavior: PointerDragBehavior;
  56015. private _pointerObserver;
  56016. /**
  56017. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56018. */
  56019. snapDistance: number;
  56020. /**
  56021. * Event that fires each time the gizmo snaps to a new location.
  56022. * * snapDistance is the the change in distance
  56023. */
  56024. onSnapObservable: Observable<{
  56025. snapDistance: number;
  56026. }>;
  56027. /**
  56028. * If the scaling operation should be done on all axis (default: false)
  56029. */
  56030. uniformScaling: boolean;
  56031. /**
  56032. * Custom sensitivity value for the drag strength
  56033. */
  56034. sensitivity: number;
  56035. private _isEnabled;
  56036. private _parent;
  56037. private _arrow;
  56038. private _coloredMaterial;
  56039. private _hoverMaterial;
  56040. /**
  56041. * Creates an AxisScaleGizmo
  56042. * @param gizmoLayer The utility layer the gizmo will be added to
  56043. * @param dragAxis The axis which the gizmo will be able to scale on
  56044. * @param color The color of the gizmo
  56045. * @param thickness display gizmo axis thickness
  56046. */
  56047. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56048. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56049. /**
  56050. * If the gizmo is enabled
  56051. */
  56052. set isEnabled(value: boolean);
  56053. get isEnabled(): boolean;
  56054. /**
  56055. * Disposes of the gizmo
  56056. */
  56057. dispose(): void;
  56058. /**
  56059. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56060. * @param mesh The mesh to replace the default mesh of the gizmo
  56061. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56062. */
  56063. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56064. }
  56065. }
  56066. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  56067. import { Observable } from "babylonjs/Misc/observable";
  56068. import { Nullable } from "babylonjs/types";
  56069. import { Vector3 } from "babylonjs/Maths/math.vector";
  56070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56071. import { Mesh } from "babylonjs/Meshes/mesh";
  56072. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56073. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56074. import { Color3 } from "babylonjs/Maths/math.color";
  56075. import "babylonjs/Meshes/Builders/boxBuilder";
  56076. /**
  56077. * Bounding box gizmo
  56078. */
  56079. export class BoundingBoxGizmo extends Gizmo {
  56080. private _lineBoundingBox;
  56081. private _rotateSpheresParent;
  56082. private _scaleBoxesParent;
  56083. private _boundingDimensions;
  56084. private _renderObserver;
  56085. private _pointerObserver;
  56086. private _scaleDragSpeed;
  56087. private _tmpQuaternion;
  56088. private _tmpVector;
  56089. private _tmpRotationMatrix;
  56090. /**
  56091. * 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)
  56092. */
  56093. ignoreChildren: boolean;
  56094. /**
  56095. * 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)
  56096. */
  56097. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56098. /**
  56099. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56100. */
  56101. rotationSphereSize: number;
  56102. /**
  56103. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56104. */
  56105. scaleBoxSize: number;
  56106. /**
  56107. * 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)
  56108. */
  56109. fixedDragMeshScreenSize: boolean;
  56110. /**
  56111. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56112. */
  56113. fixedDragMeshScreenSizeDistanceFactor: number;
  56114. /**
  56115. * Fired when a rotation sphere or scale box is dragged
  56116. */
  56117. onDragStartObservable: Observable<{}>;
  56118. /**
  56119. * Fired when a scale box is dragged
  56120. */
  56121. onScaleBoxDragObservable: Observable<{}>;
  56122. /**
  56123. * Fired when a scale box drag is ended
  56124. */
  56125. onScaleBoxDragEndObservable: Observable<{}>;
  56126. /**
  56127. * Fired when a rotation sphere is dragged
  56128. */
  56129. onRotationSphereDragObservable: Observable<{}>;
  56130. /**
  56131. * Fired when a rotation sphere drag is ended
  56132. */
  56133. onRotationSphereDragEndObservable: Observable<{}>;
  56134. /**
  56135. * 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)
  56136. */
  56137. scalePivot: Nullable<Vector3>;
  56138. /**
  56139. * Mesh used as a pivot to rotate the attached node
  56140. */
  56141. private _anchorMesh;
  56142. private _existingMeshScale;
  56143. private _dragMesh;
  56144. private pointerDragBehavior;
  56145. private coloredMaterial;
  56146. private hoverColoredMaterial;
  56147. /**
  56148. * Sets the color of the bounding box gizmo
  56149. * @param color the color to set
  56150. */
  56151. setColor(color: Color3): void;
  56152. /**
  56153. * Creates an BoundingBoxGizmo
  56154. * @param gizmoLayer The utility layer the gizmo will be added to
  56155. * @param color The color of the gizmo
  56156. */
  56157. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56158. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56159. private _selectNode;
  56160. /**
  56161. * Updates the bounding box information for the Gizmo
  56162. */
  56163. updateBoundingBox(): void;
  56164. private _updateRotationSpheres;
  56165. private _updateScaleBoxes;
  56166. /**
  56167. * Enables rotation on the specified axis and disables rotation on the others
  56168. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56169. */
  56170. setEnabledRotationAxis(axis: string): void;
  56171. /**
  56172. * Enables/disables scaling
  56173. * @param enable if scaling should be enabled
  56174. * @param homogeneousScaling defines if scaling should only be homogeneous
  56175. */
  56176. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56177. private _updateDummy;
  56178. /**
  56179. * Enables a pointer drag behavior on the bounding box of the gizmo
  56180. */
  56181. enableDragBehavior(): void;
  56182. /**
  56183. * Disposes of the gizmo
  56184. */
  56185. dispose(): void;
  56186. /**
  56187. * 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)
  56188. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56189. * @returns the bounding box mesh with the passed in mesh as a child
  56190. */
  56191. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56192. /**
  56193. * CustomMeshes are not supported by this gizmo
  56194. * @param mesh The mesh to replace the default mesh of the gizmo
  56195. */
  56196. setCustomMesh(mesh: Mesh): void;
  56197. }
  56198. }
  56199. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56200. import { Observable } from "babylonjs/Misc/observable";
  56201. import { Nullable } from "babylonjs/types";
  56202. import { Vector3 } from "babylonjs/Maths/math.vector";
  56203. import { Color3 } from "babylonjs/Maths/math.color";
  56204. import { Node } from "babylonjs/node";
  56205. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56206. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56207. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56208. import "babylonjs/Meshes/Builders/linesBuilder";
  56209. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56210. /**
  56211. * Single plane rotation gizmo
  56212. */
  56213. export class PlaneRotationGizmo extends Gizmo {
  56214. /**
  56215. * Drag behavior responsible for the gizmos dragging interactions
  56216. */
  56217. dragBehavior: PointerDragBehavior;
  56218. private _pointerObserver;
  56219. /**
  56220. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56221. */
  56222. snapDistance: number;
  56223. /**
  56224. * Event that fires each time the gizmo snaps to a new location.
  56225. * * snapDistance is the the change in distance
  56226. */
  56227. onSnapObservable: Observable<{
  56228. snapDistance: number;
  56229. }>;
  56230. private _isEnabled;
  56231. private _parent;
  56232. /**
  56233. * Creates a PlaneRotationGizmo
  56234. * @param gizmoLayer The utility layer the gizmo will be added to
  56235. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56236. * @param color The color of the gizmo
  56237. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56238. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56239. * @param thickness display gizmo axis thickness
  56240. */
  56241. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56242. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56243. /**
  56244. * If the gizmo is enabled
  56245. */
  56246. set isEnabled(value: boolean);
  56247. get isEnabled(): boolean;
  56248. /**
  56249. * Disposes of the gizmo
  56250. */
  56251. dispose(): void;
  56252. }
  56253. }
  56254. declare module "babylonjs/Gizmos/rotationGizmo" {
  56255. import { Observable } from "babylonjs/Misc/observable";
  56256. import { Nullable } from "babylonjs/types";
  56257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56258. import { Mesh } from "babylonjs/Meshes/mesh";
  56259. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56260. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56261. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56262. import { Node } from "babylonjs/node";
  56263. /**
  56264. * Gizmo that enables rotating a mesh along 3 axis
  56265. */
  56266. export class RotationGizmo extends Gizmo {
  56267. /**
  56268. * Internal gizmo used for interactions on the x axis
  56269. */
  56270. xGizmo: PlaneRotationGizmo;
  56271. /**
  56272. * Internal gizmo used for interactions on the y axis
  56273. */
  56274. yGizmo: PlaneRotationGizmo;
  56275. /**
  56276. * Internal gizmo used for interactions on the z axis
  56277. */
  56278. zGizmo: PlaneRotationGizmo;
  56279. /** Fires an event when any of it's sub gizmos are dragged */
  56280. onDragStartObservable: Observable<unknown>;
  56281. /** Fires an event when any of it's sub gizmos are released from dragging */
  56282. onDragEndObservable: Observable<unknown>;
  56283. private _meshAttached;
  56284. private _nodeAttached;
  56285. get attachedMesh(): Nullable<AbstractMesh>;
  56286. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56287. get attachedNode(): Nullable<Node>;
  56288. set attachedNode(node: Nullable<Node>);
  56289. /**
  56290. * True when the mouse pointer is hovering a gizmo mesh
  56291. */
  56292. get isHovered(): boolean;
  56293. /**
  56294. * Creates a RotationGizmo
  56295. * @param gizmoLayer The utility layer the gizmo will be added to
  56296. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56297. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56298. * @param thickness display gizmo axis thickness
  56299. */
  56300. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56301. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56302. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56303. /**
  56304. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56305. */
  56306. set snapDistance(value: number);
  56307. get snapDistance(): number;
  56308. /**
  56309. * Ratio for the scale of the gizmo (Default: 1)
  56310. */
  56311. set scaleRatio(value: number);
  56312. get scaleRatio(): number;
  56313. /**
  56314. * Disposes of the gizmo
  56315. */
  56316. dispose(): void;
  56317. /**
  56318. * CustomMeshes are not supported by this gizmo
  56319. * @param mesh The mesh to replace the default mesh of the gizmo
  56320. */
  56321. setCustomMesh(mesh: Mesh): void;
  56322. }
  56323. }
  56324. declare module "babylonjs/Gizmos/gizmoManager" {
  56325. import { Observable } from "babylonjs/Misc/observable";
  56326. import { Nullable } from "babylonjs/types";
  56327. import { Scene, IDisposable } from "babylonjs/scene";
  56328. import { Node } from "babylonjs/node";
  56329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56330. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56331. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  56332. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56333. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56334. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56335. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  56336. /**
  56337. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56338. */
  56339. export class GizmoManager implements IDisposable {
  56340. private scene;
  56341. /**
  56342. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56343. */
  56344. gizmos: {
  56345. positionGizmo: Nullable<PositionGizmo>;
  56346. rotationGizmo: Nullable<RotationGizmo>;
  56347. scaleGizmo: Nullable<ScaleGizmo>;
  56348. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56349. };
  56350. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56351. clearGizmoOnEmptyPointerEvent: boolean;
  56352. /** Fires an event when the manager is attached to a mesh */
  56353. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56354. /** Fires an event when the manager is attached to a node */
  56355. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56356. private _gizmosEnabled;
  56357. private _pointerObserver;
  56358. private _attachedMesh;
  56359. private _attachedNode;
  56360. private _boundingBoxColor;
  56361. private _defaultUtilityLayer;
  56362. private _defaultKeepDepthUtilityLayer;
  56363. private _thickness;
  56364. /**
  56365. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56366. */
  56367. boundingBoxDragBehavior: SixDofDragBehavior;
  56368. /**
  56369. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56370. */
  56371. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56372. /**
  56373. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56374. */
  56375. attachableNodes: Nullable<Array<Node>>;
  56376. /**
  56377. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56378. */
  56379. usePointerToAttachGizmos: boolean;
  56380. /**
  56381. * Utility layer that the bounding box gizmo belongs to
  56382. */
  56383. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56384. /**
  56385. * Utility layer that all gizmos besides bounding box belong to
  56386. */
  56387. get utilityLayer(): UtilityLayerRenderer;
  56388. /**
  56389. * True when the mouse pointer is hovering a gizmo mesh
  56390. */
  56391. get isHovered(): boolean;
  56392. /**
  56393. * Instatiates a gizmo manager
  56394. * @param scene the scene to overlay the gizmos on top of
  56395. * @param thickness display gizmo axis thickness
  56396. */
  56397. constructor(scene: Scene, thickness?: number);
  56398. /**
  56399. * Attaches a set of gizmos to the specified mesh
  56400. * @param mesh The mesh the gizmo's should be attached to
  56401. */
  56402. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56403. /**
  56404. * Attaches a set of gizmos to the specified node
  56405. * @param node The node the gizmo's should be attached to
  56406. */
  56407. attachToNode(node: Nullable<Node>): void;
  56408. /**
  56409. * If the position gizmo is enabled
  56410. */
  56411. set positionGizmoEnabled(value: boolean);
  56412. get positionGizmoEnabled(): boolean;
  56413. /**
  56414. * If the rotation gizmo is enabled
  56415. */
  56416. set rotationGizmoEnabled(value: boolean);
  56417. get rotationGizmoEnabled(): boolean;
  56418. /**
  56419. * If the scale gizmo is enabled
  56420. */
  56421. set scaleGizmoEnabled(value: boolean);
  56422. get scaleGizmoEnabled(): boolean;
  56423. /**
  56424. * If the boundingBox gizmo is enabled
  56425. */
  56426. set boundingBoxGizmoEnabled(value: boolean);
  56427. get boundingBoxGizmoEnabled(): boolean;
  56428. /**
  56429. * Disposes of the gizmo manager
  56430. */
  56431. dispose(): void;
  56432. }
  56433. }
  56434. declare module "babylonjs/Lights/directionalLight" {
  56435. import { Camera } from "babylonjs/Cameras/camera";
  56436. import { Scene } from "babylonjs/scene";
  56437. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56439. import { Light } from "babylonjs/Lights/light";
  56440. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56441. import { Effect } from "babylonjs/Materials/effect";
  56442. /**
  56443. * A directional light is defined by a direction (what a surprise!).
  56444. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56445. * 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.
  56446. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56447. */
  56448. export class DirectionalLight extends ShadowLight {
  56449. private _shadowFrustumSize;
  56450. /**
  56451. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56452. */
  56453. get shadowFrustumSize(): number;
  56454. /**
  56455. * Specifies a fix frustum size for the shadow generation.
  56456. */
  56457. set shadowFrustumSize(value: number);
  56458. private _shadowOrthoScale;
  56459. /**
  56460. * Gets the shadow projection scale against the optimal computed one.
  56461. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56462. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56463. */
  56464. get shadowOrthoScale(): number;
  56465. /**
  56466. * Sets the shadow projection scale against the optimal computed one.
  56467. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56468. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56469. */
  56470. set shadowOrthoScale(value: number);
  56471. /**
  56472. * Automatically compute the projection matrix to best fit (including all the casters)
  56473. * on each frame.
  56474. */
  56475. autoUpdateExtends: boolean;
  56476. /**
  56477. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56478. * on each frame. autoUpdateExtends must be set to true for this to work
  56479. */
  56480. autoCalcShadowZBounds: boolean;
  56481. private _orthoLeft;
  56482. private _orthoRight;
  56483. private _orthoTop;
  56484. private _orthoBottom;
  56485. /**
  56486. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56487. * The directional light is emitted from everywhere in the given direction.
  56488. * It can cast shadows.
  56489. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56490. * @param name The friendly name of the light
  56491. * @param direction The direction of the light
  56492. * @param scene The scene the light belongs to
  56493. */
  56494. constructor(name: string, direction: Vector3, scene: Scene);
  56495. /**
  56496. * Returns the string "DirectionalLight".
  56497. * @return The class name
  56498. */
  56499. getClassName(): string;
  56500. /**
  56501. * Returns the integer 1.
  56502. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56503. */
  56504. getTypeID(): number;
  56505. /**
  56506. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56507. * Returns the DirectionalLight Shadow projection matrix.
  56508. */
  56509. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56510. /**
  56511. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56512. * Returns the DirectionalLight Shadow projection matrix.
  56513. */
  56514. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56515. /**
  56516. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56517. * Returns the DirectionalLight Shadow projection matrix.
  56518. */
  56519. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56520. protected _buildUniformLayout(): void;
  56521. /**
  56522. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56523. * @param effect The effect to update
  56524. * @param lightIndex The index of the light in the effect to update
  56525. * @returns The directional light
  56526. */
  56527. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56528. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56529. /**
  56530. * Gets the minZ used for shadow according to both the scene and the light.
  56531. *
  56532. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56533. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56534. * @param activeCamera The camera we are returning the min for
  56535. * @returns the depth min z
  56536. */
  56537. getDepthMinZ(activeCamera: Camera): number;
  56538. /**
  56539. * Gets the maxZ used for shadow according to both the scene and the light.
  56540. *
  56541. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56542. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56543. * @param activeCamera The camera we are returning the max for
  56544. * @returns the depth max z
  56545. */
  56546. getDepthMaxZ(activeCamera: Camera): number;
  56547. /**
  56548. * Prepares the list of defines specific to the light type.
  56549. * @param defines the list of defines
  56550. * @param lightIndex defines the index of the light for the effect
  56551. */
  56552. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56553. }
  56554. }
  56555. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56556. import { Mesh } from "babylonjs/Meshes/mesh";
  56557. /**
  56558. * Class containing static functions to help procedurally build meshes
  56559. */
  56560. export class HemisphereBuilder {
  56561. /**
  56562. * Creates a hemisphere mesh
  56563. * @param name defines the name of the mesh
  56564. * @param options defines the options used to create the mesh
  56565. * @param scene defines the hosting scene
  56566. * @returns the hemisphere mesh
  56567. */
  56568. static CreateHemisphere(name: string, options: {
  56569. segments?: number;
  56570. diameter?: number;
  56571. sideOrientation?: number;
  56572. }, scene: any): Mesh;
  56573. }
  56574. }
  56575. declare module "babylonjs/Lights/spotLight" {
  56576. import { Nullable } from "babylonjs/types";
  56577. import { Scene } from "babylonjs/scene";
  56578. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56580. import { Effect } from "babylonjs/Materials/effect";
  56581. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56582. import { Light } from "babylonjs/Lights/light";
  56583. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56584. /**
  56585. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56586. * These values define a cone of light starting from the position, emitting toward the direction.
  56587. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56588. * and the exponent defines the speed of the decay of the light with distance (reach).
  56589. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56590. */
  56591. export class SpotLight extends ShadowLight {
  56592. private _angle;
  56593. private _innerAngle;
  56594. private _cosHalfAngle;
  56595. private _lightAngleScale;
  56596. private _lightAngleOffset;
  56597. /**
  56598. * Gets the cone angle of the spot light in Radians.
  56599. */
  56600. get angle(): number;
  56601. /**
  56602. * Sets the cone angle of the spot light in Radians.
  56603. */
  56604. set angle(value: number);
  56605. /**
  56606. * Only used in gltf falloff mode, this defines the angle where
  56607. * the directional falloff will start before cutting at angle which could be seen
  56608. * as outer angle.
  56609. */
  56610. get innerAngle(): number;
  56611. /**
  56612. * Only used in gltf falloff mode, this defines the angle where
  56613. * the directional falloff will start before cutting at angle which could be seen
  56614. * as outer angle.
  56615. */
  56616. set innerAngle(value: number);
  56617. private _shadowAngleScale;
  56618. /**
  56619. * Allows scaling the angle of the light for shadow generation only.
  56620. */
  56621. get shadowAngleScale(): number;
  56622. /**
  56623. * Allows scaling the angle of the light for shadow generation only.
  56624. */
  56625. set shadowAngleScale(value: number);
  56626. /**
  56627. * The light decay speed with the distance from the emission spot.
  56628. */
  56629. exponent: number;
  56630. private _projectionTextureMatrix;
  56631. /**
  56632. * Allows reading the projecton texture
  56633. */
  56634. get projectionTextureMatrix(): Matrix;
  56635. protected _projectionTextureLightNear: number;
  56636. /**
  56637. * Gets the near clip of the Spotlight for texture projection.
  56638. */
  56639. get projectionTextureLightNear(): number;
  56640. /**
  56641. * Sets the near clip of the Spotlight for texture projection.
  56642. */
  56643. set projectionTextureLightNear(value: number);
  56644. protected _projectionTextureLightFar: number;
  56645. /**
  56646. * Gets the far clip of the Spotlight for texture projection.
  56647. */
  56648. get projectionTextureLightFar(): number;
  56649. /**
  56650. * Sets the far clip of the Spotlight for texture projection.
  56651. */
  56652. set projectionTextureLightFar(value: number);
  56653. protected _projectionTextureUpDirection: Vector3;
  56654. /**
  56655. * Gets the Up vector of the Spotlight for texture projection.
  56656. */
  56657. get projectionTextureUpDirection(): Vector3;
  56658. /**
  56659. * Sets the Up vector of the Spotlight for texture projection.
  56660. */
  56661. set projectionTextureUpDirection(value: Vector3);
  56662. private _projectionTexture;
  56663. /**
  56664. * Gets the projection texture of the light.
  56665. */
  56666. get projectionTexture(): Nullable<BaseTexture>;
  56667. /**
  56668. * Sets the projection texture of the light.
  56669. */
  56670. set projectionTexture(value: Nullable<BaseTexture>);
  56671. private _projectionTextureViewLightDirty;
  56672. private _projectionTextureProjectionLightDirty;
  56673. private _projectionTextureDirty;
  56674. private _projectionTextureViewTargetVector;
  56675. private _projectionTextureViewLightMatrix;
  56676. private _projectionTextureProjectionLightMatrix;
  56677. private _projectionTextureScalingMatrix;
  56678. /**
  56679. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56680. * It can cast shadows.
  56681. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56682. * @param name The light friendly name
  56683. * @param position The position of the spot light in the scene
  56684. * @param direction The direction of the light in the scene
  56685. * @param angle The cone angle of the light in Radians
  56686. * @param exponent The light decay speed with the distance from the emission spot
  56687. * @param scene The scene the lights belongs to
  56688. */
  56689. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56690. /**
  56691. * Returns the string "SpotLight".
  56692. * @returns the class name
  56693. */
  56694. getClassName(): string;
  56695. /**
  56696. * Returns the integer 2.
  56697. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56698. */
  56699. getTypeID(): number;
  56700. /**
  56701. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56702. */
  56703. protected _setDirection(value: Vector3): void;
  56704. /**
  56705. * Overrides the position setter to recompute the projection texture view light Matrix.
  56706. */
  56707. protected _setPosition(value: Vector3): void;
  56708. /**
  56709. * 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.
  56710. * Returns the SpotLight.
  56711. */
  56712. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56713. protected _computeProjectionTextureViewLightMatrix(): void;
  56714. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56715. /**
  56716. * Main function for light texture projection matrix computing.
  56717. */
  56718. protected _computeProjectionTextureMatrix(): void;
  56719. protected _buildUniformLayout(): void;
  56720. private _computeAngleValues;
  56721. /**
  56722. * Sets the passed Effect "effect" with the Light textures.
  56723. * @param effect The effect to update
  56724. * @param lightIndex The index of the light in the effect to update
  56725. * @returns The light
  56726. */
  56727. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56728. /**
  56729. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56730. * @param effect The effect to update
  56731. * @param lightIndex The index of the light in the effect to update
  56732. * @returns The spot light
  56733. */
  56734. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56735. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56736. /**
  56737. * Disposes the light and the associated resources.
  56738. */
  56739. dispose(): void;
  56740. /**
  56741. * Prepares the list of defines specific to the light type.
  56742. * @param defines the list of defines
  56743. * @param lightIndex defines the index of the light for the effect
  56744. */
  56745. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56746. }
  56747. }
  56748. declare module "babylonjs/Gizmos/lightGizmo" {
  56749. import { Nullable } from "babylonjs/types";
  56750. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56751. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56752. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56753. import { Light } from "babylonjs/Lights/light";
  56754. import { Observable } from "babylonjs/Misc/observable";
  56755. /**
  56756. * Gizmo that enables viewing a light
  56757. */
  56758. export class LightGizmo extends Gizmo {
  56759. private _lightMesh;
  56760. private _material;
  56761. private _cachedPosition;
  56762. private _cachedForward;
  56763. private _attachedMeshParent;
  56764. private _pointerObserver;
  56765. /**
  56766. * Event that fires each time the gizmo is clicked
  56767. */
  56768. onClickedObservable: Observable<Light>;
  56769. /**
  56770. * Creates a LightGizmo
  56771. * @param gizmoLayer The utility layer the gizmo will be added to
  56772. */
  56773. constructor(gizmoLayer?: UtilityLayerRenderer);
  56774. private _light;
  56775. /**
  56776. * The light that the gizmo is attached to
  56777. */
  56778. set light(light: Nullable<Light>);
  56779. get light(): Nullable<Light>;
  56780. /**
  56781. * Gets the material used to render the light gizmo
  56782. */
  56783. get material(): StandardMaterial;
  56784. /**
  56785. * @hidden
  56786. * Updates the gizmo to match the attached mesh's position/rotation
  56787. */
  56788. protected _update(): void;
  56789. private static _Scale;
  56790. /**
  56791. * Creates the lines for a light mesh
  56792. */
  56793. private static _CreateLightLines;
  56794. /**
  56795. * Disposes of the light gizmo
  56796. */
  56797. dispose(): void;
  56798. private static _CreateHemisphericLightMesh;
  56799. private static _CreatePointLightMesh;
  56800. private static _CreateSpotLightMesh;
  56801. private static _CreateDirectionalLightMesh;
  56802. }
  56803. }
  56804. declare module "babylonjs/Gizmos/cameraGizmo" {
  56805. import { Nullable } from "babylonjs/types";
  56806. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56807. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56808. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56809. import { Camera } from "babylonjs/Cameras/camera";
  56810. import { Observable } from "babylonjs/Misc/observable";
  56811. /**
  56812. * Gizmo that enables viewing a camera
  56813. */
  56814. export class CameraGizmo extends Gizmo {
  56815. private _cameraMesh;
  56816. private _cameraLinesMesh;
  56817. private _material;
  56818. private _pointerObserver;
  56819. /**
  56820. * Event that fires each time the gizmo is clicked
  56821. */
  56822. onClickedObservable: Observable<Camera>;
  56823. /**
  56824. * Creates a CameraGizmo
  56825. * @param gizmoLayer The utility layer the gizmo will be added to
  56826. */
  56827. constructor(gizmoLayer?: UtilityLayerRenderer);
  56828. private _camera;
  56829. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  56830. get displayFrustum(): boolean;
  56831. set displayFrustum(value: boolean);
  56832. /**
  56833. * The camera that the gizmo is attached to
  56834. */
  56835. set camera(camera: Nullable<Camera>);
  56836. get camera(): Nullable<Camera>;
  56837. /**
  56838. * Gets the material used to render the camera gizmo
  56839. */
  56840. get material(): StandardMaterial;
  56841. /**
  56842. * @hidden
  56843. * Updates the gizmo to match the attached mesh's position/rotation
  56844. */
  56845. protected _update(): void;
  56846. private static _Scale;
  56847. private _invProjection;
  56848. /**
  56849. * Disposes of the camera gizmo
  56850. */
  56851. dispose(): void;
  56852. private static _CreateCameraMesh;
  56853. private static _CreateCameraFrustum;
  56854. }
  56855. }
  56856. declare module "babylonjs/Gizmos/index" {
  56857. export * from "babylonjs/Gizmos/axisDragGizmo";
  56858. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56859. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56860. export * from "babylonjs/Gizmos/gizmo";
  56861. export * from "babylonjs/Gizmos/gizmoManager";
  56862. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56863. export * from "babylonjs/Gizmos/positionGizmo";
  56864. export * from "babylonjs/Gizmos/rotationGizmo";
  56865. export * from "babylonjs/Gizmos/scaleGizmo";
  56866. export * from "babylonjs/Gizmos/lightGizmo";
  56867. export * from "babylonjs/Gizmos/cameraGizmo";
  56868. export * from "babylonjs/Gizmos/planeDragGizmo";
  56869. }
  56870. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56871. /** @hidden */
  56872. export var backgroundFragmentDeclaration: {
  56873. name: string;
  56874. shader: string;
  56875. };
  56876. }
  56877. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56878. /** @hidden */
  56879. export var backgroundUboDeclaration: {
  56880. name: string;
  56881. shader: string;
  56882. };
  56883. }
  56884. declare module "babylonjs/Shaders/background.fragment" {
  56885. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56886. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56887. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56888. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56889. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56890. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56891. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56892. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56893. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56894. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56895. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56896. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56897. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56898. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56899. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56900. /** @hidden */
  56901. export var backgroundPixelShader: {
  56902. name: string;
  56903. shader: string;
  56904. };
  56905. }
  56906. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56907. /** @hidden */
  56908. export var backgroundVertexDeclaration: {
  56909. name: string;
  56910. shader: string;
  56911. };
  56912. }
  56913. declare module "babylonjs/Shaders/background.vertex" {
  56914. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56915. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56916. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56917. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56918. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56919. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56920. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56921. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56922. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56923. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56924. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56925. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56926. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56927. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56928. /** @hidden */
  56929. export var backgroundVertexShader: {
  56930. name: string;
  56931. shader: string;
  56932. };
  56933. }
  56934. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56935. import { Nullable, int, float } from "babylonjs/types";
  56936. import { Scene } from "babylonjs/scene";
  56937. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56938. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56940. import { Mesh } from "babylonjs/Meshes/mesh";
  56941. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56942. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56943. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56944. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56945. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56946. import { Color3 } from "babylonjs/Maths/math.color";
  56947. import "babylonjs/Shaders/background.fragment";
  56948. import "babylonjs/Shaders/background.vertex";
  56949. /**
  56950. * Background material used to create an efficient environement around your scene.
  56951. */
  56952. export class BackgroundMaterial extends PushMaterial {
  56953. /**
  56954. * Standard reflectance value at parallel view angle.
  56955. */
  56956. static StandardReflectance0: number;
  56957. /**
  56958. * Standard reflectance value at grazing angle.
  56959. */
  56960. static StandardReflectance90: number;
  56961. protected _primaryColor: Color3;
  56962. /**
  56963. * Key light Color (multiply against the environement texture)
  56964. */
  56965. primaryColor: Color3;
  56966. protected __perceptualColor: Nullable<Color3>;
  56967. /**
  56968. * Experimental Internal Use Only.
  56969. *
  56970. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56971. * This acts as a helper to set the primary color to a more "human friendly" value.
  56972. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56973. * output color as close as possible from the chosen value.
  56974. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56975. * part of lighting setup.)
  56976. */
  56977. get _perceptualColor(): Nullable<Color3>;
  56978. set _perceptualColor(value: Nullable<Color3>);
  56979. protected _primaryColorShadowLevel: float;
  56980. /**
  56981. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56982. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56983. */
  56984. get primaryColorShadowLevel(): float;
  56985. set primaryColorShadowLevel(value: float);
  56986. protected _primaryColorHighlightLevel: float;
  56987. /**
  56988. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56989. * The primary color is used at the level chosen to define what the white area would look.
  56990. */
  56991. get primaryColorHighlightLevel(): float;
  56992. set primaryColorHighlightLevel(value: float);
  56993. protected _reflectionTexture: Nullable<BaseTexture>;
  56994. /**
  56995. * Reflection Texture used in the material.
  56996. * Should be author in a specific way for the best result (refer to the documentation).
  56997. */
  56998. reflectionTexture: Nullable<BaseTexture>;
  56999. protected _reflectionBlur: float;
  57000. /**
  57001. * Reflection Texture level of blur.
  57002. *
  57003. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  57004. * texture twice.
  57005. */
  57006. reflectionBlur: float;
  57007. protected _diffuseTexture: Nullable<BaseTexture>;
  57008. /**
  57009. * Diffuse Texture used in the material.
  57010. * Should be author in a specific way for the best result (refer to the documentation).
  57011. */
  57012. diffuseTexture: Nullable<BaseTexture>;
  57013. protected _shadowLights: Nullable<IShadowLight[]>;
  57014. /**
  57015. * Specify the list of lights casting shadow on the material.
  57016. * All scene shadow lights will be included if null.
  57017. */
  57018. shadowLights: Nullable<IShadowLight[]>;
  57019. protected _shadowLevel: float;
  57020. /**
  57021. * Helps adjusting the shadow to a softer level if required.
  57022. * 0 means black shadows and 1 means no shadows.
  57023. */
  57024. shadowLevel: float;
  57025. protected _sceneCenter: Vector3;
  57026. /**
  57027. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57028. * It is usually zero but might be interesting to modify according to your setup.
  57029. */
  57030. sceneCenter: Vector3;
  57031. protected _opacityFresnel: boolean;
  57032. /**
  57033. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57034. * This helps ensuring a nice transition when the camera goes under the ground.
  57035. */
  57036. opacityFresnel: boolean;
  57037. protected _reflectionFresnel: boolean;
  57038. /**
  57039. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57040. * This helps adding a mirror texture on the ground.
  57041. */
  57042. reflectionFresnel: boolean;
  57043. protected _reflectionFalloffDistance: number;
  57044. /**
  57045. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57046. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57047. */
  57048. reflectionFalloffDistance: number;
  57049. protected _reflectionAmount: number;
  57050. /**
  57051. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57052. */
  57053. reflectionAmount: number;
  57054. protected _reflectionReflectance0: number;
  57055. /**
  57056. * This specifies the weight of the reflection at grazing angle.
  57057. */
  57058. reflectionReflectance0: number;
  57059. protected _reflectionReflectance90: number;
  57060. /**
  57061. * This specifies the weight of the reflection at a perpendicular point of view.
  57062. */
  57063. reflectionReflectance90: number;
  57064. /**
  57065. * Sets the reflection reflectance fresnel values according to the default standard
  57066. * empirically know to work well :-)
  57067. */
  57068. set reflectionStandardFresnelWeight(value: number);
  57069. protected _useRGBColor: boolean;
  57070. /**
  57071. * Helps to directly use the maps channels instead of their level.
  57072. */
  57073. useRGBColor: boolean;
  57074. protected _enableNoise: boolean;
  57075. /**
  57076. * This helps reducing the banding effect that could occur on the background.
  57077. */
  57078. enableNoise: boolean;
  57079. /**
  57080. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57081. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57082. * Recommended to be keep at 1.0 except for special cases.
  57083. */
  57084. get fovMultiplier(): number;
  57085. set fovMultiplier(value: number);
  57086. private _fovMultiplier;
  57087. /**
  57088. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57089. */
  57090. useEquirectangularFOV: boolean;
  57091. private _maxSimultaneousLights;
  57092. /**
  57093. * Number of Simultaneous lights allowed on the material.
  57094. */
  57095. maxSimultaneousLights: int;
  57096. private _shadowOnly;
  57097. /**
  57098. * Make the material only render shadows
  57099. */
  57100. shadowOnly: boolean;
  57101. /**
  57102. * Default configuration related to image processing available in the Background Material.
  57103. */
  57104. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57105. /**
  57106. * Keep track of the image processing observer to allow dispose and replace.
  57107. */
  57108. private _imageProcessingObserver;
  57109. /**
  57110. * Attaches a new image processing configuration to the PBR Material.
  57111. * @param configuration (if null the scene configuration will be use)
  57112. */
  57113. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57114. /**
  57115. * Gets the image processing configuration used either in this material.
  57116. */
  57117. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57118. /**
  57119. * Sets the Default image processing configuration used either in the this material.
  57120. *
  57121. * If sets to null, the scene one is in use.
  57122. */
  57123. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57124. /**
  57125. * Gets wether the color curves effect is enabled.
  57126. */
  57127. get cameraColorCurvesEnabled(): boolean;
  57128. /**
  57129. * Sets wether the color curves effect is enabled.
  57130. */
  57131. set cameraColorCurvesEnabled(value: boolean);
  57132. /**
  57133. * Gets wether the color grading effect is enabled.
  57134. */
  57135. get cameraColorGradingEnabled(): boolean;
  57136. /**
  57137. * Gets wether the color grading effect is enabled.
  57138. */
  57139. set cameraColorGradingEnabled(value: boolean);
  57140. /**
  57141. * Gets wether tonemapping is enabled or not.
  57142. */
  57143. get cameraToneMappingEnabled(): boolean;
  57144. /**
  57145. * Sets wether tonemapping is enabled or not
  57146. */
  57147. set cameraToneMappingEnabled(value: boolean);
  57148. /**
  57149. * The camera exposure used on this material.
  57150. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57151. * This corresponds to a photographic exposure.
  57152. */
  57153. get cameraExposure(): float;
  57154. /**
  57155. * The camera exposure used on this material.
  57156. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57157. * This corresponds to a photographic exposure.
  57158. */
  57159. set cameraExposure(value: float);
  57160. /**
  57161. * Gets The camera contrast used on this material.
  57162. */
  57163. get cameraContrast(): float;
  57164. /**
  57165. * Sets The camera contrast used on this material.
  57166. */
  57167. set cameraContrast(value: float);
  57168. /**
  57169. * Gets the Color Grading 2D Lookup Texture.
  57170. */
  57171. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57172. /**
  57173. * Sets the Color Grading 2D Lookup Texture.
  57174. */
  57175. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57176. /**
  57177. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57178. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57179. * 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;
  57180. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57181. */
  57182. get cameraColorCurves(): Nullable<ColorCurves>;
  57183. /**
  57184. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57185. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57186. * 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;
  57187. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57188. */
  57189. set cameraColorCurves(value: Nullable<ColorCurves>);
  57190. /**
  57191. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57192. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57193. */
  57194. switchToBGR: boolean;
  57195. private _renderTargets;
  57196. private _reflectionControls;
  57197. private _white;
  57198. private _primaryShadowColor;
  57199. private _primaryHighlightColor;
  57200. /**
  57201. * Instantiates a Background Material in the given scene
  57202. * @param name The friendly name of the material
  57203. * @param scene The scene to add the material to
  57204. */
  57205. constructor(name: string, scene: Scene);
  57206. /**
  57207. * Gets a boolean indicating that current material needs to register RTT
  57208. */
  57209. get hasRenderTargetTextures(): boolean;
  57210. /**
  57211. * The entire material has been created in order to prevent overdraw.
  57212. * @returns false
  57213. */
  57214. needAlphaTesting(): boolean;
  57215. /**
  57216. * The entire material has been created in order to prevent overdraw.
  57217. * @returns true if blending is enable
  57218. */
  57219. needAlphaBlending(): boolean;
  57220. /**
  57221. * Checks wether the material is ready to be rendered for a given mesh.
  57222. * @param mesh The mesh to render
  57223. * @param subMesh The submesh to check against
  57224. * @param useInstances Specify wether or not the material is used with instances
  57225. * @returns true if all the dependencies are ready (Textures, Effects...)
  57226. */
  57227. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57228. /**
  57229. * Compute the primary color according to the chosen perceptual color.
  57230. */
  57231. private _computePrimaryColorFromPerceptualColor;
  57232. /**
  57233. * Compute the highlights and shadow colors according to their chosen levels.
  57234. */
  57235. private _computePrimaryColors;
  57236. /**
  57237. * Build the uniform buffer used in the material.
  57238. */
  57239. buildUniformLayout(): void;
  57240. /**
  57241. * Unbind the material.
  57242. */
  57243. unbind(): void;
  57244. /**
  57245. * Bind only the world matrix to the material.
  57246. * @param world The world matrix to bind.
  57247. */
  57248. bindOnlyWorldMatrix(world: Matrix): void;
  57249. /**
  57250. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57251. * @param world The world matrix to bind.
  57252. * @param subMesh The submesh to bind for.
  57253. */
  57254. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57255. /**
  57256. * Checks to see if a texture is used in the material.
  57257. * @param texture - Base texture to use.
  57258. * @returns - Boolean specifying if a texture is used in the material.
  57259. */
  57260. hasTexture(texture: BaseTexture): boolean;
  57261. /**
  57262. * Dispose the material.
  57263. * @param forceDisposeEffect Force disposal of the associated effect.
  57264. * @param forceDisposeTextures Force disposal of the associated textures.
  57265. */
  57266. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57267. /**
  57268. * Clones the material.
  57269. * @param name The cloned name.
  57270. * @returns The cloned material.
  57271. */
  57272. clone(name: string): BackgroundMaterial;
  57273. /**
  57274. * Serializes the current material to its JSON representation.
  57275. * @returns The JSON representation.
  57276. */
  57277. serialize(): any;
  57278. /**
  57279. * Gets the class name of the material
  57280. * @returns "BackgroundMaterial"
  57281. */
  57282. getClassName(): string;
  57283. /**
  57284. * Parse a JSON input to create back a background material.
  57285. * @param source The JSON data to parse
  57286. * @param scene The scene to create the parsed material in
  57287. * @param rootUrl The root url of the assets the material depends upon
  57288. * @returns the instantiated BackgroundMaterial.
  57289. */
  57290. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57291. }
  57292. }
  57293. declare module "babylonjs/Helpers/environmentHelper" {
  57294. import { Observable } from "babylonjs/Misc/observable";
  57295. import { Nullable } from "babylonjs/types";
  57296. import { Scene } from "babylonjs/scene";
  57297. import { Vector3 } from "babylonjs/Maths/math.vector";
  57298. import { Color3 } from "babylonjs/Maths/math.color";
  57299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57300. import { Mesh } from "babylonjs/Meshes/mesh";
  57301. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57302. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  57303. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57304. import "babylonjs/Meshes/Builders/planeBuilder";
  57305. import "babylonjs/Meshes/Builders/boxBuilder";
  57306. /**
  57307. * Represents the different options available during the creation of
  57308. * a Environment helper.
  57309. *
  57310. * This can control the default ground, skybox and image processing setup of your scene.
  57311. */
  57312. export interface IEnvironmentHelperOptions {
  57313. /**
  57314. * Specifies whether or not to create a ground.
  57315. * True by default.
  57316. */
  57317. createGround: boolean;
  57318. /**
  57319. * Specifies the ground size.
  57320. * 15 by default.
  57321. */
  57322. groundSize: number;
  57323. /**
  57324. * The texture used on the ground for the main color.
  57325. * Comes from the BabylonJS CDN by default.
  57326. *
  57327. * Remarks: Can be either a texture or a url.
  57328. */
  57329. groundTexture: string | BaseTexture;
  57330. /**
  57331. * The color mixed in the ground texture by default.
  57332. * BabylonJS clearColor by default.
  57333. */
  57334. groundColor: Color3;
  57335. /**
  57336. * Specifies the ground opacity.
  57337. * 1 by default.
  57338. */
  57339. groundOpacity: number;
  57340. /**
  57341. * Enables the ground to receive shadows.
  57342. * True by default.
  57343. */
  57344. enableGroundShadow: boolean;
  57345. /**
  57346. * Helps preventing the shadow to be fully black on the ground.
  57347. * 0.5 by default.
  57348. */
  57349. groundShadowLevel: number;
  57350. /**
  57351. * Creates a mirror texture attach to the ground.
  57352. * false by default.
  57353. */
  57354. enableGroundMirror: boolean;
  57355. /**
  57356. * Specifies the ground mirror size ratio.
  57357. * 0.3 by default as the default kernel is 64.
  57358. */
  57359. groundMirrorSizeRatio: number;
  57360. /**
  57361. * Specifies the ground mirror blur kernel size.
  57362. * 64 by default.
  57363. */
  57364. groundMirrorBlurKernel: number;
  57365. /**
  57366. * Specifies the ground mirror visibility amount.
  57367. * 1 by default
  57368. */
  57369. groundMirrorAmount: number;
  57370. /**
  57371. * Specifies the ground mirror reflectance weight.
  57372. * This uses the standard weight of the background material to setup the fresnel effect
  57373. * of the mirror.
  57374. * 1 by default.
  57375. */
  57376. groundMirrorFresnelWeight: number;
  57377. /**
  57378. * Specifies the ground mirror Falloff distance.
  57379. * This can helps reducing the size of the reflection.
  57380. * 0 by Default.
  57381. */
  57382. groundMirrorFallOffDistance: number;
  57383. /**
  57384. * Specifies the ground mirror texture type.
  57385. * Unsigned Int by Default.
  57386. */
  57387. groundMirrorTextureType: number;
  57388. /**
  57389. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57390. * the shown objects.
  57391. */
  57392. groundYBias: number;
  57393. /**
  57394. * Specifies whether or not to create a skybox.
  57395. * True by default.
  57396. */
  57397. createSkybox: boolean;
  57398. /**
  57399. * Specifies the skybox size.
  57400. * 20 by default.
  57401. */
  57402. skyboxSize: number;
  57403. /**
  57404. * The texture used on the skybox for the main color.
  57405. * Comes from the BabylonJS CDN by default.
  57406. *
  57407. * Remarks: Can be either a texture or a url.
  57408. */
  57409. skyboxTexture: string | BaseTexture;
  57410. /**
  57411. * The color mixed in the skybox texture by default.
  57412. * BabylonJS clearColor by default.
  57413. */
  57414. skyboxColor: Color3;
  57415. /**
  57416. * The background rotation around the Y axis of the scene.
  57417. * This helps aligning the key lights of your scene with the background.
  57418. * 0 by default.
  57419. */
  57420. backgroundYRotation: number;
  57421. /**
  57422. * Compute automatically the size of the elements to best fit with the scene.
  57423. */
  57424. sizeAuto: boolean;
  57425. /**
  57426. * Default position of the rootMesh if autoSize is not true.
  57427. */
  57428. rootPosition: Vector3;
  57429. /**
  57430. * Sets up the image processing in the scene.
  57431. * true by default.
  57432. */
  57433. setupImageProcessing: boolean;
  57434. /**
  57435. * The texture used as your environment texture in the scene.
  57436. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57437. *
  57438. * Remarks: Can be either a texture or a url.
  57439. */
  57440. environmentTexture: string | BaseTexture;
  57441. /**
  57442. * The value of the exposure to apply to the scene.
  57443. * 0.6 by default if setupImageProcessing is true.
  57444. */
  57445. cameraExposure: number;
  57446. /**
  57447. * The value of the contrast to apply to the scene.
  57448. * 1.6 by default if setupImageProcessing is true.
  57449. */
  57450. cameraContrast: number;
  57451. /**
  57452. * Specifies whether or not tonemapping should be enabled in the scene.
  57453. * true by default if setupImageProcessing is true.
  57454. */
  57455. toneMappingEnabled: boolean;
  57456. }
  57457. /**
  57458. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57459. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57460. * It also helps with the default setup of your imageProcessing configuration.
  57461. */
  57462. export class EnvironmentHelper {
  57463. /**
  57464. * Default ground texture URL.
  57465. */
  57466. private static _groundTextureCDNUrl;
  57467. /**
  57468. * Default skybox texture URL.
  57469. */
  57470. private static _skyboxTextureCDNUrl;
  57471. /**
  57472. * Default environment texture URL.
  57473. */
  57474. private static _environmentTextureCDNUrl;
  57475. /**
  57476. * Creates the default options for the helper.
  57477. */
  57478. private static _getDefaultOptions;
  57479. private _rootMesh;
  57480. /**
  57481. * Gets the root mesh created by the helper.
  57482. */
  57483. get rootMesh(): Mesh;
  57484. private _skybox;
  57485. /**
  57486. * Gets the skybox created by the helper.
  57487. */
  57488. get skybox(): Nullable<Mesh>;
  57489. private _skyboxTexture;
  57490. /**
  57491. * Gets the skybox texture created by the helper.
  57492. */
  57493. get skyboxTexture(): Nullable<BaseTexture>;
  57494. private _skyboxMaterial;
  57495. /**
  57496. * Gets the skybox material created by the helper.
  57497. */
  57498. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57499. private _ground;
  57500. /**
  57501. * Gets the ground mesh created by the helper.
  57502. */
  57503. get ground(): Nullable<Mesh>;
  57504. private _groundTexture;
  57505. /**
  57506. * Gets the ground texture created by the helper.
  57507. */
  57508. get groundTexture(): Nullable<BaseTexture>;
  57509. private _groundMirror;
  57510. /**
  57511. * Gets the ground mirror created by the helper.
  57512. */
  57513. get groundMirror(): Nullable<MirrorTexture>;
  57514. /**
  57515. * Gets the ground mirror render list to helps pushing the meshes
  57516. * you wish in the ground reflection.
  57517. */
  57518. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57519. private _groundMaterial;
  57520. /**
  57521. * Gets the ground material created by the helper.
  57522. */
  57523. get groundMaterial(): Nullable<BackgroundMaterial>;
  57524. /**
  57525. * Stores the creation options.
  57526. */
  57527. private readonly _scene;
  57528. private _options;
  57529. /**
  57530. * This observable will be notified with any error during the creation of the environment,
  57531. * mainly texture creation errors.
  57532. */
  57533. onErrorObservable: Observable<{
  57534. message?: string;
  57535. exception?: any;
  57536. }>;
  57537. /**
  57538. * constructor
  57539. * @param options Defines the options we want to customize the helper
  57540. * @param scene The scene to add the material to
  57541. */
  57542. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57543. /**
  57544. * Updates the background according to the new options
  57545. * @param options
  57546. */
  57547. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57548. /**
  57549. * Sets the primary color of all the available elements.
  57550. * @param color the main color to affect to the ground and the background
  57551. */
  57552. setMainColor(color: Color3): void;
  57553. /**
  57554. * Setup the image processing according to the specified options.
  57555. */
  57556. private _setupImageProcessing;
  57557. /**
  57558. * Setup the environment texture according to the specified options.
  57559. */
  57560. private _setupEnvironmentTexture;
  57561. /**
  57562. * Setup the background according to the specified options.
  57563. */
  57564. private _setupBackground;
  57565. /**
  57566. * Get the scene sizes according to the setup.
  57567. */
  57568. private _getSceneSize;
  57569. /**
  57570. * Setup the ground according to the specified options.
  57571. */
  57572. private _setupGround;
  57573. /**
  57574. * Setup the ground material according to the specified options.
  57575. */
  57576. private _setupGroundMaterial;
  57577. /**
  57578. * Setup the ground diffuse texture according to the specified options.
  57579. */
  57580. private _setupGroundDiffuseTexture;
  57581. /**
  57582. * Setup the ground mirror texture according to the specified options.
  57583. */
  57584. private _setupGroundMirrorTexture;
  57585. /**
  57586. * Setup the ground to receive the mirror texture.
  57587. */
  57588. private _setupMirrorInGroundMaterial;
  57589. /**
  57590. * Setup the skybox according to the specified options.
  57591. */
  57592. private _setupSkybox;
  57593. /**
  57594. * Setup the skybox material according to the specified options.
  57595. */
  57596. private _setupSkyboxMaterial;
  57597. /**
  57598. * Setup the skybox reflection texture according to the specified options.
  57599. */
  57600. private _setupSkyboxReflectionTexture;
  57601. private _errorHandler;
  57602. /**
  57603. * Dispose all the elements created by the Helper.
  57604. */
  57605. dispose(): void;
  57606. }
  57607. }
  57608. declare module "babylonjs/Helpers/textureDome" {
  57609. import { Scene } from "babylonjs/scene";
  57610. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57611. import { Mesh } from "babylonjs/Meshes/mesh";
  57612. import { Texture } from "babylonjs/Materials/Textures/texture";
  57613. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57614. import "babylonjs/Meshes/Builders/sphereBuilder";
  57615. import { Nullable } from "babylonjs/types";
  57616. import { Observable } from "babylonjs/Misc/observable";
  57617. /**
  57618. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  57619. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  57620. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57621. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57622. */
  57623. export abstract class TextureDome<T extends Texture> extends TransformNode {
  57624. protected onError: Nullable<(message?: string, exception?: any) => void>;
  57625. /**
  57626. * Define the source as a Monoscopic panoramic 360/180.
  57627. */
  57628. static readonly MODE_MONOSCOPIC: number;
  57629. /**
  57630. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  57631. */
  57632. static readonly MODE_TOPBOTTOM: number;
  57633. /**
  57634. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  57635. */
  57636. static readonly MODE_SIDEBYSIDE: number;
  57637. private _halfDome;
  57638. protected _useDirectMapping: boolean;
  57639. /**
  57640. * The texture being displayed on the sphere
  57641. */
  57642. protected _texture: T;
  57643. /**
  57644. * Gets the texture being displayed on the sphere
  57645. */
  57646. get texture(): T;
  57647. /**
  57648. * Sets the texture being displayed on the sphere
  57649. */
  57650. set texture(newTexture: T);
  57651. /**
  57652. * The skybox material
  57653. */
  57654. protected _material: BackgroundMaterial;
  57655. /**
  57656. * The surface used for the dome
  57657. */
  57658. protected _mesh: Mesh;
  57659. /**
  57660. * Gets the mesh used for the dome.
  57661. */
  57662. get mesh(): Mesh;
  57663. /**
  57664. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  57665. */
  57666. private _halfDomeMask;
  57667. /**
  57668. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57669. * Also see the options.resolution property.
  57670. */
  57671. get fovMultiplier(): number;
  57672. set fovMultiplier(value: number);
  57673. protected _textureMode: number;
  57674. /**
  57675. * Gets or set the current texture mode for the texture. It can be:
  57676. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57677. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57678. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57679. */
  57680. get textureMode(): number;
  57681. /**
  57682. * Sets the current texture mode for the texture. It can be:
  57683. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57684. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57685. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57686. */
  57687. set textureMode(value: number);
  57688. /**
  57689. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  57690. */
  57691. get halfDome(): boolean;
  57692. /**
  57693. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57694. */
  57695. set halfDome(enabled: boolean);
  57696. /**
  57697. * Oberserver used in Stereoscopic VR Mode.
  57698. */
  57699. private _onBeforeCameraRenderObserver;
  57700. /**
  57701. * Observable raised when an error occured while loading the 360 image
  57702. */
  57703. onLoadErrorObservable: Observable<string>;
  57704. /**
  57705. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  57706. * @param name Element's name, child elements will append suffixes for their own names.
  57707. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  57708. * @param options An object containing optional or exposed sub element properties
  57709. */
  57710. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  57711. resolution?: number;
  57712. clickToPlay?: boolean;
  57713. autoPlay?: boolean;
  57714. loop?: boolean;
  57715. size?: number;
  57716. poster?: string;
  57717. faceForward?: boolean;
  57718. useDirectMapping?: boolean;
  57719. halfDomeMode?: boolean;
  57720. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57721. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  57722. protected _changeTextureMode(value: number): void;
  57723. /**
  57724. * Releases resources associated with this node.
  57725. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57726. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57727. */
  57728. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57729. }
  57730. }
  57731. declare module "babylonjs/Helpers/photoDome" {
  57732. import { Scene } from "babylonjs/scene";
  57733. import { Texture } from "babylonjs/Materials/Textures/texture";
  57734. import { TextureDome } from "babylonjs/Helpers/textureDome";
  57735. /**
  57736. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57737. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57738. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57739. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57740. */
  57741. export class PhotoDome extends TextureDome<Texture> {
  57742. /**
  57743. * Define the image as a Monoscopic panoramic 360 image.
  57744. */
  57745. static readonly MODE_MONOSCOPIC: number;
  57746. /**
  57747. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57748. */
  57749. static readonly MODE_TOPBOTTOM: number;
  57750. /**
  57751. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57752. */
  57753. static readonly MODE_SIDEBYSIDE: number;
  57754. /**
  57755. * Gets or sets the texture being displayed on the sphere
  57756. */
  57757. get photoTexture(): Texture;
  57758. /**
  57759. * sets the texture being displayed on the sphere
  57760. */
  57761. set photoTexture(value: Texture);
  57762. /**
  57763. * Gets the current video mode for the video. It can be:
  57764. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57765. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57766. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57767. */
  57768. get imageMode(): number;
  57769. /**
  57770. * Sets the current video mode for the video. It can be:
  57771. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57772. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57773. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57774. */
  57775. set imageMode(value: number);
  57776. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  57777. }
  57778. }
  57779. declare module "babylonjs/Misc/rgbdTextureTools" {
  57780. import "babylonjs/Shaders/rgbdDecode.fragment";
  57781. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57782. import { Texture } from "babylonjs/Materials/Textures/texture";
  57783. /**
  57784. * Class used to host RGBD texture specific utilities
  57785. */
  57786. export class RGBDTextureTools {
  57787. /**
  57788. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57789. * @param texture the texture to expand.
  57790. */
  57791. static ExpandRGBDTexture(texture: Texture): void;
  57792. }
  57793. }
  57794. declare module "babylonjs/Misc/brdfTextureTools" {
  57795. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57796. import { Scene } from "babylonjs/scene";
  57797. /**
  57798. * Class used to host texture specific utilities
  57799. */
  57800. export class BRDFTextureTools {
  57801. /**
  57802. * Prevents texture cache collision
  57803. */
  57804. private static _instanceNumber;
  57805. /**
  57806. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57807. * @param scene defines the hosting scene
  57808. * @returns the environment BRDF texture
  57809. */
  57810. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57811. private static _environmentBRDFBase64Texture;
  57812. }
  57813. }
  57814. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57815. import { Nullable } from "babylonjs/types";
  57816. import { Color3 } from "babylonjs/Maths/math.color";
  57817. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57818. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57819. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57820. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57821. import { Engine } from "babylonjs/Engines/engine";
  57822. import { Scene } from "babylonjs/scene";
  57823. /**
  57824. * @hidden
  57825. */
  57826. export interface IMaterialClearCoatDefines {
  57827. CLEARCOAT: boolean;
  57828. CLEARCOAT_DEFAULTIOR: boolean;
  57829. CLEARCOAT_TEXTURE: boolean;
  57830. CLEARCOAT_TEXTUREDIRECTUV: number;
  57831. CLEARCOAT_BUMP: boolean;
  57832. CLEARCOAT_BUMPDIRECTUV: number;
  57833. CLEARCOAT_REMAP_F0: boolean;
  57834. CLEARCOAT_TINT: boolean;
  57835. CLEARCOAT_TINT_TEXTURE: boolean;
  57836. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57837. /** @hidden */
  57838. _areTexturesDirty: boolean;
  57839. }
  57840. /**
  57841. * Define the code related to the clear coat parameters of the pbr material.
  57842. */
  57843. export class PBRClearCoatConfiguration {
  57844. /**
  57845. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57846. * The default fits with a polyurethane material.
  57847. */
  57848. private static readonly _DefaultIndexOfRefraction;
  57849. private _isEnabled;
  57850. /**
  57851. * Defines if the clear coat is enabled in the material.
  57852. */
  57853. isEnabled: boolean;
  57854. /**
  57855. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57856. */
  57857. intensity: number;
  57858. /**
  57859. * Defines the clear coat layer roughness.
  57860. */
  57861. roughness: number;
  57862. private _indexOfRefraction;
  57863. /**
  57864. * Defines the index of refraction of the clear coat.
  57865. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57866. * The default fits with a polyurethane material.
  57867. * Changing the default value is more performance intensive.
  57868. */
  57869. indexOfRefraction: number;
  57870. private _texture;
  57871. /**
  57872. * Stores the clear coat values in a texture.
  57873. */
  57874. texture: Nullable<BaseTexture>;
  57875. private _remapF0OnInterfaceChange;
  57876. /**
  57877. * Defines if the F0 value should be remapped to account for the interface change in the material.
  57878. */
  57879. remapF0OnInterfaceChange: boolean;
  57880. private _bumpTexture;
  57881. /**
  57882. * Define the clear coat specific bump texture.
  57883. */
  57884. bumpTexture: Nullable<BaseTexture>;
  57885. private _isTintEnabled;
  57886. /**
  57887. * Defines if the clear coat tint is enabled in the material.
  57888. */
  57889. isTintEnabled: boolean;
  57890. /**
  57891. * Defines the clear coat tint of the material.
  57892. * This is only use if tint is enabled
  57893. */
  57894. tintColor: Color3;
  57895. /**
  57896. * Defines the distance at which the tint color should be found in the
  57897. * clear coat media.
  57898. * This is only use if tint is enabled
  57899. */
  57900. tintColorAtDistance: number;
  57901. /**
  57902. * Defines the clear coat layer thickness.
  57903. * This is only use if tint is enabled
  57904. */
  57905. tintThickness: number;
  57906. private _tintTexture;
  57907. /**
  57908. * Stores the clear tint values in a texture.
  57909. * rgb is tint
  57910. * a is a thickness factor
  57911. */
  57912. tintTexture: Nullable<BaseTexture>;
  57913. /** @hidden */
  57914. private _internalMarkAllSubMeshesAsTexturesDirty;
  57915. /** @hidden */
  57916. _markAllSubMeshesAsTexturesDirty(): void;
  57917. /**
  57918. * Instantiate a new istance of clear coat configuration.
  57919. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57920. */
  57921. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57922. /**
  57923. * Gets wehter the submesh is ready to be used or not.
  57924. * @param defines the list of "defines" to update.
  57925. * @param scene defines the scene the material belongs to.
  57926. * @param engine defines the engine the material belongs to.
  57927. * @param disableBumpMap defines wether the material disables bump or not.
  57928. * @returns - boolean indicating that the submesh is ready or not.
  57929. */
  57930. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57931. /**
  57932. * Checks to see if a texture is used in the material.
  57933. * @param defines the list of "defines" to update.
  57934. * @param scene defines the scene to the material belongs to.
  57935. */
  57936. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57937. /**
  57938. * Binds the material data.
  57939. * @param uniformBuffer defines the Uniform buffer to fill in.
  57940. * @param scene defines the scene the material belongs to.
  57941. * @param engine defines the engine the material belongs to.
  57942. * @param disableBumpMap defines wether the material disables bump or not.
  57943. * @param isFrozen defines wether the material is frozen or not.
  57944. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57945. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57946. */
  57947. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57948. /**
  57949. * Checks to see if a texture is used in the material.
  57950. * @param texture - Base texture to use.
  57951. * @returns - Boolean specifying if a texture is used in the material.
  57952. */
  57953. hasTexture(texture: BaseTexture): boolean;
  57954. /**
  57955. * Returns an array of the actively used textures.
  57956. * @param activeTextures Array of BaseTextures
  57957. */
  57958. getActiveTextures(activeTextures: BaseTexture[]): void;
  57959. /**
  57960. * Returns the animatable textures.
  57961. * @param animatables Array of animatable textures.
  57962. */
  57963. getAnimatables(animatables: IAnimatable[]): void;
  57964. /**
  57965. * Disposes the resources of the material.
  57966. * @param forceDisposeTextures - Forces the disposal of all textures.
  57967. */
  57968. dispose(forceDisposeTextures?: boolean): void;
  57969. /**
  57970. * Get the current class name of the texture useful for serialization or dynamic coding.
  57971. * @returns "PBRClearCoatConfiguration"
  57972. */
  57973. getClassName(): string;
  57974. /**
  57975. * Add fallbacks to the effect fallbacks list.
  57976. * @param defines defines the Base texture to use.
  57977. * @param fallbacks defines the current fallback list.
  57978. * @param currentRank defines the current fallback rank.
  57979. * @returns the new fallback rank.
  57980. */
  57981. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57982. /**
  57983. * Add the required uniforms to the current list.
  57984. * @param uniforms defines the current uniform list.
  57985. */
  57986. static AddUniforms(uniforms: string[]): void;
  57987. /**
  57988. * Add the required samplers to the current list.
  57989. * @param samplers defines the current sampler list.
  57990. */
  57991. static AddSamplers(samplers: string[]): void;
  57992. /**
  57993. * Add the required uniforms to the current buffer.
  57994. * @param uniformBuffer defines the current uniform buffer.
  57995. */
  57996. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57997. /**
  57998. * Makes a duplicate of the current configuration into another one.
  57999. * @param clearCoatConfiguration define the config where to copy the info
  58000. */
  58001. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  58002. /**
  58003. * Serializes this clear coat configuration.
  58004. * @returns - An object with the serialized config.
  58005. */
  58006. serialize(): any;
  58007. /**
  58008. * Parses a anisotropy Configuration from a serialized object.
  58009. * @param source - Serialized object.
  58010. * @param scene Defines the scene we are parsing for
  58011. * @param rootUrl Defines the rootUrl to load from
  58012. */
  58013. parse(source: any, scene: Scene, rootUrl: string): void;
  58014. }
  58015. }
  58016. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  58017. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58019. import { Vector2 } from "babylonjs/Maths/math.vector";
  58020. import { Scene } from "babylonjs/scene";
  58021. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58022. import { Nullable } from "babylonjs/types";
  58023. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58024. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58025. /**
  58026. * @hidden
  58027. */
  58028. export interface IMaterialAnisotropicDefines {
  58029. ANISOTROPIC: boolean;
  58030. ANISOTROPIC_TEXTURE: boolean;
  58031. ANISOTROPIC_TEXTUREDIRECTUV: number;
  58032. MAINUV1: boolean;
  58033. _areTexturesDirty: boolean;
  58034. _needUVs: boolean;
  58035. }
  58036. /**
  58037. * Define the code related to the anisotropic parameters of the pbr material.
  58038. */
  58039. export class PBRAnisotropicConfiguration {
  58040. private _isEnabled;
  58041. /**
  58042. * Defines if the anisotropy is enabled in the material.
  58043. */
  58044. isEnabled: boolean;
  58045. /**
  58046. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  58047. */
  58048. intensity: number;
  58049. /**
  58050. * Defines if the effect is along the tangents, bitangents or in between.
  58051. * By default, the effect is "strectching" the highlights along the tangents.
  58052. */
  58053. direction: Vector2;
  58054. private _texture;
  58055. /**
  58056. * Stores the anisotropy values in a texture.
  58057. * rg is direction (like normal from -1 to 1)
  58058. * b is a intensity
  58059. */
  58060. texture: Nullable<BaseTexture>;
  58061. /** @hidden */
  58062. private _internalMarkAllSubMeshesAsTexturesDirty;
  58063. /** @hidden */
  58064. _markAllSubMeshesAsTexturesDirty(): void;
  58065. /**
  58066. * Instantiate a new istance of anisotropy configuration.
  58067. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58068. */
  58069. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58070. /**
  58071. * Specifies that the submesh is ready to be used.
  58072. * @param defines the list of "defines" to update.
  58073. * @param scene defines the scene the material belongs to.
  58074. * @returns - boolean indicating that the submesh is ready or not.
  58075. */
  58076. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  58077. /**
  58078. * Checks to see if a texture is used in the material.
  58079. * @param defines the list of "defines" to update.
  58080. * @param mesh the mesh we are preparing the defines for.
  58081. * @param scene defines the scene the material belongs to.
  58082. */
  58083. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  58084. /**
  58085. * Binds the material data.
  58086. * @param uniformBuffer defines the Uniform buffer to fill in.
  58087. * @param scene defines the scene the material belongs to.
  58088. * @param isFrozen defines wether the material is frozen or not.
  58089. */
  58090. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58091. /**
  58092. * Checks to see if a texture is used in the material.
  58093. * @param texture - Base texture to use.
  58094. * @returns - Boolean specifying if a texture is used in the material.
  58095. */
  58096. hasTexture(texture: BaseTexture): boolean;
  58097. /**
  58098. * Returns an array of the actively used textures.
  58099. * @param activeTextures Array of BaseTextures
  58100. */
  58101. getActiveTextures(activeTextures: BaseTexture[]): void;
  58102. /**
  58103. * Returns the animatable textures.
  58104. * @param animatables Array of animatable textures.
  58105. */
  58106. getAnimatables(animatables: IAnimatable[]): void;
  58107. /**
  58108. * Disposes the resources of the material.
  58109. * @param forceDisposeTextures - Forces the disposal of all textures.
  58110. */
  58111. dispose(forceDisposeTextures?: boolean): void;
  58112. /**
  58113. * Get the current class name of the texture useful for serialization or dynamic coding.
  58114. * @returns "PBRAnisotropicConfiguration"
  58115. */
  58116. getClassName(): string;
  58117. /**
  58118. * Add fallbacks to the effect fallbacks list.
  58119. * @param defines defines the Base texture to use.
  58120. * @param fallbacks defines the current fallback list.
  58121. * @param currentRank defines the current fallback rank.
  58122. * @returns the new fallback rank.
  58123. */
  58124. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58125. /**
  58126. * Add the required uniforms to the current list.
  58127. * @param uniforms defines the current uniform list.
  58128. */
  58129. static AddUniforms(uniforms: string[]): void;
  58130. /**
  58131. * Add the required uniforms to the current buffer.
  58132. * @param uniformBuffer defines the current uniform buffer.
  58133. */
  58134. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58135. /**
  58136. * Add the required samplers to the current list.
  58137. * @param samplers defines the current sampler list.
  58138. */
  58139. static AddSamplers(samplers: string[]): void;
  58140. /**
  58141. * Makes a duplicate of the current configuration into another one.
  58142. * @param anisotropicConfiguration define the config where to copy the info
  58143. */
  58144. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  58145. /**
  58146. * Serializes this anisotropy configuration.
  58147. * @returns - An object with the serialized config.
  58148. */
  58149. serialize(): any;
  58150. /**
  58151. * Parses a anisotropy Configuration from a serialized object.
  58152. * @param source - Serialized object.
  58153. * @param scene Defines the scene we are parsing for
  58154. * @param rootUrl Defines the rootUrl to load from
  58155. */
  58156. parse(source: any, scene: Scene, rootUrl: string): void;
  58157. }
  58158. }
  58159. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  58160. import { Scene } from "babylonjs/scene";
  58161. /**
  58162. * @hidden
  58163. */
  58164. export interface IMaterialBRDFDefines {
  58165. BRDF_V_HEIGHT_CORRELATED: boolean;
  58166. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58167. SPHERICAL_HARMONICS: boolean;
  58168. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58169. /** @hidden */
  58170. _areMiscDirty: boolean;
  58171. }
  58172. /**
  58173. * Define the code related to the BRDF parameters of the pbr material.
  58174. */
  58175. export class PBRBRDFConfiguration {
  58176. /**
  58177. * Default value used for the energy conservation.
  58178. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58179. */
  58180. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  58181. /**
  58182. * Default value used for the Smith Visibility Height Correlated mode.
  58183. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58184. */
  58185. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  58186. /**
  58187. * Default value used for the IBL diffuse part.
  58188. * This can help switching back to the polynomials mode globally which is a tiny bit
  58189. * less GPU intensive at the drawback of a lower quality.
  58190. */
  58191. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  58192. /**
  58193. * Default value used for activating energy conservation for the specular workflow.
  58194. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58195. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58196. */
  58197. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  58198. private _useEnergyConservation;
  58199. /**
  58200. * Defines if the material uses energy conservation.
  58201. */
  58202. useEnergyConservation: boolean;
  58203. private _useSmithVisibilityHeightCorrelated;
  58204. /**
  58205. * LEGACY Mode set to false
  58206. * Defines if the material uses height smith correlated visibility term.
  58207. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  58208. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  58209. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  58210. * Not relying on height correlated will also disable energy conservation.
  58211. */
  58212. useSmithVisibilityHeightCorrelated: boolean;
  58213. private _useSphericalHarmonics;
  58214. /**
  58215. * LEGACY Mode set to false
  58216. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  58217. * diffuse part of the IBL.
  58218. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  58219. * to the ground truth.
  58220. */
  58221. useSphericalHarmonics: boolean;
  58222. private _useSpecularGlossinessInputEnergyConservation;
  58223. /**
  58224. * Defines if the material uses energy conservation, when the specular workflow is active.
  58225. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58226. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58227. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  58228. */
  58229. useSpecularGlossinessInputEnergyConservation: boolean;
  58230. /** @hidden */
  58231. private _internalMarkAllSubMeshesAsMiscDirty;
  58232. /** @hidden */
  58233. _markAllSubMeshesAsMiscDirty(): void;
  58234. /**
  58235. * Instantiate a new istance of clear coat configuration.
  58236. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  58237. */
  58238. constructor(markAllSubMeshesAsMiscDirty: () => void);
  58239. /**
  58240. * Checks to see if a texture is used in the material.
  58241. * @param defines the list of "defines" to update.
  58242. */
  58243. prepareDefines(defines: IMaterialBRDFDefines): void;
  58244. /**
  58245. * Get the current class name of the texture useful for serialization or dynamic coding.
  58246. * @returns "PBRClearCoatConfiguration"
  58247. */
  58248. getClassName(): string;
  58249. /**
  58250. * Makes a duplicate of the current configuration into another one.
  58251. * @param brdfConfiguration define the config where to copy the info
  58252. */
  58253. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  58254. /**
  58255. * Serializes this BRDF configuration.
  58256. * @returns - An object with the serialized config.
  58257. */
  58258. serialize(): any;
  58259. /**
  58260. * Parses a anisotropy Configuration from a serialized object.
  58261. * @param source - Serialized object.
  58262. * @param scene Defines the scene we are parsing for
  58263. * @param rootUrl Defines the rootUrl to load from
  58264. */
  58265. parse(source: any, scene: Scene, rootUrl: string): void;
  58266. }
  58267. }
  58268. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  58269. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58270. import { Color3 } from "babylonjs/Maths/math.color";
  58271. import { Scene } from "babylonjs/scene";
  58272. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58273. import { Nullable } from "babylonjs/types";
  58274. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58275. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58276. /**
  58277. * @hidden
  58278. */
  58279. export interface IMaterialSheenDefines {
  58280. SHEEN: boolean;
  58281. SHEEN_TEXTURE: boolean;
  58282. SHEEN_TEXTUREDIRECTUV: number;
  58283. SHEEN_LINKWITHALBEDO: boolean;
  58284. SHEEN_ROUGHNESS: boolean;
  58285. SHEEN_ALBEDOSCALING: boolean;
  58286. /** @hidden */
  58287. _areTexturesDirty: boolean;
  58288. }
  58289. /**
  58290. * Define the code related to the Sheen parameters of the pbr material.
  58291. */
  58292. export class PBRSheenConfiguration {
  58293. private _isEnabled;
  58294. /**
  58295. * Defines if the material uses sheen.
  58296. */
  58297. isEnabled: boolean;
  58298. private _linkSheenWithAlbedo;
  58299. /**
  58300. * Defines if the sheen is linked to the sheen color.
  58301. */
  58302. linkSheenWithAlbedo: boolean;
  58303. /**
  58304. * Defines the sheen intensity.
  58305. */
  58306. intensity: number;
  58307. /**
  58308. * Defines the sheen color.
  58309. */
  58310. color: Color3;
  58311. private _texture;
  58312. /**
  58313. * Stores the sheen tint values in a texture.
  58314. * rgb is tint
  58315. * a is a intensity or roughness if roughness has been defined
  58316. */
  58317. texture: Nullable<BaseTexture>;
  58318. private _roughness;
  58319. /**
  58320. * Defines the sheen roughness.
  58321. * It is not taken into account if linkSheenWithAlbedo is true.
  58322. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  58323. */
  58324. roughness: Nullable<number>;
  58325. private _albedoScaling;
  58326. /**
  58327. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  58328. * It allows the strength of the sheen effect to not depend on the base color of the material,
  58329. * making it easier to setup and tweak the effect
  58330. */
  58331. albedoScaling: boolean;
  58332. /** @hidden */
  58333. private _internalMarkAllSubMeshesAsTexturesDirty;
  58334. /** @hidden */
  58335. _markAllSubMeshesAsTexturesDirty(): void;
  58336. /**
  58337. * Instantiate a new istance of clear coat configuration.
  58338. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58339. */
  58340. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58341. /**
  58342. * Specifies that the submesh is ready to be used.
  58343. * @param defines the list of "defines" to update.
  58344. * @param scene defines the scene the material belongs to.
  58345. * @returns - boolean indicating that the submesh is ready or not.
  58346. */
  58347. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  58348. /**
  58349. * Checks to see if a texture is used in the material.
  58350. * @param defines the list of "defines" to update.
  58351. * @param scene defines the scene the material belongs to.
  58352. */
  58353. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  58354. /**
  58355. * Binds the material data.
  58356. * @param uniformBuffer defines the Uniform buffer to fill in.
  58357. * @param scene defines the scene the material belongs to.
  58358. * @param isFrozen defines wether the material is frozen or not.
  58359. */
  58360. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58361. /**
  58362. * Checks to see if a texture is used in the material.
  58363. * @param texture - Base texture to use.
  58364. * @returns - Boolean specifying if a texture is used in the material.
  58365. */
  58366. hasTexture(texture: BaseTexture): boolean;
  58367. /**
  58368. * Returns an array of the actively used textures.
  58369. * @param activeTextures Array of BaseTextures
  58370. */
  58371. getActiveTextures(activeTextures: BaseTexture[]): void;
  58372. /**
  58373. * Returns the animatable textures.
  58374. * @param animatables Array of animatable textures.
  58375. */
  58376. getAnimatables(animatables: IAnimatable[]): void;
  58377. /**
  58378. * Disposes the resources of the material.
  58379. * @param forceDisposeTextures - Forces the disposal of all textures.
  58380. */
  58381. dispose(forceDisposeTextures?: boolean): void;
  58382. /**
  58383. * Get the current class name of the texture useful for serialization or dynamic coding.
  58384. * @returns "PBRSheenConfiguration"
  58385. */
  58386. getClassName(): string;
  58387. /**
  58388. * Add fallbacks to the effect fallbacks list.
  58389. * @param defines defines the Base texture to use.
  58390. * @param fallbacks defines the current fallback list.
  58391. * @param currentRank defines the current fallback rank.
  58392. * @returns the new fallback rank.
  58393. */
  58394. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58395. /**
  58396. * Add the required uniforms to the current list.
  58397. * @param uniforms defines the current uniform list.
  58398. */
  58399. static AddUniforms(uniforms: string[]): void;
  58400. /**
  58401. * Add the required uniforms to the current buffer.
  58402. * @param uniformBuffer defines the current uniform buffer.
  58403. */
  58404. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58405. /**
  58406. * Add the required samplers to the current list.
  58407. * @param samplers defines the current sampler list.
  58408. */
  58409. static AddSamplers(samplers: string[]): void;
  58410. /**
  58411. * Makes a duplicate of the current configuration into another one.
  58412. * @param sheenConfiguration define the config where to copy the info
  58413. */
  58414. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  58415. /**
  58416. * Serializes this BRDF configuration.
  58417. * @returns - An object with the serialized config.
  58418. */
  58419. serialize(): any;
  58420. /**
  58421. * Parses a anisotropy Configuration from a serialized object.
  58422. * @param source - Serialized object.
  58423. * @param scene Defines the scene we are parsing for
  58424. * @param rootUrl Defines the rootUrl to load from
  58425. */
  58426. parse(source: any, scene: Scene, rootUrl: string): void;
  58427. }
  58428. }
  58429. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  58430. import { Nullable } from "babylonjs/types";
  58431. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58432. import { Color3 } from "babylonjs/Maths/math.color";
  58433. import { SmartArray } from "babylonjs/Misc/smartArray";
  58434. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58435. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58436. import { Effect } from "babylonjs/Materials/effect";
  58437. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58438. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58439. import { Engine } from "babylonjs/Engines/engine";
  58440. import { Scene } from "babylonjs/scene";
  58441. /**
  58442. * @hidden
  58443. */
  58444. export interface IMaterialSubSurfaceDefines {
  58445. SUBSURFACE: boolean;
  58446. SS_REFRACTION: boolean;
  58447. SS_TRANSLUCENCY: boolean;
  58448. SS_SCATTERING: boolean;
  58449. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58450. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58451. SS_REFRACTIONMAP_3D: boolean;
  58452. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58453. SS_LODINREFRACTIONALPHA: boolean;
  58454. SS_GAMMAREFRACTION: boolean;
  58455. SS_RGBDREFRACTION: boolean;
  58456. SS_LINEARSPECULARREFRACTION: boolean;
  58457. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58458. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58459. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58460. /** @hidden */
  58461. _areTexturesDirty: boolean;
  58462. }
  58463. /**
  58464. * Define the code related to the sub surface parameters of the pbr material.
  58465. */
  58466. export class PBRSubSurfaceConfiguration {
  58467. private _isRefractionEnabled;
  58468. /**
  58469. * Defines if the refraction is enabled in the material.
  58470. */
  58471. isRefractionEnabled: boolean;
  58472. private _isTranslucencyEnabled;
  58473. /**
  58474. * Defines if the translucency is enabled in the material.
  58475. */
  58476. isTranslucencyEnabled: boolean;
  58477. private _isScatteringEnabled;
  58478. /**
  58479. * Defines if the sub surface scattering is enabled in the material.
  58480. */
  58481. isScatteringEnabled: boolean;
  58482. private _scatteringDiffusionProfileIndex;
  58483. /**
  58484. * Diffusion profile for subsurface scattering.
  58485. * Useful for better scattering in the skins or foliages.
  58486. */
  58487. get scatteringDiffusionProfile(): Nullable<Color3>;
  58488. set scatteringDiffusionProfile(c: Nullable<Color3>);
  58489. /**
  58490. * Defines the refraction intensity of the material.
  58491. * The refraction when enabled replaces the Diffuse part of the material.
  58492. * The intensity helps transitionning between diffuse and refraction.
  58493. */
  58494. refractionIntensity: number;
  58495. /**
  58496. * Defines the translucency intensity of the material.
  58497. * When translucency has been enabled, this defines how much of the "translucency"
  58498. * is addded to the diffuse part of the material.
  58499. */
  58500. translucencyIntensity: number;
  58501. /**
  58502. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  58503. */
  58504. useAlbedoToTintRefraction: boolean;
  58505. private _thicknessTexture;
  58506. /**
  58507. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  58508. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  58509. * 0 would mean minimumThickness
  58510. * 1 would mean maximumThickness
  58511. * The other channels might be use as a mask to vary the different effects intensity.
  58512. */
  58513. thicknessTexture: Nullable<BaseTexture>;
  58514. private _refractionTexture;
  58515. /**
  58516. * Defines the texture to use for refraction.
  58517. */
  58518. refractionTexture: Nullable<BaseTexture>;
  58519. private _indexOfRefraction;
  58520. /**
  58521. * Index of refraction of the material base layer.
  58522. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58523. *
  58524. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58525. *
  58526. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58527. */
  58528. indexOfRefraction: number;
  58529. private _volumeIndexOfRefraction;
  58530. /**
  58531. * Index of refraction of the material's volume.
  58532. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58533. *
  58534. * This ONLY impacts refraction. If not provided or given a non-valid value,
  58535. * the volume will use the same IOR as the surface.
  58536. */
  58537. get volumeIndexOfRefraction(): number;
  58538. set volumeIndexOfRefraction(value: number);
  58539. private _invertRefractionY;
  58540. /**
  58541. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58542. */
  58543. invertRefractionY: boolean;
  58544. private _linkRefractionWithTransparency;
  58545. /**
  58546. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58547. * Materials half opaque for instance using refraction could benefit from this control.
  58548. */
  58549. linkRefractionWithTransparency: boolean;
  58550. /**
  58551. * Defines the minimum thickness stored in the thickness map.
  58552. * If no thickness map is defined, this value will be used to simulate thickness.
  58553. */
  58554. minimumThickness: number;
  58555. /**
  58556. * Defines the maximum thickness stored in the thickness map.
  58557. */
  58558. maximumThickness: number;
  58559. /**
  58560. * Defines the volume tint of the material.
  58561. * This is used for both translucency and scattering.
  58562. */
  58563. tintColor: Color3;
  58564. /**
  58565. * Defines the distance at which the tint color should be found in the media.
  58566. * This is used for refraction only.
  58567. */
  58568. tintColorAtDistance: number;
  58569. /**
  58570. * Defines how far each channel transmit through the media.
  58571. * It is defined as a color to simplify it selection.
  58572. */
  58573. diffusionDistance: Color3;
  58574. private _useMaskFromThicknessTexture;
  58575. /**
  58576. * Stores the intensity of the different subsurface effects in the thickness texture.
  58577. * * the green channel is the translucency intensity.
  58578. * * the blue channel is the scattering intensity.
  58579. * * the alpha channel is the refraction intensity.
  58580. */
  58581. useMaskFromThicknessTexture: boolean;
  58582. private _scene;
  58583. /** @hidden */
  58584. private _internalMarkAllSubMeshesAsTexturesDirty;
  58585. private _internalMarkScenePrePassDirty;
  58586. /** @hidden */
  58587. _markAllSubMeshesAsTexturesDirty(): void;
  58588. /** @hidden */
  58589. _markScenePrePassDirty(): void;
  58590. /**
  58591. * Instantiate a new istance of sub surface configuration.
  58592. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58593. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  58594. * @param scene The scene
  58595. */
  58596. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  58597. /**
  58598. * Gets wehter the submesh is ready to be used or not.
  58599. * @param defines the list of "defines" to update.
  58600. * @param scene defines the scene the material belongs to.
  58601. * @returns - boolean indicating that the submesh is ready or not.
  58602. */
  58603. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  58604. /**
  58605. * Checks to see if a texture is used in the material.
  58606. * @param defines the list of "defines" to update.
  58607. * @param scene defines the scene to the material belongs to.
  58608. */
  58609. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  58610. /**
  58611. * Binds the material data.
  58612. * @param uniformBuffer defines the Uniform buffer to fill in.
  58613. * @param scene defines the scene the material belongs to.
  58614. * @param engine defines the engine the material belongs to.
  58615. * @param isFrozen defines whether the material is frozen or not.
  58616. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  58617. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  58618. */
  58619. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  58620. /**
  58621. * Unbinds the material from the mesh.
  58622. * @param activeEffect defines the effect that should be unbound from.
  58623. * @returns true if unbound, otherwise false
  58624. */
  58625. unbind(activeEffect: Effect): boolean;
  58626. /**
  58627. * Returns the texture used for refraction or null if none is used.
  58628. * @param scene defines the scene the material belongs to.
  58629. * @returns - Refraction texture if present. If no refraction texture and refraction
  58630. * is linked with transparency, returns environment texture. Otherwise, returns null.
  58631. */
  58632. private _getRefractionTexture;
  58633. /**
  58634. * Returns true if alpha blending should be disabled.
  58635. */
  58636. get disableAlphaBlending(): boolean;
  58637. /**
  58638. * Fills the list of render target textures.
  58639. * @param renderTargets the list of render targets to update
  58640. */
  58641. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  58642. /**
  58643. * Checks to see if a texture is used in the material.
  58644. * @param texture - Base texture to use.
  58645. * @returns - Boolean specifying if a texture is used in the material.
  58646. */
  58647. hasTexture(texture: BaseTexture): boolean;
  58648. /**
  58649. * Gets a boolean indicating that current material needs to register RTT
  58650. * @returns true if this uses a render target otherwise false.
  58651. */
  58652. hasRenderTargetTextures(): boolean;
  58653. /**
  58654. * Returns an array of the actively used textures.
  58655. * @param activeTextures Array of BaseTextures
  58656. */
  58657. getActiveTextures(activeTextures: BaseTexture[]): void;
  58658. /**
  58659. * Returns the animatable textures.
  58660. * @param animatables Array of animatable textures.
  58661. */
  58662. getAnimatables(animatables: IAnimatable[]): void;
  58663. /**
  58664. * Disposes the resources of the material.
  58665. * @param forceDisposeTextures - Forces the disposal of all textures.
  58666. */
  58667. dispose(forceDisposeTextures?: boolean): void;
  58668. /**
  58669. * Get the current class name of the texture useful for serialization or dynamic coding.
  58670. * @returns "PBRSubSurfaceConfiguration"
  58671. */
  58672. getClassName(): string;
  58673. /**
  58674. * Add fallbacks to the effect fallbacks list.
  58675. * @param defines defines the Base texture to use.
  58676. * @param fallbacks defines the current fallback list.
  58677. * @param currentRank defines the current fallback rank.
  58678. * @returns the new fallback rank.
  58679. */
  58680. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58681. /**
  58682. * Add the required uniforms to the current list.
  58683. * @param uniforms defines the current uniform list.
  58684. */
  58685. static AddUniforms(uniforms: string[]): void;
  58686. /**
  58687. * Add the required samplers to the current list.
  58688. * @param samplers defines the current sampler list.
  58689. */
  58690. static AddSamplers(samplers: string[]): void;
  58691. /**
  58692. * Add the required uniforms to the current buffer.
  58693. * @param uniformBuffer defines the current uniform buffer.
  58694. */
  58695. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58696. /**
  58697. * Makes a duplicate of the current configuration into another one.
  58698. * @param configuration define the config where to copy the info
  58699. */
  58700. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58701. /**
  58702. * Serializes this Sub Surface configuration.
  58703. * @returns - An object with the serialized config.
  58704. */
  58705. serialize(): any;
  58706. /**
  58707. * Parses a anisotropy Configuration from a serialized object.
  58708. * @param source - Serialized object.
  58709. * @param scene Defines the scene we are parsing for
  58710. * @param rootUrl Defines the rootUrl to load from
  58711. */
  58712. parse(source: any, scene: Scene, rootUrl: string): void;
  58713. }
  58714. }
  58715. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58716. /** @hidden */
  58717. export var pbrFragmentDeclaration: {
  58718. name: string;
  58719. shader: string;
  58720. };
  58721. }
  58722. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58723. /** @hidden */
  58724. export var pbrUboDeclaration: {
  58725. name: string;
  58726. shader: string;
  58727. };
  58728. }
  58729. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58730. /** @hidden */
  58731. export var pbrFragmentExtraDeclaration: {
  58732. name: string;
  58733. shader: string;
  58734. };
  58735. }
  58736. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58737. /** @hidden */
  58738. export var pbrFragmentSamplersDeclaration: {
  58739. name: string;
  58740. shader: string;
  58741. };
  58742. }
  58743. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  58744. /** @hidden */
  58745. export var subSurfaceScatteringFunctions: {
  58746. name: string;
  58747. shader: string;
  58748. };
  58749. }
  58750. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58751. /** @hidden */
  58752. export var importanceSampling: {
  58753. name: string;
  58754. shader: string;
  58755. };
  58756. }
  58757. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58758. /** @hidden */
  58759. export var pbrHelperFunctions: {
  58760. name: string;
  58761. shader: string;
  58762. };
  58763. }
  58764. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58765. /** @hidden */
  58766. export var harmonicsFunctions: {
  58767. name: string;
  58768. shader: string;
  58769. };
  58770. }
  58771. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58772. /** @hidden */
  58773. export var pbrDirectLightingSetupFunctions: {
  58774. name: string;
  58775. shader: string;
  58776. };
  58777. }
  58778. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58779. /** @hidden */
  58780. export var pbrDirectLightingFalloffFunctions: {
  58781. name: string;
  58782. shader: string;
  58783. };
  58784. }
  58785. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58786. /** @hidden */
  58787. export var pbrBRDFFunctions: {
  58788. name: string;
  58789. shader: string;
  58790. };
  58791. }
  58792. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58793. /** @hidden */
  58794. export var hdrFilteringFunctions: {
  58795. name: string;
  58796. shader: string;
  58797. };
  58798. }
  58799. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58800. /** @hidden */
  58801. export var pbrDirectLightingFunctions: {
  58802. name: string;
  58803. shader: string;
  58804. };
  58805. }
  58806. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58807. /** @hidden */
  58808. export var pbrIBLFunctions: {
  58809. name: string;
  58810. shader: string;
  58811. };
  58812. }
  58813. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58814. /** @hidden */
  58815. export var pbrBlockAlbedoOpacity: {
  58816. name: string;
  58817. shader: string;
  58818. };
  58819. }
  58820. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58821. /** @hidden */
  58822. export var pbrBlockReflectivity: {
  58823. name: string;
  58824. shader: string;
  58825. };
  58826. }
  58827. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58828. /** @hidden */
  58829. export var pbrBlockAmbientOcclusion: {
  58830. name: string;
  58831. shader: string;
  58832. };
  58833. }
  58834. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58835. /** @hidden */
  58836. export var pbrBlockAlphaFresnel: {
  58837. name: string;
  58838. shader: string;
  58839. };
  58840. }
  58841. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58842. /** @hidden */
  58843. export var pbrBlockAnisotropic: {
  58844. name: string;
  58845. shader: string;
  58846. };
  58847. }
  58848. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58849. /** @hidden */
  58850. export var pbrBlockReflection: {
  58851. name: string;
  58852. shader: string;
  58853. };
  58854. }
  58855. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58856. /** @hidden */
  58857. export var pbrBlockSheen: {
  58858. name: string;
  58859. shader: string;
  58860. };
  58861. }
  58862. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58863. /** @hidden */
  58864. export var pbrBlockClearcoat: {
  58865. name: string;
  58866. shader: string;
  58867. };
  58868. }
  58869. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58870. /** @hidden */
  58871. export var pbrBlockSubSurface: {
  58872. name: string;
  58873. shader: string;
  58874. };
  58875. }
  58876. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58877. /** @hidden */
  58878. export var pbrBlockNormalGeometric: {
  58879. name: string;
  58880. shader: string;
  58881. };
  58882. }
  58883. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58884. /** @hidden */
  58885. export var pbrBlockNormalFinal: {
  58886. name: string;
  58887. shader: string;
  58888. };
  58889. }
  58890. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58891. /** @hidden */
  58892. export var pbrBlockLightmapInit: {
  58893. name: string;
  58894. shader: string;
  58895. };
  58896. }
  58897. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58898. /** @hidden */
  58899. export var pbrBlockGeometryInfo: {
  58900. name: string;
  58901. shader: string;
  58902. };
  58903. }
  58904. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58905. /** @hidden */
  58906. export var pbrBlockReflectance0: {
  58907. name: string;
  58908. shader: string;
  58909. };
  58910. }
  58911. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58912. /** @hidden */
  58913. export var pbrBlockReflectance: {
  58914. name: string;
  58915. shader: string;
  58916. };
  58917. }
  58918. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58919. /** @hidden */
  58920. export var pbrBlockDirectLighting: {
  58921. name: string;
  58922. shader: string;
  58923. };
  58924. }
  58925. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58926. /** @hidden */
  58927. export var pbrBlockFinalLitComponents: {
  58928. name: string;
  58929. shader: string;
  58930. };
  58931. }
  58932. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58933. /** @hidden */
  58934. export var pbrBlockFinalUnlitComponents: {
  58935. name: string;
  58936. shader: string;
  58937. };
  58938. }
  58939. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58940. /** @hidden */
  58941. export var pbrBlockFinalColorComposition: {
  58942. name: string;
  58943. shader: string;
  58944. };
  58945. }
  58946. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58947. /** @hidden */
  58948. export var pbrBlockImageProcessing: {
  58949. name: string;
  58950. shader: string;
  58951. };
  58952. }
  58953. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58954. /** @hidden */
  58955. export var pbrDebug: {
  58956. name: string;
  58957. shader: string;
  58958. };
  58959. }
  58960. declare module "babylonjs/Shaders/pbr.fragment" {
  58961. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58962. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58963. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58964. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58965. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58966. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58967. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58968. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58969. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58970. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58971. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58972. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58973. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58974. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58975. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58976. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58977. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58978. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58979. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58980. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58981. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58982. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58983. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58984. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58985. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58986. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58987. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58988. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58989. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58990. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58991. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58992. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58993. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58994. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58995. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58996. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58997. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58998. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58999. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  59000. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  59001. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  59002. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  59003. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  59004. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  59005. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  59006. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  59007. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  59008. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  59009. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  59010. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  59011. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  59012. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  59013. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  59014. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  59015. /** @hidden */
  59016. export var pbrPixelShader: {
  59017. name: string;
  59018. shader: string;
  59019. };
  59020. }
  59021. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  59022. /** @hidden */
  59023. export var pbrVertexDeclaration: {
  59024. name: string;
  59025. shader: string;
  59026. };
  59027. }
  59028. declare module "babylonjs/Shaders/pbr.vertex" {
  59029. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  59030. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  59031. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59032. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59033. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59034. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  59035. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  59036. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  59037. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  59038. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59039. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59040. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59041. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59042. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59043. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59044. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59045. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59046. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  59047. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59048. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  59049. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59050. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  59051. /** @hidden */
  59052. export var pbrVertexShader: {
  59053. name: string;
  59054. shader: string;
  59055. };
  59056. }
  59057. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  59058. import { Nullable } from "babylonjs/types";
  59059. import { Scene } from "babylonjs/scene";
  59060. import { Matrix } from "babylonjs/Maths/math.vector";
  59061. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59063. import { Mesh } from "babylonjs/Meshes/mesh";
  59064. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  59065. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  59066. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  59067. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  59068. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  59069. import { Color3 } from "babylonjs/Maths/math.color";
  59070. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59071. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  59072. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59073. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59074. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59075. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59076. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  59077. import "babylonjs/Shaders/pbr.fragment";
  59078. import "babylonjs/Shaders/pbr.vertex";
  59079. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  59080. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  59081. /**
  59082. * Manages the defines for the PBR Material.
  59083. * @hidden
  59084. */
  59085. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  59086. PBR: boolean;
  59087. NUM_SAMPLES: string;
  59088. REALTIME_FILTERING: boolean;
  59089. MAINUV1: boolean;
  59090. MAINUV2: boolean;
  59091. UV1: boolean;
  59092. UV2: boolean;
  59093. ALBEDO: boolean;
  59094. GAMMAALBEDO: boolean;
  59095. ALBEDODIRECTUV: number;
  59096. VERTEXCOLOR: boolean;
  59097. DETAIL: boolean;
  59098. DETAILDIRECTUV: number;
  59099. DETAIL_NORMALBLENDMETHOD: number;
  59100. AMBIENT: boolean;
  59101. AMBIENTDIRECTUV: number;
  59102. AMBIENTINGRAYSCALE: boolean;
  59103. OPACITY: boolean;
  59104. VERTEXALPHA: boolean;
  59105. OPACITYDIRECTUV: number;
  59106. OPACITYRGB: boolean;
  59107. ALPHATEST: boolean;
  59108. DEPTHPREPASS: boolean;
  59109. ALPHABLEND: boolean;
  59110. ALPHAFROMALBEDO: boolean;
  59111. ALPHATESTVALUE: string;
  59112. SPECULAROVERALPHA: boolean;
  59113. RADIANCEOVERALPHA: boolean;
  59114. ALPHAFRESNEL: boolean;
  59115. LINEARALPHAFRESNEL: boolean;
  59116. PREMULTIPLYALPHA: boolean;
  59117. EMISSIVE: boolean;
  59118. EMISSIVEDIRECTUV: number;
  59119. REFLECTIVITY: boolean;
  59120. REFLECTIVITYDIRECTUV: number;
  59121. SPECULARTERM: boolean;
  59122. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  59123. MICROSURFACEAUTOMATIC: boolean;
  59124. LODBASEDMICROSFURACE: boolean;
  59125. MICROSURFACEMAP: boolean;
  59126. MICROSURFACEMAPDIRECTUV: number;
  59127. METALLICWORKFLOW: boolean;
  59128. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  59129. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  59130. METALLNESSSTOREINMETALMAPBLUE: boolean;
  59131. AOSTOREINMETALMAPRED: boolean;
  59132. METALLIC_REFLECTANCE: boolean;
  59133. METALLIC_REFLECTANCEDIRECTUV: number;
  59134. ENVIRONMENTBRDF: boolean;
  59135. ENVIRONMENTBRDF_RGBD: boolean;
  59136. NORMAL: boolean;
  59137. TANGENT: boolean;
  59138. BUMP: boolean;
  59139. BUMPDIRECTUV: number;
  59140. OBJECTSPACE_NORMALMAP: boolean;
  59141. PARALLAX: boolean;
  59142. PARALLAXOCCLUSION: boolean;
  59143. NORMALXYSCALE: boolean;
  59144. LIGHTMAP: boolean;
  59145. LIGHTMAPDIRECTUV: number;
  59146. USELIGHTMAPASSHADOWMAP: boolean;
  59147. GAMMALIGHTMAP: boolean;
  59148. RGBDLIGHTMAP: boolean;
  59149. REFLECTION: boolean;
  59150. REFLECTIONMAP_3D: boolean;
  59151. REFLECTIONMAP_SPHERICAL: boolean;
  59152. REFLECTIONMAP_PLANAR: boolean;
  59153. REFLECTIONMAP_CUBIC: boolean;
  59154. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  59155. REFLECTIONMAP_PROJECTION: boolean;
  59156. REFLECTIONMAP_SKYBOX: boolean;
  59157. REFLECTIONMAP_EXPLICIT: boolean;
  59158. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  59159. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  59160. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  59161. INVERTCUBICMAP: boolean;
  59162. USESPHERICALFROMREFLECTIONMAP: boolean;
  59163. USEIRRADIANCEMAP: boolean;
  59164. SPHERICAL_HARMONICS: boolean;
  59165. USESPHERICALINVERTEX: boolean;
  59166. REFLECTIONMAP_OPPOSITEZ: boolean;
  59167. LODINREFLECTIONALPHA: boolean;
  59168. GAMMAREFLECTION: boolean;
  59169. RGBDREFLECTION: boolean;
  59170. LINEARSPECULARREFLECTION: boolean;
  59171. RADIANCEOCCLUSION: boolean;
  59172. HORIZONOCCLUSION: boolean;
  59173. INSTANCES: boolean;
  59174. THIN_INSTANCES: boolean;
  59175. PREPASS: boolean;
  59176. PREPASS_IRRADIANCE: boolean;
  59177. PREPASS_IRRADIANCE_INDEX: number;
  59178. PREPASS_ALBEDO: boolean;
  59179. PREPASS_ALBEDO_INDEX: number;
  59180. PREPASS_DEPTHNORMAL: boolean;
  59181. PREPASS_DEPTHNORMAL_INDEX: number;
  59182. SCENE_MRT_COUNT: number;
  59183. NUM_BONE_INFLUENCERS: number;
  59184. BonesPerMesh: number;
  59185. BONETEXTURE: boolean;
  59186. NONUNIFORMSCALING: boolean;
  59187. MORPHTARGETS: boolean;
  59188. MORPHTARGETS_NORMAL: boolean;
  59189. MORPHTARGETS_TANGENT: boolean;
  59190. MORPHTARGETS_UV: boolean;
  59191. NUM_MORPH_INFLUENCERS: number;
  59192. IMAGEPROCESSING: boolean;
  59193. VIGNETTE: boolean;
  59194. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59195. VIGNETTEBLENDMODEOPAQUE: boolean;
  59196. TONEMAPPING: boolean;
  59197. TONEMAPPING_ACES: boolean;
  59198. CONTRAST: boolean;
  59199. COLORCURVES: boolean;
  59200. COLORGRADING: boolean;
  59201. COLORGRADING3D: boolean;
  59202. SAMPLER3DGREENDEPTH: boolean;
  59203. SAMPLER3DBGRMAP: boolean;
  59204. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59205. EXPOSURE: boolean;
  59206. MULTIVIEW: boolean;
  59207. USEPHYSICALLIGHTFALLOFF: boolean;
  59208. USEGLTFLIGHTFALLOFF: boolean;
  59209. TWOSIDEDLIGHTING: boolean;
  59210. SHADOWFLOAT: boolean;
  59211. CLIPPLANE: boolean;
  59212. CLIPPLANE2: boolean;
  59213. CLIPPLANE3: boolean;
  59214. CLIPPLANE4: boolean;
  59215. CLIPPLANE5: boolean;
  59216. CLIPPLANE6: boolean;
  59217. POINTSIZE: boolean;
  59218. FOG: boolean;
  59219. LOGARITHMICDEPTH: boolean;
  59220. FORCENORMALFORWARD: boolean;
  59221. SPECULARAA: boolean;
  59222. CLEARCOAT: boolean;
  59223. CLEARCOAT_DEFAULTIOR: boolean;
  59224. CLEARCOAT_TEXTURE: boolean;
  59225. CLEARCOAT_TEXTUREDIRECTUV: number;
  59226. CLEARCOAT_BUMP: boolean;
  59227. CLEARCOAT_BUMPDIRECTUV: number;
  59228. CLEARCOAT_REMAP_F0: boolean;
  59229. CLEARCOAT_TINT: boolean;
  59230. CLEARCOAT_TINT_TEXTURE: boolean;
  59231. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  59232. ANISOTROPIC: boolean;
  59233. ANISOTROPIC_TEXTURE: boolean;
  59234. ANISOTROPIC_TEXTUREDIRECTUV: number;
  59235. BRDF_V_HEIGHT_CORRELATED: boolean;
  59236. MS_BRDF_ENERGY_CONSERVATION: boolean;
  59237. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  59238. SHEEN: boolean;
  59239. SHEEN_TEXTURE: boolean;
  59240. SHEEN_TEXTUREDIRECTUV: number;
  59241. SHEEN_LINKWITHALBEDO: boolean;
  59242. SHEEN_ROUGHNESS: boolean;
  59243. SHEEN_ALBEDOSCALING: boolean;
  59244. SUBSURFACE: boolean;
  59245. SS_REFRACTION: boolean;
  59246. SS_TRANSLUCENCY: boolean;
  59247. SS_SCATTERING: boolean;
  59248. SS_THICKNESSANDMASK_TEXTURE: boolean;
  59249. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  59250. SS_REFRACTIONMAP_3D: boolean;
  59251. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  59252. SS_LODINREFRACTIONALPHA: boolean;
  59253. SS_GAMMAREFRACTION: boolean;
  59254. SS_RGBDREFRACTION: boolean;
  59255. SS_LINEARSPECULARREFRACTION: boolean;
  59256. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  59257. SS_ALBEDOFORREFRACTIONTINT: boolean;
  59258. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  59259. UNLIT: boolean;
  59260. DEBUGMODE: number;
  59261. /**
  59262. * Initializes the PBR Material defines.
  59263. */
  59264. constructor();
  59265. /**
  59266. * Resets the PBR Material defines.
  59267. */
  59268. reset(): void;
  59269. }
  59270. /**
  59271. * The Physically based material base class of BJS.
  59272. *
  59273. * This offers the main features of a standard PBR material.
  59274. * For more information, please refer to the documentation :
  59275. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59276. */
  59277. export abstract class PBRBaseMaterial extends PushMaterial {
  59278. /**
  59279. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59280. */
  59281. static readonly PBRMATERIAL_OPAQUE: number;
  59282. /**
  59283. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59284. */
  59285. static readonly PBRMATERIAL_ALPHATEST: number;
  59286. /**
  59287. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59288. */
  59289. static readonly PBRMATERIAL_ALPHABLEND: number;
  59290. /**
  59291. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59292. * They are also discarded below the alpha cutoff threshold to improve performances.
  59293. */
  59294. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59295. /**
  59296. * Defines the default value of how much AO map is occluding the analytical lights
  59297. * (point spot...).
  59298. */
  59299. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59300. /**
  59301. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  59302. */
  59303. static readonly LIGHTFALLOFF_PHYSICAL: number;
  59304. /**
  59305. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  59306. * to enhance interoperability with other engines.
  59307. */
  59308. static readonly LIGHTFALLOFF_GLTF: number;
  59309. /**
  59310. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  59311. * to enhance interoperability with other materials.
  59312. */
  59313. static readonly LIGHTFALLOFF_STANDARD: number;
  59314. /**
  59315. * Intensity of the direct lights e.g. the four lights available in your scene.
  59316. * This impacts both the direct diffuse and specular highlights.
  59317. */
  59318. protected _directIntensity: number;
  59319. /**
  59320. * Intensity of the emissive part of the material.
  59321. * This helps controlling the emissive effect without modifying the emissive color.
  59322. */
  59323. protected _emissiveIntensity: number;
  59324. /**
  59325. * Intensity of the environment e.g. how much the environment will light the object
  59326. * either through harmonics for rough material or through the refelction for shiny ones.
  59327. */
  59328. protected _environmentIntensity: number;
  59329. /**
  59330. * This is a special control allowing the reduction of the specular highlights coming from the
  59331. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59332. */
  59333. protected _specularIntensity: number;
  59334. /**
  59335. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  59336. */
  59337. private _lightingInfos;
  59338. /**
  59339. * Debug Control allowing disabling the bump map on this material.
  59340. */
  59341. protected _disableBumpMap: boolean;
  59342. /**
  59343. * AKA Diffuse Texture in standard nomenclature.
  59344. */
  59345. protected _albedoTexture: Nullable<BaseTexture>;
  59346. /**
  59347. * AKA Occlusion Texture in other nomenclature.
  59348. */
  59349. protected _ambientTexture: Nullable<BaseTexture>;
  59350. /**
  59351. * AKA Occlusion Texture Intensity in other nomenclature.
  59352. */
  59353. protected _ambientTextureStrength: number;
  59354. /**
  59355. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59356. * 1 means it completely occludes it
  59357. * 0 mean it has no impact
  59358. */
  59359. protected _ambientTextureImpactOnAnalyticalLights: number;
  59360. /**
  59361. * Stores the alpha values in a texture.
  59362. */
  59363. protected _opacityTexture: Nullable<BaseTexture>;
  59364. /**
  59365. * Stores the reflection values in a texture.
  59366. */
  59367. protected _reflectionTexture: Nullable<BaseTexture>;
  59368. /**
  59369. * Stores the emissive values in a texture.
  59370. */
  59371. protected _emissiveTexture: Nullable<BaseTexture>;
  59372. /**
  59373. * AKA Specular texture in other nomenclature.
  59374. */
  59375. protected _reflectivityTexture: Nullable<BaseTexture>;
  59376. /**
  59377. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59378. */
  59379. protected _metallicTexture: Nullable<BaseTexture>;
  59380. /**
  59381. * Specifies the metallic scalar of the metallic/roughness workflow.
  59382. * Can also be used to scale the metalness values of the metallic texture.
  59383. */
  59384. protected _metallic: Nullable<number>;
  59385. /**
  59386. * Specifies the roughness scalar of the metallic/roughness workflow.
  59387. * Can also be used to scale the roughness values of the metallic texture.
  59388. */
  59389. protected _roughness: Nullable<number>;
  59390. /**
  59391. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59392. * By default the indexOfrefraction is used to compute F0;
  59393. *
  59394. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59395. *
  59396. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59397. * F90 = metallicReflectanceColor;
  59398. */
  59399. protected _metallicF0Factor: number;
  59400. /**
  59401. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59402. * By default the F90 is always 1;
  59403. *
  59404. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59405. *
  59406. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59407. * F90 = metallicReflectanceColor;
  59408. */
  59409. protected _metallicReflectanceColor: Color3;
  59410. /**
  59411. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59412. * This is multiply against the scalar values defined in the material.
  59413. */
  59414. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  59415. /**
  59416. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59417. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59418. */
  59419. protected _microSurfaceTexture: Nullable<BaseTexture>;
  59420. /**
  59421. * Stores surface normal data used to displace a mesh in a texture.
  59422. */
  59423. protected _bumpTexture: Nullable<BaseTexture>;
  59424. /**
  59425. * Stores the pre-calculated light information of a mesh in a texture.
  59426. */
  59427. protected _lightmapTexture: Nullable<BaseTexture>;
  59428. /**
  59429. * The color of a material in ambient lighting.
  59430. */
  59431. protected _ambientColor: Color3;
  59432. /**
  59433. * AKA Diffuse Color in other nomenclature.
  59434. */
  59435. protected _albedoColor: Color3;
  59436. /**
  59437. * AKA Specular Color in other nomenclature.
  59438. */
  59439. protected _reflectivityColor: Color3;
  59440. /**
  59441. * The color applied when light is reflected from a material.
  59442. */
  59443. protected _reflectionColor: Color3;
  59444. /**
  59445. * The color applied when light is emitted from a material.
  59446. */
  59447. protected _emissiveColor: Color3;
  59448. /**
  59449. * AKA Glossiness in other nomenclature.
  59450. */
  59451. protected _microSurface: number;
  59452. /**
  59453. * Specifies that the material will use the light map as a show map.
  59454. */
  59455. protected _useLightmapAsShadowmap: boolean;
  59456. /**
  59457. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59458. * makes the reflect vector face the model (under horizon).
  59459. */
  59460. protected _useHorizonOcclusion: boolean;
  59461. /**
  59462. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59463. * too much the area relying on ambient texture to define their ambient occlusion.
  59464. */
  59465. protected _useRadianceOcclusion: boolean;
  59466. /**
  59467. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59468. */
  59469. protected _useAlphaFromAlbedoTexture: boolean;
  59470. /**
  59471. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  59472. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59473. */
  59474. protected _useSpecularOverAlpha: boolean;
  59475. /**
  59476. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59477. */
  59478. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59479. /**
  59480. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59481. */
  59482. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  59483. /**
  59484. * Specifies if the metallic texture contains the roughness information in its green channel.
  59485. */
  59486. protected _useRoughnessFromMetallicTextureGreen: boolean;
  59487. /**
  59488. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59489. */
  59490. protected _useMetallnessFromMetallicTextureBlue: boolean;
  59491. /**
  59492. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59493. */
  59494. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  59495. /**
  59496. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59497. */
  59498. protected _useAmbientInGrayScale: boolean;
  59499. /**
  59500. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59501. * The material will try to infer what glossiness each pixel should be.
  59502. */
  59503. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  59504. /**
  59505. * Defines the falloff type used in this material.
  59506. * It by default is Physical.
  59507. */
  59508. protected _lightFalloff: number;
  59509. /**
  59510. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59511. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59512. */
  59513. protected _useRadianceOverAlpha: boolean;
  59514. /**
  59515. * Allows using an object space normal map (instead of tangent space).
  59516. */
  59517. protected _useObjectSpaceNormalMap: boolean;
  59518. /**
  59519. * Allows using the bump map in parallax mode.
  59520. */
  59521. protected _useParallax: boolean;
  59522. /**
  59523. * Allows using the bump map in parallax occlusion mode.
  59524. */
  59525. protected _useParallaxOcclusion: boolean;
  59526. /**
  59527. * Controls the scale bias of the parallax mode.
  59528. */
  59529. protected _parallaxScaleBias: number;
  59530. /**
  59531. * If sets to true, disables all the lights affecting the material.
  59532. */
  59533. protected _disableLighting: boolean;
  59534. /**
  59535. * Number of Simultaneous lights allowed on the material.
  59536. */
  59537. protected _maxSimultaneousLights: number;
  59538. /**
  59539. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  59540. */
  59541. protected _invertNormalMapX: boolean;
  59542. /**
  59543. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  59544. */
  59545. protected _invertNormalMapY: boolean;
  59546. /**
  59547. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59548. */
  59549. protected _twoSidedLighting: boolean;
  59550. /**
  59551. * Defines the alpha limits in alpha test mode.
  59552. */
  59553. protected _alphaCutOff: number;
  59554. /**
  59555. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59556. */
  59557. protected _forceAlphaTest: boolean;
  59558. /**
  59559. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59560. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59561. */
  59562. protected _useAlphaFresnel: boolean;
  59563. /**
  59564. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59565. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59566. */
  59567. protected _useLinearAlphaFresnel: boolean;
  59568. /**
  59569. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  59570. * from cos thetav and roughness:
  59571. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  59572. */
  59573. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  59574. /**
  59575. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59576. */
  59577. protected _forceIrradianceInFragment: boolean;
  59578. private _realTimeFiltering;
  59579. /**
  59580. * Enables realtime filtering on the texture.
  59581. */
  59582. get realTimeFiltering(): boolean;
  59583. set realTimeFiltering(b: boolean);
  59584. private _realTimeFilteringQuality;
  59585. /**
  59586. * Quality switch for realtime filtering
  59587. */
  59588. get realTimeFilteringQuality(): number;
  59589. set realTimeFilteringQuality(n: number);
  59590. /**
  59591. * Can this material render to several textures at once
  59592. */
  59593. get canRenderToMRT(): boolean;
  59594. /**
  59595. * Force normal to face away from face.
  59596. */
  59597. protected _forceNormalForward: boolean;
  59598. /**
  59599. * Enables specular anti aliasing in the PBR shader.
  59600. * It will both interacts on the Geometry for analytical and IBL lighting.
  59601. * It also prefilter the roughness map based on the bump values.
  59602. */
  59603. protected _enableSpecularAntiAliasing: boolean;
  59604. /**
  59605. * Default configuration related to image processing available in the PBR Material.
  59606. */
  59607. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59608. /**
  59609. * Keep track of the image processing observer to allow dispose and replace.
  59610. */
  59611. private _imageProcessingObserver;
  59612. /**
  59613. * Attaches a new image processing configuration to the PBR Material.
  59614. * @param configuration
  59615. */
  59616. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59617. /**
  59618. * Stores the available render targets.
  59619. */
  59620. private _renderTargets;
  59621. /**
  59622. * Sets the global ambient color for the material used in lighting calculations.
  59623. */
  59624. private _globalAmbientColor;
  59625. /**
  59626. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59627. */
  59628. private _useLogarithmicDepth;
  59629. /**
  59630. * If set to true, no lighting calculations will be applied.
  59631. */
  59632. private _unlit;
  59633. private _debugMode;
  59634. /**
  59635. * @hidden
  59636. * This is reserved for the inspector.
  59637. * Defines the material debug mode.
  59638. * It helps seeing only some components of the material while troubleshooting.
  59639. */
  59640. debugMode: number;
  59641. /**
  59642. * @hidden
  59643. * This is reserved for the inspector.
  59644. * Specify from where on screen the debug mode should start.
  59645. * The value goes from -1 (full screen) to 1 (not visible)
  59646. * It helps with side by side comparison against the final render
  59647. * This defaults to -1
  59648. */
  59649. private debugLimit;
  59650. /**
  59651. * @hidden
  59652. * This is reserved for the inspector.
  59653. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59654. * You can use the factor to better multiply the final value.
  59655. */
  59656. private debugFactor;
  59657. /**
  59658. * Defines the clear coat layer parameters for the material.
  59659. */
  59660. readonly clearCoat: PBRClearCoatConfiguration;
  59661. /**
  59662. * Defines the anisotropic parameters for the material.
  59663. */
  59664. readonly anisotropy: PBRAnisotropicConfiguration;
  59665. /**
  59666. * Defines the BRDF parameters for the material.
  59667. */
  59668. readonly brdf: PBRBRDFConfiguration;
  59669. /**
  59670. * Defines the Sheen parameters for the material.
  59671. */
  59672. readonly sheen: PBRSheenConfiguration;
  59673. /**
  59674. * Defines the SubSurface parameters for the material.
  59675. */
  59676. readonly subSurface: PBRSubSurfaceConfiguration;
  59677. /**
  59678. * Defines the detail map parameters for the material.
  59679. */
  59680. readonly detailMap: DetailMapConfiguration;
  59681. protected _rebuildInParallel: boolean;
  59682. /**
  59683. * Instantiates a new PBRMaterial instance.
  59684. *
  59685. * @param name The material name
  59686. * @param scene The scene the material will be use in.
  59687. */
  59688. constructor(name: string, scene: Scene);
  59689. /**
  59690. * Gets a boolean indicating that current material needs to register RTT
  59691. */
  59692. get hasRenderTargetTextures(): boolean;
  59693. /**
  59694. * Gets the name of the material class.
  59695. */
  59696. getClassName(): string;
  59697. /**
  59698. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59699. */
  59700. get useLogarithmicDepth(): boolean;
  59701. /**
  59702. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59703. */
  59704. set useLogarithmicDepth(value: boolean);
  59705. /**
  59706. * Returns true if alpha blending should be disabled.
  59707. */
  59708. protected get _disableAlphaBlending(): boolean;
  59709. /**
  59710. * Specifies whether or not this material should be rendered in alpha blend mode.
  59711. */
  59712. needAlphaBlending(): boolean;
  59713. /**
  59714. * Specifies whether or not this material should be rendered in alpha test mode.
  59715. */
  59716. needAlphaTesting(): boolean;
  59717. /**
  59718. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59719. */
  59720. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59721. /**
  59722. * Gets the texture used for the alpha test.
  59723. */
  59724. getAlphaTestTexture(): Nullable<BaseTexture>;
  59725. /**
  59726. * Specifies that the submesh is ready to be used.
  59727. * @param mesh - BJS mesh.
  59728. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59729. * @param useInstances - Specifies that instances should be used.
  59730. * @returns - boolean indicating that the submesh is ready or not.
  59731. */
  59732. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59733. /**
  59734. * Specifies if the material uses metallic roughness workflow.
  59735. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59736. */
  59737. isMetallicWorkflow(): boolean;
  59738. private _prepareEffect;
  59739. private _prepareDefines;
  59740. /**
  59741. * Force shader compilation
  59742. */
  59743. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59744. /**
  59745. * Initializes the uniform buffer layout for the shader.
  59746. */
  59747. buildUniformLayout(): void;
  59748. /**
  59749. * Unbinds the material from the mesh
  59750. */
  59751. unbind(): void;
  59752. /**
  59753. * Binds the submesh data.
  59754. * @param world - The world matrix.
  59755. * @param mesh - The BJS mesh.
  59756. * @param subMesh - A submesh of the BJS mesh.
  59757. */
  59758. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59759. /**
  59760. * Returns the animatable textures.
  59761. * @returns - Array of animatable textures.
  59762. */
  59763. getAnimatables(): IAnimatable[];
  59764. /**
  59765. * Returns the texture used for reflections.
  59766. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59767. */
  59768. private _getReflectionTexture;
  59769. /**
  59770. * Returns an array of the actively used textures.
  59771. * @returns - Array of BaseTextures
  59772. */
  59773. getActiveTextures(): BaseTexture[];
  59774. /**
  59775. * Checks to see if a texture is used in the material.
  59776. * @param texture - Base texture to use.
  59777. * @returns - Boolean specifying if a texture is used in the material.
  59778. */
  59779. hasTexture(texture: BaseTexture): boolean;
  59780. /**
  59781. * Sets the required values to the prepass renderer.
  59782. * @param prePassRenderer defines the prepass renderer to setup
  59783. */
  59784. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59785. /**
  59786. * Disposes the resources of the material.
  59787. * @param forceDisposeEffect - Forces the disposal of effects.
  59788. * @param forceDisposeTextures - Forces the disposal of all textures.
  59789. */
  59790. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59791. }
  59792. }
  59793. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59794. import { Nullable } from "babylonjs/types";
  59795. import { Scene } from "babylonjs/scene";
  59796. import { Color3 } from "babylonjs/Maths/math.color";
  59797. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59798. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59799. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59800. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59801. /**
  59802. * The Physically based material of BJS.
  59803. *
  59804. * This offers the main features of a standard PBR material.
  59805. * For more information, please refer to the documentation :
  59806. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59807. */
  59808. export class PBRMaterial extends PBRBaseMaterial {
  59809. /**
  59810. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59811. */
  59812. static readonly PBRMATERIAL_OPAQUE: number;
  59813. /**
  59814. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59815. */
  59816. static readonly PBRMATERIAL_ALPHATEST: number;
  59817. /**
  59818. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59819. */
  59820. static readonly PBRMATERIAL_ALPHABLEND: number;
  59821. /**
  59822. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59823. * They are also discarded below the alpha cutoff threshold to improve performances.
  59824. */
  59825. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59826. /**
  59827. * Defines the default value of how much AO map is occluding the analytical lights
  59828. * (point spot...).
  59829. */
  59830. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59831. /**
  59832. * Intensity of the direct lights e.g. the four lights available in your scene.
  59833. * This impacts both the direct diffuse and specular highlights.
  59834. */
  59835. directIntensity: number;
  59836. /**
  59837. * Intensity of the emissive part of the material.
  59838. * This helps controlling the emissive effect without modifying the emissive color.
  59839. */
  59840. emissiveIntensity: number;
  59841. /**
  59842. * Intensity of the environment e.g. how much the environment will light the object
  59843. * either through harmonics for rough material or through the refelction for shiny ones.
  59844. */
  59845. environmentIntensity: number;
  59846. /**
  59847. * This is a special control allowing the reduction of the specular highlights coming from the
  59848. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59849. */
  59850. specularIntensity: number;
  59851. /**
  59852. * Debug Control allowing disabling the bump map on this material.
  59853. */
  59854. disableBumpMap: boolean;
  59855. /**
  59856. * AKA Diffuse Texture in standard nomenclature.
  59857. */
  59858. albedoTexture: BaseTexture;
  59859. /**
  59860. * AKA Occlusion Texture in other nomenclature.
  59861. */
  59862. ambientTexture: BaseTexture;
  59863. /**
  59864. * AKA Occlusion Texture Intensity in other nomenclature.
  59865. */
  59866. ambientTextureStrength: number;
  59867. /**
  59868. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59869. * 1 means it completely occludes it
  59870. * 0 mean it has no impact
  59871. */
  59872. ambientTextureImpactOnAnalyticalLights: number;
  59873. /**
  59874. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59875. */
  59876. opacityTexture: BaseTexture;
  59877. /**
  59878. * Stores the reflection values in a texture.
  59879. */
  59880. reflectionTexture: Nullable<BaseTexture>;
  59881. /**
  59882. * Stores the emissive values in a texture.
  59883. */
  59884. emissiveTexture: BaseTexture;
  59885. /**
  59886. * AKA Specular texture in other nomenclature.
  59887. */
  59888. reflectivityTexture: BaseTexture;
  59889. /**
  59890. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59891. */
  59892. metallicTexture: BaseTexture;
  59893. /**
  59894. * Specifies the metallic scalar of the metallic/roughness workflow.
  59895. * Can also be used to scale the metalness values of the metallic texture.
  59896. */
  59897. metallic: Nullable<number>;
  59898. /**
  59899. * Specifies the roughness scalar of the metallic/roughness workflow.
  59900. * Can also be used to scale the roughness values of the metallic texture.
  59901. */
  59902. roughness: Nullable<number>;
  59903. /**
  59904. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59905. * By default the indexOfrefraction is used to compute F0;
  59906. *
  59907. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59908. *
  59909. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59910. * F90 = metallicReflectanceColor;
  59911. */
  59912. metallicF0Factor: number;
  59913. /**
  59914. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59915. * By default the F90 is always 1;
  59916. *
  59917. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59918. *
  59919. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59920. * F90 = metallicReflectanceColor;
  59921. */
  59922. metallicReflectanceColor: Color3;
  59923. /**
  59924. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59925. * This is multiply against the scalar values defined in the material.
  59926. */
  59927. metallicReflectanceTexture: Nullable<BaseTexture>;
  59928. /**
  59929. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59930. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59931. */
  59932. microSurfaceTexture: BaseTexture;
  59933. /**
  59934. * Stores surface normal data used to displace a mesh in a texture.
  59935. */
  59936. bumpTexture: BaseTexture;
  59937. /**
  59938. * Stores the pre-calculated light information of a mesh in a texture.
  59939. */
  59940. lightmapTexture: BaseTexture;
  59941. /**
  59942. * Stores the refracted light information in a texture.
  59943. */
  59944. get refractionTexture(): Nullable<BaseTexture>;
  59945. set refractionTexture(value: Nullable<BaseTexture>);
  59946. /**
  59947. * The color of a material in ambient lighting.
  59948. */
  59949. ambientColor: Color3;
  59950. /**
  59951. * AKA Diffuse Color in other nomenclature.
  59952. */
  59953. albedoColor: Color3;
  59954. /**
  59955. * AKA Specular Color in other nomenclature.
  59956. */
  59957. reflectivityColor: Color3;
  59958. /**
  59959. * The color reflected from the material.
  59960. */
  59961. reflectionColor: Color3;
  59962. /**
  59963. * The color emitted from the material.
  59964. */
  59965. emissiveColor: Color3;
  59966. /**
  59967. * AKA Glossiness in other nomenclature.
  59968. */
  59969. microSurface: number;
  59970. /**
  59971. * Index of refraction of the material base layer.
  59972. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59973. *
  59974. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59975. *
  59976. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59977. */
  59978. get indexOfRefraction(): number;
  59979. set indexOfRefraction(value: number);
  59980. /**
  59981. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59982. */
  59983. get invertRefractionY(): boolean;
  59984. set invertRefractionY(value: boolean);
  59985. /**
  59986. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59987. * Materials half opaque for instance using refraction could benefit from this control.
  59988. */
  59989. get linkRefractionWithTransparency(): boolean;
  59990. set linkRefractionWithTransparency(value: boolean);
  59991. /**
  59992. * If true, the light map contains occlusion information instead of lighting info.
  59993. */
  59994. useLightmapAsShadowmap: boolean;
  59995. /**
  59996. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59997. */
  59998. useAlphaFromAlbedoTexture: boolean;
  59999. /**
  60000. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  60001. */
  60002. forceAlphaTest: boolean;
  60003. /**
  60004. * Defines the alpha limits in alpha test mode.
  60005. */
  60006. alphaCutOff: number;
  60007. /**
  60008. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  60009. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  60010. */
  60011. useSpecularOverAlpha: boolean;
  60012. /**
  60013. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  60014. */
  60015. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  60016. /**
  60017. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  60018. */
  60019. useRoughnessFromMetallicTextureAlpha: boolean;
  60020. /**
  60021. * Specifies if the metallic texture contains the roughness information in its green channel.
  60022. */
  60023. useRoughnessFromMetallicTextureGreen: boolean;
  60024. /**
  60025. * Specifies if the metallic texture contains the metallness information in its blue channel.
  60026. */
  60027. useMetallnessFromMetallicTextureBlue: boolean;
  60028. /**
  60029. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  60030. */
  60031. useAmbientOcclusionFromMetallicTextureRed: boolean;
  60032. /**
  60033. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  60034. */
  60035. useAmbientInGrayScale: boolean;
  60036. /**
  60037. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  60038. * The material will try to infer what glossiness each pixel should be.
  60039. */
  60040. useAutoMicroSurfaceFromReflectivityMap: boolean;
  60041. /**
  60042. * BJS is using an harcoded light falloff based on a manually sets up range.
  60043. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  60044. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  60045. */
  60046. get usePhysicalLightFalloff(): boolean;
  60047. /**
  60048. * BJS is using an harcoded light falloff based on a manually sets up range.
  60049. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  60050. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  60051. */
  60052. set usePhysicalLightFalloff(value: boolean);
  60053. /**
  60054. * In order to support the falloff compatibility with gltf, a special mode has been added
  60055. * to reproduce the gltf light falloff.
  60056. */
  60057. get useGLTFLightFalloff(): boolean;
  60058. /**
  60059. * In order to support the falloff compatibility with gltf, a special mode has been added
  60060. * to reproduce the gltf light falloff.
  60061. */
  60062. set useGLTFLightFalloff(value: boolean);
  60063. /**
  60064. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  60065. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  60066. */
  60067. useRadianceOverAlpha: boolean;
  60068. /**
  60069. * Allows using an object space normal map (instead of tangent space).
  60070. */
  60071. useObjectSpaceNormalMap: boolean;
  60072. /**
  60073. * Allows using the bump map in parallax mode.
  60074. */
  60075. useParallax: boolean;
  60076. /**
  60077. * Allows using the bump map in parallax occlusion mode.
  60078. */
  60079. useParallaxOcclusion: boolean;
  60080. /**
  60081. * Controls the scale bias of the parallax mode.
  60082. */
  60083. parallaxScaleBias: number;
  60084. /**
  60085. * If sets to true, disables all the lights affecting the material.
  60086. */
  60087. disableLighting: boolean;
  60088. /**
  60089. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  60090. */
  60091. forceIrradianceInFragment: boolean;
  60092. /**
  60093. * Number of Simultaneous lights allowed on the material.
  60094. */
  60095. maxSimultaneousLights: number;
  60096. /**
  60097. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60098. */
  60099. invertNormalMapX: boolean;
  60100. /**
  60101. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60102. */
  60103. invertNormalMapY: boolean;
  60104. /**
  60105. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60106. */
  60107. twoSidedLighting: boolean;
  60108. /**
  60109. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60110. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  60111. */
  60112. useAlphaFresnel: boolean;
  60113. /**
  60114. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60115. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  60116. */
  60117. useLinearAlphaFresnel: boolean;
  60118. /**
  60119. * Let user defines the brdf lookup texture used for IBL.
  60120. * A default 8bit version is embedded but you could point at :
  60121. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  60122. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  60123. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  60124. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  60125. */
  60126. environmentBRDFTexture: Nullable<BaseTexture>;
  60127. /**
  60128. * Force normal to face away from face.
  60129. */
  60130. forceNormalForward: boolean;
  60131. /**
  60132. * Enables specular anti aliasing in the PBR shader.
  60133. * It will both interacts on the Geometry for analytical and IBL lighting.
  60134. * It also prefilter the roughness map based on the bump values.
  60135. */
  60136. enableSpecularAntiAliasing: boolean;
  60137. /**
  60138. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  60139. * makes the reflect vector face the model (under horizon).
  60140. */
  60141. useHorizonOcclusion: boolean;
  60142. /**
  60143. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  60144. * too much the area relying on ambient texture to define their ambient occlusion.
  60145. */
  60146. useRadianceOcclusion: boolean;
  60147. /**
  60148. * If set to true, no lighting calculations will be applied.
  60149. */
  60150. unlit: boolean;
  60151. /**
  60152. * Gets the image processing configuration used either in this material.
  60153. */
  60154. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60155. /**
  60156. * Sets the Default image processing configuration used either in the this material.
  60157. *
  60158. * If sets to null, the scene one is in use.
  60159. */
  60160. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60161. /**
  60162. * Gets wether the color curves effect is enabled.
  60163. */
  60164. get cameraColorCurvesEnabled(): boolean;
  60165. /**
  60166. * Sets wether the color curves effect is enabled.
  60167. */
  60168. set cameraColorCurvesEnabled(value: boolean);
  60169. /**
  60170. * Gets wether the color grading effect is enabled.
  60171. */
  60172. get cameraColorGradingEnabled(): boolean;
  60173. /**
  60174. * Gets wether the color grading effect is enabled.
  60175. */
  60176. set cameraColorGradingEnabled(value: boolean);
  60177. /**
  60178. * Gets wether tonemapping is enabled or not.
  60179. */
  60180. get cameraToneMappingEnabled(): boolean;
  60181. /**
  60182. * Sets wether tonemapping is enabled or not
  60183. */
  60184. set cameraToneMappingEnabled(value: boolean);
  60185. /**
  60186. * The camera exposure used on this material.
  60187. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60188. * This corresponds to a photographic exposure.
  60189. */
  60190. get cameraExposure(): number;
  60191. /**
  60192. * The camera exposure used on this material.
  60193. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60194. * This corresponds to a photographic exposure.
  60195. */
  60196. set cameraExposure(value: number);
  60197. /**
  60198. * Gets The camera contrast used on this material.
  60199. */
  60200. get cameraContrast(): number;
  60201. /**
  60202. * Sets The camera contrast used on this material.
  60203. */
  60204. set cameraContrast(value: number);
  60205. /**
  60206. * Gets the Color Grading 2D Lookup Texture.
  60207. */
  60208. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60209. /**
  60210. * Sets the Color Grading 2D Lookup Texture.
  60211. */
  60212. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60213. /**
  60214. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60215. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60216. * 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;
  60217. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60218. */
  60219. get cameraColorCurves(): Nullable<ColorCurves>;
  60220. /**
  60221. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60222. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60223. * 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;
  60224. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60225. */
  60226. set cameraColorCurves(value: Nullable<ColorCurves>);
  60227. /**
  60228. * Instantiates a new PBRMaterial instance.
  60229. *
  60230. * @param name The material name
  60231. * @param scene The scene the material will be use in.
  60232. */
  60233. constructor(name: string, scene: Scene);
  60234. /**
  60235. * Returns the name of this material class.
  60236. */
  60237. getClassName(): string;
  60238. /**
  60239. * Makes a duplicate of the current material.
  60240. * @param name - name to use for the new material.
  60241. */
  60242. clone(name: string): PBRMaterial;
  60243. /**
  60244. * Serializes this PBR Material.
  60245. * @returns - An object with the serialized material.
  60246. */
  60247. serialize(): any;
  60248. /**
  60249. * Parses a PBR Material from a serialized object.
  60250. * @param source - Serialized object.
  60251. * @param scene - BJS scene instance.
  60252. * @param rootUrl - url for the scene object
  60253. * @returns - PBRMaterial
  60254. */
  60255. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  60256. }
  60257. }
  60258. declare module "babylonjs/Misc/dds" {
  60259. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60260. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60261. import { Nullable } from "babylonjs/types";
  60262. import { Scene } from "babylonjs/scene";
  60263. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60264. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60265. /**
  60266. * Direct draw surface info
  60267. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60268. */
  60269. export interface DDSInfo {
  60270. /**
  60271. * Width of the texture
  60272. */
  60273. width: number;
  60274. /**
  60275. * Width of the texture
  60276. */
  60277. height: number;
  60278. /**
  60279. * Number of Mipmaps for the texture
  60280. * @see https://en.wikipedia.org/wiki/Mipmap
  60281. */
  60282. mipmapCount: number;
  60283. /**
  60284. * If the textures format is a known fourCC format
  60285. * @see https://www.fourcc.org/
  60286. */
  60287. isFourCC: boolean;
  60288. /**
  60289. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60290. */
  60291. isRGB: boolean;
  60292. /**
  60293. * If the texture is a lumincance format
  60294. */
  60295. isLuminance: boolean;
  60296. /**
  60297. * If this is a cube texture
  60298. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60299. */
  60300. isCube: boolean;
  60301. /**
  60302. * If the texture is a compressed format eg. FOURCC_DXT1
  60303. */
  60304. isCompressed: boolean;
  60305. /**
  60306. * The dxgiFormat of the texture
  60307. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60308. */
  60309. dxgiFormat: number;
  60310. /**
  60311. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60312. */
  60313. textureType: number;
  60314. /**
  60315. * Sphericle polynomial created for the dds texture
  60316. */
  60317. sphericalPolynomial?: SphericalPolynomial;
  60318. }
  60319. /**
  60320. * Class used to provide DDS decompression tools
  60321. */
  60322. export class DDSTools {
  60323. /**
  60324. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60325. */
  60326. static StoreLODInAlphaChannel: boolean;
  60327. /**
  60328. * Gets DDS information from an array buffer
  60329. * @param data defines the array buffer view to read data from
  60330. * @returns the DDS information
  60331. */
  60332. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60333. private static _FloatView;
  60334. private static _Int32View;
  60335. private static _ToHalfFloat;
  60336. private static _FromHalfFloat;
  60337. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60338. private static _GetHalfFloatRGBAArrayBuffer;
  60339. private static _GetFloatRGBAArrayBuffer;
  60340. private static _GetFloatAsUIntRGBAArrayBuffer;
  60341. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60342. private static _GetRGBAArrayBuffer;
  60343. private static _ExtractLongWordOrder;
  60344. private static _GetRGBArrayBuffer;
  60345. private static _GetLuminanceArrayBuffer;
  60346. /**
  60347. * Uploads DDS Levels to a Babylon Texture
  60348. * @hidden
  60349. */
  60350. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60351. }
  60352. module "babylonjs/Engines/thinEngine" {
  60353. interface ThinEngine {
  60354. /**
  60355. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60356. * @param rootUrl defines the url where the file to load is located
  60357. * @param scene defines the current scene
  60358. * @param lodScale defines scale to apply to the mip map selection
  60359. * @param lodOffset defines offset to apply to the mip map selection
  60360. * @param onLoad defines an optional callback raised when the texture is loaded
  60361. * @param onError defines an optional callback raised if there is an issue to load the texture
  60362. * @param format defines the format of the data
  60363. * @param forcedExtension defines the extension to use to pick the right loader
  60364. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60365. * @returns the cube texture as an InternalTexture
  60366. */
  60367. 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;
  60368. }
  60369. }
  60370. }
  60371. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60372. import { Nullable } from "babylonjs/types";
  60373. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60374. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60375. /**
  60376. * Implementation of the DDS Texture Loader.
  60377. * @hidden
  60378. */
  60379. export class _DDSTextureLoader implements IInternalTextureLoader {
  60380. /**
  60381. * Defines wether the loader supports cascade loading the different faces.
  60382. */
  60383. readonly supportCascades: boolean;
  60384. /**
  60385. * This returns if the loader support the current file information.
  60386. * @param extension defines the file extension of the file being loaded
  60387. * @returns true if the loader can load the specified file
  60388. */
  60389. canLoad(extension: string): boolean;
  60390. /**
  60391. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60392. * @param data contains the texture data
  60393. * @param texture defines the BabylonJS internal texture
  60394. * @param createPolynomials will be true if polynomials have been requested
  60395. * @param onLoad defines the callback to trigger once the texture is ready
  60396. * @param onError defines the callback to trigger in case of error
  60397. */
  60398. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60399. /**
  60400. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60401. * @param data contains the texture data
  60402. * @param texture defines the BabylonJS internal texture
  60403. * @param callback defines the method to call once ready to upload
  60404. */
  60405. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60406. }
  60407. }
  60408. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60409. import { Nullable } from "babylonjs/types";
  60410. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60411. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60412. /**
  60413. * Implementation of the ENV Texture Loader.
  60414. * @hidden
  60415. */
  60416. export class _ENVTextureLoader implements IInternalTextureLoader {
  60417. /**
  60418. * Defines wether the loader supports cascade loading the different faces.
  60419. */
  60420. readonly supportCascades: boolean;
  60421. /**
  60422. * This returns if the loader support the current file information.
  60423. * @param extension defines the file extension of the file being loaded
  60424. * @returns true if the loader can load the specified file
  60425. */
  60426. canLoad(extension: string): boolean;
  60427. /**
  60428. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60429. * @param data contains the texture data
  60430. * @param texture defines the BabylonJS internal texture
  60431. * @param createPolynomials will be true if polynomials have been requested
  60432. * @param onLoad defines the callback to trigger once the texture is ready
  60433. * @param onError defines the callback to trigger in case of error
  60434. */
  60435. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60436. /**
  60437. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60438. * @param data contains the texture data
  60439. * @param texture defines the BabylonJS internal texture
  60440. * @param callback defines the method to call once ready to upload
  60441. */
  60442. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60443. }
  60444. }
  60445. declare module "babylonjs/Misc/khronosTextureContainer" {
  60446. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60447. /**
  60448. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60449. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60450. */
  60451. export class KhronosTextureContainer {
  60452. /** contents of the KTX container file */
  60453. data: ArrayBufferView;
  60454. private static HEADER_LEN;
  60455. private static COMPRESSED_2D;
  60456. private static COMPRESSED_3D;
  60457. private static TEX_2D;
  60458. private static TEX_3D;
  60459. /**
  60460. * Gets the openGL type
  60461. */
  60462. glType: number;
  60463. /**
  60464. * Gets the openGL type size
  60465. */
  60466. glTypeSize: number;
  60467. /**
  60468. * Gets the openGL format
  60469. */
  60470. glFormat: number;
  60471. /**
  60472. * Gets the openGL internal format
  60473. */
  60474. glInternalFormat: number;
  60475. /**
  60476. * Gets the base internal format
  60477. */
  60478. glBaseInternalFormat: number;
  60479. /**
  60480. * Gets image width in pixel
  60481. */
  60482. pixelWidth: number;
  60483. /**
  60484. * Gets image height in pixel
  60485. */
  60486. pixelHeight: number;
  60487. /**
  60488. * Gets image depth in pixels
  60489. */
  60490. pixelDepth: number;
  60491. /**
  60492. * Gets the number of array elements
  60493. */
  60494. numberOfArrayElements: number;
  60495. /**
  60496. * Gets the number of faces
  60497. */
  60498. numberOfFaces: number;
  60499. /**
  60500. * Gets the number of mipmap levels
  60501. */
  60502. numberOfMipmapLevels: number;
  60503. /**
  60504. * Gets the bytes of key value data
  60505. */
  60506. bytesOfKeyValueData: number;
  60507. /**
  60508. * Gets the load type
  60509. */
  60510. loadType: number;
  60511. /**
  60512. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60513. */
  60514. isInvalid: boolean;
  60515. /**
  60516. * Creates a new KhronosTextureContainer
  60517. * @param data contents of the KTX container file
  60518. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60519. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60520. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60521. */
  60522. constructor(
  60523. /** contents of the KTX container file */
  60524. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60525. /**
  60526. * Uploads KTX content to a Babylon Texture.
  60527. * It is assumed that the texture has already been created & is currently bound
  60528. * @hidden
  60529. */
  60530. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60531. private _upload2DCompressedLevels;
  60532. /**
  60533. * Checks if the given data starts with a KTX file identifier.
  60534. * @param data the data to check
  60535. * @returns true if the data is a KTX file or false otherwise
  60536. */
  60537. static IsValid(data: ArrayBufferView): boolean;
  60538. }
  60539. }
  60540. declare module "babylonjs/Misc/workerPool" {
  60541. import { IDisposable } from "babylonjs/scene";
  60542. /**
  60543. * Helper class to push actions to a pool of workers.
  60544. */
  60545. export class WorkerPool implements IDisposable {
  60546. private _workerInfos;
  60547. private _pendingActions;
  60548. /**
  60549. * Constructor
  60550. * @param workers Array of workers to use for actions
  60551. */
  60552. constructor(workers: Array<Worker>);
  60553. /**
  60554. * Terminates all workers and clears any pending actions.
  60555. */
  60556. dispose(): void;
  60557. /**
  60558. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60559. * pended until a worker has completed its action.
  60560. * @param action The action to perform. Call onComplete when the action is complete.
  60561. */
  60562. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60563. private _execute;
  60564. }
  60565. }
  60566. declare module "babylonjs/Misc/khronosTextureContainer2" {
  60567. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60568. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60569. /**
  60570. * Class for loading KTX2 files
  60571. */
  60572. export class KhronosTextureContainer2 {
  60573. private static _WorkerPoolPromise?;
  60574. private static _Initialized;
  60575. private static _Ktx2Decoder;
  60576. /**
  60577. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  60578. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  60579. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  60580. * Urls you can change:
  60581. * URLConfig.jsDecoderModule
  60582. * URLConfig.wasmUASTCToASTC
  60583. * URLConfig.wasmUASTCToBC7
  60584. * URLConfig.jsMSCTranscoder
  60585. * URLConfig.wasmMSCTranscoder
  60586. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  60587. */
  60588. static URLConfig: {
  60589. jsDecoderModule: string;
  60590. wasmUASTCToASTC: null;
  60591. wasmUASTCToBC7: null;
  60592. jsMSCTranscoder: null;
  60593. wasmMSCTranscoder: null;
  60594. };
  60595. /**
  60596. * Default number of workers used to handle data decoding
  60597. */
  60598. static DefaultNumWorkers: number;
  60599. private static GetDefaultNumWorkers;
  60600. private _engine;
  60601. private static _CreateWorkerPool;
  60602. /**
  60603. * Constructor
  60604. * @param engine The engine to use
  60605. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60606. */
  60607. constructor(engine: ThinEngine, numWorkers?: number);
  60608. /** @hidden */
  60609. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  60610. /**
  60611. * Stop all async operations and release resources.
  60612. */
  60613. dispose(): void;
  60614. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  60615. /**
  60616. * Checks if the given data starts with a KTX2 file identifier.
  60617. * @param data the data to check
  60618. * @returns true if the data is a KTX2 file or false otherwise
  60619. */
  60620. static IsValid(data: ArrayBufferView): boolean;
  60621. }
  60622. }
  60623. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  60624. import { Nullable } from "babylonjs/types";
  60625. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60626. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60627. /**
  60628. * Implementation of the KTX Texture Loader.
  60629. * @hidden
  60630. */
  60631. export class _KTXTextureLoader implements IInternalTextureLoader {
  60632. /**
  60633. * Defines wether the loader supports cascade loading the different faces.
  60634. */
  60635. readonly supportCascades: boolean;
  60636. /**
  60637. * This returns if the loader support the current file information.
  60638. * @param extension defines the file extension of the file being loaded
  60639. * @param mimeType defines the optional mime type of the file being loaded
  60640. * @returns true if the loader can load the specified file
  60641. */
  60642. canLoad(extension: string, mimeType?: string): boolean;
  60643. /**
  60644. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60645. * @param data contains the texture data
  60646. * @param texture defines the BabylonJS internal texture
  60647. * @param createPolynomials will be true if polynomials have been requested
  60648. * @param onLoad defines the callback to trigger once the texture is ready
  60649. * @param onError defines the callback to trigger in case of error
  60650. */
  60651. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60652. /**
  60653. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60654. * @param data contains the texture data
  60655. * @param texture defines the BabylonJS internal texture
  60656. * @param callback defines the method to call once ready to upload
  60657. */
  60658. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  60659. }
  60660. }
  60661. declare module "babylonjs/Helpers/sceneHelpers" {
  60662. import { Nullable } from "babylonjs/types";
  60663. import { Mesh } from "babylonjs/Meshes/mesh";
  60664. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60665. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  60666. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  60667. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60668. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60669. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60670. import "babylonjs/Meshes/Builders/boxBuilder";
  60671. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60672. /** @hidden */
  60673. export var _forceSceneHelpersToBundle: boolean;
  60674. module "babylonjs/scene" {
  60675. interface Scene {
  60676. /**
  60677. * Creates a default light for the scene.
  60678. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60679. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60680. */
  60681. createDefaultLight(replace?: boolean): void;
  60682. /**
  60683. * Creates a default camera for the scene.
  60684. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60685. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60686. * @param replace has default false, when true replaces the active camera in the scene
  60687. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60688. */
  60689. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60690. /**
  60691. * Creates a default camera and a default light.
  60692. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60693. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60694. * @param replace has the default false, when true replaces the active camera/light in the scene
  60695. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60696. */
  60697. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60698. /**
  60699. * Creates a new sky box
  60700. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60701. * @param environmentTexture defines the texture to use as environment texture
  60702. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60703. * @param scale defines the overall scale of the skybox
  60704. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60705. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60706. * @returns a new mesh holding the sky box
  60707. */
  60708. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60709. /**
  60710. * Creates a new environment
  60711. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60712. * @param options defines the options you can use to configure the environment
  60713. * @returns the new EnvironmentHelper
  60714. */
  60715. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60716. /**
  60717. * Creates a new VREXperienceHelper
  60718. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60719. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60720. * @returns a new VREXperienceHelper
  60721. */
  60722. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60723. /**
  60724. * Creates a new WebXRDefaultExperience
  60725. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60726. * @param options experience options
  60727. * @returns a promise for a new WebXRDefaultExperience
  60728. */
  60729. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60730. }
  60731. }
  60732. }
  60733. declare module "babylonjs/Helpers/videoDome" {
  60734. import { Scene } from "babylonjs/scene";
  60735. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60736. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60737. /**
  60738. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60739. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60740. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60741. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60742. */
  60743. export class VideoDome extends TextureDome<VideoTexture> {
  60744. /**
  60745. * Define the video source as a Monoscopic panoramic 360 video.
  60746. */
  60747. static readonly MODE_MONOSCOPIC: number;
  60748. /**
  60749. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60750. */
  60751. static readonly MODE_TOPBOTTOM: number;
  60752. /**
  60753. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60754. */
  60755. static readonly MODE_SIDEBYSIDE: number;
  60756. /**
  60757. * Get the video texture associated with this video dome
  60758. */
  60759. get videoTexture(): VideoTexture;
  60760. /**
  60761. * Get the video mode of this dome
  60762. */
  60763. get videoMode(): number;
  60764. /**
  60765. * Set the video mode of this dome.
  60766. * @see textureMode
  60767. */
  60768. set videoMode(value: number);
  60769. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  60770. }
  60771. }
  60772. declare module "babylonjs/Helpers/index" {
  60773. export * from "babylonjs/Helpers/environmentHelper";
  60774. export * from "babylonjs/Helpers/photoDome";
  60775. export * from "babylonjs/Helpers/sceneHelpers";
  60776. export * from "babylonjs/Helpers/videoDome";
  60777. }
  60778. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60779. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60780. import { IDisposable } from "babylonjs/scene";
  60781. import { Engine } from "babylonjs/Engines/engine";
  60782. /**
  60783. * This class can be used to get instrumentation data from a Babylon engine
  60784. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60785. */
  60786. export class EngineInstrumentation implements IDisposable {
  60787. /**
  60788. * Define the instrumented engine.
  60789. */
  60790. engine: Engine;
  60791. private _captureGPUFrameTime;
  60792. private _gpuFrameTimeToken;
  60793. private _gpuFrameTime;
  60794. private _captureShaderCompilationTime;
  60795. private _shaderCompilationTime;
  60796. private _onBeginFrameObserver;
  60797. private _onEndFrameObserver;
  60798. private _onBeforeShaderCompilationObserver;
  60799. private _onAfterShaderCompilationObserver;
  60800. /**
  60801. * Gets the perf counter used for GPU frame time
  60802. */
  60803. get gpuFrameTimeCounter(): PerfCounter;
  60804. /**
  60805. * Gets the GPU frame time capture status
  60806. */
  60807. get captureGPUFrameTime(): boolean;
  60808. /**
  60809. * Enable or disable the GPU frame time capture
  60810. */
  60811. set captureGPUFrameTime(value: boolean);
  60812. /**
  60813. * Gets the perf counter used for shader compilation time
  60814. */
  60815. get shaderCompilationTimeCounter(): PerfCounter;
  60816. /**
  60817. * Gets the shader compilation time capture status
  60818. */
  60819. get captureShaderCompilationTime(): boolean;
  60820. /**
  60821. * Enable or disable the shader compilation time capture
  60822. */
  60823. set captureShaderCompilationTime(value: boolean);
  60824. /**
  60825. * Instantiates a new engine instrumentation.
  60826. * This class can be used to get instrumentation data from a Babylon engine
  60827. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60828. * @param engine Defines the engine to instrument
  60829. */
  60830. constructor(
  60831. /**
  60832. * Define the instrumented engine.
  60833. */
  60834. engine: Engine);
  60835. /**
  60836. * Dispose and release associated resources.
  60837. */
  60838. dispose(): void;
  60839. }
  60840. }
  60841. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60842. import { Scene, IDisposable } from "babylonjs/scene";
  60843. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60844. /**
  60845. * This class can be used to get instrumentation data from a Babylon engine
  60846. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60847. */
  60848. export class SceneInstrumentation implements IDisposable {
  60849. /**
  60850. * Defines the scene to instrument
  60851. */
  60852. scene: Scene;
  60853. private _captureActiveMeshesEvaluationTime;
  60854. private _activeMeshesEvaluationTime;
  60855. private _captureRenderTargetsRenderTime;
  60856. private _renderTargetsRenderTime;
  60857. private _captureFrameTime;
  60858. private _frameTime;
  60859. private _captureRenderTime;
  60860. private _renderTime;
  60861. private _captureInterFrameTime;
  60862. private _interFrameTime;
  60863. private _captureParticlesRenderTime;
  60864. private _particlesRenderTime;
  60865. private _captureSpritesRenderTime;
  60866. private _spritesRenderTime;
  60867. private _capturePhysicsTime;
  60868. private _physicsTime;
  60869. private _captureAnimationsTime;
  60870. private _animationsTime;
  60871. private _captureCameraRenderTime;
  60872. private _cameraRenderTime;
  60873. private _onBeforeActiveMeshesEvaluationObserver;
  60874. private _onAfterActiveMeshesEvaluationObserver;
  60875. private _onBeforeRenderTargetsRenderObserver;
  60876. private _onAfterRenderTargetsRenderObserver;
  60877. private _onAfterRenderObserver;
  60878. private _onBeforeDrawPhaseObserver;
  60879. private _onAfterDrawPhaseObserver;
  60880. private _onBeforeAnimationsObserver;
  60881. private _onBeforeParticlesRenderingObserver;
  60882. private _onAfterParticlesRenderingObserver;
  60883. private _onBeforeSpritesRenderingObserver;
  60884. private _onAfterSpritesRenderingObserver;
  60885. private _onBeforePhysicsObserver;
  60886. private _onAfterPhysicsObserver;
  60887. private _onAfterAnimationsObserver;
  60888. private _onBeforeCameraRenderObserver;
  60889. private _onAfterCameraRenderObserver;
  60890. /**
  60891. * Gets the perf counter used for active meshes evaluation time
  60892. */
  60893. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60894. /**
  60895. * Gets the active meshes evaluation time capture status
  60896. */
  60897. get captureActiveMeshesEvaluationTime(): boolean;
  60898. /**
  60899. * Enable or disable the active meshes evaluation time capture
  60900. */
  60901. set captureActiveMeshesEvaluationTime(value: boolean);
  60902. /**
  60903. * Gets the perf counter used for render targets render time
  60904. */
  60905. get renderTargetsRenderTimeCounter(): PerfCounter;
  60906. /**
  60907. * Gets the render targets render time capture status
  60908. */
  60909. get captureRenderTargetsRenderTime(): boolean;
  60910. /**
  60911. * Enable or disable the render targets render time capture
  60912. */
  60913. set captureRenderTargetsRenderTime(value: boolean);
  60914. /**
  60915. * Gets the perf counter used for particles render time
  60916. */
  60917. get particlesRenderTimeCounter(): PerfCounter;
  60918. /**
  60919. * Gets the particles render time capture status
  60920. */
  60921. get captureParticlesRenderTime(): boolean;
  60922. /**
  60923. * Enable or disable the particles render time capture
  60924. */
  60925. set captureParticlesRenderTime(value: boolean);
  60926. /**
  60927. * Gets the perf counter used for sprites render time
  60928. */
  60929. get spritesRenderTimeCounter(): PerfCounter;
  60930. /**
  60931. * Gets the sprites render time capture status
  60932. */
  60933. get captureSpritesRenderTime(): boolean;
  60934. /**
  60935. * Enable or disable the sprites render time capture
  60936. */
  60937. set captureSpritesRenderTime(value: boolean);
  60938. /**
  60939. * Gets the perf counter used for physics time
  60940. */
  60941. get physicsTimeCounter(): PerfCounter;
  60942. /**
  60943. * Gets the physics time capture status
  60944. */
  60945. get capturePhysicsTime(): boolean;
  60946. /**
  60947. * Enable or disable the physics time capture
  60948. */
  60949. set capturePhysicsTime(value: boolean);
  60950. /**
  60951. * Gets the perf counter used for animations time
  60952. */
  60953. get animationsTimeCounter(): PerfCounter;
  60954. /**
  60955. * Gets the animations time capture status
  60956. */
  60957. get captureAnimationsTime(): boolean;
  60958. /**
  60959. * Enable or disable the animations time capture
  60960. */
  60961. set captureAnimationsTime(value: boolean);
  60962. /**
  60963. * Gets the perf counter used for frame time capture
  60964. */
  60965. get frameTimeCounter(): PerfCounter;
  60966. /**
  60967. * Gets the frame time capture status
  60968. */
  60969. get captureFrameTime(): boolean;
  60970. /**
  60971. * Enable or disable the frame time capture
  60972. */
  60973. set captureFrameTime(value: boolean);
  60974. /**
  60975. * Gets the perf counter used for inter-frames time capture
  60976. */
  60977. get interFrameTimeCounter(): PerfCounter;
  60978. /**
  60979. * Gets the inter-frames time capture status
  60980. */
  60981. get captureInterFrameTime(): boolean;
  60982. /**
  60983. * Enable or disable the inter-frames time capture
  60984. */
  60985. set captureInterFrameTime(value: boolean);
  60986. /**
  60987. * Gets the perf counter used for render time capture
  60988. */
  60989. get renderTimeCounter(): PerfCounter;
  60990. /**
  60991. * Gets the render time capture status
  60992. */
  60993. get captureRenderTime(): boolean;
  60994. /**
  60995. * Enable or disable the render time capture
  60996. */
  60997. set captureRenderTime(value: boolean);
  60998. /**
  60999. * Gets the perf counter used for camera render time capture
  61000. */
  61001. get cameraRenderTimeCounter(): PerfCounter;
  61002. /**
  61003. * Gets the camera render time capture status
  61004. */
  61005. get captureCameraRenderTime(): boolean;
  61006. /**
  61007. * Enable or disable the camera render time capture
  61008. */
  61009. set captureCameraRenderTime(value: boolean);
  61010. /**
  61011. * Gets the perf counter used for draw calls
  61012. */
  61013. get drawCallsCounter(): PerfCounter;
  61014. /**
  61015. * Instantiates a new scene instrumentation.
  61016. * This class can be used to get instrumentation data from a Babylon engine
  61017. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61018. * @param scene Defines the scene to instrument
  61019. */
  61020. constructor(
  61021. /**
  61022. * Defines the scene to instrument
  61023. */
  61024. scene: Scene);
  61025. /**
  61026. * Dispose and release associated resources.
  61027. */
  61028. dispose(): void;
  61029. }
  61030. }
  61031. declare module "babylonjs/Instrumentation/index" {
  61032. export * from "babylonjs/Instrumentation/engineInstrumentation";
  61033. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  61034. export * from "babylonjs/Instrumentation/timeToken";
  61035. }
  61036. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  61037. /** @hidden */
  61038. export var glowMapGenerationPixelShader: {
  61039. name: string;
  61040. shader: string;
  61041. };
  61042. }
  61043. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  61044. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61045. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61046. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61047. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61048. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61049. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61050. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61051. /** @hidden */
  61052. export var glowMapGenerationVertexShader: {
  61053. name: string;
  61054. shader: string;
  61055. };
  61056. }
  61057. declare module "babylonjs/Layers/effectLayer" {
  61058. import { Observable } from "babylonjs/Misc/observable";
  61059. import { Nullable } from "babylonjs/types";
  61060. import { Camera } from "babylonjs/Cameras/camera";
  61061. import { Scene } from "babylonjs/scene";
  61062. import { ISize } from "babylonjs/Maths/math.size";
  61063. import { Color4 } from "babylonjs/Maths/math.color";
  61064. import { Engine } from "babylonjs/Engines/engine";
  61065. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61067. import { Mesh } from "babylonjs/Meshes/mesh";
  61068. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61069. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61070. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61071. import { Effect } from "babylonjs/Materials/effect";
  61072. import { Material } from "babylonjs/Materials/material";
  61073. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61074. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61075. /**
  61076. * Effect layer options. This helps customizing the behaviour
  61077. * of the effect layer.
  61078. */
  61079. export interface IEffectLayerOptions {
  61080. /**
  61081. * Multiplication factor apply to the canvas size to compute the render target size
  61082. * used to generated the objects (the smaller the faster).
  61083. */
  61084. mainTextureRatio: number;
  61085. /**
  61086. * Enforces a fixed size texture to ensure effect stability across devices.
  61087. */
  61088. mainTextureFixedSize?: number;
  61089. /**
  61090. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61091. */
  61092. alphaBlendingMode: number;
  61093. /**
  61094. * The camera attached to the layer.
  61095. */
  61096. camera: Nullable<Camera>;
  61097. /**
  61098. * The rendering group to draw the layer in.
  61099. */
  61100. renderingGroupId: number;
  61101. }
  61102. /**
  61103. * The effect layer Helps adding post process effect blended with the main pass.
  61104. *
  61105. * This can be for instance use to generate glow or higlight effects on the scene.
  61106. *
  61107. * The effect layer class can not be used directly and is intented to inherited from to be
  61108. * customized per effects.
  61109. */
  61110. export abstract class EffectLayer {
  61111. private _vertexBuffers;
  61112. private _indexBuffer;
  61113. private _cachedDefines;
  61114. private _effectLayerMapGenerationEffect;
  61115. private _effectLayerOptions;
  61116. private _mergeEffect;
  61117. protected _scene: Scene;
  61118. protected _engine: Engine;
  61119. protected _maxSize: number;
  61120. protected _mainTextureDesiredSize: ISize;
  61121. protected _mainTexture: RenderTargetTexture;
  61122. protected _shouldRender: boolean;
  61123. protected _postProcesses: PostProcess[];
  61124. protected _textures: BaseTexture[];
  61125. protected _emissiveTextureAndColor: {
  61126. texture: Nullable<BaseTexture>;
  61127. color: Color4;
  61128. };
  61129. /**
  61130. * The name of the layer
  61131. */
  61132. name: string;
  61133. /**
  61134. * The clear color of the texture used to generate the glow map.
  61135. */
  61136. neutralColor: Color4;
  61137. /**
  61138. * Specifies whether the highlight layer is enabled or not.
  61139. */
  61140. isEnabled: boolean;
  61141. /**
  61142. * Gets the camera attached to the layer.
  61143. */
  61144. get camera(): Nullable<Camera>;
  61145. /**
  61146. * Gets the rendering group id the layer should render in.
  61147. */
  61148. get renderingGroupId(): number;
  61149. set renderingGroupId(renderingGroupId: number);
  61150. /**
  61151. * An event triggered when the effect layer has been disposed.
  61152. */
  61153. onDisposeObservable: Observable<EffectLayer>;
  61154. /**
  61155. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61156. */
  61157. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61158. /**
  61159. * An event triggered when the generated texture is being merged in the scene.
  61160. */
  61161. onBeforeComposeObservable: Observable<EffectLayer>;
  61162. /**
  61163. * An event triggered when the mesh is rendered into the effect render target.
  61164. */
  61165. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61166. /**
  61167. * An event triggered after the mesh has been rendered into the effect render target.
  61168. */
  61169. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61170. /**
  61171. * An event triggered when the generated texture has been merged in the scene.
  61172. */
  61173. onAfterComposeObservable: Observable<EffectLayer>;
  61174. /**
  61175. * An event triggered when the efffect layer changes its size.
  61176. */
  61177. onSizeChangedObservable: Observable<EffectLayer>;
  61178. /** @hidden */
  61179. static _SceneComponentInitialization: (scene: Scene) => void;
  61180. /**
  61181. * Instantiates a new effect Layer and references it in the scene.
  61182. * @param name The name of the layer
  61183. * @param scene The scene to use the layer in
  61184. */
  61185. constructor(
  61186. /** The Friendly of the effect in the scene */
  61187. name: string, scene: Scene);
  61188. /**
  61189. * Get the effect name of the layer.
  61190. * @return The effect name
  61191. */
  61192. abstract getEffectName(): string;
  61193. /**
  61194. * Checks for the readiness of the element composing the layer.
  61195. * @param subMesh the mesh to check for
  61196. * @param useInstances specify whether or not to use instances to render the mesh
  61197. * @return true if ready otherwise, false
  61198. */
  61199. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61200. /**
  61201. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61202. * @returns true if the effect requires stencil during the main canvas render pass.
  61203. */
  61204. abstract needStencil(): boolean;
  61205. /**
  61206. * Create the merge effect. This is the shader use to blit the information back
  61207. * to the main canvas at the end of the scene rendering.
  61208. * @returns The effect containing the shader used to merge the effect on the main canvas
  61209. */
  61210. protected abstract _createMergeEffect(): Effect;
  61211. /**
  61212. * Creates the render target textures and post processes used in the effect layer.
  61213. */
  61214. protected abstract _createTextureAndPostProcesses(): void;
  61215. /**
  61216. * Implementation specific of rendering the generating effect on the main canvas.
  61217. * @param effect The effect used to render through
  61218. */
  61219. protected abstract _internalRender(effect: Effect): void;
  61220. /**
  61221. * Sets the required values for both the emissive texture and and the main color.
  61222. */
  61223. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61224. /**
  61225. * Free any resources and references associated to a mesh.
  61226. * Internal use
  61227. * @param mesh The mesh to free.
  61228. */
  61229. abstract _disposeMesh(mesh: Mesh): void;
  61230. /**
  61231. * Serializes this layer (Glow or Highlight for example)
  61232. * @returns a serialized layer object
  61233. */
  61234. abstract serialize?(): any;
  61235. /**
  61236. * Initializes the effect layer with the required options.
  61237. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61238. */
  61239. protected _init(options: Partial<IEffectLayerOptions>): void;
  61240. /**
  61241. * Generates the index buffer of the full screen quad blending to the main canvas.
  61242. */
  61243. private _generateIndexBuffer;
  61244. /**
  61245. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61246. */
  61247. private _generateVertexBuffer;
  61248. /**
  61249. * Sets the main texture desired size which is the closest power of two
  61250. * of the engine canvas size.
  61251. */
  61252. private _setMainTextureSize;
  61253. /**
  61254. * Creates the main texture for the effect layer.
  61255. */
  61256. protected _createMainTexture(): void;
  61257. /**
  61258. * Adds specific effects defines.
  61259. * @param defines The defines to add specifics to.
  61260. */
  61261. protected _addCustomEffectDefines(defines: string[]): void;
  61262. /**
  61263. * Checks for the readiness of the element composing the layer.
  61264. * @param subMesh the mesh to check for
  61265. * @param useInstances specify whether or not to use instances to render the mesh
  61266. * @param emissiveTexture the associated emissive texture used to generate the glow
  61267. * @return true if ready otherwise, false
  61268. */
  61269. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61270. /**
  61271. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61272. */
  61273. render(): void;
  61274. /**
  61275. * Determine if a given mesh will be used in the current effect.
  61276. * @param mesh mesh to test
  61277. * @returns true if the mesh will be used
  61278. */
  61279. hasMesh(mesh: AbstractMesh): boolean;
  61280. /**
  61281. * Returns true if the layer contains information to display, otherwise false.
  61282. * @returns true if the glow layer should be rendered
  61283. */
  61284. shouldRender(): boolean;
  61285. /**
  61286. * Returns true if the mesh should render, otherwise false.
  61287. * @param mesh The mesh to render
  61288. * @returns true if it should render otherwise false
  61289. */
  61290. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61291. /**
  61292. * Returns true if the mesh can be rendered, otherwise false.
  61293. * @param mesh The mesh to render
  61294. * @param material The material used on the mesh
  61295. * @returns true if it can be rendered otherwise false
  61296. */
  61297. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61298. /**
  61299. * Returns true if the mesh should render, otherwise false.
  61300. * @param mesh The mesh to render
  61301. * @returns true if it should render otherwise false
  61302. */
  61303. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61304. /**
  61305. * Renders the submesh passed in parameter to the generation map.
  61306. */
  61307. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61308. /**
  61309. * Defines whether the current material of the mesh should be use to render the effect.
  61310. * @param mesh defines the current mesh to render
  61311. */
  61312. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61313. /**
  61314. * Rebuild the required buffers.
  61315. * @hidden Internal use only.
  61316. */
  61317. _rebuild(): void;
  61318. /**
  61319. * Dispose only the render target textures and post process.
  61320. */
  61321. private _disposeTextureAndPostProcesses;
  61322. /**
  61323. * Dispose the highlight layer and free resources.
  61324. */
  61325. dispose(): void;
  61326. /**
  61327. * Gets the class name of the effect layer
  61328. * @returns the string with the class name of the effect layer
  61329. */
  61330. getClassName(): string;
  61331. /**
  61332. * Creates an effect layer from parsed effect layer data
  61333. * @param parsedEffectLayer defines effect layer data
  61334. * @param scene defines the current scene
  61335. * @param rootUrl defines the root URL containing the effect layer information
  61336. * @returns a parsed effect Layer
  61337. */
  61338. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61339. }
  61340. }
  61341. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61342. import { Scene } from "babylonjs/scene";
  61343. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61344. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61345. import { AbstractScene } from "babylonjs/abstractScene";
  61346. module "babylonjs/abstractScene" {
  61347. interface AbstractScene {
  61348. /**
  61349. * The list of effect layers (highlights/glow) added to the scene
  61350. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61351. * @see https://doc.babylonjs.com/how_to/glow_layer
  61352. */
  61353. effectLayers: Array<EffectLayer>;
  61354. /**
  61355. * Removes the given effect layer from this scene.
  61356. * @param toRemove defines the effect layer to remove
  61357. * @returns the index of the removed effect layer
  61358. */
  61359. removeEffectLayer(toRemove: EffectLayer): number;
  61360. /**
  61361. * Adds the given effect layer to this scene
  61362. * @param newEffectLayer defines the effect layer to add
  61363. */
  61364. addEffectLayer(newEffectLayer: EffectLayer): void;
  61365. }
  61366. }
  61367. /**
  61368. * Defines the layer scene component responsible to manage any effect layers
  61369. * in a given scene.
  61370. */
  61371. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61372. /**
  61373. * The component name helpfull to identify the component in the list of scene components.
  61374. */
  61375. readonly name: string;
  61376. /**
  61377. * The scene the component belongs to.
  61378. */
  61379. scene: Scene;
  61380. private _engine;
  61381. private _renderEffects;
  61382. private _needStencil;
  61383. private _previousStencilState;
  61384. /**
  61385. * Creates a new instance of the component for the given scene
  61386. * @param scene Defines the scene to register the component in
  61387. */
  61388. constructor(scene: Scene);
  61389. /**
  61390. * Registers the component in a given scene
  61391. */
  61392. register(): void;
  61393. /**
  61394. * Rebuilds the elements related to this component in case of
  61395. * context lost for instance.
  61396. */
  61397. rebuild(): void;
  61398. /**
  61399. * Serializes the component data to the specified json object
  61400. * @param serializationObject The object to serialize to
  61401. */
  61402. serialize(serializationObject: any): void;
  61403. /**
  61404. * Adds all the elements from the container to the scene
  61405. * @param container the container holding the elements
  61406. */
  61407. addFromContainer(container: AbstractScene): void;
  61408. /**
  61409. * Removes all the elements in the container from the scene
  61410. * @param container contains the elements to remove
  61411. * @param dispose if the removed element should be disposed (default: false)
  61412. */
  61413. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61414. /**
  61415. * Disposes the component and the associated ressources.
  61416. */
  61417. dispose(): void;
  61418. private _isReadyForMesh;
  61419. private _renderMainTexture;
  61420. private _setStencil;
  61421. private _setStencilBack;
  61422. private _draw;
  61423. private _drawCamera;
  61424. private _drawRenderingGroup;
  61425. }
  61426. }
  61427. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61428. /** @hidden */
  61429. export var glowMapMergePixelShader: {
  61430. name: string;
  61431. shader: string;
  61432. };
  61433. }
  61434. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61435. /** @hidden */
  61436. export var glowMapMergeVertexShader: {
  61437. name: string;
  61438. shader: string;
  61439. };
  61440. }
  61441. declare module "babylonjs/Layers/glowLayer" {
  61442. import { Nullable } from "babylonjs/types";
  61443. import { Camera } from "babylonjs/Cameras/camera";
  61444. import { Scene } from "babylonjs/scene";
  61445. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61447. import { Mesh } from "babylonjs/Meshes/mesh";
  61448. import { Texture } from "babylonjs/Materials/Textures/texture";
  61449. import { Effect } from "babylonjs/Materials/effect";
  61450. import { Material } from "babylonjs/Materials/material";
  61451. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61452. import { Color4 } from "babylonjs/Maths/math.color";
  61453. import "babylonjs/Shaders/glowMapMerge.fragment";
  61454. import "babylonjs/Shaders/glowMapMerge.vertex";
  61455. import "babylonjs/Layers/effectLayerSceneComponent";
  61456. module "babylonjs/abstractScene" {
  61457. interface AbstractScene {
  61458. /**
  61459. * Return a the first highlight layer of the scene with a given name.
  61460. * @param name The name of the highlight layer to look for.
  61461. * @return The highlight layer if found otherwise null.
  61462. */
  61463. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61464. }
  61465. }
  61466. /**
  61467. * Glow layer options. This helps customizing the behaviour
  61468. * of the glow layer.
  61469. */
  61470. export interface IGlowLayerOptions {
  61471. /**
  61472. * Multiplication factor apply to the canvas size to compute the render target size
  61473. * used to generated the glowing objects (the smaller the faster).
  61474. */
  61475. mainTextureRatio: number;
  61476. /**
  61477. * Enforces a fixed size texture to ensure resize independant blur.
  61478. */
  61479. mainTextureFixedSize?: number;
  61480. /**
  61481. * How big is the kernel of the blur texture.
  61482. */
  61483. blurKernelSize: number;
  61484. /**
  61485. * The camera attached to the layer.
  61486. */
  61487. camera: Nullable<Camera>;
  61488. /**
  61489. * Enable MSAA by chosing the number of samples.
  61490. */
  61491. mainTextureSamples?: number;
  61492. /**
  61493. * The rendering group to draw the layer in.
  61494. */
  61495. renderingGroupId: number;
  61496. }
  61497. /**
  61498. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61499. *
  61500. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61501. *
  61502. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61503. */
  61504. export class GlowLayer extends EffectLayer {
  61505. /**
  61506. * Effect Name of the layer.
  61507. */
  61508. static readonly EffectName: string;
  61509. /**
  61510. * The default blur kernel size used for the glow.
  61511. */
  61512. static DefaultBlurKernelSize: number;
  61513. /**
  61514. * The default texture size ratio used for the glow.
  61515. */
  61516. static DefaultTextureRatio: number;
  61517. /**
  61518. * Sets the kernel size of the blur.
  61519. */
  61520. set blurKernelSize(value: number);
  61521. /**
  61522. * Gets the kernel size of the blur.
  61523. */
  61524. get blurKernelSize(): number;
  61525. /**
  61526. * Sets the glow intensity.
  61527. */
  61528. set intensity(value: number);
  61529. /**
  61530. * Gets the glow intensity.
  61531. */
  61532. get intensity(): number;
  61533. private _options;
  61534. private _intensity;
  61535. private _horizontalBlurPostprocess1;
  61536. private _verticalBlurPostprocess1;
  61537. private _horizontalBlurPostprocess2;
  61538. private _verticalBlurPostprocess2;
  61539. private _blurTexture1;
  61540. private _blurTexture2;
  61541. private _postProcesses1;
  61542. private _postProcesses2;
  61543. private _includedOnlyMeshes;
  61544. private _excludedMeshes;
  61545. private _meshesUsingTheirOwnMaterials;
  61546. /**
  61547. * Callback used to let the user override the color selection on a per mesh basis
  61548. */
  61549. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61550. /**
  61551. * Callback used to let the user override the texture selection on a per mesh basis
  61552. */
  61553. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61554. /**
  61555. * Instantiates a new glow Layer and references it to the scene.
  61556. * @param name The name of the layer
  61557. * @param scene The scene to use the layer in
  61558. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61559. */
  61560. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  61561. /**
  61562. * Get the effect name of the layer.
  61563. * @return The effect name
  61564. */
  61565. getEffectName(): string;
  61566. /**
  61567. * Create the merge effect. This is the shader use to blit the information back
  61568. * to the main canvas at the end of the scene rendering.
  61569. */
  61570. protected _createMergeEffect(): Effect;
  61571. /**
  61572. * Creates the render target textures and post processes used in the glow layer.
  61573. */
  61574. protected _createTextureAndPostProcesses(): void;
  61575. /**
  61576. * Checks for the readiness of the element composing the layer.
  61577. * @param subMesh the mesh to check for
  61578. * @param useInstances specify wether or not to use instances to render the mesh
  61579. * @param emissiveTexture the associated emissive texture used to generate the glow
  61580. * @return true if ready otherwise, false
  61581. */
  61582. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61583. /**
  61584. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61585. */
  61586. needStencil(): boolean;
  61587. /**
  61588. * Returns true if the mesh can be rendered, otherwise false.
  61589. * @param mesh The mesh to render
  61590. * @param material The material used on the mesh
  61591. * @returns true if it can be rendered otherwise false
  61592. */
  61593. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61594. /**
  61595. * Implementation specific of rendering the generating effect on the main canvas.
  61596. * @param effect The effect used to render through
  61597. */
  61598. protected _internalRender(effect: Effect): void;
  61599. /**
  61600. * Sets the required values for both the emissive texture and and the main color.
  61601. */
  61602. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61603. /**
  61604. * Returns true if the mesh should render, otherwise false.
  61605. * @param mesh The mesh to render
  61606. * @returns true if it should render otherwise false
  61607. */
  61608. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61609. /**
  61610. * Adds specific effects defines.
  61611. * @param defines The defines to add specifics to.
  61612. */
  61613. protected _addCustomEffectDefines(defines: string[]): void;
  61614. /**
  61615. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61616. * @param mesh The mesh to exclude from the glow layer
  61617. */
  61618. addExcludedMesh(mesh: Mesh): void;
  61619. /**
  61620. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61621. * @param mesh The mesh to remove
  61622. */
  61623. removeExcludedMesh(mesh: Mesh): void;
  61624. /**
  61625. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61626. * @param mesh The mesh to include in the glow layer
  61627. */
  61628. addIncludedOnlyMesh(mesh: Mesh): void;
  61629. /**
  61630. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61631. * @param mesh The mesh to remove
  61632. */
  61633. removeIncludedOnlyMesh(mesh: Mesh): void;
  61634. /**
  61635. * Determine if a given mesh will be used in the glow layer
  61636. * @param mesh The mesh to test
  61637. * @returns true if the mesh will be highlighted by the current glow layer
  61638. */
  61639. hasMesh(mesh: AbstractMesh): boolean;
  61640. /**
  61641. * Defines whether the current material of the mesh should be use to render the effect.
  61642. * @param mesh defines the current mesh to render
  61643. */
  61644. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61645. /**
  61646. * Add a mesh to be rendered through its own material and not with emissive only.
  61647. * @param mesh The mesh for which we need to use its material
  61648. */
  61649. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61650. /**
  61651. * Remove a mesh from being rendered through its own material and not with emissive only.
  61652. * @param mesh The mesh for which we need to not use its material
  61653. */
  61654. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61655. /**
  61656. * Free any resources and references associated to a mesh.
  61657. * Internal use
  61658. * @param mesh The mesh to free.
  61659. * @hidden
  61660. */
  61661. _disposeMesh(mesh: Mesh): void;
  61662. /**
  61663. * Gets the class name of the effect layer
  61664. * @returns the string with the class name of the effect layer
  61665. */
  61666. getClassName(): string;
  61667. /**
  61668. * Serializes this glow layer
  61669. * @returns a serialized glow layer object
  61670. */
  61671. serialize(): any;
  61672. /**
  61673. * Creates a Glow Layer from parsed glow layer data
  61674. * @param parsedGlowLayer defines glow layer data
  61675. * @param scene defines the current scene
  61676. * @param rootUrl defines the root URL containing the glow layer information
  61677. * @returns a parsed Glow Layer
  61678. */
  61679. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61680. }
  61681. }
  61682. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61683. /** @hidden */
  61684. export var glowBlurPostProcessPixelShader: {
  61685. name: string;
  61686. shader: string;
  61687. };
  61688. }
  61689. declare module "babylonjs/Layers/highlightLayer" {
  61690. import { Observable } from "babylonjs/Misc/observable";
  61691. import { Nullable } from "babylonjs/types";
  61692. import { Camera } from "babylonjs/Cameras/camera";
  61693. import { Scene } from "babylonjs/scene";
  61694. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61696. import { Mesh } from "babylonjs/Meshes/mesh";
  61697. import { Effect } from "babylonjs/Materials/effect";
  61698. import { Material } from "babylonjs/Materials/material";
  61699. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61700. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61701. import "babylonjs/Shaders/glowMapMerge.fragment";
  61702. import "babylonjs/Shaders/glowMapMerge.vertex";
  61703. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61704. module "babylonjs/abstractScene" {
  61705. interface AbstractScene {
  61706. /**
  61707. * Return a the first highlight layer of the scene with a given name.
  61708. * @param name The name of the highlight layer to look for.
  61709. * @return The highlight layer if found otherwise null.
  61710. */
  61711. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61712. }
  61713. }
  61714. /**
  61715. * Highlight layer options. This helps customizing the behaviour
  61716. * of the highlight layer.
  61717. */
  61718. export interface IHighlightLayerOptions {
  61719. /**
  61720. * Multiplication factor apply to the canvas size to compute the render target size
  61721. * used to generated the glowing objects (the smaller the faster).
  61722. */
  61723. mainTextureRatio: number;
  61724. /**
  61725. * Enforces a fixed size texture to ensure resize independant blur.
  61726. */
  61727. mainTextureFixedSize?: number;
  61728. /**
  61729. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61730. * of the picture to blur (the smaller the faster).
  61731. */
  61732. blurTextureSizeRatio: number;
  61733. /**
  61734. * How big in texel of the blur texture is the vertical blur.
  61735. */
  61736. blurVerticalSize: number;
  61737. /**
  61738. * How big in texel of the blur texture is the horizontal blur.
  61739. */
  61740. blurHorizontalSize: number;
  61741. /**
  61742. * Alpha blending mode used to apply the blur. Default is combine.
  61743. */
  61744. alphaBlendingMode: number;
  61745. /**
  61746. * The camera attached to the layer.
  61747. */
  61748. camera: Nullable<Camera>;
  61749. /**
  61750. * Should we display highlight as a solid stroke?
  61751. */
  61752. isStroke?: boolean;
  61753. /**
  61754. * The rendering group to draw the layer in.
  61755. */
  61756. renderingGroupId: number;
  61757. }
  61758. /**
  61759. * The highlight layer Helps adding a glow effect around a mesh.
  61760. *
  61761. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61762. * glowy meshes to your scene.
  61763. *
  61764. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61765. */
  61766. export class HighlightLayer extends EffectLayer {
  61767. name: string;
  61768. /**
  61769. * Effect Name of the highlight layer.
  61770. */
  61771. static readonly EffectName: string;
  61772. /**
  61773. * The neutral color used during the preparation of the glow effect.
  61774. * This is black by default as the blend operation is a blend operation.
  61775. */
  61776. static NeutralColor: Color4;
  61777. /**
  61778. * Stencil value used for glowing meshes.
  61779. */
  61780. static GlowingMeshStencilReference: number;
  61781. /**
  61782. * Stencil value used for the other meshes in the scene.
  61783. */
  61784. static NormalMeshStencilReference: number;
  61785. /**
  61786. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61787. */
  61788. innerGlow: boolean;
  61789. /**
  61790. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61791. */
  61792. outerGlow: boolean;
  61793. /**
  61794. * Specifies the horizontal size of the blur.
  61795. */
  61796. set blurHorizontalSize(value: number);
  61797. /**
  61798. * Specifies the vertical size of the blur.
  61799. */
  61800. set blurVerticalSize(value: number);
  61801. /**
  61802. * Gets the horizontal size of the blur.
  61803. */
  61804. get blurHorizontalSize(): number;
  61805. /**
  61806. * Gets the vertical size of the blur.
  61807. */
  61808. get blurVerticalSize(): number;
  61809. /**
  61810. * An event triggered when the highlight layer is being blurred.
  61811. */
  61812. onBeforeBlurObservable: Observable<HighlightLayer>;
  61813. /**
  61814. * An event triggered when the highlight layer has been blurred.
  61815. */
  61816. onAfterBlurObservable: Observable<HighlightLayer>;
  61817. private _instanceGlowingMeshStencilReference;
  61818. private _options;
  61819. private _downSamplePostprocess;
  61820. private _horizontalBlurPostprocess;
  61821. private _verticalBlurPostprocess;
  61822. private _blurTexture;
  61823. private _meshes;
  61824. private _excludedMeshes;
  61825. /**
  61826. * Instantiates a new highlight Layer and references it to the scene..
  61827. * @param name The name of the layer
  61828. * @param scene The scene to use the layer in
  61829. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61830. */
  61831. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61832. /**
  61833. * Get the effect name of the layer.
  61834. * @return The effect name
  61835. */
  61836. getEffectName(): string;
  61837. /**
  61838. * Create the merge effect. This is the shader use to blit the information back
  61839. * to the main canvas at the end of the scene rendering.
  61840. */
  61841. protected _createMergeEffect(): Effect;
  61842. /**
  61843. * Creates the render target textures and post processes used in the highlight layer.
  61844. */
  61845. protected _createTextureAndPostProcesses(): void;
  61846. /**
  61847. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61848. */
  61849. needStencil(): boolean;
  61850. /**
  61851. * Checks for the readiness of the element composing the layer.
  61852. * @param subMesh the mesh to check for
  61853. * @param useInstances specify wether or not to use instances to render the mesh
  61854. * @param emissiveTexture the associated emissive texture used to generate the glow
  61855. * @return true if ready otherwise, false
  61856. */
  61857. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61858. /**
  61859. * Implementation specific of rendering the generating effect on the main canvas.
  61860. * @param effect The effect used to render through
  61861. */
  61862. protected _internalRender(effect: Effect): void;
  61863. /**
  61864. * Returns true if the layer contains information to display, otherwise false.
  61865. */
  61866. shouldRender(): boolean;
  61867. /**
  61868. * Returns true if the mesh should render, otherwise false.
  61869. * @param mesh The mesh to render
  61870. * @returns true if it should render otherwise false
  61871. */
  61872. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61873. /**
  61874. * Returns true if the mesh can be rendered, otherwise false.
  61875. * @param mesh The mesh to render
  61876. * @param material The material used on the mesh
  61877. * @returns true if it can be rendered otherwise false
  61878. */
  61879. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61880. /**
  61881. * Adds specific effects defines.
  61882. * @param defines The defines to add specifics to.
  61883. */
  61884. protected _addCustomEffectDefines(defines: string[]): void;
  61885. /**
  61886. * Sets the required values for both the emissive texture and and the main color.
  61887. */
  61888. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61889. /**
  61890. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61891. * @param mesh The mesh to exclude from the highlight layer
  61892. */
  61893. addExcludedMesh(mesh: Mesh): void;
  61894. /**
  61895. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61896. * @param mesh The mesh to highlight
  61897. */
  61898. removeExcludedMesh(mesh: Mesh): void;
  61899. /**
  61900. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61901. * @param mesh mesh to test
  61902. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61903. */
  61904. hasMesh(mesh: AbstractMesh): boolean;
  61905. /**
  61906. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61907. * @param mesh The mesh to highlight
  61908. * @param color The color of the highlight
  61909. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61910. */
  61911. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61912. /**
  61913. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61914. * @param mesh The mesh to highlight
  61915. */
  61916. removeMesh(mesh: Mesh): void;
  61917. /**
  61918. * Remove all the meshes currently referenced in the highlight layer
  61919. */
  61920. removeAllMeshes(): void;
  61921. /**
  61922. * Force the stencil to the normal expected value for none glowing parts
  61923. */
  61924. private _defaultStencilReference;
  61925. /**
  61926. * Free any resources and references associated to a mesh.
  61927. * Internal use
  61928. * @param mesh The mesh to free.
  61929. * @hidden
  61930. */
  61931. _disposeMesh(mesh: Mesh): void;
  61932. /**
  61933. * Dispose the highlight layer and free resources.
  61934. */
  61935. dispose(): void;
  61936. /**
  61937. * Gets the class name of the effect layer
  61938. * @returns the string with the class name of the effect layer
  61939. */
  61940. getClassName(): string;
  61941. /**
  61942. * Serializes this Highlight layer
  61943. * @returns a serialized Highlight layer object
  61944. */
  61945. serialize(): any;
  61946. /**
  61947. * Creates a Highlight layer from parsed Highlight layer data
  61948. * @param parsedHightlightLayer defines the Highlight layer data
  61949. * @param scene defines the current scene
  61950. * @param rootUrl defines the root URL containing the Highlight layer information
  61951. * @returns a parsed Highlight layer
  61952. */
  61953. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61954. }
  61955. }
  61956. declare module "babylonjs/Layers/layerSceneComponent" {
  61957. import { Scene } from "babylonjs/scene";
  61958. import { ISceneComponent } from "babylonjs/sceneComponent";
  61959. import { Layer } from "babylonjs/Layers/layer";
  61960. import { AbstractScene } from "babylonjs/abstractScene";
  61961. module "babylonjs/abstractScene" {
  61962. interface AbstractScene {
  61963. /**
  61964. * The list of layers (background and foreground) of the scene
  61965. */
  61966. layers: Array<Layer>;
  61967. }
  61968. }
  61969. /**
  61970. * Defines the layer scene component responsible to manage any layers
  61971. * in a given scene.
  61972. */
  61973. export class LayerSceneComponent implements ISceneComponent {
  61974. /**
  61975. * The component name helpfull to identify the component in the list of scene components.
  61976. */
  61977. readonly name: string;
  61978. /**
  61979. * The scene the component belongs to.
  61980. */
  61981. scene: Scene;
  61982. private _engine;
  61983. /**
  61984. * Creates a new instance of the component for the given scene
  61985. * @param scene Defines the scene to register the component in
  61986. */
  61987. constructor(scene: Scene);
  61988. /**
  61989. * Registers the component in a given scene
  61990. */
  61991. register(): void;
  61992. /**
  61993. * Rebuilds the elements related to this component in case of
  61994. * context lost for instance.
  61995. */
  61996. rebuild(): void;
  61997. /**
  61998. * Disposes the component and the associated ressources.
  61999. */
  62000. dispose(): void;
  62001. private _draw;
  62002. private _drawCameraPredicate;
  62003. private _drawCameraBackground;
  62004. private _drawCameraForeground;
  62005. private _drawRenderTargetPredicate;
  62006. private _drawRenderTargetBackground;
  62007. private _drawRenderTargetForeground;
  62008. /**
  62009. * Adds all the elements from the container to the scene
  62010. * @param container the container holding the elements
  62011. */
  62012. addFromContainer(container: AbstractScene): void;
  62013. /**
  62014. * Removes all the elements in the container from the scene
  62015. * @param container contains the elements to remove
  62016. * @param dispose if the removed element should be disposed (default: false)
  62017. */
  62018. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62019. }
  62020. }
  62021. declare module "babylonjs/Shaders/layer.fragment" {
  62022. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62023. /** @hidden */
  62024. export var layerPixelShader: {
  62025. name: string;
  62026. shader: string;
  62027. };
  62028. }
  62029. declare module "babylonjs/Shaders/layer.vertex" {
  62030. /** @hidden */
  62031. export var layerVertexShader: {
  62032. name: string;
  62033. shader: string;
  62034. };
  62035. }
  62036. declare module "babylonjs/Layers/layer" {
  62037. import { Observable } from "babylonjs/Misc/observable";
  62038. import { Nullable } from "babylonjs/types";
  62039. import { Scene } from "babylonjs/scene";
  62040. import { Vector2 } from "babylonjs/Maths/math.vector";
  62041. import { Color4 } from "babylonjs/Maths/math.color";
  62042. import { Texture } from "babylonjs/Materials/Textures/texture";
  62043. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62044. import "babylonjs/Shaders/layer.fragment";
  62045. import "babylonjs/Shaders/layer.vertex";
  62046. /**
  62047. * This represents a full screen 2d layer.
  62048. * This can be useful to display a picture in the background of your scene for instance.
  62049. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62050. */
  62051. export class Layer {
  62052. /**
  62053. * Define the name of the layer.
  62054. */
  62055. name: string;
  62056. /**
  62057. * Define the texture the layer should display.
  62058. */
  62059. texture: Nullable<Texture>;
  62060. /**
  62061. * Is the layer in background or foreground.
  62062. */
  62063. isBackground: boolean;
  62064. /**
  62065. * Define the color of the layer (instead of texture).
  62066. */
  62067. color: Color4;
  62068. /**
  62069. * Define the scale of the layer in order to zoom in out of the texture.
  62070. */
  62071. scale: Vector2;
  62072. /**
  62073. * Define an offset for the layer in order to shift the texture.
  62074. */
  62075. offset: Vector2;
  62076. /**
  62077. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62078. */
  62079. alphaBlendingMode: number;
  62080. /**
  62081. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62082. * Alpha test will not mix with the background color in case of transparency.
  62083. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62084. */
  62085. alphaTest: boolean;
  62086. /**
  62087. * Define a mask to restrict the layer to only some of the scene cameras.
  62088. */
  62089. layerMask: number;
  62090. /**
  62091. * Define the list of render target the layer is visible into.
  62092. */
  62093. renderTargetTextures: RenderTargetTexture[];
  62094. /**
  62095. * Define if the layer is only used in renderTarget or if it also
  62096. * renders in the main frame buffer of the canvas.
  62097. */
  62098. renderOnlyInRenderTargetTextures: boolean;
  62099. private _scene;
  62100. private _vertexBuffers;
  62101. private _indexBuffer;
  62102. private _effect;
  62103. private _previousDefines;
  62104. /**
  62105. * An event triggered when the layer is disposed.
  62106. */
  62107. onDisposeObservable: Observable<Layer>;
  62108. private _onDisposeObserver;
  62109. /**
  62110. * Back compatibility with callback before the onDisposeObservable existed.
  62111. * The set callback will be triggered when the layer has been disposed.
  62112. */
  62113. set onDispose(callback: () => void);
  62114. /**
  62115. * An event triggered before rendering the scene
  62116. */
  62117. onBeforeRenderObservable: Observable<Layer>;
  62118. private _onBeforeRenderObserver;
  62119. /**
  62120. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62121. * The set callback will be triggered just before rendering the layer.
  62122. */
  62123. set onBeforeRender(callback: () => void);
  62124. /**
  62125. * An event triggered after rendering the scene
  62126. */
  62127. onAfterRenderObservable: Observable<Layer>;
  62128. private _onAfterRenderObserver;
  62129. /**
  62130. * Back compatibility with callback before the onAfterRenderObservable existed.
  62131. * The set callback will be triggered just after rendering the layer.
  62132. */
  62133. set onAfterRender(callback: () => void);
  62134. /**
  62135. * Instantiates a new layer.
  62136. * This represents a full screen 2d layer.
  62137. * This can be useful to display a picture in the background of your scene for instance.
  62138. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62139. * @param name Define the name of the layer in the scene
  62140. * @param imgUrl Define the url of the texture to display in the layer
  62141. * @param scene Define the scene the layer belongs to
  62142. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62143. * @param color Defines a color for the layer
  62144. */
  62145. constructor(
  62146. /**
  62147. * Define the name of the layer.
  62148. */
  62149. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62150. private _createIndexBuffer;
  62151. /** @hidden */
  62152. _rebuild(): void;
  62153. /**
  62154. * Renders the layer in the scene.
  62155. */
  62156. render(): void;
  62157. /**
  62158. * Disposes and releases the associated ressources.
  62159. */
  62160. dispose(): void;
  62161. }
  62162. }
  62163. declare module "babylonjs/Layers/index" {
  62164. export * from "babylonjs/Layers/effectLayer";
  62165. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62166. export * from "babylonjs/Layers/glowLayer";
  62167. export * from "babylonjs/Layers/highlightLayer";
  62168. export * from "babylonjs/Layers/layer";
  62169. export * from "babylonjs/Layers/layerSceneComponent";
  62170. }
  62171. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62172. /** @hidden */
  62173. export var lensFlarePixelShader: {
  62174. name: string;
  62175. shader: string;
  62176. };
  62177. }
  62178. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62179. /** @hidden */
  62180. export var lensFlareVertexShader: {
  62181. name: string;
  62182. shader: string;
  62183. };
  62184. }
  62185. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62186. import { Scene } from "babylonjs/scene";
  62187. import { Vector3 } from "babylonjs/Maths/math.vector";
  62188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62189. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62190. import "babylonjs/Shaders/lensFlare.fragment";
  62191. import "babylonjs/Shaders/lensFlare.vertex";
  62192. import { Viewport } from "babylonjs/Maths/math.viewport";
  62193. /**
  62194. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62195. * It is usually composed of several `lensFlare`.
  62196. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62197. */
  62198. export class LensFlareSystem {
  62199. /**
  62200. * Define the name of the lens flare system
  62201. */
  62202. name: string;
  62203. /**
  62204. * List of lens flares used in this system.
  62205. */
  62206. lensFlares: LensFlare[];
  62207. /**
  62208. * Define a limit from the border the lens flare can be visible.
  62209. */
  62210. borderLimit: number;
  62211. /**
  62212. * Define a viewport border we do not want to see the lens flare in.
  62213. */
  62214. viewportBorder: number;
  62215. /**
  62216. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62217. */
  62218. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62219. /**
  62220. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62221. */
  62222. layerMask: number;
  62223. /**
  62224. * Define the id of the lens flare system in the scene.
  62225. * (equal to name by default)
  62226. */
  62227. id: string;
  62228. private _scene;
  62229. private _emitter;
  62230. private _vertexBuffers;
  62231. private _indexBuffer;
  62232. private _effect;
  62233. private _positionX;
  62234. private _positionY;
  62235. private _isEnabled;
  62236. /** @hidden */
  62237. static _SceneComponentInitialization: (scene: Scene) => void;
  62238. /**
  62239. * Instantiates a lens flare system.
  62240. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62241. * It is usually composed of several `lensFlare`.
  62242. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62243. * @param name Define the name of the lens flare system in the scene
  62244. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62245. * @param scene Define the scene the lens flare system belongs to
  62246. */
  62247. constructor(
  62248. /**
  62249. * Define the name of the lens flare system
  62250. */
  62251. name: string, emitter: any, scene: Scene);
  62252. /**
  62253. * Define if the lens flare system is enabled.
  62254. */
  62255. get isEnabled(): boolean;
  62256. set isEnabled(value: boolean);
  62257. /**
  62258. * Get the scene the effects belongs to.
  62259. * @returns the scene holding the lens flare system
  62260. */
  62261. getScene(): Scene;
  62262. /**
  62263. * Get the emitter of the lens flare system.
  62264. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62265. * @returns the emitter of the lens flare system
  62266. */
  62267. getEmitter(): any;
  62268. /**
  62269. * Set the emitter of the lens flare system.
  62270. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62271. * @param newEmitter Define the new emitter of the system
  62272. */
  62273. setEmitter(newEmitter: any): void;
  62274. /**
  62275. * Get the lens flare system emitter position.
  62276. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62277. * @returns the position
  62278. */
  62279. getEmitterPosition(): Vector3;
  62280. /**
  62281. * @hidden
  62282. */
  62283. computeEffectivePosition(globalViewport: Viewport): boolean;
  62284. /** @hidden */
  62285. _isVisible(): boolean;
  62286. /**
  62287. * @hidden
  62288. */
  62289. render(): boolean;
  62290. /**
  62291. * Dispose and release the lens flare with its associated resources.
  62292. */
  62293. dispose(): void;
  62294. /**
  62295. * Parse a lens flare system from a JSON repressentation
  62296. * @param parsedLensFlareSystem Define the JSON to parse
  62297. * @param scene Define the scene the parsed system should be instantiated in
  62298. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62299. * @returns the parsed system
  62300. */
  62301. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62302. /**
  62303. * Serialize the current Lens Flare System into a JSON representation.
  62304. * @returns the serialized JSON
  62305. */
  62306. serialize(): any;
  62307. }
  62308. }
  62309. declare module "babylonjs/LensFlares/lensFlare" {
  62310. import { Nullable } from "babylonjs/types";
  62311. import { Color3 } from "babylonjs/Maths/math.color";
  62312. import { Texture } from "babylonjs/Materials/Textures/texture";
  62313. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62314. /**
  62315. * This represents one of the lens effect in a `lensFlareSystem`.
  62316. * It controls one of the indiviual texture used in the effect.
  62317. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62318. */
  62319. export class LensFlare {
  62320. /**
  62321. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62322. */
  62323. size: number;
  62324. /**
  62325. * 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.
  62326. */
  62327. position: number;
  62328. /**
  62329. * Define the lens color.
  62330. */
  62331. color: Color3;
  62332. /**
  62333. * Define the lens texture.
  62334. */
  62335. texture: Nullable<Texture>;
  62336. /**
  62337. * Define the alpha mode to render this particular lens.
  62338. */
  62339. alphaMode: number;
  62340. private _system;
  62341. /**
  62342. * Creates a new Lens Flare.
  62343. * This represents one of the lens effect in a `lensFlareSystem`.
  62344. * It controls one of the indiviual texture used in the effect.
  62345. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62346. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62347. * @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.
  62348. * @param color Define the lens color
  62349. * @param imgUrl Define the lens texture url
  62350. * @param system Define the `lensFlareSystem` this flare is part of
  62351. * @returns The newly created Lens Flare
  62352. */
  62353. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62354. /**
  62355. * Instantiates a new Lens Flare.
  62356. * This represents one of the lens effect in a `lensFlareSystem`.
  62357. * It controls one of the indiviual texture used in the effect.
  62358. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62359. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62360. * @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.
  62361. * @param color Define the lens color
  62362. * @param imgUrl Define the lens texture url
  62363. * @param system Define the `lensFlareSystem` this flare is part of
  62364. */
  62365. constructor(
  62366. /**
  62367. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62368. */
  62369. size: number,
  62370. /**
  62371. * 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.
  62372. */
  62373. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62374. /**
  62375. * Dispose and release the lens flare with its associated resources.
  62376. */
  62377. dispose(): void;
  62378. }
  62379. }
  62380. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62381. import { Nullable } from "babylonjs/types";
  62382. import { Scene } from "babylonjs/scene";
  62383. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62384. import { AbstractScene } from "babylonjs/abstractScene";
  62385. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62386. module "babylonjs/abstractScene" {
  62387. interface AbstractScene {
  62388. /**
  62389. * The list of lens flare system added to the scene
  62390. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62391. */
  62392. lensFlareSystems: Array<LensFlareSystem>;
  62393. /**
  62394. * Removes the given lens flare system from this scene.
  62395. * @param toRemove The lens flare system to remove
  62396. * @returns The index of the removed lens flare system
  62397. */
  62398. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62399. /**
  62400. * Adds the given lens flare system to this scene
  62401. * @param newLensFlareSystem The lens flare system to add
  62402. */
  62403. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62404. /**
  62405. * Gets a lens flare system using its name
  62406. * @param name defines the name to look for
  62407. * @returns the lens flare system or null if not found
  62408. */
  62409. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62410. /**
  62411. * Gets a lens flare system using its id
  62412. * @param id defines the id to look for
  62413. * @returns the lens flare system or null if not found
  62414. */
  62415. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62416. }
  62417. }
  62418. /**
  62419. * Defines the lens flare scene component responsible to manage any lens flares
  62420. * in a given scene.
  62421. */
  62422. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62423. /**
  62424. * The component name helpfull to identify the component in the list of scene components.
  62425. */
  62426. readonly name: string;
  62427. /**
  62428. * The scene the component belongs to.
  62429. */
  62430. scene: Scene;
  62431. /**
  62432. * Creates a new instance of the component for the given scene
  62433. * @param scene Defines the scene to register the component in
  62434. */
  62435. constructor(scene: Scene);
  62436. /**
  62437. * Registers the component in a given scene
  62438. */
  62439. register(): void;
  62440. /**
  62441. * Rebuilds the elements related to this component in case of
  62442. * context lost for instance.
  62443. */
  62444. rebuild(): void;
  62445. /**
  62446. * Adds all the elements from the container to the scene
  62447. * @param container the container holding the elements
  62448. */
  62449. addFromContainer(container: AbstractScene): void;
  62450. /**
  62451. * Removes all the elements in the container from the scene
  62452. * @param container contains the elements to remove
  62453. * @param dispose if the removed element should be disposed (default: false)
  62454. */
  62455. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62456. /**
  62457. * Serializes the component data to the specified json object
  62458. * @param serializationObject The object to serialize to
  62459. */
  62460. serialize(serializationObject: any): void;
  62461. /**
  62462. * Disposes the component and the associated ressources.
  62463. */
  62464. dispose(): void;
  62465. private _draw;
  62466. }
  62467. }
  62468. declare module "babylonjs/LensFlares/index" {
  62469. export * from "babylonjs/LensFlares/lensFlare";
  62470. export * from "babylonjs/LensFlares/lensFlareSystem";
  62471. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62472. }
  62473. declare module "babylonjs/Shaders/depth.fragment" {
  62474. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62475. /** @hidden */
  62476. export var depthPixelShader: {
  62477. name: string;
  62478. shader: string;
  62479. };
  62480. }
  62481. declare module "babylonjs/Shaders/depth.vertex" {
  62482. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62483. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62484. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62485. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62486. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62487. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62488. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62489. /** @hidden */
  62490. export var depthVertexShader: {
  62491. name: string;
  62492. shader: string;
  62493. };
  62494. }
  62495. declare module "babylonjs/Rendering/depthRenderer" {
  62496. import { Nullable } from "babylonjs/types";
  62497. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62498. import { Scene } from "babylonjs/scene";
  62499. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62500. import { Camera } from "babylonjs/Cameras/camera";
  62501. import "babylonjs/Shaders/depth.fragment";
  62502. import "babylonjs/Shaders/depth.vertex";
  62503. /**
  62504. * This represents a depth renderer in Babylon.
  62505. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62506. */
  62507. export class DepthRenderer {
  62508. private _scene;
  62509. private _depthMap;
  62510. private _effect;
  62511. private readonly _storeNonLinearDepth;
  62512. private readonly _clearColor;
  62513. /** Get if the depth renderer is using packed depth or not */
  62514. readonly isPacked: boolean;
  62515. private _cachedDefines;
  62516. private _camera;
  62517. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62518. enabled: boolean;
  62519. /**
  62520. * Specifiess that the depth renderer will only be used within
  62521. * the camera it is created for.
  62522. * This can help forcing its rendering during the camera processing.
  62523. */
  62524. useOnlyInActiveCamera: boolean;
  62525. /** @hidden */
  62526. static _SceneComponentInitialization: (scene: Scene) => void;
  62527. /**
  62528. * Instantiates a depth renderer
  62529. * @param scene The scene the renderer belongs to
  62530. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62531. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62532. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62533. */
  62534. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62535. /**
  62536. * Creates the depth rendering effect and checks if the effect is ready.
  62537. * @param subMesh The submesh to be used to render the depth map of
  62538. * @param useInstances If multiple world instances should be used
  62539. * @returns if the depth renderer is ready to render the depth map
  62540. */
  62541. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62542. /**
  62543. * Gets the texture which the depth map will be written to.
  62544. * @returns The depth map texture
  62545. */
  62546. getDepthMap(): RenderTargetTexture;
  62547. /**
  62548. * Disposes of the depth renderer.
  62549. */
  62550. dispose(): void;
  62551. }
  62552. }
  62553. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62554. /** @hidden */
  62555. export var minmaxReduxPixelShader: {
  62556. name: string;
  62557. shader: string;
  62558. };
  62559. }
  62560. declare module "babylonjs/Misc/minMaxReducer" {
  62561. import { Nullable } from "babylonjs/types";
  62562. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62563. import { Camera } from "babylonjs/Cameras/camera";
  62564. import { Observer } from "babylonjs/Misc/observable";
  62565. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62566. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  62567. import { Observable } from "babylonjs/Misc/observable";
  62568. import "babylonjs/Shaders/minmaxRedux.fragment";
  62569. /**
  62570. * This class computes a min/max reduction from a texture: it means it computes the minimum
  62571. * and maximum values from all values of the texture.
  62572. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  62573. * The source values are read from the red channel of the texture.
  62574. */
  62575. export class MinMaxReducer {
  62576. /**
  62577. * Observable triggered when the computation has been performed
  62578. */
  62579. onAfterReductionPerformed: Observable<{
  62580. min: number;
  62581. max: number;
  62582. }>;
  62583. protected _camera: Camera;
  62584. protected _sourceTexture: Nullable<RenderTargetTexture>;
  62585. protected _reductionSteps: Nullable<Array<PostProcess>>;
  62586. protected _postProcessManager: PostProcessManager;
  62587. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  62588. protected _forceFullscreenViewport: boolean;
  62589. /**
  62590. * Creates a min/max reducer
  62591. * @param camera The camera to use for the post processes
  62592. */
  62593. constructor(camera: Camera);
  62594. /**
  62595. * Gets the texture used to read the values from.
  62596. */
  62597. get sourceTexture(): Nullable<RenderTargetTexture>;
  62598. /**
  62599. * Sets the source texture to read the values from.
  62600. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62601. * because in such textures '1' value must not be taken into account to compute the maximum
  62602. * as this value is used to clear the texture.
  62603. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62604. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62605. * @param depthRedux Indicates if the texture is a depth texture or not
  62606. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62607. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62608. */
  62609. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62610. /**
  62611. * Defines the refresh rate of the computation.
  62612. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62613. */
  62614. get refreshRate(): number;
  62615. set refreshRate(value: number);
  62616. protected _activated: boolean;
  62617. /**
  62618. * Gets the activation status of the reducer
  62619. */
  62620. get activated(): boolean;
  62621. /**
  62622. * Activates the reduction computation.
  62623. * When activated, the observers registered in onAfterReductionPerformed are
  62624. * called after the compuation is performed
  62625. */
  62626. activate(): void;
  62627. /**
  62628. * Deactivates the reduction computation.
  62629. */
  62630. deactivate(): void;
  62631. /**
  62632. * Disposes the min/max reducer
  62633. * @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.
  62634. */
  62635. dispose(disposeAll?: boolean): void;
  62636. }
  62637. }
  62638. declare module "babylonjs/Misc/depthReducer" {
  62639. import { Nullable } from "babylonjs/types";
  62640. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62641. import { Camera } from "babylonjs/Cameras/camera";
  62642. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62643. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62644. /**
  62645. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62646. */
  62647. export class DepthReducer extends MinMaxReducer {
  62648. private _depthRenderer;
  62649. private _depthRendererId;
  62650. /**
  62651. * Gets the depth renderer used for the computation.
  62652. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62653. */
  62654. get depthRenderer(): Nullable<DepthRenderer>;
  62655. /**
  62656. * Creates a depth reducer
  62657. * @param camera The camera used to render the depth texture
  62658. */
  62659. constructor(camera: Camera);
  62660. /**
  62661. * Sets the depth renderer to use to generate the depth map
  62662. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62663. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62664. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62665. */
  62666. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62667. /** @hidden */
  62668. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62669. /**
  62670. * Activates the reduction computation.
  62671. * When activated, the observers registered in onAfterReductionPerformed are
  62672. * called after the compuation is performed
  62673. */
  62674. activate(): void;
  62675. /**
  62676. * Deactivates the reduction computation.
  62677. */
  62678. deactivate(): void;
  62679. /**
  62680. * Disposes the depth reducer
  62681. * @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.
  62682. */
  62683. dispose(disposeAll?: boolean): void;
  62684. }
  62685. }
  62686. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62687. import { Nullable } from "babylonjs/types";
  62688. import { Scene } from "babylonjs/scene";
  62689. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62690. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62692. import { Effect } from "babylonjs/Materials/effect";
  62693. import "babylonjs/Shaders/shadowMap.fragment";
  62694. import "babylonjs/Shaders/shadowMap.vertex";
  62695. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62696. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62697. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62698. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62699. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62700. /**
  62701. * A CSM implementation allowing casting shadows on large scenes.
  62702. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62703. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62704. */
  62705. export class CascadedShadowGenerator extends ShadowGenerator {
  62706. private static readonly frustumCornersNDCSpace;
  62707. /**
  62708. * Name of the CSM class
  62709. */
  62710. static CLASSNAME: string;
  62711. /**
  62712. * Defines the default number of cascades used by the CSM.
  62713. */
  62714. static readonly DEFAULT_CASCADES_COUNT: number;
  62715. /**
  62716. * Defines the minimum number of cascades used by the CSM.
  62717. */
  62718. static readonly MIN_CASCADES_COUNT: number;
  62719. /**
  62720. * Defines the maximum number of cascades used by the CSM.
  62721. */
  62722. static readonly MAX_CASCADES_COUNT: number;
  62723. protected _validateFilter(filter: number): number;
  62724. /**
  62725. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62726. */
  62727. penumbraDarkness: number;
  62728. private _numCascades;
  62729. /**
  62730. * Gets or set the number of cascades used by the CSM.
  62731. */
  62732. get numCascades(): number;
  62733. set numCascades(value: number);
  62734. /**
  62735. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62736. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62737. */
  62738. stabilizeCascades: boolean;
  62739. private _freezeShadowCastersBoundingInfo;
  62740. private _freezeShadowCastersBoundingInfoObservable;
  62741. /**
  62742. * Enables or disables the shadow casters bounding info computation.
  62743. * If your shadow casters don't move, you can disable this feature.
  62744. * If it is enabled, the bounding box computation is done every frame.
  62745. */
  62746. get freezeShadowCastersBoundingInfo(): boolean;
  62747. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62748. private _scbiMin;
  62749. private _scbiMax;
  62750. protected _computeShadowCastersBoundingInfo(): void;
  62751. protected _shadowCastersBoundingInfo: BoundingInfo;
  62752. /**
  62753. * Gets or sets the shadow casters bounding info.
  62754. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62755. * so that the system won't overwrite the bounds you provide
  62756. */
  62757. get shadowCastersBoundingInfo(): BoundingInfo;
  62758. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62759. protected _breaksAreDirty: boolean;
  62760. protected _minDistance: number;
  62761. protected _maxDistance: number;
  62762. /**
  62763. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62764. *
  62765. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62766. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62767. * @param min minimal distance for the breaks (default to 0.)
  62768. * @param max maximal distance for the breaks (default to 1.)
  62769. */
  62770. setMinMaxDistance(min: number, max: number): void;
  62771. /** Gets the minimal distance used in the cascade break computation */
  62772. get minDistance(): number;
  62773. /** Gets the maximal distance used in the cascade break computation */
  62774. get maxDistance(): number;
  62775. /**
  62776. * Gets the class name of that object
  62777. * @returns "CascadedShadowGenerator"
  62778. */
  62779. getClassName(): string;
  62780. private _cascadeMinExtents;
  62781. private _cascadeMaxExtents;
  62782. /**
  62783. * Gets a cascade minimum extents
  62784. * @param cascadeIndex index of the cascade
  62785. * @returns the minimum cascade extents
  62786. */
  62787. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62788. /**
  62789. * Gets a cascade maximum extents
  62790. * @param cascadeIndex index of the cascade
  62791. * @returns the maximum cascade extents
  62792. */
  62793. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62794. private _cascades;
  62795. private _currentLayer;
  62796. private _viewSpaceFrustumsZ;
  62797. private _viewMatrices;
  62798. private _projectionMatrices;
  62799. private _transformMatrices;
  62800. private _transformMatricesAsArray;
  62801. private _frustumLengths;
  62802. private _lightSizeUVCorrection;
  62803. private _depthCorrection;
  62804. private _frustumCornersWorldSpace;
  62805. private _frustumCenter;
  62806. private _shadowCameraPos;
  62807. private _shadowMaxZ;
  62808. /**
  62809. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62810. * It defaults to camera.maxZ
  62811. */
  62812. get shadowMaxZ(): number;
  62813. /**
  62814. * Sets the shadow max z distance.
  62815. */
  62816. set shadowMaxZ(value: number);
  62817. protected _debug: boolean;
  62818. /**
  62819. * Gets or sets the debug flag.
  62820. * When enabled, the cascades are materialized by different colors on the screen.
  62821. */
  62822. get debug(): boolean;
  62823. set debug(dbg: boolean);
  62824. private _depthClamp;
  62825. /**
  62826. * Gets or sets the depth clamping value.
  62827. *
  62828. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62829. * to account for the shadow casters far away.
  62830. *
  62831. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62832. */
  62833. get depthClamp(): boolean;
  62834. set depthClamp(value: boolean);
  62835. private _cascadeBlendPercentage;
  62836. /**
  62837. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62838. * It defaults to 0.1 (10% blending).
  62839. */
  62840. get cascadeBlendPercentage(): number;
  62841. set cascadeBlendPercentage(value: number);
  62842. private _lambda;
  62843. /**
  62844. * Gets or set the lambda parameter.
  62845. * This parameter is used to split the camera frustum and create the cascades.
  62846. * 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.
  62847. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62848. */
  62849. get lambda(): number;
  62850. set lambda(value: number);
  62851. /**
  62852. * Gets the view matrix corresponding to a given cascade
  62853. * @param cascadeNum cascade to retrieve the view matrix from
  62854. * @returns the cascade view matrix
  62855. */
  62856. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62857. /**
  62858. * Gets the projection matrix corresponding to a given cascade
  62859. * @param cascadeNum cascade to retrieve the projection matrix from
  62860. * @returns the cascade projection matrix
  62861. */
  62862. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62863. /**
  62864. * Gets the transformation matrix corresponding to a given cascade
  62865. * @param cascadeNum cascade to retrieve the transformation matrix from
  62866. * @returns the cascade transformation matrix
  62867. */
  62868. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62869. private _depthRenderer;
  62870. /**
  62871. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62872. *
  62873. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62874. *
  62875. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62876. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62877. * @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
  62878. */
  62879. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62880. private _depthReducer;
  62881. private _autoCalcDepthBounds;
  62882. /**
  62883. * Gets or sets the autoCalcDepthBounds property.
  62884. *
  62885. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62886. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62887. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62888. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62889. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62890. */
  62891. get autoCalcDepthBounds(): boolean;
  62892. set autoCalcDepthBounds(value: boolean);
  62893. /**
  62894. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62895. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62896. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62897. * for setting the refresh rate on the renderer yourself!
  62898. */
  62899. get autoCalcDepthBoundsRefreshRate(): number;
  62900. set autoCalcDepthBoundsRefreshRate(value: number);
  62901. /**
  62902. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62903. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62904. * you change the camera near/far planes!
  62905. */
  62906. splitFrustum(): void;
  62907. private _splitFrustum;
  62908. private _computeMatrices;
  62909. private _computeFrustumInWorldSpace;
  62910. private _computeCascadeFrustum;
  62911. /**
  62912. * Support test.
  62913. */
  62914. static get IsSupported(): boolean;
  62915. /** @hidden */
  62916. static _SceneComponentInitialization: (scene: Scene) => void;
  62917. /**
  62918. * Creates a Cascaded Shadow Generator object.
  62919. * A ShadowGenerator is the required tool to use the shadows.
  62920. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62921. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62922. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62923. * @param light The directional light object generating the shadows.
  62924. * @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.
  62925. */
  62926. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62927. protected _initializeGenerator(): void;
  62928. protected _createTargetRenderTexture(): void;
  62929. protected _initializeShadowMap(): void;
  62930. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62931. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62932. /**
  62933. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62934. * @param defines Defines of the material we want to update
  62935. * @param lightIndex Index of the light in the enabled light list of the material
  62936. */
  62937. prepareDefines(defines: any, lightIndex: number): void;
  62938. /**
  62939. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62940. * defined in the generator but impacting the effect).
  62941. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62942. * @param effect The effect we are binfing the information for
  62943. */
  62944. bindShadowLight(lightIndex: string, effect: Effect): void;
  62945. /**
  62946. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62947. * (eq to view projection * shadow projection matrices)
  62948. * @returns The transform matrix used to create the shadow map
  62949. */
  62950. getTransformMatrix(): Matrix;
  62951. /**
  62952. * Disposes the ShadowGenerator.
  62953. * Returns nothing.
  62954. */
  62955. dispose(): void;
  62956. /**
  62957. * Serializes the shadow generator setup to a json object.
  62958. * @returns The serialized JSON object
  62959. */
  62960. serialize(): any;
  62961. /**
  62962. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62963. * @param parsedShadowGenerator The JSON object to parse
  62964. * @param scene The scene to create the shadow map for
  62965. * @returns The parsed shadow generator
  62966. */
  62967. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62968. }
  62969. }
  62970. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62971. import { Scene } from "babylonjs/scene";
  62972. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62973. import { AbstractScene } from "babylonjs/abstractScene";
  62974. /**
  62975. * Defines the shadow generator component responsible to manage any shadow generators
  62976. * in a given scene.
  62977. */
  62978. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62979. /**
  62980. * The component name helpfull to identify the component in the list of scene components.
  62981. */
  62982. readonly name: string;
  62983. /**
  62984. * The scene the component belongs to.
  62985. */
  62986. scene: Scene;
  62987. /**
  62988. * Creates a new instance of the component for the given scene
  62989. * @param scene Defines the scene to register the component in
  62990. */
  62991. constructor(scene: Scene);
  62992. /**
  62993. * Registers the component in a given scene
  62994. */
  62995. register(): void;
  62996. /**
  62997. * Rebuilds the elements related to this component in case of
  62998. * context lost for instance.
  62999. */
  63000. rebuild(): void;
  63001. /**
  63002. * Serializes the component data to the specified json object
  63003. * @param serializationObject The object to serialize to
  63004. */
  63005. serialize(serializationObject: any): void;
  63006. /**
  63007. * Adds all the elements from the container to the scene
  63008. * @param container the container holding the elements
  63009. */
  63010. addFromContainer(container: AbstractScene): void;
  63011. /**
  63012. * Removes all the elements in the container from the scene
  63013. * @param container contains the elements to remove
  63014. * @param dispose if the removed element should be disposed (default: false)
  63015. */
  63016. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63017. /**
  63018. * Rebuilds the elements related to this component in case of
  63019. * context lost for instance.
  63020. */
  63021. dispose(): void;
  63022. private _gatherRenderTargets;
  63023. }
  63024. }
  63025. declare module "babylonjs/Lights/Shadows/index" {
  63026. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  63027. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  63028. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  63029. }
  63030. declare module "babylonjs/Lights/pointLight" {
  63031. import { Scene } from "babylonjs/scene";
  63032. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63034. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63035. import { Effect } from "babylonjs/Materials/effect";
  63036. /**
  63037. * A point light is a light defined by an unique point in world space.
  63038. * The light is emitted in every direction from this point.
  63039. * A good example of a point light is a standard light bulb.
  63040. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63041. */
  63042. export class PointLight extends ShadowLight {
  63043. private _shadowAngle;
  63044. /**
  63045. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63046. * This specifies what angle the shadow will use to be created.
  63047. *
  63048. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63049. */
  63050. get shadowAngle(): number;
  63051. /**
  63052. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63053. * This specifies what angle the shadow will use to be created.
  63054. *
  63055. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63056. */
  63057. set shadowAngle(value: number);
  63058. /**
  63059. * Gets the direction if it has been set.
  63060. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63061. */
  63062. get direction(): Vector3;
  63063. /**
  63064. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63065. */
  63066. set direction(value: Vector3);
  63067. /**
  63068. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63069. * A PointLight emits the light in every direction.
  63070. * It can cast shadows.
  63071. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63072. * ```javascript
  63073. * var pointLight = new PointLight("pl", camera.position, scene);
  63074. * ```
  63075. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63076. * @param name The light friendly name
  63077. * @param position The position of the point light in the scene
  63078. * @param scene The scene the lights belongs to
  63079. */
  63080. constructor(name: string, position: Vector3, scene: Scene);
  63081. /**
  63082. * Returns the string "PointLight"
  63083. * @returns the class name
  63084. */
  63085. getClassName(): string;
  63086. /**
  63087. * Returns the integer 0.
  63088. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63089. */
  63090. getTypeID(): number;
  63091. /**
  63092. * Specifies wether or not the shadowmap should be a cube texture.
  63093. * @returns true if the shadowmap needs to be a cube texture.
  63094. */
  63095. needCube(): boolean;
  63096. /**
  63097. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63098. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63099. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63100. */
  63101. getShadowDirection(faceIndex?: number): Vector3;
  63102. /**
  63103. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63104. * - fov = PI / 2
  63105. * - aspect ratio : 1.0
  63106. * - z-near and far equal to the active camera minZ and maxZ.
  63107. * Returns the PointLight.
  63108. */
  63109. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63110. protected _buildUniformLayout(): void;
  63111. /**
  63112. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63113. * @param effect The effect to update
  63114. * @param lightIndex The index of the light in the effect to update
  63115. * @returns The point light
  63116. */
  63117. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63118. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63119. /**
  63120. * Prepares the list of defines specific to the light type.
  63121. * @param defines the list of defines
  63122. * @param lightIndex defines the index of the light for the effect
  63123. */
  63124. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63125. }
  63126. }
  63127. declare module "babylonjs/Lights/index" {
  63128. export * from "babylonjs/Lights/light";
  63129. export * from "babylonjs/Lights/shadowLight";
  63130. export * from "babylonjs/Lights/Shadows/index";
  63131. export * from "babylonjs/Lights/directionalLight";
  63132. export * from "babylonjs/Lights/hemisphericLight";
  63133. export * from "babylonjs/Lights/pointLight";
  63134. export * from "babylonjs/Lights/spotLight";
  63135. }
  63136. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63137. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63138. /**
  63139. * Header information of HDR texture files.
  63140. */
  63141. export interface HDRInfo {
  63142. /**
  63143. * The height of the texture in pixels.
  63144. */
  63145. height: number;
  63146. /**
  63147. * The width of the texture in pixels.
  63148. */
  63149. width: number;
  63150. /**
  63151. * The index of the beginning of the data in the binary file.
  63152. */
  63153. dataPosition: number;
  63154. }
  63155. /**
  63156. * This groups tools to convert HDR texture to native colors array.
  63157. */
  63158. export class HDRTools {
  63159. private static Ldexp;
  63160. private static Rgbe2float;
  63161. private static readStringLine;
  63162. /**
  63163. * Reads header information from an RGBE texture stored in a native array.
  63164. * More information on this format are available here:
  63165. * https://en.wikipedia.org/wiki/RGBE_image_format
  63166. *
  63167. * @param uint8array The binary file stored in native array.
  63168. * @return The header information.
  63169. */
  63170. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63171. /**
  63172. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63173. * This RGBE texture needs to store the information as a panorama.
  63174. *
  63175. * More information on this format are available here:
  63176. * https://en.wikipedia.org/wiki/RGBE_image_format
  63177. *
  63178. * @param buffer The binary file stored in an array buffer.
  63179. * @param size The expected size of the extracted cubemap.
  63180. * @return The Cube Map information.
  63181. */
  63182. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63183. /**
  63184. * Returns the pixels data extracted from an RGBE texture.
  63185. * This pixels will be stored left to right up to down in the R G B order in one array.
  63186. *
  63187. * More information on this format are available here:
  63188. * https://en.wikipedia.org/wiki/RGBE_image_format
  63189. *
  63190. * @param uint8array The binary file stored in an array buffer.
  63191. * @param hdrInfo The header information of the file.
  63192. * @return The pixels data in RGB right to left up to down order.
  63193. */
  63194. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63195. private static RGBE_ReadPixels_RLE;
  63196. private static RGBE_ReadPixels_NOT_RLE;
  63197. }
  63198. }
  63199. declare module "babylonjs/Materials/effectRenderer" {
  63200. import { Nullable } from "babylonjs/types";
  63201. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63202. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63203. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63204. import { Viewport } from "babylonjs/Maths/math.viewport";
  63205. import { Observable } from "babylonjs/Misc/observable";
  63206. import { Effect } from "babylonjs/Materials/effect";
  63207. import "babylonjs/Shaders/postprocess.vertex";
  63208. /**
  63209. * Effect Render Options
  63210. */
  63211. export interface IEffectRendererOptions {
  63212. /**
  63213. * Defines the vertices positions.
  63214. */
  63215. positions?: number[];
  63216. /**
  63217. * Defines the indices.
  63218. */
  63219. indices?: number[];
  63220. }
  63221. /**
  63222. * Helper class to render one or more effects.
  63223. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63224. */
  63225. export class EffectRenderer {
  63226. private engine;
  63227. private static _DefaultOptions;
  63228. private _vertexBuffers;
  63229. private _indexBuffer;
  63230. private _fullscreenViewport;
  63231. /**
  63232. * Creates an effect renderer
  63233. * @param engine the engine to use for rendering
  63234. * @param options defines the options of the effect renderer
  63235. */
  63236. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63237. /**
  63238. * Sets the current viewport in normalized coordinates 0-1
  63239. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63240. */
  63241. setViewport(viewport?: Viewport): void;
  63242. /**
  63243. * Binds the embedded attributes buffer to the effect.
  63244. * @param effect Defines the effect to bind the attributes for
  63245. */
  63246. bindBuffers(effect: Effect): void;
  63247. /**
  63248. * Sets the current effect wrapper to use during draw.
  63249. * The effect needs to be ready before calling this api.
  63250. * This also sets the default full screen position attribute.
  63251. * @param effectWrapper Defines the effect to draw with
  63252. */
  63253. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63254. /**
  63255. * Restores engine states
  63256. */
  63257. restoreStates(): void;
  63258. /**
  63259. * Draws a full screen quad.
  63260. */
  63261. draw(): void;
  63262. private isRenderTargetTexture;
  63263. /**
  63264. * renders one or more effects to a specified texture
  63265. * @param effectWrapper the effect to renderer
  63266. * @param outputTexture texture to draw to, if null it will render to the screen.
  63267. */
  63268. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63269. /**
  63270. * Disposes of the effect renderer
  63271. */
  63272. dispose(): void;
  63273. }
  63274. /**
  63275. * Options to create an EffectWrapper
  63276. */
  63277. interface EffectWrapperCreationOptions {
  63278. /**
  63279. * Engine to use to create the effect
  63280. */
  63281. engine: ThinEngine;
  63282. /**
  63283. * Fragment shader for the effect
  63284. */
  63285. fragmentShader: string;
  63286. /**
  63287. * Use the shader store instead of direct source code
  63288. */
  63289. useShaderStore?: boolean;
  63290. /**
  63291. * Vertex shader for the effect
  63292. */
  63293. vertexShader?: string;
  63294. /**
  63295. * Attributes to use in the shader
  63296. */
  63297. attributeNames?: Array<string>;
  63298. /**
  63299. * Uniforms to use in the shader
  63300. */
  63301. uniformNames?: Array<string>;
  63302. /**
  63303. * Texture sampler names to use in the shader
  63304. */
  63305. samplerNames?: Array<string>;
  63306. /**
  63307. * Defines to use in the shader
  63308. */
  63309. defines?: Array<string>;
  63310. /**
  63311. * Callback when effect is compiled
  63312. */
  63313. onCompiled?: Nullable<(effect: Effect) => void>;
  63314. /**
  63315. * The friendly name of the effect displayed in Spector.
  63316. */
  63317. name?: string;
  63318. }
  63319. /**
  63320. * Wraps an effect to be used for rendering
  63321. */
  63322. export class EffectWrapper {
  63323. /**
  63324. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63325. */
  63326. onApplyObservable: Observable<{}>;
  63327. /**
  63328. * The underlying effect
  63329. */
  63330. effect: Effect;
  63331. /**
  63332. * Creates an effect to be renderer
  63333. * @param creationOptions options to create the effect
  63334. */
  63335. constructor(creationOptions: EffectWrapperCreationOptions);
  63336. /**
  63337. * Disposes of the effect wrapper
  63338. */
  63339. dispose(): void;
  63340. }
  63341. }
  63342. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63343. /** @hidden */
  63344. export var hdrFilteringVertexShader: {
  63345. name: string;
  63346. shader: string;
  63347. };
  63348. }
  63349. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63350. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63351. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63352. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63353. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63354. /** @hidden */
  63355. export var hdrFilteringPixelShader: {
  63356. name: string;
  63357. shader: string;
  63358. };
  63359. }
  63360. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63361. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63362. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63363. import { Nullable } from "babylonjs/types";
  63364. import "babylonjs/Shaders/hdrFiltering.vertex";
  63365. import "babylonjs/Shaders/hdrFiltering.fragment";
  63366. /**
  63367. * Options for texture filtering
  63368. */
  63369. interface IHDRFilteringOptions {
  63370. /**
  63371. * Scales pixel intensity for the input HDR map.
  63372. */
  63373. hdrScale?: number;
  63374. /**
  63375. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63376. */
  63377. quality?: number;
  63378. }
  63379. /**
  63380. * Filters HDR maps to get correct renderings of PBR reflections
  63381. */
  63382. export class HDRFiltering {
  63383. private _engine;
  63384. private _effectRenderer;
  63385. private _effectWrapper;
  63386. private _lodGenerationOffset;
  63387. private _lodGenerationScale;
  63388. /**
  63389. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63390. * you care about baking speed.
  63391. */
  63392. quality: number;
  63393. /**
  63394. * Scales pixel intensity for the input HDR map.
  63395. */
  63396. hdrScale: number;
  63397. /**
  63398. * Instantiates HDR filter for reflection maps
  63399. *
  63400. * @param engine Thin engine
  63401. * @param options Options
  63402. */
  63403. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63404. private _createRenderTarget;
  63405. private _prefilterInternal;
  63406. private _createEffect;
  63407. /**
  63408. * Get a value indicating if the filter is ready to be used
  63409. * @param texture Texture to filter
  63410. * @returns true if the filter is ready
  63411. */
  63412. isReady(texture: BaseTexture): boolean;
  63413. /**
  63414. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63415. * Prefiltering will be invoked at the end of next rendering pass.
  63416. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63417. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63418. * @param texture Texture to filter
  63419. * @param onFinished Callback when filtering is done
  63420. * @return Promise called when prefiltering is done
  63421. */
  63422. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63423. }
  63424. }
  63425. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63426. import { Nullable } from "babylonjs/types";
  63427. import { Scene } from "babylonjs/scene";
  63428. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63429. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63430. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63431. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63432. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63433. /**
  63434. * This represents a texture coming from an HDR input.
  63435. *
  63436. * The only supported format is currently panorama picture stored in RGBE format.
  63437. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63438. */
  63439. export class HDRCubeTexture extends BaseTexture {
  63440. private static _facesMapping;
  63441. private _generateHarmonics;
  63442. private _noMipmap;
  63443. private _prefilterOnLoad;
  63444. private _textureMatrix;
  63445. private _size;
  63446. private _onLoad;
  63447. private _onError;
  63448. /**
  63449. * The texture URL.
  63450. */
  63451. url: string;
  63452. protected _isBlocking: boolean;
  63453. /**
  63454. * Sets wether or not the texture is blocking during loading.
  63455. */
  63456. set isBlocking(value: boolean);
  63457. /**
  63458. * Gets wether or not the texture is blocking during loading.
  63459. */
  63460. get isBlocking(): boolean;
  63461. protected _rotationY: number;
  63462. /**
  63463. * Sets texture matrix rotation angle around Y axis in radians.
  63464. */
  63465. set rotationY(value: number);
  63466. /**
  63467. * Gets texture matrix rotation angle around Y axis radians.
  63468. */
  63469. get rotationY(): number;
  63470. /**
  63471. * Gets or sets the center of the bounding box associated with the cube texture
  63472. * It must define where the camera used to render the texture was set
  63473. */
  63474. boundingBoxPosition: Vector3;
  63475. private _boundingBoxSize;
  63476. /**
  63477. * Gets or sets the size of the bounding box associated with the cube texture
  63478. * When defined, the cubemap will switch to local mode
  63479. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63480. * @example https://www.babylonjs-playground.com/#RNASML
  63481. */
  63482. set boundingBoxSize(value: Vector3);
  63483. get boundingBoxSize(): Vector3;
  63484. /**
  63485. * Instantiates an HDRTexture from the following parameters.
  63486. *
  63487. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63488. * @param sceneOrEngine The scene or engine the texture will be used in
  63489. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63490. * @param noMipmap Forces to not generate the mipmap if true
  63491. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63492. * @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)
  63493. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63494. */
  63495. 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>);
  63496. /**
  63497. * Get the current class name of the texture useful for serialization or dynamic coding.
  63498. * @returns "HDRCubeTexture"
  63499. */
  63500. getClassName(): string;
  63501. /**
  63502. * Occurs when the file is raw .hdr file.
  63503. */
  63504. private loadTexture;
  63505. clone(): HDRCubeTexture;
  63506. delayLoad(): void;
  63507. /**
  63508. * Get the texture reflection matrix used to rotate/transform the reflection.
  63509. * @returns the reflection matrix
  63510. */
  63511. getReflectionTextureMatrix(): Matrix;
  63512. /**
  63513. * Set the texture reflection matrix used to rotate/transform the reflection.
  63514. * @param value Define the reflection matrix to set
  63515. */
  63516. setReflectionTextureMatrix(value: Matrix): void;
  63517. /**
  63518. * Parses a JSON representation of an HDR Texture in order to create the texture
  63519. * @param parsedTexture Define the JSON representation
  63520. * @param scene Define the scene the texture should be created in
  63521. * @param rootUrl Define the root url in case we need to load relative dependencies
  63522. * @returns the newly created texture after parsing
  63523. */
  63524. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63525. serialize(): any;
  63526. }
  63527. }
  63528. declare module "babylonjs/Physics/physicsEngine" {
  63529. import { Nullable } from "babylonjs/types";
  63530. import { Vector3 } from "babylonjs/Maths/math.vector";
  63531. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63532. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63533. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63534. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63535. /**
  63536. * Class used to control physics engine
  63537. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63538. */
  63539. export class PhysicsEngine implements IPhysicsEngine {
  63540. private _physicsPlugin;
  63541. /**
  63542. * Global value used to control the smallest number supported by the simulation
  63543. */
  63544. static Epsilon: number;
  63545. private _impostors;
  63546. private _joints;
  63547. private _subTimeStep;
  63548. /**
  63549. * Gets the gravity vector used by the simulation
  63550. */
  63551. gravity: Vector3;
  63552. /**
  63553. * Factory used to create the default physics plugin.
  63554. * @returns The default physics plugin
  63555. */
  63556. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63557. /**
  63558. * Creates a new Physics Engine
  63559. * @param gravity defines the gravity vector used by the simulation
  63560. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  63561. */
  63562. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  63563. /**
  63564. * Sets the gravity vector used by the simulation
  63565. * @param gravity defines the gravity vector to use
  63566. */
  63567. setGravity(gravity: Vector3): void;
  63568. /**
  63569. * Set the time step of the physics engine.
  63570. * Default is 1/60.
  63571. * To slow it down, enter 1/600 for example.
  63572. * To speed it up, 1/30
  63573. * @param newTimeStep defines the new timestep to apply to this world.
  63574. */
  63575. setTimeStep(newTimeStep?: number): void;
  63576. /**
  63577. * Get the time step of the physics engine.
  63578. * @returns the current time step
  63579. */
  63580. getTimeStep(): number;
  63581. /**
  63582. * Set the sub time step of the physics engine.
  63583. * Default is 0 meaning there is no sub steps
  63584. * To increase physics resolution precision, set a small value (like 1 ms)
  63585. * @param subTimeStep defines the new sub timestep used for physics resolution.
  63586. */
  63587. setSubTimeStep(subTimeStep?: number): void;
  63588. /**
  63589. * Get the sub time step of the physics engine.
  63590. * @returns the current sub time step
  63591. */
  63592. getSubTimeStep(): number;
  63593. /**
  63594. * Release all resources
  63595. */
  63596. dispose(): void;
  63597. /**
  63598. * Gets the name of the current physics plugin
  63599. * @returns the name of the plugin
  63600. */
  63601. getPhysicsPluginName(): string;
  63602. /**
  63603. * Adding a new impostor for the impostor tracking.
  63604. * This will be done by the impostor itself.
  63605. * @param impostor the impostor to add
  63606. */
  63607. addImpostor(impostor: PhysicsImpostor): void;
  63608. /**
  63609. * Remove an impostor from the engine.
  63610. * This impostor and its mesh will not longer be updated by the physics engine.
  63611. * @param impostor the impostor to remove
  63612. */
  63613. removeImpostor(impostor: PhysicsImpostor): void;
  63614. /**
  63615. * Add a joint to the physics engine
  63616. * @param mainImpostor defines the main impostor to which the joint is added.
  63617. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63618. * @param joint defines the joint that will connect both impostors.
  63619. */
  63620. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63621. /**
  63622. * Removes a joint from the simulation
  63623. * @param mainImpostor defines the impostor used with the joint
  63624. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63625. * @param joint defines the joint to remove
  63626. */
  63627. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63628. /**
  63629. * Called by the scene. No need to call it.
  63630. * @param delta defines the timespam between frames
  63631. */
  63632. _step(delta: number): void;
  63633. /**
  63634. * Gets the current plugin used to run the simulation
  63635. * @returns current plugin
  63636. */
  63637. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63638. /**
  63639. * Gets the list of physic impostors
  63640. * @returns an array of PhysicsImpostor
  63641. */
  63642. getImpostors(): Array<PhysicsImpostor>;
  63643. /**
  63644. * Gets the impostor for a physics enabled object
  63645. * @param object defines the object impersonated by the impostor
  63646. * @returns the PhysicsImpostor or null if not found
  63647. */
  63648. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63649. /**
  63650. * Gets the impostor for a physics body object
  63651. * @param body defines physics body used by the impostor
  63652. * @returns the PhysicsImpostor or null if not found
  63653. */
  63654. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63655. /**
  63656. * Does a raycast in the physics world
  63657. * @param from when should the ray start?
  63658. * @param to when should the ray end?
  63659. * @returns PhysicsRaycastResult
  63660. */
  63661. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63662. }
  63663. }
  63664. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63665. import { Nullable } from "babylonjs/types";
  63666. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63668. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63669. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63670. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63671. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63672. /** @hidden */
  63673. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63674. private _useDeltaForWorldStep;
  63675. world: any;
  63676. name: string;
  63677. private _physicsMaterials;
  63678. private _fixedTimeStep;
  63679. private _cannonRaycastResult;
  63680. private _raycastResult;
  63681. private _physicsBodysToRemoveAfterStep;
  63682. private _firstFrame;
  63683. BJSCANNON: any;
  63684. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63685. setGravity(gravity: Vector3): void;
  63686. setTimeStep(timeStep: number): void;
  63687. getTimeStep(): number;
  63688. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63689. private _removeMarkedPhysicsBodiesFromWorld;
  63690. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63691. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63692. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63693. private _processChildMeshes;
  63694. removePhysicsBody(impostor: PhysicsImpostor): void;
  63695. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63696. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63697. private _addMaterial;
  63698. private _checkWithEpsilon;
  63699. private _createShape;
  63700. private _createHeightmap;
  63701. private _minus90X;
  63702. private _plus90X;
  63703. private _tmpPosition;
  63704. private _tmpDeltaPosition;
  63705. private _tmpUnityRotation;
  63706. private _updatePhysicsBodyTransformation;
  63707. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63708. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63709. isSupported(): boolean;
  63710. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63711. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63712. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63713. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63714. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63715. getBodyMass(impostor: PhysicsImpostor): number;
  63716. getBodyFriction(impostor: PhysicsImpostor): number;
  63717. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63718. getBodyRestitution(impostor: PhysicsImpostor): number;
  63719. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63720. sleepBody(impostor: PhysicsImpostor): void;
  63721. wakeUpBody(impostor: PhysicsImpostor): void;
  63722. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63723. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63724. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63725. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63726. getRadius(impostor: PhysicsImpostor): number;
  63727. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63728. dispose(): void;
  63729. private _extendNamespace;
  63730. /**
  63731. * Does a raycast in the physics world
  63732. * @param from when should the ray start?
  63733. * @param to when should the ray end?
  63734. * @returns PhysicsRaycastResult
  63735. */
  63736. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63737. }
  63738. }
  63739. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63740. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63741. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63742. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63744. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63745. import { Nullable } from "babylonjs/types";
  63746. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63747. /** @hidden */
  63748. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63749. private _useDeltaForWorldStep;
  63750. world: any;
  63751. name: string;
  63752. BJSOIMO: any;
  63753. private _raycastResult;
  63754. private _fixedTimeStep;
  63755. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63756. setGravity(gravity: Vector3): void;
  63757. setTimeStep(timeStep: number): void;
  63758. getTimeStep(): number;
  63759. private _tmpImpostorsArray;
  63760. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63761. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63762. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63763. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63764. private _tmpPositionVector;
  63765. removePhysicsBody(impostor: PhysicsImpostor): void;
  63766. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63767. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63768. isSupported(): boolean;
  63769. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63770. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63771. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63772. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63773. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63774. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63775. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63776. getBodyMass(impostor: PhysicsImpostor): number;
  63777. getBodyFriction(impostor: PhysicsImpostor): number;
  63778. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63779. getBodyRestitution(impostor: PhysicsImpostor): number;
  63780. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63781. sleepBody(impostor: PhysicsImpostor): void;
  63782. wakeUpBody(impostor: PhysicsImpostor): void;
  63783. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63784. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63785. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63786. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63787. getRadius(impostor: PhysicsImpostor): number;
  63788. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63789. dispose(): void;
  63790. /**
  63791. * Does a raycast in the physics world
  63792. * @param from when should the ray start?
  63793. * @param to when should the ray end?
  63794. * @returns PhysicsRaycastResult
  63795. */
  63796. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63797. }
  63798. }
  63799. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63800. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63801. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63802. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63803. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63804. import { Nullable } from "babylonjs/types";
  63805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63806. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63807. /**
  63808. * AmmoJS Physics plugin
  63809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63810. * @see https://github.com/kripken/ammo.js/
  63811. */
  63812. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63813. private _useDeltaForWorldStep;
  63814. /**
  63815. * Reference to the Ammo library
  63816. */
  63817. bjsAMMO: any;
  63818. /**
  63819. * Created ammoJS world which physics bodies are added to
  63820. */
  63821. world: any;
  63822. /**
  63823. * Name of the plugin
  63824. */
  63825. name: string;
  63826. private _timeStep;
  63827. private _fixedTimeStep;
  63828. private _maxSteps;
  63829. private _tmpQuaternion;
  63830. private _tmpAmmoTransform;
  63831. private _tmpAmmoQuaternion;
  63832. private _tmpAmmoConcreteContactResultCallback;
  63833. private _collisionConfiguration;
  63834. private _dispatcher;
  63835. private _overlappingPairCache;
  63836. private _solver;
  63837. private _softBodySolver;
  63838. private _tmpAmmoVectorA;
  63839. private _tmpAmmoVectorB;
  63840. private _tmpAmmoVectorC;
  63841. private _tmpAmmoVectorD;
  63842. private _tmpContactCallbackResult;
  63843. private _tmpAmmoVectorRCA;
  63844. private _tmpAmmoVectorRCB;
  63845. private _raycastResult;
  63846. private static readonly DISABLE_COLLISION_FLAG;
  63847. private static readonly KINEMATIC_FLAG;
  63848. private static readonly DISABLE_DEACTIVATION_FLAG;
  63849. /**
  63850. * Initializes the ammoJS plugin
  63851. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63852. * @param ammoInjection can be used to inject your own ammo reference
  63853. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63854. */
  63855. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63856. /**
  63857. * Sets the gravity of the physics world (m/(s^2))
  63858. * @param gravity Gravity to set
  63859. */
  63860. setGravity(gravity: Vector3): void;
  63861. /**
  63862. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63863. * @param timeStep timestep to use in seconds
  63864. */
  63865. setTimeStep(timeStep: number): void;
  63866. /**
  63867. * 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)
  63868. * @param fixedTimeStep fixedTimeStep to use in seconds
  63869. */
  63870. setFixedTimeStep(fixedTimeStep: number): void;
  63871. /**
  63872. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63873. * @param maxSteps the maximum number of steps by the physics engine per frame
  63874. */
  63875. setMaxSteps(maxSteps: number): void;
  63876. /**
  63877. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63878. * @returns the current timestep in seconds
  63879. */
  63880. getTimeStep(): number;
  63881. /**
  63882. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63883. */
  63884. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63885. private _isImpostorInContact;
  63886. private _isImpostorPairInContact;
  63887. private _stepSimulation;
  63888. /**
  63889. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63890. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63891. * After the step the babylon meshes are set to the position of the physics imposters
  63892. * @param delta amount of time to step forward
  63893. * @param impostors array of imposters to update before/after the step
  63894. */
  63895. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63896. /**
  63897. * Update babylon mesh to match physics world object
  63898. * @param impostor imposter to match
  63899. */
  63900. private _afterSoftStep;
  63901. /**
  63902. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63903. * @param impostor imposter to match
  63904. */
  63905. private _ropeStep;
  63906. /**
  63907. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63908. * @param impostor imposter to match
  63909. */
  63910. private _softbodyOrClothStep;
  63911. private _tmpMatrix;
  63912. /**
  63913. * Applies an impulse on the imposter
  63914. * @param impostor imposter to apply impulse to
  63915. * @param force amount of force to be applied to the imposter
  63916. * @param contactPoint the location to apply the impulse on the imposter
  63917. */
  63918. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63919. /**
  63920. * Applies a force on the imposter
  63921. * @param impostor imposter to apply force
  63922. * @param force amount of force to be applied to the imposter
  63923. * @param contactPoint the location to apply the force on the imposter
  63924. */
  63925. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63926. /**
  63927. * Creates a physics body using the plugin
  63928. * @param impostor the imposter to create the physics body on
  63929. */
  63930. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63931. /**
  63932. * Removes the physics body from the imposter and disposes of the body's memory
  63933. * @param impostor imposter to remove the physics body from
  63934. */
  63935. removePhysicsBody(impostor: PhysicsImpostor): void;
  63936. /**
  63937. * Generates a joint
  63938. * @param impostorJoint the imposter joint to create the joint with
  63939. */
  63940. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63941. /**
  63942. * Removes a joint
  63943. * @param impostorJoint the imposter joint to remove the joint from
  63944. */
  63945. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63946. private _addMeshVerts;
  63947. /**
  63948. * Initialise the soft body vertices to match its object's (mesh) vertices
  63949. * Softbody vertices (nodes) are in world space and to match this
  63950. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63951. * @param impostor to create the softbody for
  63952. */
  63953. private _softVertexData;
  63954. /**
  63955. * Create an impostor's soft body
  63956. * @param impostor to create the softbody for
  63957. */
  63958. private _createSoftbody;
  63959. /**
  63960. * Create cloth for an impostor
  63961. * @param impostor to create the softbody for
  63962. */
  63963. private _createCloth;
  63964. /**
  63965. * Create rope for an impostor
  63966. * @param impostor to create the softbody for
  63967. */
  63968. private _createRope;
  63969. /**
  63970. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63971. * @param impostor to create the custom physics shape for
  63972. */
  63973. private _createCustom;
  63974. private _addHullVerts;
  63975. private _createShape;
  63976. /**
  63977. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63978. * @param impostor imposter containing the physics body and babylon object
  63979. */
  63980. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63981. /**
  63982. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63983. * @param impostor imposter containing the physics body and babylon object
  63984. * @param newPosition new position
  63985. * @param newRotation new rotation
  63986. */
  63987. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63988. /**
  63989. * If this plugin is supported
  63990. * @returns true if its supported
  63991. */
  63992. isSupported(): boolean;
  63993. /**
  63994. * Sets the linear velocity of the physics body
  63995. * @param impostor imposter to set the velocity on
  63996. * @param velocity velocity to set
  63997. */
  63998. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63999. /**
  64000. * Sets the angular velocity of the physics body
  64001. * @param impostor imposter to set the velocity on
  64002. * @param velocity velocity to set
  64003. */
  64004. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64005. /**
  64006. * gets the linear velocity
  64007. * @param impostor imposter to get linear velocity from
  64008. * @returns linear velocity
  64009. */
  64010. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64011. /**
  64012. * gets the angular velocity
  64013. * @param impostor imposter to get angular velocity from
  64014. * @returns angular velocity
  64015. */
  64016. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64017. /**
  64018. * Sets the mass of physics body
  64019. * @param impostor imposter to set the mass on
  64020. * @param mass mass to set
  64021. */
  64022. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64023. /**
  64024. * Gets the mass of the physics body
  64025. * @param impostor imposter to get the mass from
  64026. * @returns mass
  64027. */
  64028. getBodyMass(impostor: PhysicsImpostor): number;
  64029. /**
  64030. * Gets friction of the impostor
  64031. * @param impostor impostor to get friction from
  64032. * @returns friction value
  64033. */
  64034. getBodyFriction(impostor: PhysicsImpostor): number;
  64035. /**
  64036. * Sets friction of the impostor
  64037. * @param impostor impostor to set friction on
  64038. * @param friction friction value
  64039. */
  64040. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64041. /**
  64042. * Gets restitution of the impostor
  64043. * @param impostor impostor to get restitution from
  64044. * @returns restitution value
  64045. */
  64046. getBodyRestitution(impostor: PhysicsImpostor): number;
  64047. /**
  64048. * Sets resitution of the impostor
  64049. * @param impostor impostor to set resitution on
  64050. * @param restitution resitution value
  64051. */
  64052. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64053. /**
  64054. * Gets pressure inside the impostor
  64055. * @param impostor impostor to get pressure from
  64056. * @returns pressure value
  64057. */
  64058. getBodyPressure(impostor: PhysicsImpostor): number;
  64059. /**
  64060. * Sets pressure inside a soft body impostor
  64061. * Cloth and rope must remain 0 pressure
  64062. * @param impostor impostor to set pressure on
  64063. * @param pressure pressure value
  64064. */
  64065. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64066. /**
  64067. * Gets stiffness of the impostor
  64068. * @param impostor impostor to get stiffness from
  64069. * @returns pressure value
  64070. */
  64071. getBodyStiffness(impostor: PhysicsImpostor): number;
  64072. /**
  64073. * Sets stiffness of the impostor
  64074. * @param impostor impostor to set stiffness on
  64075. * @param stiffness stiffness value from 0 to 1
  64076. */
  64077. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64078. /**
  64079. * Gets velocityIterations of the impostor
  64080. * @param impostor impostor to get velocity iterations from
  64081. * @returns velocityIterations value
  64082. */
  64083. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64084. /**
  64085. * Sets velocityIterations of the impostor
  64086. * @param impostor impostor to set velocity iterations on
  64087. * @param velocityIterations velocityIterations value
  64088. */
  64089. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64090. /**
  64091. * Gets positionIterations of the impostor
  64092. * @param impostor impostor to get position iterations from
  64093. * @returns positionIterations value
  64094. */
  64095. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64096. /**
  64097. * Sets positionIterations of the impostor
  64098. * @param impostor impostor to set position on
  64099. * @param positionIterations positionIterations value
  64100. */
  64101. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64102. /**
  64103. * Append an anchor to a cloth object
  64104. * @param impostor is the cloth impostor to add anchor to
  64105. * @param otherImpostor is the rigid impostor to anchor to
  64106. * @param width ratio across width from 0 to 1
  64107. * @param height ratio up height from 0 to 1
  64108. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64109. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64110. */
  64111. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64112. /**
  64113. * Append an hook to a rope object
  64114. * @param impostor is the rope impostor to add hook to
  64115. * @param otherImpostor is the rigid impostor to hook to
  64116. * @param length ratio along the rope from 0 to 1
  64117. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64118. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64119. */
  64120. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64121. /**
  64122. * Sleeps the physics body and stops it from being active
  64123. * @param impostor impostor to sleep
  64124. */
  64125. sleepBody(impostor: PhysicsImpostor): void;
  64126. /**
  64127. * Activates the physics body
  64128. * @param impostor impostor to activate
  64129. */
  64130. wakeUpBody(impostor: PhysicsImpostor): void;
  64131. /**
  64132. * Updates the distance parameters of the joint
  64133. * @param joint joint to update
  64134. * @param maxDistance maximum distance of the joint
  64135. * @param minDistance minimum distance of the joint
  64136. */
  64137. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64138. /**
  64139. * Sets a motor on the joint
  64140. * @param joint joint to set motor on
  64141. * @param speed speed of the motor
  64142. * @param maxForce maximum force of the motor
  64143. * @param motorIndex index of the motor
  64144. */
  64145. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64146. /**
  64147. * Sets the motors limit
  64148. * @param joint joint to set limit on
  64149. * @param upperLimit upper limit
  64150. * @param lowerLimit lower limit
  64151. */
  64152. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64153. /**
  64154. * Syncs the position and rotation of a mesh with the impostor
  64155. * @param mesh mesh to sync
  64156. * @param impostor impostor to update the mesh with
  64157. */
  64158. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64159. /**
  64160. * Gets the radius of the impostor
  64161. * @param impostor impostor to get radius from
  64162. * @returns the radius
  64163. */
  64164. getRadius(impostor: PhysicsImpostor): number;
  64165. /**
  64166. * Gets the box size of the impostor
  64167. * @param impostor impostor to get box size from
  64168. * @param result the resulting box size
  64169. */
  64170. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64171. /**
  64172. * Disposes of the impostor
  64173. */
  64174. dispose(): void;
  64175. /**
  64176. * Does a raycast in the physics world
  64177. * @param from when should the ray start?
  64178. * @param to when should the ray end?
  64179. * @returns PhysicsRaycastResult
  64180. */
  64181. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64182. }
  64183. }
  64184. declare module "babylonjs/Probes/reflectionProbe" {
  64185. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64186. import { Vector3 } from "babylonjs/Maths/math.vector";
  64187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64188. import { Nullable } from "babylonjs/types";
  64189. import { Scene } from "babylonjs/scene";
  64190. module "babylonjs/abstractScene" {
  64191. interface AbstractScene {
  64192. /**
  64193. * The list of reflection probes added to the scene
  64194. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64195. */
  64196. reflectionProbes: Array<ReflectionProbe>;
  64197. /**
  64198. * Removes the given reflection probe from this scene.
  64199. * @param toRemove The reflection probe to remove
  64200. * @returns The index of the removed reflection probe
  64201. */
  64202. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64203. /**
  64204. * Adds the given reflection probe to this scene.
  64205. * @param newReflectionProbe The reflection probe to add
  64206. */
  64207. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64208. }
  64209. }
  64210. /**
  64211. * Class used to generate realtime reflection / refraction cube textures
  64212. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64213. */
  64214. export class ReflectionProbe {
  64215. /** defines the name of the probe */
  64216. name: string;
  64217. private _scene;
  64218. private _renderTargetTexture;
  64219. private _projectionMatrix;
  64220. private _viewMatrix;
  64221. private _target;
  64222. private _add;
  64223. private _attachedMesh;
  64224. private _invertYAxis;
  64225. /** Gets or sets probe position (center of the cube map) */
  64226. position: Vector3;
  64227. /**
  64228. * Creates a new reflection probe
  64229. * @param name defines the name of the probe
  64230. * @param size defines the texture resolution (for each face)
  64231. * @param scene defines the hosting scene
  64232. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64233. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64234. */
  64235. constructor(
  64236. /** defines the name of the probe */
  64237. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64238. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64239. get samples(): number;
  64240. set samples(value: number);
  64241. /** Gets or sets the refresh rate to use (on every frame by default) */
  64242. get refreshRate(): number;
  64243. set refreshRate(value: number);
  64244. /**
  64245. * Gets the hosting scene
  64246. * @returns a Scene
  64247. */
  64248. getScene(): Scene;
  64249. /** Gets the internal CubeTexture used to render to */
  64250. get cubeTexture(): RenderTargetTexture;
  64251. /** Gets the list of meshes to render */
  64252. get renderList(): Nullable<AbstractMesh[]>;
  64253. /**
  64254. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64255. * @param mesh defines the mesh to attach to
  64256. */
  64257. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64258. /**
  64259. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64260. * @param renderingGroupId The rendering group id corresponding to its index
  64261. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64262. */
  64263. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64264. /**
  64265. * Clean all associated resources
  64266. */
  64267. dispose(): void;
  64268. /**
  64269. * Converts the reflection probe information to a readable string for debug purpose.
  64270. * @param fullDetails Supports for multiple levels of logging within scene loading
  64271. * @returns the human readable reflection probe info
  64272. */
  64273. toString(fullDetails?: boolean): string;
  64274. /**
  64275. * Get the class name of the relfection probe.
  64276. * @returns "ReflectionProbe"
  64277. */
  64278. getClassName(): string;
  64279. /**
  64280. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64281. * @returns The JSON representation of the texture
  64282. */
  64283. serialize(): any;
  64284. /**
  64285. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64286. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64287. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64288. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64289. * @returns The parsed reflection probe if successful
  64290. */
  64291. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64292. }
  64293. }
  64294. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64295. /** @hidden */
  64296. export var _BabylonLoaderRegistered: boolean;
  64297. /**
  64298. * Helps setting up some configuration for the babylon file loader.
  64299. */
  64300. export class BabylonFileLoaderConfiguration {
  64301. /**
  64302. * The loader does not allow injecting custom physix engine into the plugins.
  64303. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64304. * So you could set this variable to your engine import to make it work.
  64305. */
  64306. static LoaderInjectedPhysicsEngine: any;
  64307. }
  64308. }
  64309. declare module "babylonjs/Loading/Plugins/index" {
  64310. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64311. }
  64312. declare module "babylonjs/Loading/index" {
  64313. export * from "babylonjs/Loading/loadingScreen";
  64314. export * from "babylonjs/Loading/Plugins/index";
  64315. export * from "babylonjs/Loading/sceneLoader";
  64316. export * from "babylonjs/Loading/sceneLoaderFlags";
  64317. }
  64318. declare module "babylonjs/Materials/Background/index" {
  64319. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64320. }
  64321. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64322. import { Scene } from "babylonjs/scene";
  64323. import { Color3 } from "babylonjs/Maths/math.color";
  64324. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64325. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64326. /**
  64327. * The Physically based simple base material of BJS.
  64328. *
  64329. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64330. * It is used as the base class for both the specGloss and metalRough conventions.
  64331. */
  64332. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64333. /**
  64334. * Number of Simultaneous lights allowed on the material.
  64335. */
  64336. maxSimultaneousLights: number;
  64337. /**
  64338. * If sets to true, disables all the lights affecting the material.
  64339. */
  64340. disableLighting: boolean;
  64341. /**
  64342. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64343. */
  64344. environmentTexture: BaseTexture;
  64345. /**
  64346. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64347. */
  64348. invertNormalMapX: boolean;
  64349. /**
  64350. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64351. */
  64352. invertNormalMapY: boolean;
  64353. /**
  64354. * Normal map used in the model.
  64355. */
  64356. normalTexture: BaseTexture;
  64357. /**
  64358. * Emissivie color used to self-illuminate the model.
  64359. */
  64360. emissiveColor: Color3;
  64361. /**
  64362. * Emissivie texture used to self-illuminate the model.
  64363. */
  64364. emissiveTexture: BaseTexture;
  64365. /**
  64366. * Occlusion Channel Strenght.
  64367. */
  64368. occlusionStrength: number;
  64369. /**
  64370. * Occlusion Texture of the material (adding extra occlusion effects).
  64371. */
  64372. occlusionTexture: BaseTexture;
  64373. /**
  64374. * Defines the alpha limits in alpha test mode.
  64375. */
  64376. alphaCutOff: number;
  64377. /**
  64378. * Gets the current double sided mode.
  64379. */
  64380. get doubleSided(): boolean;
  64381. /**
  64382. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64383. */
  64384. set doubleSided(value: boolean);
  64385. /**
  64386. * Stores the pre-calculated light information of a mesh in a texture.
  64387. */
  64388. lightmapTexture: BaseTexture;
  64389. /**
  64390. * If true, the light map contains occlusion information instead of lighting info.
  64391. */
  64392. useLightmapAsShadowmap: boolean;
  64393. /**
  64394. * Instantiates a new PBRMaterial instance.
  64395. *
  64396. * @param name The material name
  64397. * @param scene The scene the material will be use in.
  64398. */
  64399. constructor(name: string, scene: Scene);
  64400. getClassName(): string;
  64401. }
  64402. }
  64403. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64404. import { Scene } from "babylonjs/scene";
  64405. import { Color3 } from "babylonjs/Maths/math.color";
  64406. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64407. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64408. /**
  64409. * The PBR material of BJS following the metal roughness convention.
  64410. *
  64411. * This fits to the PBR convention in the GLTF definition:
  64412. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64413. */
  64414. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64415. /**
  64416. * The base color has two different interpretations depending on the value of metalness.
  64417. * When the material is a metal, the base color is the specific measured reflectance value
  64418. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64419. * of the material.
  64420. */
  64421. baseColor: Color3;
  64422. /**
  64423. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64424. * well as opacity information in the alpha channel.
  64425. */
  64426. baseTexture: BaseTexture;
  64427. /**
  64428. * Specifies the metallic scalar value of the material.
  64429. * Can also be used to scale the metalness values of the metallic texture.
  64430. */
  64431. metallic: number;
  64432. /**
  64433. * Specifies the roughness scalar value of the material.
  64434. * Can also be used to scale the roughness values of the metallic texture.
  64435. */
  64436. roughness: number;
  64437. /**
  64438. * Texture containing both the metallic value in the B channel and the
  64439. * roughness value in the G channel to keep better precision.
  64440. */
  64441. metallicRoughnessTexture: BaseTexture;
  64442. /**
  64443. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64444. *
  64445. * @param name The material name
  64446. * @param scene The scene the material will be use in.
  64447. */
  64448. constructor(name: string, scene: Scene);
  64449. /**
  64450. * Return the currrent class name of the material.
  64451. */
  64452. getClassName(): string;
  64453. /**
  64454. * Makes a duplicate of the current material.
  64455. * @param name - name to use for the new material.
  64456. */
  64457. clone(name: string): PBRMetallicRoughnessMaterial;
  64458. /**
  64459. * Serialize the material to a parsable JSON object.
  64460. */
  64461. serialize(): any;
  64462. /**
  64463. * Parses a JSON object correponding to the serialize function.
  64464. */
  64465. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64466. }
  64467. }
  64468. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64469. import { Scene } from "babylonjs/scene";
  64470. import { Color3 } from "babylonjs/Maths/math.color";
  64471. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64472. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64473. /**
  64474. * The PBR material of BJS following the specular glossiness convention.
  64475. *
  64476. * This fits to the PBR convention in the GLTF definition:
  64477. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64478. */
  64479. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64480. /**
  64481. * Specifies the diffuse color of the material.
  64482. */
  64483. diffuseColor: Color3;
  64484. /**
  64485. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64486. * channel.
  64487. */
  64488. diffuseTexture: BaseTexture;
  64489. /**
  64490. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64491. */
  64492. specularColor: Color3;
  64493. /**
  64494. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64495. */
  64496. glossiness: number;
  64497. /**
  64498. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64499. */
  64500. specularGlossinessTexture: BaseTexture;
  64501. /**
  64502. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64503. *
  64504. * @param name The material name
  64505. * @param scene The scene the material will be use in.
  64506. */
  64507. constructor(name: string, scene: Scene);
  64508. /**
  64509. * Return the currrent class name of the material.
  64510. */
  64511. getClassName(): string;
  64512. /**
  64513. * Makes a duplicate of the current material.
  64514. * @param name - name to use for the new material.
  64515. */
  64516. clone(name: string): PBRSpecularGlossinessMaterial;
  64517. /**
  64518. * Serialize the material to a parsable JSON object.
  64519. */
  64520. serialize(): any;
  64521. /**
  64522. * Parses a JSON object correponding to the serialize function.
  64523. */
  64524. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64525. }
  64526. }
  64527. declare module "babylonjs/Materials/PBR/index" {
  64528. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64529. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64530. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64531. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64532. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64533. }
  64534. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64535. import { Nullable } from "babylonjs/types";
  64536. import { Scene } from "babylonjs/scene";
  64537. import { Matrix } from "babylonjs/Maths/math.vector";
  64538. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64539. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64540. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64541. /**
  64542. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64543. * It can help converting any input color in a desired output one. This can then be used to create effects
  64544. * from sepia, black and white to sixties or futuristic rendering...
  64545. *
  64546. * The only supported format is currently 3dl.
  64547. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64548. */
  64549. export class ColorGradingTexture extends BaseTexture {
  64550. /**
  64551. * The texture URL.
  64552. */
  64553. url: string;
  64554. /**
  64555. * Empty line regex stored for GC.
  64556. */
  64557. private static _noneEmptyLineRegex;
  64558. private _textureMatrix;
  64559. private _onLoad;
  64560. /**
  64561. * Instantiates a ColorGradingTexture from the following parameters.
  64562. *
  64563. * @param url The location of the color gradind data (currently only supporting 3dl)
  64564. * @param sceneOrEngine The scene or engine the texture will be used in
  64565. * @param onLoad defines a callback triggered when the texture has been loaded
  64566. */
  64567. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  64568. /**
  64569. * Fires the onload event from the constructor if requested.
  64570. */
  64571. private _triggerOnLoad;
  64572. /**
  64573. * Returns the texture matrix used in most of the material.
  64574. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  64575. */
  64576. getTextureMatrix(): Matrix;
  64577. /**
  64578. * Occurs when the file being loaded is a .3dl LUT file.
  64579. */
  64580. private load3dlTexture;
  64581. /**
  64582. * Starts the loading process of the texture.
  64583. */
  64584. private loadTexture;
  64585. /**
  64586. * Clones the color gradind texture.
  64587. */
  64588. clone(): ColorGradingTexture;
  64589. /**
  64590. * Called during delayed load for textures.
  64591. */
  64592. delayLoad(): void;
  64593. /**
  64594. * Parses a color grading texture serialized by Babylon.
  64595. * @param parsedTexture The texture information being parsedTexture
  64596. * @param scene The scene to load the texture in
  64597. * @param rootUrl The root url of the data assets to load
  64598. * @return A color gradind texture
  64599. */
  64600. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64601. /**
  64602. * Serializes the LUT texture to json format.
  64603. */
  64604. serialize(): any;
  64605. }
  64606. }
  64607. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64608. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64609. import { Scene } from "babylonjs/scene";
  64610. import { Nullable } from "babylonjs/types";
  64611. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64612. /**
  64613. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64614. */
  64615. export class EquiRectangularCubeTexture extends BaseTexture {
  64616. /** The six faces of the cube. */
  64617. private static _FacesMapping;
  64618. private _noMipmap;
  64619. private _onLoad;
  64620. private _onError;
  64621. /** The size of the cubemap. */
  64622. private _size;
  64623. /** The buffer of the image. */
  64624. private _buffer;
  64625. /** The width of the input image. */
  64626. private _width;
  64627. /** The height of the input image. */
  64628. private _height;
  64629. /** The URL to the image. */
  64630. url: string;
  64631. /**
  64632. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64633. * @param url The location of the image
  64634. * @param scene The scene the texture will be used in
  64635. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64636. * @param noMipmap Forces to not generate the mipmap if true
  64637. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64638. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64639. * @param onLoad — defines a callback called when texture is loaded
  64640. * @param onError — defines a callback called if there is an error
  64641. */
  64642. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64643. /**
  64644. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64645. */
  64646. private loadImage;
  64647. /**
  64648. * Convert the image buffer into a cubemap and create a CubeTexture.
  64649. */
  64650. private loadTexture;
  64651. /**
  64652. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64653. * @param buffer The ArrayBuffer that should be converted.
  64654. * @returns The buffer as Float32Array.
  64655. */
  64656. private getFloat32ArrayFromArrayBuffer;
  64657. /**
  64658. * Get the current class name of the texture useful for serialization or dynamic coding.
  64659. * @returns "EquiRectangularCubeTexture"
  64660. */
  64661. getClassName(): string;
  64662. /**
  64663. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64664. * @returns A clone of the current EquiRectangularCubeTexture.
  64665. */
  64666. clone(): EquiRectangularCubeTexture;
  64667. }
  64668. }
  64669. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64670. import { Nullable } from "babylonjs/types";
  64671. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64672. import { Matrix } from "babylonjs/Maths/math.vector";
  64673. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64674. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64675. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64676. import { Scene } from "babylonjs/scene";
  64677. /**
  64678. * Defines the options related to the creation of an HtmlElementTexture
  64679. */
  64680. export interface IHtmlElementTextureOptions {
  64681. /**
  64682. * Defines wether mip maps should be created or not.
  64683. */
  64684. generateMipMaps?: boolean;
  64685. /**
  64686. * Defines the sampling mode of the texture.
  64687. */
  64688. samplingMode?: number;
  64689. /**
  64690. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64691. */
  64692. engine: Nullable<ThinEngine>;
  64693. /**
  64694. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64695. */
  64696. scene: Nullable<Scene>;
  64697. }
  64698. /**
  64699. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64700. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64701. * is automatically managed.
  64702. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64703. * in your application.
  64704. *
  64705. * As the update is not automatic, you need to call them manually.
  64706. */
  64707. export class HtmlElementTexture extends BaseTexture {
  64708. /**
  64709. * The texture URL.
  64710. */
  64711. element: HTMLVideoElement | HTMLCanvasElement;
  64712. private static readonly DefaultOptions;
  64713. private _textureMatrix;
  64714. private _isVideo;
  64715. private _generateMipMaps;
  64716. private _samplingMode;
  64717. /**
  64718. * Instantiates a HtmlElementTexture from the following parameters.
  64719. *
  64720. * @param name Defines the name of the texture
  64721. * @param element Defines the video or canvas the texture is filled with
  64722. * @param options Defines the other none mandatory texture creation options
  64723. */
  64724. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64725. private _createInternalTexture;
  64726. /**
  64727. * Returns the texture matrix used in most of the material.
  64728. */
  64729. getTextureMatrix(): Matrix;
  64730. /**
  64731. * Updates the content of the texture.
  64732. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64733. */
  64734. update(invertY?: Nullable<boolean>): void;
  64735. }
  64736. }
  64737. declare module "babylonjs/Misc/tga" {
  64738. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64739. /**
  64740. * Based on jsTGALoader - Javascript loader for TGA file
  64741. * By Vincent Thibault
  64742. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64743. */
  64744. export class TGATools {
  64745. private static _TYPE_INDEXED;
  64746. private static _TYPE_RGB;
  64747. private static _TYPE_GREY;
  64748. private static _TYPE_RLE_INDEXED;
  64749. private static _TYPE_RLE_RGB;
  64750. private static _TYPE_RLE_GREY;
  64751. private static _ORIGIN_MASK;
  64752. private static _ORIGIN_SHIFT;
  64753. private static _ORIGIN_BL;
  64754. private static _ORIGIN_BR;
  64755. private static _ORIGIN_UL;
  64756. private static _ORIGIN_UR;
  64757. /**
  64758. * Gets the header of a TGA file
  64759. * @param data defines the TGA data
  64760. * @returns the header
  64761. */
  64762. static GetTGAHeader(data: Uint8Array): any;
  64763. /**
  64764. * Uploads TGA content to a Babylon Texture
  64765. * @hidden
  64766. */
  64767. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64768. /** @hidden */
  64769. 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;
  64770. /** @hidden */
  64771. 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;
  64772. /** @hidden */
  64773. 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;
  64774. /** @hidden */
  64775. 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;
  64776. /** @hidden */
  64777. 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;
  64778. /** @hidden */
  64779. 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;
  64780. }
  64781. }
  64782. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64783. import { Nullable } from "babylonjs/types";
  64784. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64785. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64786. /**
  64787. * Implementation of the TGA Texture Loader.
  64788. * @hidden
  64789. */
  64790. export class _TGATextureLoader implements IInternalTextureLoader {
  64791. /**
  64792. * Defines wether the loader supports cascade loading the different faces.
  64793. */
  64794. readonly supportCascades: boolean;
  64795. /**
  64796. * This returns if the loader support the current file information.
  64797. * @param extension defines the file extension of the file being loaded
  64798. * @returns true if the loader can load the specified file
  64799. */
  64800. canLoad(extension: string): boolean;
  64801. /**
  64802. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64803. * @param data contains the texture data
  64804. * @param texture defines the BabylonJS internal texture
  64805. * @param createPolynomials will be true if polynomials have been requested
  64806. * @param onLoad defines the callback to trigger once the texture is ready
  64807. * @param onError defines the callback to trigger in case of error
  64808. */
  64809. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64810. /**
  64811. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64812. * @param data contains the texture data
  64813. * @param texture defines the BabylonJS internal texture
  64814. * @param callback defines the method to call once ready to upload
  64815. */
  64816. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64817. }
  64818. }
  64819. declare module "babylonjs/Misc/basis" {
  64820. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64821. /**
  64822. * Info about the .basis files
  64823. */
  64824. class BasisFileInfo {
  64825. /**
  64826. * If the file has alpha
  64827. */
  64828. hasAlpha: boolean;
  64829. /**
  64830. * Info about each image of the basis file
  64831. */
  64832. images: Array<{
  64833. levels: Array<{
  64834. width: number;
  64835. height: number;
  64836. transcodedPixels: ArrayBufferView;
  64837. }>;
  64838. }>;
  64839. }
  64840. /**
  64841. * Result of transcoding a basis file
  64842. */
  64843. class TranscodeResult {
  64844. /**
  64845. * Info about the .basis file
  64846. */
  64847. fileInfo: BasisFileInfo;
  64848. /**
  64849. * Format to use when loading the file
  64850. */
  64851. format: number;
  64852. }
  64853. /**
  64854. * Configuration options for the Basis transcoder
  64855. */
  64856. export class BasisTranscodeConfiguration {
  64857. /**
  64858. * Supported compression formats used to determine the supported output format of the transcoder
  64859. */
  64860. supportedCompressionFormats?: {
  64861. /**
  64862. * etc1 compression format
  64863. */
  64864. etc1?: boolean;
  64865. /**
  64866. * s3tc compression format
  64867. */
  64868. s3tc?: boolean;
  64869. /**
  64870. * pvrtc compression format
  64871. */
  64872. pvrtc?: boolean;
  64873. /**
  64874. * etc2 compression format
  64875. */
  64876. etc2?: boolean;
  64877. };
  64878. /**
  64879. * If mipmap levels should be loaded for transcoded images (Default: true)
  64880. */
  64881. loadMipmapLevels?: boolean;
  64882. /**
  64883. * Index of a single image to load (Default: all images)
  64884. */
  64885. loadSingleImage?: number;
  64886. }
  64887. /**
  64888. * Used to load .Basis files
  64889. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64890. */
  64891. export class BasisTools {
  64892. private static _IgnoreSupportedFormats;
  64893. /**
  64894. * URL to use when loading the basis transcoder
  64895. */
  64896. static JSModuleURL: string;
  64897. /**
  64898. * URL to use when loading the wasm module for the transcoder
  64899. */
  64900. static WasmModuleURL: string;
  64901. /**
  64902. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64903. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64904. * @returns internal format corresponding to the Basis format
  64905. */
  64906. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64907. private static _WorkerPromise;
  64908. private static _Worker;
  64909. private static _actionId;
  64910. private static _CreateWorkerAsync;
  64911. /**
  64912. * Transcodes a loaded image file to compressed pixel data
  64913. * @param data image data to transcode
  64914. * @param config configuration options for the transcoding
  64915. * @returns a promise resulting in the transcoded image
  64916. */
  64917. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64918. /**
  64919. * Loads a texture from the transcode result
  64920. * @param texture texture load to
  64921. * @param transcodeResult the result of transcoding the basis file to load from
  64922. */
  64923. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64924. }
  64925. }
  64926. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64927. import { Nullable } from "babylonjs/types";
  64928. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64929. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64930. /**
  64931. * Loader for .basis file format
  64932. */
  64933. export class _BasisTextureLoader implements IInternalTextureLoader {
  64934. /**
  64935. * Defines whether the loader supports cascade loading the different faces.
  64936. */
  64937. readonly supportCascades: boolean;
  64938. /**
  64939. * This returns if the loader support the current file information.
  64940. * @param extension defines the file extension of the file being loaded
  64941. * @returns true if the loader can load the specified file
  64942. */
  64943. canLoad(extension: string): boolean;
  64944. /**
  64945. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64946. * @param data contains the texture data
  64947. * @param texture defines the BabylonJS internal texture
  64948. * @param createPolynomials will be true if polynomials have been requested
  64949. * @param onLoad defines the callback to trigger once the texture is ready
  64950. * @param onError defines the callback to trigger in case of error
  64951. */
  64952. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64953. /**
  64954. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64955. * @param data contains the texture data
  64956. * @param texture defines the BabylonJS internal texture
  64957. * @param callback defines the method to call once ready to upload
  64958. */
  64959. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64960. }
  64961. }
  64962. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64963. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64964. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64965. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64966. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64967. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64968. }
  64969. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64970. import { Vector2 } from "babylonjs/Maths/math.vector";
  64971. /**
  64972. * Defines the basic options interface of a TexturePacker Frame
  64973. */
  64974. export interface ITexturePackerFrame {
  64975. /**
  64976. * The frame ID
  64977. */
  64978. id: number;
  64979. /**
  64980. * The frames Scale
  64981. */
  64982. scale: Vector2;
  64983. /**
  64984. * The Frames offset
  64985. */
  64986. offset: Vector2;
  64987. }
  64988. /**
  64989. * This is a support class for frame Data on texture packer sets.
  64990. */
  64991. export class TexturePackerFrame implements ITexturePackerFrame {
  64992. /**
  64993. * The frame ID
  64994. */
  64995. id: number;
  64996. /**
  64997. * The frames Scale
  64998. */
  64999. scale: Vector2;
  65000. /**
  65001. * The Frames offset
  65002. */
  65003. offset: Vector2;
  65004. /**
  65005. * Initializes a texture package frame.
  65006. * @param id The numerical frame identifier
  65007. * @param scale Scalar Vector2 for UV frame
  65008. * @param offset Vector2 for the frame position in UV units.
  65009. * @returns TexturePackerFrame
  65010. */
  65011. constructor(id: number, scale: Vector2, offset: Vector2);
  65012. }
  65013. }
  65014. declare module "babylonjs/Materials/Textures/Packer/packer" {
  65015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65016. import { Scene } from "babylonjs/scene";
  65017. import { Nullable } from "babylonjs/types";
  65018. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  65019. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  65020. /**
  65021. * Defines the basic options interface of a TexturePacker
  65022. */
  65023. export interface ITexturePackerOptions {
  65024. /**
  65025. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  65026. */
  65027. map?: string[];
  65028. /**
  65029. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65030. */
  65031. uvsIn?: string;
  65032. /**
  65033. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65034. */
  65035. uvsOut?: string;
  65036. /**
  65037. * number representing the layout style. Defaults to LAYOUT_STRIP
  65038. */
  65039. layout?: number;
  65040. /**
  65041. * number of columns if using custom column count layout(2). This defaults to 4.
  65042. */
  65043. colnum?: number;
  65044. /**
  65045. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  65046. */
  65047. updateInputMeshes?: boolean;
  65048. /**
  65049. * boolean flag to dispose all the source textures. Defaults to true.
  65050. */
  65051. disposeSources?: boolean;
  65052. /**
  65053. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  65054. */
  65055. fillBlanks?: boolean;
  65056. /**
  65057. * string value representing the context fill style color. Defaults to 'black'.
  65058. */
  65059. customFillColor?: string;
  65060. /**
  65061. * Width and Height Value of each Frame in the TexturePacker Sets
  65062. */
  65063. frameSize?: number;
  65064. /**
  65065. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65066. */
  65067. paddingRatio?: number;
  65068. /**
  65069. * Number that declares the fill method for the padding gutter.
  65070. */
  65071. paddingMode?: number;
  65072. /**
  65073. * If in SUBUV_COLOR padding mode what color to use.
  65074. */
  65075. paddingColor?: Color3 | Color4;
  65076. }
  65077. /**
  65078. * Defines the basic interface of a TexturePacker JSON File
  65079. */
  65080. export interface ITexturePackerJSON {
  65081. /**
  65082. * The frame ID
  65083. */
  65084. name: string;
  65085. /**
  65086. * The base64 channel data
  65087. */
  65088. sets: any;
  65089. /**
  65090. * The options of the Packer
  65091. */
  65092. options: ITexturePackerOptions;
  65093. /**
  65094. * The frame data of the Packer
  65095. */
  65096. frames: Array<number>;
  65097. }
  65098. /**
  65099. * This is a support class that generates a series of packed texture sets.
  65100. * @see https://doc.babylonjs.com/babylon101/materials
  65101. */
  65102. export class TexturePacker {
  65103. /** Packer Layout Constant 0 */
  65104. static readonly LAYOUT_STRIP: number;
  65105. /** Packer Layout Constant 1 */
  65106. static readonly LAYOUT_POWER2: number;
  65107. /** Packer Layout Constant 2 */
  65108. static readonly LAYOUT_COLNUM: number;
  65109. /** Packer Layout Constant 0 */
  65110. static readonly SUBUV_WRAP: number;
  65111. /** Packer Layout Constant 1 */
  65112. static readonly SUBUV_EXTEND: number;
  65113. /** Packer Layout Constant 2 */
  65114. static readonly SUBUV_COLOR: number;
  65115. /** The Name of the Texture Package */
  65116. name: string;
  65117. /** The scene scope of the TexturePacker */
  65118. scene: Scene;
  65119. /** The Meshes to target */
  65120. meshes: AbstractMesh[];
  65121. /** Arguments passed with the Constructor */
  65122. options: ITexturePackerOptions;
  65123. /** The promise that is started upon initialization */
  65124. promise: Nullable<Promise<TexturePacker | string>>;
  65125. /** The Container object for the channel sets that are generated */
  65126. sets: object;
  65127. /** The Container array for the frames that are generated */
  65128. frames: TexturePackerFrame[];
  65129. /** The expected number of textures the system is parsing. */
  65130. private _expecting;
  65131. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65132. private _paddingValue;
  65133. /**
  65134. * Initializes a texture package series from an array of meshes or a single mesh.
  65135. * @param name The name of the package
  65136. * @param meshes The target meshes to compose the package from
  65137. * @param options The arguments that texture packer should follow while building.
  65138. * @param scene The scene which the textures are scoped to.
  65139. * @returns TexturePacker
  65140. */
  65141. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65142. /**
  65143. * Starts the package process
  65144. * @param resolve The promises resolution function
  65145. * @returns TexturePacker
  65146. */
  65147. private _createFrames;
  65148. /**
  65149. * Calculates the Size of the Channel Sets
  65150. * @returns Vector2
  65151. */
  65152. private _calculateSize;
  65153. /**
  65154. * Calculates the UV data for the frames.
  65155. * @param baseSize the base frameSize
  65156. * @param padding the base frame padding
  65157. * @param dtSize size of the Dynamic Texture for that channel
  65158. * @param dtUnits is 1/dtSize
  65159. * @param update flag to update the input meshes
  65160. */
  65161. private _calculateMeshUVFrames;
  65162. /**
  65163. * Calculates the frames Offset.
  65164. * @param index of the frame
  65165. * @returns Vector2
  65166. */
  65167. private _getFrameOffset;
  65168. /**
  65169. * Updates a Mesh to the frame data
  65170. * @param mesh that is the target
  65171. * @param frameID or the frame index
  65172. */
  65173. private _updateMeshUV;
  65174. /**
  65175. * Updates a Meshes materials to use the texture packer channels
  65176. * @param m is the mesh to target
  65177. * @param force all channels on the packer to be set.
  65178. */
  65179. private _updateTextureReferences;
  65180. /**
  65181. * Public method to set a Mesh to a frame
  65182. * @param m that is the target
  65183. * @param frameID or the frame index
  65184. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65185. */
  65186. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65187. /**
  65188. * Starts the async promise to compile the texture packer.
  65189. * @returns Promise<void>
  65190. */
  65191. processAsync(): Promise<void>;
  65192. /**
  65193. * Disposes all textures associated with this packer
  65194. */
  65195. dispose(): void;
  65196. /**
  65197. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65198. * @param imageType is the image type to use.
  65199. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65200. */
  65201. download(imageType?: string, quality?: number): void;
  65202. /**
  65203. * Public method to load a texturePacker JSON file.
  65204. * @param data of the JSON file in string format.
  65205. */
  65206. updateFromJSON(data: string): void;
  65207. }
  65208. }
  65209. declare module "babylonjs/Materials/Textures/Packer/index" {
  65210. export * from "babylonjs/Materials/Textures/Packer/packer";
  65211. export * from "babylonjs/Materials/Textures/Packer/frame";
  65212. }
  65213. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65214. import { Scene } from "babylonjs/scene";
  65215. import { Texture } from "babylonjs/Materials/Textures/texture";
  65216. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65217. /**
  65218. * 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.
  65219. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65220. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65221. */
  65222. export class CustomProceduralTexture extends ProceduralTexture {
  65223. private _animate;
  65224. private _time;
  65225. private _config;
  65226. private _texturePath;
  65227. /**
  65228. * Instantiates a new Custom Procedural Texture.
  65229. * 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.
  65230. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65231. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65232. * @param name Define the name of the texture
  65233. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65234. * @param size Define the size of the texture to create
  65235. * @param scene Define the scene the texture belongs to
  65236. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65237. * @param generateMipMaps Define if the texture should creates mip maps or not
  65238. */
  65239. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65240. private _loadJson;
  65241. /**
  65242. * Is the texture ready to be used ? (rendered at least once)
  65243. * @returns true if ready, otherwise, false.
  65244. */
  65245. isReady(): boolean;
  65246. /**
  65247. * Render the texture to its associated render target.
  65248. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65249. */
  65250. render(useCameraPostProcess?: boolean): void;
  65251. /**
  65252. * Update the list of dependant textures samplers in the shader.
  65253. */
  65254. updateTextures(): void;
  65255. /**
  65256. * Update the uniform values of the procedural texture in the shader.
  65257. */
  65258. updateShaderUniforms(): void;
  65259. /**
  65260. * Define if the texture animates or not.
  65261. */
  65262. get animate(): boolean;
  65263. set animate(value: boolean);
  65264. }
  65265. }
  65266. declare module "babylonjs/Shaders/noise.fragment" {
  65267. /** @hidden */
  65268. export var noisePixelShader: {
  65269. name: string;
  65270. shader: string;
  65271. };
  65272. }
  65273. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65274. import { Nullable } from "babylonjs/types";
  65275. import { Scene } from "babylonjs/scene";
  65276. import { Texture } from "babylonjs/Materials/Textures/texture";
  65277. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65278. import "babylonjs/Shaders/noise.fragment";
  65279. /**
  65280. * Class used to generate noise procedural textures
  65281. */
  65282. export class NoiseProceduralTexture extends ProceduralTexture {
  65283. /** Gets or sets the start time (default is 0) */
  65284. time: number;
  65285. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65286. brightness: number;
  65287. /** Defines the number of octaves to process */
  65288. octaves: number;
  65289. /** Defines the level of persistence (0.8 by default) */
  65290. persistence: number;
  65291. /** Gets or sets animation speed factor (default is 1) */
  65292. animationSpeedFactor: number;
  65293. /**
  65294. * Creates a new NoiseProceduralTexture
  65295. * @param name defines the name fo the texture
  65296. * @param size defines the size of the texture (default is 256)
  65297. * @param scene defines the hosting scene
  65298. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65299. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65300. */
  65301. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65302. private _updateShaderUniforms;
  65303. protected _getDefines(): string;
  65304. /** Generate the current state of the procedural texture */
  65305. render(useCameraPostProcess?: boolean): void;
  65306. /**
  65307. * Serializes this noise procedural texture
  65308. * @returns a serialized noise procedural texture object
  65309. */
  65310. serialize(): any;
  65311. /**
  65312. * Clone the texture.
  65313. * @returns the cloned texture
  65314. */
  65315. clone(): NoiseProceduralTexture;
  65316. /**
  65317. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65318. * @param parsedTexture defines parsed texture data
  65319. * @param scene defines the current scene
  65320. * @param rootUrl defines the root URL containing noise procedural texture information
  65321. * @returns a parsed NoiseProceduralTexture
  65322. */
  65323. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65324. }
  65325. }
  65326. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65327. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65328. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65329. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65330. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65331. }
  65332. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65333. import { Nullable } from "babylonjs/types";
  65334. import { Scene } from "babylonjs/scene";
  65335. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65336. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65337. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65338. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65339. /**
  65340. * Raw cube texture where the raw buffers are passed in
  65341. */
  65342. export class RawCubeTexture extends CubeTexture {
  65343. /**
  65344. * Creates a cube texture where the raw buffers are passed in.
  65345. * @param scene defines the scene the texture is attached to
  65346. * @param data defines the array of data to use to create each face
  65347. * @param size defines the size of the textures
  65348. * @param format defines the format of the data
  65349. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65350. * @param generateMipMaps defines if the engine should generate the mip levels
  65351. * @param invertY defines if data must be stored with Y axis inverted
  65352. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65353. * @param compression defines the compression used (null by default)
  65354. */
  65355. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65356. /**
  65357. * Updates the raw cube texture.
  65358. * @param data defines the data to store
  65359. * @param format defines the data format
  65360. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65361. * @param invertY defines if data must be stored with Y axis inverted
  65362. * @param compression defines the compression used (null by default)
  65363. * @param level defines which level of the texture to update
  65364. */
  65365. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65366. /**
  65367. * Updates a raw cube texture with RGBD encoded data.
  65368. * @param data defines the array of data [mipmap][face] to use to create each face
  65369. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65370. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65371. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65372. * @returns a promsie that resolves when the operation is complete
  65373. */
  65374. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65375. /**
  65376. * Clones the raw cube texture.
  65377. * @return a new cube texture
  65378. */
  65379. clone(): CubeTexture;
  65380. /** @hidden */
  65381. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65382. }
  65383. }
  65384. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65385. import { Scene } from "babylonjs/scene";
  65386. import { Texture } from "babylonjs/Materials/Textures/texture";
  65387. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65388. /**
  65389. * Class used to store 2D array textures containing user data
  65390. */
  65391. export class RawTexture2DArray extends Texture {
  65392. /** Gets or sets the texture format to use */
  65393. format: number;
  65394. /**
  65395. * Create a new RawTexture2DArray
  65396. * @param data defines the data of the texture
  65397. * @param width defines the width of the texture
  65398. * @param height defines the height of the texture
  65399. * @param depth defines the number of layers of the texture
  65400. * @param format defines the texture format to use
  65401. * @param scene defines the hosting scene
  65402. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65403. * @param invertY defines if texture must be stored with Y axis inverted
  65404. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65405. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65406. */
  65407. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65408. /** Gets or sets the texture format to use */
  65409. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65410. /**
  65411. * Update the texture with new data
  65412. * @param data defines the data to store in the texture
  65413. */
  65414. update(data: ArrayBufferView): void;
  65415. }
  65416. }
  65417. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65418. import { Scene } from "babylonjs/scene";
  65419. import { Texture } from "babylonjs/Materials/Textures/texture";
  65420. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65421. /**
  65422. * Class used to store 3D textures containing user data
  65423. */
  65424. export class RawTexture3D extends Texture {
  65425. /** Gets or sets the texture format to use */
  65426. format: number;
  65427. /**
  65428. * Create a new RawTexture3D
  65429. * @param data defines the data of the texture
  65430. * @param width defines the width of the texture
  65431. * @param height defines the height of the texture
  65432. * @param depth defines the depth of the texture
  65433. * @param format defines the texture format to use
  65434. * @param scene defines the hosting scene
  65435. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65436. * @param invertY defines if texture must be stored with Y axis inverted
  65437. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65438. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65439. */
  65440. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65441. /** Gets or sets the texture format to use */
  65442. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65443. /**
  65444. * Update the texture with new data
  65445. * @param data defines the data to store in the texture
  65446. */
  65447. update(data: ArrayBufferView): void;
  65448. }
  65449. }
  65450. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65451. import { Scene } from "babylonjs/scene";
  65452. import { Plane } from "babylonjs/Maths/math.plane";
  65453. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65454. /**
  65455. * Creates a refraction texture used by refraction channel of the standard material.
  65456. * It is like a mirror but to see through a material.
  65457. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65458. */
  65459. export class RefractionTexture extends RenderTargetTexture {
  65460. /**
  65461. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65462. * 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.
  65463. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65464. */
  65465. refractionPlane: Plane;
  65466. /**
  65467. * Define how deep under the surface we should see.
  65468. */
  65469. depth: number;
  65470. /**
  65471. * Creates a refraction texture used by refraction channel of the standard material.
  65472. * It is like a mirror but to see through a material.
  65473. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65474. * @param name Define the texture name
  65475. * @param size Define the size of the underlying texture
  65476. * @param scene Define the scene the refraction belongs to
  65477. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65478. */
  65479. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65480. /**
  65481. * Clone the refraction texture.
  65482. * @returns the cloned texture
  65483. */
  65484. clone(): RefractionTexture;
  65485. /**
  65486. * Serialize the texture to a JSON representation you could use in Parse later on
  65487. * @returns the serialized JSON representation
  65488. */
  65489. serialize(): any;
  65490. }
  65491. }
  65492. declare module "babylonjs/Materials/Textures/index" {
  65493. export * from "babylonjs/Materials/Textures/baseTexture";
  65494. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65495. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65496. export * from "babylonjs/Materials/Textures/cubeTexture";
  65497. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65498. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65499. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65500. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65501. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65502. export * from "babylonjs/Materials/Textures/internalTexture";
  65503. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65504. export * from "babylonjs/Materials/Textures/Loaders/index";
  65505. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65506. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65507. export * from "babylonjs/Materials/Textures/Packer/index";
  65508. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65509. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65510. export * from "babylonjs/Materials/Textures/rawTexture";
  65511. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65512. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65513. export * from "babylonjs/Materials/Textures/refractionTexture";
  65514. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65515. export * from "babylonjs/Materials/Textures/texture";
  65516. export * from "babylonjs/Materials/Textures/videoTexture";
  65517. }
  65518. declare module "babylonjs/Materials/Node/Enums/index" {
  65519. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65520. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65521. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65522. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65523. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65524. }
  65525. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65526. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65527. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65529. import { Mesh } from "babylonjs/Meshes/mesh";
  65530. import { Effect } from "babylonjs/Materials/effect";
  65531. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65532. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65533. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65534. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65535. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65536. /**
  65537. * Block used to add support for vertex skinning (bones)
  65538. */
  65539. export class BonesBlock extends NodeMaterialBlock {
  65540. /**
  65541. * Creates a new BonesBlock
  65542. * @param name defines the block name
  65543. */
  65544. constructor(name: string);
  65545. /**
  65546. * Initialize the block and prepare the context for build
  65547. * @param state defines the state that will be used for the build
  65548. */
  65549. initialize(state: NodeMaterialBuildState): void;
  65550. /**
  65551. * Gets the current class name
  65552. * @returns the class name
  65553. */
  65554. getClassName(): string;
  65555. /**
  65556. * Gets the matrix indices input component
  65557. */
  65558. get matricesIndices(): NodeMaterialConnectionPoint;
  65559. /**
  65560. * Gets the matrix weights input component
  65561. */
  65562. get matricesWeights(): NodeMaterialConnectionPoint;
  65563. /**
  65564. * Gets the extra matrix indices input component
  65565. */
  65566. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  65567. /**
  65568. * Gets the extra matrix weights input component
  65569. */
  65570. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  65571. /**
  65572. * Gets the world input component
  65573. */
  65574. get world(): NodeMaterialConnectionPoint;
  65575. /**
  65576. * Gets the output component
  65577. */
  65578. get output(): NodeMaterialConnectionPoint;
  65579. autoConfigure(material: NodeMaterial): void;
  65580. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  65581. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65582. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65583. protected _buildBlock(state: NodeMaterialBuildState): this;
  65584. }
  65585. }
  65586. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  65587. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65588. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65589. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65591. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65592. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65593. /**
  65594. * Block used to add support for instances
  65595. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65596. */
  65597. export class InstancesBlock extends NodeMaterialBlock {
  65598. /**
  65599. * Creates a new InstancesBlock
  65600. * @param name defines the block name
  65601. */
  65602. constructor(name: string);
  65603. /**
  65604. * Gets the current class name
  65605. * @returns the class name
  65606. */
  65607. getClassName(): string;
  65608. /**
  65609. * Gets the first world row input component
  65610. */
  65611. get world0(): NodeMaterialConnectionPoint;
  65612. /**
  65613. * Gets the second world row input component
  65614. */
  65615. get world1(): NodeMaterialConnectionPoint;
  65616. /**
  65617. * Gets the third world row input component
  65618. */
  65619. get world2(): NodeMaterialConnectionPoint;
  65620. /**
  65621. * Gets the forth world row input component
  65622. */
  65623. get world3(): NodeMaterialConnectionPoint;
  65624. /**
  65625. * Gets the world input component
  65626. */
  65627. get world(): NodeMaterialConnectionPoint;
  65628. /**
  65629. * Gets the output component
  65630. */
  65631. get output(): NodeMaterialConnectionPoint;
  65632. /**
  65633. * Gets the isntanceID component
  65634. */
  65635. get instanceID(): NodeMaterialConnectionPoint;
  65636. autoConfigure(material: NodeMaterial): void;
  65637. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65638. protected _buildBlock(state: NodeMaterialBuildState): this;
  65639. }
  65640. }
  65641. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  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 { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65646. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65647. import { Effect } from "babylonjs/Materials/effect";
  65648. import { Mesh } from "babylonjs/Meshes/mesh";
  65649. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65650. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65651. /**
  65652. * Block used to add morph targets support to vertex shader
  65653. */
  65654. export class MorphTargetsBlock extends NodeMaterialBlock {
  65655. private _repeatableContentAnchor;
  65656. /**
  65657. * Create a new MorphTargetsBlock
  65658. * @param name defines the block name
  65659. */
  65660. constructor(name: string);
  65661. /**
  65662. * Gets the current class name
  65663. * @returns the class name
  65664. */
  65665. getClassName(): string;
  65666. /**
  65667. * Gets the position input component
  65668. */
  65669. get position(): NodeMaterialConnectionPoint;
  65670. /**
  65671. * Gets the normal input component
  65672. */
  65673. get normal(): NodeMaterialConnectionPoint;
  65674. /**
  65675. * Gets the tangent input component
  65676. */
  65677. get tangent(): NodeMaterialConnectionPoint;
  65678. /**
  65679. * Gets the tangent input component
  65680. */
  65681. get uv(): NodeMaterialConnectionPoint;
  65682. /**
  65683. * Gets the position output component
  65684. */
  65685. get positionOutput(): NodeMaterialConnectionPoint;
  65686. /**
  65687. * Gets the normal output component
  65688. */
  65689. get normalOutput(): NodeMaterialConnectionPoint;
  65690. /**
  65691. * Gets the tangent output component
  65692. */
  65693. get tangentOutput(): NodeMaterialConnectionPoint;
  65694. /**
  65695. * Gets the tangent output component
  65696. */
  65697. get uvOutput(): NodeMaterialConnectionPoint;
  65698. initialize(state: NodeMaterialBuildState): void;
  65699. autoConfigure(material: NodeMaterial): void;
  65700. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65701. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65702. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65703. protected _buildBlock(state: NodeMaterialBuildState): this;
  65704. }
  65705. }
  65706. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65707. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65708. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65709. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65710. import { Nullable } from "babylonjs/types";
  65711. import { Scene } from "babylonjs/scene";
  65712. import { Effect } from "babylonjs/Materials/effect";
  65713. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65714. import { Mesh } from "babylonjs/Meshes/mesh";
  65715. import { Light } from "babylonjs/Lights/light";
  65716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65717. /**
  65718. * Block used to get data information from a light
  65719. */
  65720. export class LightInformationBlock extends NodeMaterialBlock {
  65721. private _lightDataUniformName;
  65722. private _lightColorUniformName;
  65723. private _lightTypeDefineName;
  65724. /**
  65725. * Gets or sets the light associated with this block
  65726. */
  65727. light: Nullable<Light>;
  65728. /**
  65729. * Creates a new LightInformationBlock
  65730. * @param name defines the block name
  65731. */
  65732. constructor(name: string);
  65733. /**
  65734. * Gets the current class name
  65735. * @returns the class name
  65736. */
  65737. getClassName(): string;
  65738. /**
  65739. * Gets the world position input component
  65740. */
  65741. get worldPosition(): NodeMaterialConnectionPoint;
  65742. /**
  65743. * Gets the direction output component
  65744. */
  65745. get direction(): NodeMaterialConnectionPoint;
  65746. /**
  65747. * Gets the direction output component
  65748. */
  65749. get color(): NodeMaterialConnectionPoint;
  65750. /**
  65751. * Gets the direction output component
  65752. */
  65753. get intensity(): NodeMaterialConnectionPoint;
  65754. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65755. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65756. protected _buildBlock(state: NodeMaterialBuildState): this;
  65757. serialize(): any;
  65758. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65759. }
  65760. }
  65761. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65762. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65763. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65764. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65765. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65766. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65767. }
  65768. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65769. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65770. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65771. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65773. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65774. import { Effect } from "babylonjs/Materials/effect";
  65775. import { Mesh } from "babylonjs/Meshes/mesh";
  65776. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65777. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65778. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65779. /**
  65780. * Block used to add image processing support to fragment shader
  65781. */
  65782. export class ImageProcessingBlock extends NodeMaterialBlock {
  65783. /**
  65784. * Create a new ImageProcessingBlock
  65785. * @param name defines the block name
  65786. */
  65787. constructor(name: string);
  65788. /**
  65789. * Gets the current class name
  65790. * @returns the class name
  65791. */
  65792. getClassName(): string;
  65793. /**
  65794. * Gets the color input component
  65795. */
  65796. get color(): NodeMaterialConnectionPoint;
  65797. /**
  65798. * Gets the output component
  65799. */
  65800. get output(): NodeMaterialConnectionPoint;
  65801. /**
  65802. * Initialize the block and prepare the context for build
  65803. * @param state defines the state that will be used for the build
  65804. */
  65805. initialize(state: NodeMaterialBuildState): void;
  65806. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65807. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65808. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65809. protected _buildBlock(state: NodeMaterialBuildState): this;
  65810. }
  65811. }
  65812. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65813. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65814. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65815. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65816. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65818. import { Effect } from "babylonjs/Materials/effect";
  65819. import { Mesh } from "babylonjs/Meshes/mesh";
  65820. import { Scene } from "babylonjs/scene";
  65821. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65822. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65823. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65824. /**
  65825. * Block used to pertub normals based on a normal map
  65826. */
  65827. export class PerturbNormalBlock extends NodeMaterialBlock {
  65828. private _tangentSpaceParameterName;
  65829. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65830. invertX: boolean;
  65831. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65832. invertY: boolean;
  65833. /**
  65834. * Create a new PerturbNormalBlock
  65835. * @param name defines the block name
  65836. */
  65837. constructor(name: string);
  65838. /**
  65839. * Gets the current class name
  65840. * @returns the class name
  65841. */
  65842. getClassName(): string;
  65843. /**
  65844. * Gets the world position input component
  65845. */
  65846. get worldPosition(): NodeMaterialConnectionPoint;
  65847. /**
  65848. * Gets the world normal input component
  65849. */
  65850. get worldNormal(): NodeMaterialConnectionPoint;
  65851. /**
  65852. * Gets the world tangent input component
  65853. */
  65854. get worldTangent(): NodeMaterialConnectionPoint;
  65855. /**
  65856. * Gets the uv input component
  65857. */
  65858. get uv(): NodeMaterialConnectionPoint;
  65859. /**
  65860. * Gets the normal map color input component
  65861. */
  65862. get normalMapColor(): NodeMaterialConnectionPoint;
  65863. /**
  65864. * Gets the strength input component
  65865. */
  65866. get strength(): NodeMaterialConnectionPoint;
  65867. /**
  65868. * Gets the output component
  65869. */
  65870. get output(): NodeMaterialConnectionPoint;
  65871. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65872. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65873. autoConfigure(material: NodeMaterial): void;
  65874. protected _buildBlock(state: NodeMaterialBuildState): this;
  65875. protected _dumpPropertiesCode(): string;
  65876. serialize(): any;
  65877. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65878. }
  65879. }
  65880. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65881. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65882. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65883. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65884. /**
  65885. * Block used to discard a pixel if a value is smaller than a cutoff
  65886. */
  65887. export class DiscardBlock extends NodeMaterialBlock {
  65888. /**
  65889. * Create a new DiscardBlock
  65890. * @param name defines the block name
  65891. */
  65892. constructor(name: string);
  65893. /**
  65894. * Gets the current class name
  65895. * @returns the class name
  65896. */
  65897. getClassName(): string;
  65898. /**
  65899. * Gets the color input component
  65900. */
  65901. get value(): NodeMaterialConnectionPoint;
  65902. /**
  65903. * Gets the cutoff input component
  65904. */
  65905. get cutoff(): NodeMaterialConnectionPoint;
  65906. protected _buildBlock(state: NodeMaterialBuildState): this;
  65907. }
  65908. }
  65909. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65910. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65911. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65912. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65913. /**
  65914. * Block used to test if the fragment shader is front facing
  65915. */
  65916. export class FrontFacingBlock extends NodeMaterialBlock {
  65917. /**
  65918. * Creates a new FrontFacingBlock
  65919. * @param name defines the block name
  65920. */
  65921. constructor(name: string);
  65922. /**
  65923. * Gets the current class name
  65924. * @returns the class name
  65925. */
  65926. getClassName(): string;
  65927. /**
  65928. * Gets the output component
  65929. */
  65930. get output(): NodeMaterialConnectionPoint;
  65931. protected _buildBlock(state: NodeMaterialBuildState): this;
  65932. }
  65933. }
  65934. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65935. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65936. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65937. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65938. /**
  65939. * Block used to get the derivative value on x and y of a given input
  65940. */
  65941. export class DerivativeBlock extends NodeMaterialBlock {
  65942. /**
  65943. * Create a new DerivativeBlock
  65944. * @param name defines the block name
  65945. */
  65946. constructor(name: string);
  65947. /**
  65948. * Gets the current class name
  65949. * @returns the class name
  65950. */
  65951. getClassName(): string;
  65952. /**
  65953. * Gets the input component
  65954. */
  65955. get input(): NodeMaterialConnectionPoint;
  65956. /**
  65957. * Gets the derivative output on x
  65958. */
  65959. get dx(): NodeMaterialConnectionPoint;
  65960. /**
  65961. * Gets the derivative output on y
  65962. */
  65963. get dy(): NodeMaterialConnectionPoint;
  65964. protected _buildBlock(state: NodeMaterialBuildState): this;
  65965. }
  65966. }
  65967. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65968. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65969. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65970. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65971. /**
  65972. * Block used to make gl_FragCoord available
  65973. */
  65974. export class FragCoordBlock extends NodeMaterialBlock {
  65975. /**
  65976. * Creates a new FragCoordBlock
  65977. * @param name defines the block name
  65978. */
  65979. constructor(name: string);
  65980. /**
  65981. * Gets the current class name
  65982. * @returns the class name
  65983. */
  65984. getClassName(): string;
  65985. /**
  65986. * Gets the xy component
  65987. */
  65988. get xy(): NodeMaterialConnectionPoint;
  65989. /**
  65990. * Gets the xyz component
  65991. */
  65992. get xyz(): NodeMaterialConnectionPoint;
  65993. /**
  65994. * Gets the xyzw component
  65995. */
  65996. get xyzw(): NodeMaterialConnectionPoint;
  65997. /**
  65998. * Gets the x component
  65999. */
  66000. get x(): NodeMaterialConnectionPoint;
  66001. /**
  66002. * Gets the y component
  66003. */
  66004. get y(): NodeMaterialConnectionPoint;
  66005. /**
  66006. * Gets the z component
  66007. */
  66008. get z(): NodeMaterialConnectionPoint;
  66009. /**
  66010. * Gets the w component
  66011. */
  66012. get output(): NodeMaterialConnectionPoint;
  66013. protected writeOutputs(state: NodeMaterialBuildState): string;
  66014. protected _buildBlock(state: NodeMaterialBuildState): this;
  66015. }
  66016. }
  66017. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  66018. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66019. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66020. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66021. import { Effect } from "babylonjs/Materials/effect";
  66022. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66023. import { Mesh } from "babylonjs/Meshes/mesh";
  66024. /**
  66025. * Block used to get the screen sizes
  66026. */
  66027. export class ScreenSizeBlock extends NodeMaterialBlock {
  66028. private _varName;
  66029. private _scene;
  66030. /**
  66031. * Creates a new ScreenSizeBlock
  66032. * @param name defines the block name
  66033. */
  66034. constructor(name: string);
  66035. /**
  66036. * Gets the current class name
  66037. * @returns the class name
  66038. */
  66039. getClassName(): string;
  66040. /**
  66041. * Gets the xy component
  66042. */
  66043. get xy(): NodeMaterialConnectionPoint;
  66044. /**
  66045. * Gets the x component
  66046. */
  66047. get x(): NodeMaterialConnectionPoint;
  66048. /**
  66049. * Gets the y component
  66050. */
  66051. get y(): NodeMaterialConnectionPoint;
  66052. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66053. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66054. protected _buildBlock(state: NodeMaterialBuildState): this;
  66055. }
  66056. }
  66057. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  66058. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  66059. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  66060. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  66061. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  66062. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  66063. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  66064. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66065. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66066. }
  66067. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66068. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66069. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66070. import { Mesh } from "babylonjs/Meshes/mesh";
  66071. import { Effect } from "babylonjs/Materials/effect";
  66072. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66074. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66075. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66076. /**
  66077. * Block used to add support for scene fog
  66078. */
  66079. export class FogBlock extends NodeMaterialBlock {
  66080. private _fogDistanceName;
  66081. private _fogParameters;
  66082. /**
  66083. * Create a new FogBlock
  66084. * @param name defines the block name
  66085. */
  66086. constructor(name: string);
  66087. /**
  66088. * Gets the current class name
  66089. * @returns the class name
  66090. */
  66091. getClassName(): string;
  66092. /**
  66093. * Gets the world position input component
  66094. */
  66095. get worldPosition(): NodeMaterialConnectionPoint;
  66096. /**
  66097. * Gets the view input component
  66098. */
  66099. get view(): NodeMaterialConnectionPoint;
  66100. /**
  66101. * Gets the color input component
  66102. */
  66103. get input(): NodeMaterialConnectionPoint;
  66104. /**
  66105. * Gets the fog color input component
  66106. */
  66107. get fogColor(): NodeMaterialConnectionPoint;
  66108. /**
  66109. * Gets the output component
  66110. */
  66111. get output(): NodeMaterialConnectionPoint;
  66112. autoConfigure(material: NodeMaterial): void;
  66113. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66114. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66115. protected _buildBlock(state: NodeMaterialBuildState): this;
  66116. }
  66117. }
  66118. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  66119. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66120. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66121. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66123. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66124. import { Effect } from "babylonjs/Materials/effect";
  66125. import { Mesh } from "babylonjs/Meshes/mesh";
  66126. import { Light } from "babylonjs/Lights/light";
  66127. import { Nullable } from "babylonjs/types";
  66128. import { Scene } from "babylonjs/scene";
  66129. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66130. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66131. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66132. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66133. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66134. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66135. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66136. /**
  66137. * Block used to add light in the fragment shader
  66138. */
  66139. export class LightBlock extends NodeMaterialBlock {
  66140. private _lightId;
  66141. /**
  66142. * Gets or sets the light associated with this block
  66143. */
  66144. light: Nullable<Light>;
  66145. /**
  66146. * Create a new LightBlock
  66147. * @param name defines the block name
  66148. */
  66149. constructor(name: string);
  66150. /**
  66151. * Gets the current class name
  66152. * @returns the class name
  66153. */
  66154. getClassName(): string;
  66155. /**
  66156. * Gets the world position input component
  66157. */
  66158. get worldPosition(): NodeMaterialConnectionPoint;
  66159. /**
  66160. * Gets the world normal input component
  66161. */
  66162. get worldNormal(): NodeMaterialConnectionPoint;
  66163. /**
  66164. * Gets the camera (or eye) position component
  66165. */
  66166. get cameraPosition(): NodeMaterialConnectionPoint;
  66167. /**
  66168. * Gets the glossiness component
  66169. */
  66170. get glossiness(): NodeMaterialConnectionPoint;
  66171. /**
  66172. * Gets the glossinness power component
  66173. */
  66174. get glossPower(): NodeMaterialConnectionPoint;
  66175. /**
  66176. * Gets the diffuse color component
  66177. */
  66178. get diffuseColor(): NodeMaterialConnectionPoint;
  66179. /**
  66180. * Gets the specular color component
  66181. */
  66182. get specularColor(): NodeMaterialConnectionPoint;
  66183. /**
  66184. * Gets the diffuse output component
  66185. */
  66186. get diffuseOutput(): NodeMaterialConnectionPoint;
  66187. /**
  66188. * Gets the specular output component
  66189. */
  66190. get specularOutput(): NodeMaterialConnectionPoint;
  66191. /**
  66192. * Gets the shadow output component
  66193. */
  66194. get shadow(): NodeMaterialConnectionPoint;
  66195. autoConfigure(material: NodeMaterial): void;
  66196. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66197. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66198. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66199. private _injectVertexCode;
  66200. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66201. serialize(): any;
  66202. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66203. }
  66204. }
  66205. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66206. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66207. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66208. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66209. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66210. /**
  66211. * Block used to read a reflection texture from a sampler
  66212. */
  66213. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66214. /**
  66215. * Create a new ReflectionTextureBlock
  66216. * @param name defines the block name
  66217. */
  66218. constructor(name: string);
  66219. /**
  66220. * Gets the current class name
  66221. * @returns the class name
  66222. */
  66223. getClassName(): string;
  66224. /**
  66225. * Gets the world position input component
  66226. */
  66227. get position(): NodeMaterialConnectionPoint;
  66228. /**
  66229. * Gets the world position input component
  66230. */
  66231. get worldPosition(): NodeMaterialConnectionPoint;
  66232. /**
  66233. * Gets the world normal input component
  66234. */
  66235. get worldNormal(): NodeMaterialConnectionPoint;
  66236. /**
  66237. * Gets the world input component
  66238. */
  66239. get world(): NodeMaterialConnectionPoint;
  66240. /**
  66241. * Gets the camera (or eye) position component
  66242. */
  66243. get cameraPosition(): NodeMaterialConnectionPoint;
  66244. /**
  66245. * Gets the view input component
  66246. */
  66247. get view(): NodeMaterialConnectionPoint;
  66248. /**
  66249. * Gets the rgb output component
  66250. */
  66251. get rgb(): NodeMaterialConnectionPoint;
  66252. /**
  66253. * Gets the rgba output component
  66254. */
  66255. get rgba(): NodeMaterialConnectionPoint;
  66256. /**
  66257. * Gets the r output component
  66258. */
  66259. get r(): NodeMaterialConnectionPoint;
  66260. /**
  66261. * Gets the g output component
  66262. */
  66263. get g(): NodeMaterialConnectionPoint;
  66264. /**
  66265. * Gets the b output component
  66266. */
  66267. get b(): NodeMaterialConnectionPoint;
  66268. /**
  66269. * Gets the a output component
  66270. */
  66271. get a(): NodeMaterialConnectionPoint;
  66272. autoConfigure(material: NodeMaterial): void;
  66273. protected _buildBlock(state: NodeMaterialBuildState): this;
  66274. }
  66275. }
  66276. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66277. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66278. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66279. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66280. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66281. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66282. }
  66283. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66284. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66285. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66286. }
  66287. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66288. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66289. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66290. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66291. /**
  66292. * Block used to add 2 vectors
  66293. */
  66294. export class AddBlock extends NodeMaterialBlock {
  66295. /**
  66296. * Creates a new AddBlock
  66297. * @param name defines the block name
  66298. */
  66299. constructor(name: string);
  66300. /**
  66301. * Gets the current class name
  66302. * @returns the class name
  66303. */
  66304. getClassName(): string;
  66305. /**
  66306. * Gets the left operand input component
  66307. */
  66308. get left(): NodeMaterialConnectionPoint;
  66309. /**
  66310. * Gets the right operand input component
  66311. */
  66312. get right(): NodeMaterialConnectionPoint;
  66313. /**
  66314. * Gets the output component
  66315. */
  66316. get output(): NodeMaterialConnectionPoint;
  66317. protected _buildBlock(state: NodeMaterialBuildState): this;
  66318. }
  66319. }
  66320. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66321. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66322. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66323. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66324. /**
  66325. * Block used to scale a vector by a float
  66326. */
  66327. export class ScaleBlock extends NodeMaterialBlock {
  66328. /**
  66329. * Creates a new ScaleBlock
  66330. * @param name defines the block name
  66331. */
  66332. constructor(name: string);
  66333. /**
  66334. * Gets the current class name
  66335. * @returns the class name
  66336. */
  66337. getClassName(): string;
  66338. /**
  66339. * Gets the input component
  66340. */
  66341. get input(): NodeMaterialConnectionPoint;
  66342. /**
  66343. * Gets the factor input component
  66344. */
  66345. get factor(): NodeMaterialConnectionPoint;
  66346. /**
  66347. * Gets the output component
  66348. */
  66349. get output(): NodeMaterialConnectionPoint;
  66350. protected _buildBlock(state: NodeMaterialBuildState): this;
  66351. }
  66352. }
  66353. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66354. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66355. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66356. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66357. import { Scene } from "babylonjs/scene";
  66358. /**
  66359. * Block used to clamp a float
  66360. */
  66361. export class ClampBlock extends NodeMaterialBlock {
  66362. /** Gets or sets the minimum range */
  66363. minimum: number;
  66364. /** Gets or sets the maximum range */
  66365. maximum: number;
  66366. /**
  66367. * Creates a new ClampBlock
  66368. * @param name defines the block name
  66369. */
  66370. constructor(name: string);
  66371. /**
  66372. * Gets the current class name
  66373. * @returns the class name
  66374. */
  66375. getClassName(): string;
  66376. /**
  66377. * Gets the value input component
  66378. */
  66379. get value(): NodeMaterialConnectionPoint;
  66380. /**
  66381. * Gets the output component
  66382. */
  66383. get output(): NodeMaterialConnectionPoint;
  66384. protected _buildBlock(state: NodeMaterialBuildState): this;
  66385. protected _dumpPropertiesCode(): string;
  66386. serialize(): any;
  66387. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66388. }
  66389. }
  66390. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66391. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66392. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66393. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66394. /**
  66395. * Block used to apply a cross product between 2 vectors
  66396. */
  66397. export class CrossBlock extends NodeMaterialBlock {
  66398. /**
  66399. * Creates a new CrossBlock
  66400. * @param name defines the block name
  66401. */
  66402. constructor(name: string);
  66403. /**
  66404. * Gets the current class name
  66405. * @returns the class name
  66406. */
  66407. getClassName(): string;
  66408. /**
  66409. * Gets the left operand input component
  66410. */
  66411. get left(): NodeMaterialConnectionPoint;
  66412. /**
  66413. * Gets the right operand input component
  66414. */
  66415. get right(): NodeMaterialConnectionPoint;
  66416. /**
  66417. * Gets the output component
  66418. */
  66419. get output(): NodeMaterialConnectionPoint;
  66420. protected _buildBlock(state: NodeMaterialBuildState): this;
  66421. }
  66422. }
  66423. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66424. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66425. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66426. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66427. /**
  66428. * Block used to apply a dot product between 2 vectors
  66429. */
  66430. export class DotBlock extends NodeMaterialBlock {
  66431. /**
  66432. * Creates a new DotBlock
  66433. * @param name defines the block name
  66434. */
  66435. constructor(name: string);
  66436. /**
  66437. * Gets the current class name
  66438. * @returns the class name
  66439. */
  66440. getClassName(): string;
  66441. /**
  66442. * Gets the left operand input component
  66443. */
  66444. get left(): NodeMaterialConnectionPoint;
  66445. /**
  66446. * Gets the right operand input component
  66447. */
  66448. get right(): NodeMaterialConnectionPoint;
  66449. /**
  66450. * Gets the output component
  66451. */
  66452. get output(): NodeMaterialConnectionPoint;
  66453. protected _buildBlock(state: NodeMaterialBuildState): this;
  66454. }
  66455. }
  66456. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66457. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66458. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66459. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66460. /**
  66461. * Block used to normalize a vector
  66462. */
  66463. export class NormalizeBlock extends NodeMaterialBlock {
  66464. /**
  66465. * Creates a new NormalizeBlock
  66466. * @param name defines the block name
  66467. */
  66468. constructor(name: string);
  66469. /**
  66470. * Gets the current class name
  66471. * @returns the class name
  66472. */
  66473. getClassName(): string;
  66474. /**
  66475. * Gets the input component
  66476. */
  66477. get input(): NodeMaterialConnectionPoint;
  66478. /**
  66479. * Gets the output component
  66480. */
  66481. get output(): NodeMaterialConnectionPoint;
  66482. protected _buildBlock(state: NodeMaterialBuildState): this;
  66483. }
  66484. }
  66485. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66486. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66487. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66488. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66489. /**
  66490. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66491. */
  66492. export class ColorMergerBlock extends NodeMaterialBlock {
  66493. /**
  66494. * Create a new ColorMergerBlock
  66495. * @param name defines the block name
  66496. */
  66497. constructor(name: string);
  66498. /**
  66499. * Gets the current class name
  66500. * @returns the class name
  66501. */
  66502. getClassName(): string;
  66503. /**
  66504. * Gets the rgb component (input)
  66505. */
  66506. get rgbIn(): NodeMaterialConnectionPoint;
  66507. /**
  66508. * Gets the r component (input)
  66509. */
  66510. get r(): NodeMaterialConnectionPoint;
  66511. /**
  66512. * Gets the g component (input)
  66513. */
  66514. get g(): NodeMaterialConnectionPoint;
  66515. /**
  66516. * Gets the b component (input)
  66517. */
  66518. get b(): NodeMaterialConnectionPoint;
  66519. /**
  66520. * Gets the a component (input)
  66521. */
  66522. get a(): NodeMaterialConnectionPoint;
  66523. /**
  66524. * Gets the rgba component (output)
  66525. */
  66526. get rgba(): NodeMaterialConnectionPoint;
  66527. /**
  66528. * Gets the rgb component (output)
  66529. */
  66530. get rgbOut(): NodeMaterialConnectionPoint;
  66531. /**
  66532. * Gets the rgb component (output)
  66533. * @deprecated Please use rgbOut instead.
  66534. */
  66535. get rgb(): NodeMaterialConnectionPoint;
  66536. protected _buildBlock(state: NodeMaterialBuildState): this;
  66537. }
  66538. }
  66539. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66540. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66541. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66542. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66543. /**
  66544. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66545. */
  66546. export class VectorSplitterBlock extends NodeMaterialBlock {
  66547. /**
  66548. * Create a new VectorSplitterBlock
  66549. * @param name defines the block name
  66550. */
  66551. constructor(name: string);
  66552. /**
  66553. * Gets the current class name
  66554. * @returns the class name
  66555. */
  66556. getClassName(): string;
  66557. /**
  66558. * Gets the xyzw component (input)
  66559. */
  66560. get xyzw(): NodeMaterialConnectionPoint;
  66561. /**
  66562. * Gets the xyz component (input)
  66563. */
  66564. get xyzIn(): NodeMaterialConnectionPoint;
  66565. /**
  66566. * Gets the xy component (input)
  66567. */
  66568. get xyIn(): NodeMaterialConnectionPoint;
  66569. /**
  66570. * Gets the xyz component (output)
  66571. */
  66572. get xyzOut(): NodeMaterialConnectionPoint;
  66573. /**
  66574. * Gets the xy component (output)
  66575. */
  66576. get xyOut(): NodeMaterialConnectionPoint;
  66577. /**
  66578. * Gets the x component (output)
  66579. */
  66580. get x(): NodeMaterialConnectionPoint;
  66581. /**
  66582. * Gets the y component (output)
  66583. */
  66584. get y(): NodeMaterialConnectionPoint;
  66585. /**
  66586. * Gets the z component (output)
  66587. */
  66588. get z(): NodeMaterialConnectionPoint;
  66589. /**
  66590. * Gets the w component (output)
  66591. */
  66592. get w(): NodeMaterialConnectionPoint;
  66593. protected _inputRename(name: string): string;
  66594. protected _outputRename(name: string): string;
  66595. protected _buildBlock(state: NodeMaterialBuildState): this;
  66596. }
  66597. }
  66598. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66599. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66600. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66601. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66602. /**
  66603. * Block used to lerp between 2 values
  66604. */
  66605. export class LerpBlock extends NodeMaterialBlock {
  66606. /**
  66607. * Creates a new LerpBlock
  66608. * @param name defines the block name
  66609. */
  66610. constructor(name: string);
  66611. /**
  66612. * Gets the current class name
  66613. * @returns the class name
  66614. */
  66615. getClassName(): string;
  66616. /**
  66617. * Gets the left operand input component
  66618. */
  66619. get left(): NodeMaterialConnectionPoint;
  66620. /**
  66621. * Gets the right operand input component
  66622. */
  66623. get right(): NodeMaterialConnectionPoint;
  66624. /**
  66625. * Gets the gradient operand input component
  66626. */
  66627. get gradient(): NodeMaterialConnectionPoint;
  66628. /**
  66629. * Gets the output component
  66630. */
  66631. get output(): NodeMaterialConnectionPoint;
  66632. protected _buildBlock(state: NodeMaterialBuildState): this;
  66633. }
  66634. }
  66635. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66636. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66637. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66638. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66639. /**
  66640. * Block used to divide 2 vectors
  66641. */
  66642. export class DivideBlock extends NodeMaterialBlock {
  66643. /**
  66644. * Creates a new DivideBlock
  66645. * @param name defines the block name
  66646. */
  66647. constructor(name: string);
  66648. /**
  66649. * Gets the current class name
  66650. * @returns the class name
  66651. */
  66652. getClassName(): string;
  66653. /**
  66654. * Gets the left operand input component
  66655. */
  66656. get left(): NodeMaterialConnectionPoint;
  66657. /**
  66658. * Gets the right operand input component
  66659. */
  66660. get right(): NodeMaterialConnectionPoint;
  66661. /**
  66662. * Gets the output component
  66663. */
  66664. get output(): NodeMaterialConnectionPoint;
  66665. protected _buildBlock(state: NodeMaterialBuildState): this;
  66666. }
  66667. }
  66668. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66669. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66670. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66671. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66672. /**
  66673. * Block used to subtract 2 vectors
  66674. */
  66675. export class SubtractBlock extends NodeMaterialBlock {
  66676. /**
  66677. * Creates a new SubtractBlock
  66678. * @param name defines the block name
  66679. */
  66680. constructor(name: string);
  66681. /**
  66682. * Gets the current class name
  66683. * @returns the class name
  66684. */
  66685. getClassName(): string;
  66686. /**
  66687. * Gets the left operand input component
  66688. */
  66689. get left(): NodeMaterialConnectionPoint;
  66690. /**
  66691. * Gets the right operand input component
  66692. */
  66693. get right(): NodeMaterialConnectionPoint;
  66694. /**
  66695. * Gets the output component
  66696. */
  66697. get output(): NodeMaterialConnectionPoint;
  66698. protected _buildBlock(state: NodeMaterialBuildState): this;
  66699. }
  66700. }
  66701. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66702. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66703. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66704. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66705. /**
  66706. * Block used to step a value
  66707. */
  66708. export class StepBlock extends NodeMaterialBlock {
  66709. /**
  66710. * Creates a new StepBlock
  66711. * @param name defines the block name
  66712. */
  66713. constructor(name: string);
  66714. /**
  66715. * Gets the current class name
  66716. * @returns the class name
  66717. */
  66718. getClassName(): string;
  66719. /**
  66720. * Gets the value operand input component
  66721. */
  66722. get value(): NodeMaterialConnectionPoint;
  66723. /**
  66724. * Gets the edge operand input component
  66725. */
  66726. get edge(): NodeMaterialConnectionPoint;
  66727. /**
  66728. * Gets the output component
  66729. */
  66730. get output(): NodeMaterialConnectionPoint;
  66731. protected _buildBlock(state: NodeMaterialBuildState): this;
  66732. }
  66733. }
  66734. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66735. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66736. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66737. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66738. /**
  66739. * Block used to get the opposite (1 - x) of a value
  66740. */
  66741. export class OneMinusBlock extends NodeMaterialBlock {
  66742. /**
  66743. * Creates a new OneMinusBlock
  66744. * @param name defines the block name
  66745. */
  66746. constructor(name: string);
  66747. /**
  66748. * Gets the current class name
  66749. * @returns the class name
  66750. */
  66751. getClassName(): string;
  66752. /**
  66753. * Gets the input component
  66754. */
  66755. get input(): NodeMaterialConnectionPoint;
  66756. /**
  66757. * Gets the output component
  66758. */
  66759. get output(): NodeMaterialConnectionPoint;
  66760. protected _buildBlock(state: NodeMaterialBuildState): this;
  66761. }
  66762. }
  66763. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66764. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66765. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66766. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66767. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66768. /**
  66769. * Block used to get the view direction
  66770. */
  66771. export class ViewDirectionBlock extends NodeMaterialBlock {
  66772. /**
  66773. * Creates a new ViewDirectionBlock
  66774. * @param name defines the block name
  66775. */
  66776. constructor(name: string);
  66777. /**
  66778. * Gets the current class name
  66779. * @returns the class name
  66780. */
  66781. getClassName(): string;
  66782. /**
  66783. * Gets the world position component
  66784. */
  66785. get worldPosition(): NodeMaterialConnectionPoint;
  66786. /**
  66787. * Gets the camera position component
  66788. */
  66789. get cameraPosition(): NodeMaterialConnectionPoint;
  66790. /**
  66791. * Gets the output component
  66792. */
  66793. get output(): NodeMaterialConnectionPoint;
  66794. autoConfigure(material: NodeMaterial): void;
  66795. protected _buildBlock(state: NodeMaterialBuildState): this;
  66796. }
  66797. }
  66798. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66799. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66800. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66801. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66802. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66803. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66804. /**
  66805. * Block used to compute fresnel value
  66806. */
  66807. export class FresnelBlock extends NodeMaterialBlock {
  66808. /**
  66809. * Create a new FresnelBlock
  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 world normal input component
  66820. */
  66821. get worldNormal(): NodeMaterialConnectionPoint;
  66822. /**
  66823. * Gets the view direction input component
  66824. */
  66825. get viewDirection(): NodeMaterialConnectionPoint;
  66826. /**
  66827. * Gets the bias input component
  66828. */
  66829. get bias(): NodeMaterialConnectionPoint;
  66830. /**
  66831. * Gets the camera (or eye) position component
  66832. */
  66833. get power(): NodeMaterialConnectionPoint;
  66834. /**
  66835. * Gets the fresnel output component
  66836. */
  66837. get fresnel(): NodeMaterialConnectionPoint;
  66838. autoConfigure(material: NodeMaterial): void;
  66839. protected _buildBlock(state: NodeMaterialBuildState): this;
  66840. }
  66841. }
  66842. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66843. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66844. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66845. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66846. /**
  66847. * Block used to get the max of 2 values
  66848. */
  66849. export class MaxBlock extends NodeMaterialBlock {
  66850. /**
  66851. * Creates a new MaxBlock
  66852. * @param name defines the block name
  66853. */
  66854. constructor(name: string);
  66855. /**
  66856. * Gets the current class name
  66857. * @returns the class name
  66858. */
  66859. getClassName(): string;
  66860. /**
  66861. * Gets the left operand input component
  66862. */
  66863. get left(): NodeMaterialConnectionPoint;
  66864. /**
  66865. * Gets the right operand input component
  66866. */
  66867. get right(): NodeMaterialConnectionPoint;
  66868. /**
  66869. * Gets the output component
  66870. */
  66871. get output(): NodeMaterialConnectionPoint;
  66872. protected _buildBlock(state: NodeMaterialBuildState): this;
  66873. }
  66874. }
  66875. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66876. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66877. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66878. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66879. /**
  66880. * Block used to get the min of 2 values
  66881. */
  66882. export class MinBlock extends NodeMaterialBlock {
  66883. /**
  66884. * Creates a new MinBlock
  66885. * @param name defines the block name
  66886. */
  66887. constructor(name: string);
  66888. /**
  66889. * Gets the current class name
  66890. * @returns the class name
  66891. */
  66892. getClassName(): string;
  66893. /**
  66894. * Gets the left operand input component
  66895. */
  66896. get left(): NodeMaterialConnectionPoint;
  66897. /**
  66898. * Gets the right operand input component
  66899. */
  66900. get right(): NodeMaterialConnectionPoint;
  66901. /**
  66902. * Gets the output component
  66903. */
  66904. get output(): NodeMaterialConnectionPoint;
  66905. protected _buildBlock(state: NodeMaterialBuildState): this;
  66906. }
  66907. }
  66908. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66909. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66910. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66911. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66912. /**
  66913. * Block used to get the distance between 2 values
  66914. */
  66915. export class DistanceBlock extends NodeMaterialBlock {
  66916. /**
  66917. * Creates a new DistanceBlock
  66918. * @param name defines the block name
  66919. */
  66920. constructor(name: string);
  66921. /**
  66922. * Gets the current class name
  66923. * @returns the class name
  66924. */
  66925. getClassName(): string;
  66926. /**
  66927. * Gets the left operand input component
  66928. */
  66929. get left(): NodeMaterialConnectionPoint;
  66930. /**
  66931. * Gets the right operand input component
  66932. */
  66933. get right(): NodeMaterialConnectionPoint;
  66934. /**
  66935. * Gets the output component
  66936. */
  66937. get output(): NodeMaterialConnectionPoint;
  66938. protected _buildBlock(state: NodeMaterialBuildState): this;
  66939. }
  66940. }
  66941. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66942. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66943. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66944. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66945. /**
  66946. * Block used to get the length of a vector
  66947. */
  66948. export class LengthBlock extends NodeMaterialBlock {
  66949. /**
  66950. * Creates a new LengthBlock
  66951. * @param name defines the block name
  66952. */
  66953. constructor(name: string);
  66954. /**
  66955. * Gets the current class name
  66956. * @returns the class name
  66957. */
  66958. getClassName(): string;
  66959. /**
  66960. * Gets the value input component
  66961. */
  66962. get value(): NodeMaterialConnectionPoint;
  66963. /**
  66964. * Gets the output component
  66965. */
  66966. get output(): NodeMaterialConnectionPoint;
  66967. protected _buildBlock(state: NodeMaterialBuildState): this;
  66968. }
  66969. }
  66970. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66971. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66972. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66973. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66974. /**
  66975. * Block used to get negative version of a value (i.e. x * -1)
  66976. */
  66977. export class NegateBlock extends NodeMaterialBlock {
  66978. /**
  66979. * Creates a new NegateBlock
  66980. * @param name defines the block name
  66981. */
  66982. constructor(name: string);
  66983. /**
  66984. * Gets the current class name
  66985. * @returns the class name
  66986. */
  66987. getClassName(): string;
  66988. /**
  66989. * Gets the value input component
  66990. */
  66991. get value(): NodeMaterialConnectionPoint;
  66992. /**
  66993. * Gets the output component
  66994. */
  66995. get output(): NodeMaterialConnectionPoint;
  66996. protected _buildBlock(state: NodeMaterialBuildState): this;
  66997. }
  66998. }
  66999. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  67000. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67001. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67002. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67003. /**
  67004. * Block used to get the value of the first parameter raised to the power of the second
  67005. */
  67006. export class PowBlock extends NodeMaterialBlock {
  67007. /**
  67008. * Creates a new PowBlock
  67009. * @param name defines the block name
  67010. */
  67011. constructor(name: string);
  67012. /**
  67013. * Gets the current class name
  67014. * @returns the class name
  67015. */
  67016. getClassName(): string;
  67017. /**
  67018. * Gets the value operand input component
  67019. */
  67020. get value(): NodeMaterialConnectionPoint;
  67021. /**
  67022. * Gets the power operand input component
  67023. */
  67024. get power(): NodeMaterialConnectionPoint;
  67025. /**
  67026. * Gets the output component
  67027. */
  67028. get output(): NodeMaterialConnectionPoint;
  67029. protected _buildBlock(state: NodeMaterialBuildState): this;
  67030. }
  67031. }
  67032. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  67033. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67034. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67035. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67036. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67037. /**
  67038. * Block used to get a random number
  67039. */
  67040. export class RandomNumberBlock extends NodeMaterialBlock {
  67041. /**
  67042. * Creates a new RandomNumberBlock
  67043. * @param name defines the block name
  67044. */
  67045. constructor(name: string);
  67046. /**
  67047. * Gets the current class name
  67048. * @returns the class name
  67049. */
  67050. getClassName(): string;
  67051. /**
  67052. * Gets the seed input component
  67053. */
  67054. get seed(): NodeMaterialConnectionPoint;
  67055. /**
  67056. * Gets the output component
  67057. */
  67058. get output(): NodeMaterialConnectionPoint;
  67059. protected _buildBlock(state: NodeMaterialBuildState): this;
  67060. }
  67061. }
  67062. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  67063. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67064. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67065. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67066. /**
  67067. * Block used to compute arc tangent of 2 values
  67068. */
  67069. export class ArcTan2Block extends NodeMaterialBlock {
  67070. /**
  67071. * Creates a new ArcTan2Block
  67072. * @param name defines the block name
  67073. */
  67074. constructor(name: string);
  67075. /**
  67076. * Gets the current class name
  67077. * @returns the class name
  67078. */
  67079. getClassName(): string;
  67080. /**
  67081. * Gets the x operand input component
  67082. */
  67083. get x(): NodeMaterialConnectionPoint;
  67084. /**
  67085. * Gets the y operand input component
  67086. */
  67087. get y(): NodeMaterialConnectionPoint;
  67088. /**
  67089. * Gets the output component
  67090. */
  67091. get output(): NodeMaterialConnectionPoint;
  67092. protected _buildBlock(state: NodeMaterialBuildState): this;
  67093. }
  67094. }
  67095. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67096. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67097. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67098. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67099. /**
  67100. * Block used to smooth step a value
  67101. */
  67102. export class SmoothStepBlock extends NodeMaterialBlock {
  67103. /**
  67104. * Creates a new SmoothStepBlock
  67105. * @param name defines the block name
  67106. */
  67107. constructor(name: string);
  67108. /**
  67109. * Gets the current class name
  67110. * @returns the class name
  67111. */
  67112. getClassName(): string;
  67113. /**
  67114. * Gets the value operand input component
  67115. */
  67116. get value(): NodeMaterialConnectionPoint;
  67117. /**
  67118. * Gets the first edge operand input component
  67119. */
  67120. get edge0(): NodeMaterialConnectionPoint;
  67121. /**
  67122. * Gets the second edge operand input component
  67123. */
  67124. get edge1(): NodeMaterialConnectionPoint;
  67125. /**
  67126. * Gets the output component
  67127. */
  67128. get output(): NodeMaterialConnectionPoint;
  67129. protected _buildBlock(state: NodeMaterialBuildState): this;
  67130. }
  67131. }
  67132. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67133. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67134. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67135. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67136. /**
  67137. * Block used to get the reciprocal (1 / x) of a value
  67138. */
  67139. export class ReciprocalBlock extends NodeMaterialBlock {
  67140. /**
  67141. * Creates a new ReciprocalBlock
  67142. * @param name defines the block name
  67143. */
  67144. constructor(name: string);
  67145. /**
  67146. * Gets the current class name
  67147. * @returns the class name
  67148. */
  67149. getClassName(): string;
  67150. /**
  67151. * Gets the input component
  67152. */
  67153. get input(): NodeMaterialConnectionPoint;
  67154. /**
  67155. * Gets the output component
  67156. */
  67157. get output(): NodeMaterialConnectionPoint;
  67158. protected _buildBlock(state: NodeMaterialBuildState): this;
  67159. }
  67160. }
  67161. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67162. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67163. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67164. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67165. /**
  67166. * Block used to replace a color by another one
  67167. */
  67168. export class ReplaceColorBlock extends NodeMaterialBlock {
  67169. /**
  67170. * Creates a new ReplaceColorBlock
  67171. * @param name defines the block name
  67172. */
  67173. constructor(name: string);
  67174. /**
  67175. * Gets the current class name
  67176. * @returns the class name
  67177. */
  67178. getClassName(): string;
  67179. /**
  67180. * Gets the value input component
  67181. */
  67182. get value(): NodeMaterialConnectionPoint;
  67183. /**
  67184. * Gets the reference input component
  67185. */
  67186. get reference(): NodeMaterialConnectionPoint;
  67187. /**
  67188. * Gets the distance input component
  67189. */
  67190. get distance(): NodeMaterialConnectionPoint;
  67191. /**
  67192. * Gets the replacement input component
  67193. */
  67194. get replacement(): NodeMaterialConnectionPoint;
  67195. /**
  67196. * Gets the output component
  67197. */
  67198. get output(): NodeMaterialConnectionPoint;
  67199. protected _buildBlock(state: NodeMaterialBuildState): this;
  67200. }
  67201. }
  67202. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67203. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67204. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67205. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67206. /**
  67207. * Block used to posterize a value
  67208. * @see https://en.wikipedia.org/wiki/Posterization
  67209. */
  67210. export class PosterizeBlock extends NodeMaterialBlock {
  67211. /**
  67212. * Creates a new PosterizeBlock
  67213. * @param name defines the block name
  67214. */
  67215. constructor(name: string);
  67216. /**
  67217. * Gets the current class name
  67218. * @returns the class name
  67219. */
  67220. getClassName(): string;
  67221. /**
  67222. * Gets the value input component
  67223. */
  67224. get value(): NodeMaterialConnectionPoint;
  67225. /**
  67226. * Gets the steps input component
  67227. */
  67228. get steps(): NodeMaterialConnectionPoint;
  67229. /**
  67230. * Gets the output component
  67231. */
  67232. get output(): NodeMaterialConnectionPoint;
  67233. protected _buildBlock(state: NodeMaterialBuildState): this;
  67234. }
  67235. }
  67236. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67237. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67238. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67239. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67240. import { Scene } from "babylonjs/scene";
  67241. /**
  67242. * Operations supported by the Wave block
  67243. */
  67244. export enum WaveBlockKind {
  67245. /** SawTooth */
  67246. SawTooth = 0,
  67247. /** Square */
  67248. Square = 1,
  67249. /** Triangle */
  67250. Triangle = 2
  67251. }
  67252. /**
  67253. * Block used to apply wave operation to floats
  67254. */
  67255. export class WaveBlock extends NodeMaterialBlock {
  67256. /**
  67257. * Gets or sets the kibnd of wave to be applied by the block
  67258. */
  67259. kind: WaveBlockKind;
  67260. /**
  67261. * Creates a new WaveBlock
  67262. * @param name defines the block name
  67263. */
  67264. constructor(name: string);
  67265. /**
  67266. * Gets the current class name
  67267. * @returns the class name
  67268. */
  67269. getClassName(): string;
  67270. /**
  67271. * Gets the input component
  67272. */
  67273. get input(): NodeMaterialConnectionPoint;
  67274. /**
  67275. * Gets the output component
  67276. */
  67277. get output(): NodeMaterialConnectionPoint;
  67278. protected _buildBlock(state: NodeMaterialBuildState): this;
  67279. serialize(): any;
  67280. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67281. }
  67282. }
  67283. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67284. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67285. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67286. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67287. import { Color3 } from "babylonjs/Maths/math.color";
  67288. import { Scene } from "babylonjs/scene";
  67289. import { Observable } from "babylonjs/Misc/observable";
  67290. /**
  67291. * Class used to store a color step for the GradientBlock
  67292. */
  67293. export class GradientBlockColorStep {
  67294. private _step;
  67295. /**
  67296. * Gets value indicating which step this color is associated with (between 0 and 1)
  67297. */
  67298. get step(): number;
  67299. /**
  67300. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67301. */
  67302. set step(val: number);
  67303. private _color;
  67304. /**
  67305. * Gets the color associated with this step
  67306. */
  67307. get color(): Color3;
  67308. /**
  67309. * Sets the color associated with this step
  67310. */
  67311. set color(val: Color3);
  67312. /**
  67313. * Creates a new GradientBlockColorStep
  67314. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67315. * @param color defines the color associated with this step
  67316. */
  67317. constructor(step: number, color: Color3);
  67318. }
  67319. /**
  67320. * Block used to return a color from a gradient based on an input value between 0 and 1
  67321. */
  67322. export class GradientBlock extends NodeMaterialBlock {
  67323. /**
  67324. * Gets or sets the list of color steps
  67325. */
  67326. colorSteps: GradientBlockColorStep[];
  67327. /** Gets an observable raised when the value is changed */
  67328. onValueChangedObservable: Observable<GradientBlock>;
  67329. /** calls observable when the value is changed*/
  67330. colorStepsUpdated(): void;
  67331. /**
  67332. * Creates a new GradientBlock
  67333. * @param name defines the block name
  67334. */
  67335. constructor(name: string);
  67336. /**
  67337. * Gets the current class name
  67338. * @returns the class name
  67339. */
  67340. getClassName(): string;
  67341. /**
  67342. * Gets the gradient input component
  67343. */
  67344. get gradient(): NodeMaterialConnectionPoint;
  67345. /**
  67346. * Gets the output component
  67347. */
  67348. get output(): NodeMaterialConnectionPoint;
  67349. private _writeColorConstant;
  67350. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67351. serialize(): any;
  67352. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67353. protected _dumpPropertiesCode(): string;
  67354. }
  67355. }
  67356. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67357. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67358. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67359. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67360. /**
  67361. * Block used to normalize lerp between 2 values
  67362. */
  67363. export class NLerpBlock extends NodeMaterialBlock {
  67364. /**
  67365. * Creates a new NLerpBlock
  67366. * @param name defines the block name
  67367. */
  67368. constructor(name: string);
  67369. /**
  67370. * Gets the current class name
  67371. * @returns the class name
  67372. */
  67373. getClassName(): string;
  67374. /**
  67375. * Gets the left operand input component
  67376. */
  67377. get left(): NodeMaterialConnectionPoint;
  67378. /**
  67379. * Gets the right operand input component
  67380. */
  67381. get right(): NodeMaterialConnectionPoint;
  67382. /**
  67383. * Gets the gradient operand input component
  67384. */
  67385. get gradient(): NodeMaterialConnectionPoint;
  67386. /**
  67387. * Gets the output component
  67388. */
  67389. get output(): NodeMaterialConnectionPoint;
  67390. protected _buildBlock(state: NodeMaterialBuildState): this;
  67391. }
  67392. }
  67393. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67394. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67395. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67396. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67397. import { Scene } from "babylonjs/scene";
  67398. /**
  67399. * block used to Generate a Worley Noise 3D Noise Pattern
  67400. */
  67401. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67402. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67403. manhattanDistance: boolean;
  67404. /**
  67405. * Creates a new WorleyNoise3DBlock
  67406. * @param name defines the block name
  67407. */
  67408. constructor(name: string);
  67409. /**
  67410. * Gets the current class name
  67411. * @returns the class name
  67412. */
  67413. getClassName(): string;
  67414. /**
  67415. * Gets the seed input component
  67416. */
  67417. get seed(): NodeMaterialConnectionPoint;
  67418. /**
  67419. * Gets the jitter input component
  67420. */
  67421. get jitter(): NodeMaterialConnectionPoint;
  67422. /**
  67423. * Gets the output component
  67424. */
  67425. get output(): NodeMaterialConnectionPoint;
  67426. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67427. /**
  67428. * Exposes the properties to the UI?
  67429. */
  67430. protected _dumpPropertiesCode(): string;
  67431. /**
  67432. * Exposes the properties to the Seralize?
  67433. */
  67434. serialize(): any;
  67435. /**
  67436. * Exposes the properties to the deseralize?
  67437. */
  67438. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67439. }
  67440. }
  67441. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67442. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67443. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67444. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67445. /**
  67446. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67447. */
  67448. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67449. /**
  67450. * Creates a new SimplexPerlin3DBlock
  67451. * @param name defines the block name
  67452. */
  67453. constructor(name: string);
  67454. /**
  67455. * Gets the current class name
  67456. * @returns the class name
  67457. */
  67458. getClassName(): string;
  67459. /**
  67460. * Gets the seed operand input component
  67461. */
  67462. get seed(): NodeMaterialConnectionPoint;
  67463. /**
  67464. * Gets the output component
  67465. */
  67466. get output(): NodeMaterialConnectionPoint;
  67467. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67468. }
  67469. }
  67470. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67471. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67472. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67473. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67474. /**
  67475. * Block used to blend normals
  67476. */
  67477. export class NormalBlendBlock extends NodeMaterialBlock {
  67478. /**
  67479. * Creates a new NormalBlendBlock
  67480. * @param name defines the block name
  67481. */
  67482. constructor(name: string);
  67483. /**
  67484. * Gets the current class name
  67485. * @returns the class name
  67486. */
  67487. getClassName(): string;
  67488. /**
  67489. * Gets the first input component
  67490. */
  67491. get normalMap0(): NodeMaterialConnectionPoint;
  67492. /**
  67493. * Gets the second input component
  67494. */
  67495. get normalMap1(): NodeMaterialConnectionPoint;
  67496. /**
  67497. * Gets the output component
  67498. */
  67499. get output(): NodeMaterialConnectionPoint;
  67500. protected _buildBlock(state: NodeMaterialBuildState): this;
  67501. }
  67502. }
  67503. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67506. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67507. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67508. /**
  67509. * Block used to rotate a 2d vector by a given angle
  67510. */
  67511. export class Rotate2dBlock extends NodeMaterialBlock {
  67512. /**
  67513. * Creates a new Rotate2dBlock
  67514. * @param name defines the block name
  67515. */
  67516. constructor(name: string);
  67517. /**
  67518. * Gets the current class name
  67519. * @returns the class name
  67520. */
  67521. getClassName(): string;
  67522. /**
  67523. * Gets the input vector
  67524. */
  67525. get input(): NodeMaterialConnectionPoint;
  67526. /**
  67527. * Gets the input angle
  67528. */
  67529. get angle(): NodeMaterialConnectionPoint;
  67530. /**
  67531. * Gets the output component
  67532. */
  67533. get output(): NodeMaterialConnectionPoint;
  67534. autoConfigure(material: NodeMaterial): void;
  67535. protected _buildBlock(state: NodeMaterialBuildState): this;
  67536. }
  67537. }
  67538. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67539. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67540. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67541. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67542. /**
  67543. * Block used to get the reflected vector from a direction and a normal
  67544. */
  67545. export class ReflectBlock extends NodeMaterialBlock {
  67546. /**
  67547. * Creates a new ReflectBlock
  67548. * @param name defines the block name
  67549. */
  67550. constructor(name: string);
  67551. /**
  67552. * Gets the current class name
  67553. * @returns the class name
  67554. */
  67555. getClassName(): string;
  67556. /**
  67557. * Gets the incident component
  67558. */
  67559. get incident(): NodeMaterialConnectionPoint;
  67560. /**
  67561. * Gets the normal component
  67562. */
  67563. get normal(): NodeMaterialConnectionPoint;
  67564. /**
  67565. * Gets the output component
  67566. */
  67567. get output(): NodeMaterialConnectionPoint;
  67568. protected _buildBlock(state: NodeMaterialBuildState): this;
  67569. }
  67570. }
  67571. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67572. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67573. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67574. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67575. /**
  67576. * Block used to get the refracted vector from a direction and a normal
  67577. */
  67578. export class RefractBlock extends NodeMaterialBlock {
  67579. /**
  67580. * Creates a new RefractBlock
  67581. * @param name defines the block name
  67582. */
  67583. constructor(name: string);
  67584. /**
  67585. * Gets the current class name
  67586. * @returns the class name
  67587. */
  67588. getClassName(): string;
  67589. /**
  67590. * Gets the incident component
  67591. */
  67592. get incident(): NodeMaterialConnectionPoint;
  67593. /**
  67594. * Gets the normal component
  67595. */
  67596. get normal(): NodeMaterialConnectionPoint;
  67597. /**
  67598. * Gets the index of refraction component
  67599. */
  67600. get ior(): NodeMaterialConnectionPoint;
  67601. /**
  67602. * Gets the output component
  67603. */
  67604. get output(): NodeMaterialConnectionPoint;
  67605. protected _buildBlock(state: NodeMaterialBuildState): this;
  67606. }
  67607. }
  67608. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67609. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67610. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67611. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67612. /**
  67613. * Block used to desaturate a color
  67614. */
  67615. export class DesaturateBlock extends NodeMaterialBlock {
  67616. /**
  67617. * Creates a new DesaturateBlock
  67618. * @param name defines the block name
  67619. */
  67620. constructor(name: string);
  67621. /**
  67622. * Gets the current class name
  67623. * @returns the class name
  67624. */
  67625. getClassName(): string;
  67626. /**
  67627. * Gets the color operand input component
  67628. */
  67629. get color(): NodeMaterialConnectionPoint;
  67630. /**
  67631. * Gets the level operand input component
  67632. */
  67633. get level(): NodeMaterialConnectionPoint;
  67634. /**
  67635. * Gets the output component
  67636. */
  67637. get output(): NodeMaterialConnectionPoint;
  67638. protected _buildBlock(state: NodeMaterialBuildState): this;
  67639. }
  67640. }
  67641. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67642. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67643. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67644. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67645. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67646. import { Nullable } from "babylonjs/types";
  67647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67648. import { Scene } from "babylonjs/scene";
  67649. /**
  67650. * Block used to implement the ambient occlusion module of the PBR material
  67651. */
  67652. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67653. /**
  67654. * Create a new AmbientOcclusionBlock
  67655. * @param name defines the block name
  67656. */
  67657. constructor(name: string);
  67658. /**
  67659. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67660. */
  67661. useAmbientInGrayScale: boolean;
  67662. /**
  67663. * Initialize the block and prepare the context for build
  67664. * @param state defines the state that will be used for the build
  67665. */
  67666. initialize(state: NodeMaterialBuildState): void;
  67667. /**
  67668. * Gets the current class name
  67669. * @returns the class name
  67670. */
  67671. getClassName(): string;
  67672. /**
  67673. * Gets the texture input component
  67674. */
  67675. get texture(): NodeMaterialConnectionPoint;
  67676. /**
  67677. * Gets the texture intensity component
  67678. */
  67679. get intensity(): NodeMaterialConnectionPoint;
  67680. /**
  67681. * Gets the direct light intensity input component
  67682. */
  67683. get directLightIntensity(): NodeMaterialConnectionPoint;
  67684. /**
  67685. * Gets the ambient occlusion object output component
  67686. */
  67687. get ambientOcc(): NodeMaterialConnectionPoint;
  67688. /**
  67689. * Gets the main code of the block (fragment side)
  67690. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67691. * @returns the shader code
  67692. */
  67693. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67694. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67695. protected _buildBlock(state: NodeMaterialBuildState): this;
  67696. protected _dumpPropertiesCode(): string;
  67697. serialize(): any;
  67698. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67699. }
  67700. }
  67701. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67702. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67703. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67704. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67705. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67707. import { Nullable } from "babylonjs/types";
  67708. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67709. import { Mesh } from "babylonjs/Meshes/mesh";
  67710. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67711. import { Effect } from "babylonjs/Materials/effect";
  67712. import { Scene } from "babylonjs/scene";
  67713. /**
  67714. * Block used to implement the reflection module of the PBR material
  67715. */
  67716. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67717. /** @hidden */
  67718. _defineLODReflectionAlpha: string;
  67719. /** @hidden */
  67720. _defineLinearSpecularReflection: string;
  67721. private _vEnvironmentIrradianceName;
  67722. /** @hidden */
  67723. _vReflectionMicrosurfaceInfosName: string;
  67724. /** @hidden */
  67725. _vReflectionInfosName: string;
  67726. /** @hidden */
  67727. _vReflectionFilteringInfoName: string;
  67728. private _scene;
  67729. /**
  67730. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67731. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67732. * It's less burden on the user side in the editor part.
  67733. */
  67734. /** @hidden */
  67735. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67736. /** @hidden */
  67737. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67738. /** @hidden */
  67739. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67740. /**
  67741. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67742. * diffuse part of the IBL.
  67743. */
  67744. useSphericalHarmonics: boolean;
  67745. /**
  67746. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67747. */
  67748. forceIrradianceInFragment: boolean;
  67749. /**
  67750. * Create a new ReflectionBlock
  67751. * @param name defines the block name
  67752. */
  67753. constructor(name: string);
  67754. /**
  67755. * Gets the current class name
  67756. * @returns the class name
  67757. */
  67758. getClassName(): string;
  67759. /**
  67760. * Gets the position input component
  67761. */
  67762. get position(): NodeMaterialConnectionPoint;
  67763. /**
  67764. * Gets the world position input component
  67765. */
  67766. get worldPosition(): NodeMaterialConnectionPoint;
  67767. /**
  67768. * Gets the world normal input component
  67769. */
  67770. get worldNormal(): NodeMaterialConnectionPoint;
  67771. /**
  67772. * Gets the world input component
  67773. */
  67774. get world(): NodeMaterialConnectionPoint;
  67775. /**
  67776. * Gets the camera (or eye) position component
  67777. */
  67778. get cameraPosition(): NodeMaterialConnectionPoint;
  67779. /**
  67780. * Gets the view input component
  67781. */
  67782. get view(): NodeMaterialConnectionPoint;
  67783. /**
  67784. * Gets the color input component
  67785. */
  67786. get color(): NodeMaterialConnectionPoint;
  67787. /**
  67788. * Gets the reflection object output component
  67789. */
  67790. get reflection(): NodeMaterialConnectionPoint;
  67791. /**
  67792. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67793. */
  67794. get hasTexture(): boolean;
  67795. /**
  67796. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67797. */
  67798. get reflectionColor(): string;
  67799. protected _getTexture(): Nullable<BaseTexture>;
  67800. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67801. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67802. /**
  67803. * Gets the code to inject in the vertex shader
  67804. * @param state current state of the node material building
  67805. * @returns the shader code
  67806. */
  67807. handleVertexSide(state: NodeMaterialBuildState): string;
  67808. /**
  67809. * Gets the main code of the block (fragment side)
  67810. * @param state current state of the node material building
  67811. * @param normalVarName name of the existing variable corresponding to the normal
  67812. * @returns the shader code
  67813. */
  67814. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67815. protected _buildBlock(state: NodeMaterialBuildState): this;
  67816. protected _dumpPropertiesCode(): string;
  67817. serialize(): any;
  67818. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67819. }
  67820. }
  67821. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67822. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67823. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67824. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67825. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67827. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67828. import { Scene } from "babylonjs/scene";
  67829. import { Nullable } from "babylonjs/types";
  67830. /**
  67831. * Block used to implement the sheen module of the PBR material
  67832. */
  67833. export class SheenBlock extends NodeMaterialBlock {
  67834. /**
  67835. * Create a new SheenBlock
  67836. * @param name defines the block name
  67837. */
  67838. constructor(name: string);
  67839. /**
  67840. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67841. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67842. * making it easier to setup and tweak the effect
  67843. */
  67844. albedoScaling: boolean;
  67845. /**
  67846. * Defines if the sheen is linked to the sheen color.
  67847. */
  67848. linkSheenWithAlbedo: boolean;
  67849. /**
  67850. * Initialize the block and prepare the context for build
  67851. * @param state defines the state that will be used for the build
  67852. */
  67853. initialize(state: NodeMaterialBuildState): void;
  67854. /**
  67855. * Gets the current class name
  67856. * @returns the class name
  67857. */
  67858. getClassName(): string;
  67859. /**
  67860. * Gets the intensity input component
  67861. */
  67862. get intensity(): NodeMaterialConnectionPoint;
  67863. /**
  67864. * Gets the color input component
  67865. */
  67866. get color(): NodeMaterialConnectionPoint;
  67867. /**
  67868. * Gets the roughness input component
  67869. */
  67870. get roughness(): NodeMaterialConnectionPoint;
  67871. /**
  67872. * Gets the sheen object output component
  67873. */
  67874. get sheen(): NodeMaterialConnectionPoint;
  67875. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67876. /**
  67877. * Gets the main code of the block (fragment side)
  67878. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67879. * @returns the shader code
  67880. */
  67881. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67882. protected _buildBlock(state: NodeMaterialBuildState): this;
  67883. protected _dumpPropertiesCode(): string;
  67884. serialize(): any;
  67885. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67886. }
  67887. }
  67888. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67889. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67890. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67891. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67893. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67894. import { Scene } from "babylonjs/scene";
  67895. import { Nullable } from "babylonjs/types";
  67896. import { Mesh } from "babylonjs/Meshes/mesh";
  67897. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67898. import { Effect } from "babylonjs/Materials/effect";
  67899. /**
  67900. * Block used to implement the reflectivity module of the PBR material
  67901. */
  67902. export class ReflectivityBlock extends NodeMaterialBlock {
  67903. private _metallicReflectanceColor;
  67904. private _metallicF0Factor;
  67905. /** @hidden */
  67906. _vMetallicReflectanceFactorsName: string;
  67907. /**
  67908. * The property below is set by the main PBR block prior to calling methods of this class.
  67909. */
  67910. /** @hidden */
  67911. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67912. /**
  67913. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67914. */
  67915. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67916. /**
  67917. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67918. */
  67919. useMetallnessFromMetallicTextureBlue: boolean;
  67920. /**
  67921. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67922. */
  67923. useRoughnessFromMetallicTextureAlpha: boolean;
  67924. /**
  67925. * Specifies if the metallic texture contains the roughness information in its green channel.
  67926. */
  67927. useRoughnessFromMetallicTextureGreen: boolean;
  67928. /**
  67929. * Create a new ReflectivityBlock
  67930. * @param name defines the block name
  67931. */
  67932. constructor(name: string);
  67933. /**
  67934. * Initialize the block and prepare the context for build
  67935. * @param state defines the state that will be used for the build
  67936. */
  67937. initialize(state: NodeMaterialBuildState): void;
  67938. /**
  67939. * Gets the current class name
  67940. * @returns the class name
  67941. */
  67942. getClassName(): string;
  67943. /**
  67944. * Gets the metallic input component
  67945. */
  67946. get metallic(): NodeMaterialConnectionPoint;
  67947. /**
  67948. * Gets the roughness input component
  67949. */
  67950. get roughness(): NodeMaterialConnectionPoint;
  67951. /**
  67952. * Gets the texture input component
  67953. */
  67954. get texture(): NodeMaterialConnectionPoint;
  67955. /**
  67956. * Gets the reflectivity object output component
  67957. */
  67958. get reflectivity(): NodeMaterialConnectionPoint;
  67959. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67960. /**
  67961. * Gets the main code of the block (fragment side)
  67962. * @param state current state of the node material building
  67963. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67964. * @returns the shader code
  67965. */
  67966. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67967. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67968. protected _buildBlock(state: NodeMaterialBuildState): this;
  67969. protected _dumpPropertiesCode(): string;
  67970. serialize(): any;
  67971. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67972. }
  67973. }
  67974. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67975. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67977. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67980. /**
  67981. * Block used to implement the anisotropy module of the PBR material
  67982. */
  67983. export class AnisotropyBlock extends NodeMaterialBlock {
  67984. /**
  67985. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67986. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67987. * It's less burden on the user side in the editor part.
  67988. */
  67989. /** @hidden */
  67990. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67991. /** @hidden */
  67992. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67993. /**
  67994. * Create a new AnisotropyBlock
  67995. * @param name defines the block name
  67996. */
  67997. constructor(name: string);
  67998. /**
  67999. * Initialize the block and prepare the context for build
  68000. * @param state defines the state that will be used for the build
  68001. */
  68002. initialize(state: NodeMaterialBuildState): void;
  68003. /**
  68004. * Gets the current class name
  68005. * @returns the class name
  68006. */
  68007. getClassName(): string;
  68008. /**
  68009. * Gets the intensity input component
  68010. */
  68011. get intensity(): NodeMaterialConnectionPoint;
  68012. /**
  68013. * Gets the direction input component
  68014. */
  68015. get direction(): NodeMaterialConnectionPoint;
  68016. /**
  68017. * Gets the texture input component
  68018. */
  68019. get texture(): NodeMaterialConnectionPoint;
  68020. /**
  68021. * Gets the uv input component
  68022. */
  68023. get uv(): NodeMaterialConnectionPoint;
  68024. /**
  68025. * Gets the worldTangent input component
  68026. */
  68027. get worldTangent(): NodeMaterialConnectionPoint;
  68028. /**
  68029. * Gets the anisotropy object output component
  68030. */
  68031. get anisotropy(): NodeMaterialConnectionPoint;
  68032. private _generateTBNSpace;
  68033. /**
  68034. * Gets the main code of the block (fragment side)
  68035. * @param state current state of the node material building
  68036. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68037. * @returns the shader code
  68038. */
  68039. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68040. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68041. protected _buildBlock(state: NodeMaterialBuildState): this;
  68042. }
  68043. }
  68044. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  68045. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68046. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68047. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68048. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68050. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68051. import { Nullable } from "babylonjs/types";
  68052. import { Mesh } from "babylonjs/Meshes/mesh";
  68053. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68054. import { Effect } from "babylonjs/Materials/effect";
  68055. /**
  68056. * Block used to implement the clear coat module of the PBR material
  68057. */
  68058. export class ClearCoatBlock extends NodeMaterialBlock {
  68059. private _scene;
  68060. /**
  68061. * Create a new ClearCoatBlock
  68062. * @param name defines the block name
  68063. */
  68064. constructor(name: string);
  68065. /**
  68066. * Initialize the block and prepare the context for build
  68067. * @param state defines the state that will be used for the build
  68068. */
  68069. initialize(state: NodeMaterialBuildState): void;
  68070. /**
  68071. * Gets the current class name
  68072. * @returns the class name
  68073. */
  68074. getClassName(): string;
  68075. /**
  68076. * Gets the intensity input component
  68077. */
  68078. get intensity(): NodeMaterialConnectionPoint;
  68079. /**
  68080. * Gets the roughness input component
  68081. */
  68082. get roughness(): NodeMaterialConnectionPoint;
  68083. /**
  68084. * Gets the ior input component
  68085. */
  68086. get ior(): NodeMaterialConnectionPoint;
  68087. /**
  68088. * Gets the texture input component
  68089. */
  68090. get texture(): NodeMaterialConnectionPoint;
  68091. /**
  68092. * Gets the bump texture input component
  68093. */
  68094. get bumpTexture(): NodeMaterialConnectionPoint;
  68095. /**
  68096. * Gets the uv input component
  68097. */
  68098. get uv(): NodeMaterialConnectionPoint;
  68099. /**
  68100. * Gets the tint color input component
  68101. */
  68102. get tintColor(): NodeMaterialConnectionPoint;
  68103. /**
  68104. * Gets the tint "at distance" input component
  68105. */
  68106. get tintAtDistance(): NodeMaterialConnectionPoint;
  68107. /**
  68108. * Gets the tint thickness input component
  68109. */
  68110. get tintThickness(): NodeMaterialConnectionPoint;
  68111. /**
  68112. * Gets the world tangent input component
  68113. */
  68114. get worldTangent(): NodeMaterialConnectionPoint;
  68115. /**
  68116. * Gets the clear coat object output component
  68117. */
  68118. get clearcoat(): NodeMaterialConnectionPoint;
  68119. autoConfigure(material: NodeMaterial): void;
  68120. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68121. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68122. private _generateTBNSpace;
  68123. /**
  68124. * Gets the main code of the block (fragment side)
  68125. * @param state current state of the node material building
  68126. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68127. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68128. * @param worldPosVarName name of the variable holding the world position
  68129. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68130. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68131. * @param worldNormalVarName name of the variable holding the world normal
  68132. * @returns the shader code
  68133. */
  68134. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68135. protected _buildBlock(state: NodeMaterialBuildState): this;
  68136. }
  68137. }
  68138. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68139. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68140. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68141. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68142. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68144. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68145. import { Nullable } from "babylonjs/types";
  68146. /**
  68147. * Block used to implement the sub surface module of the PBR material
  68148. */
  68149. export class SubSurfaceBlock extends NodeMaterialBlock {
  68150. /**
  68151. * Create a new SubSurfaceBlock
  68152. * @param name defines the block name
  68153. */
  68154. constructor(name: string);
  68155. /**
  68156. * Stores the intensity of the different subsurface effects in the thickness texture.
  68157. * * the green channel is the translucency intensity.
  68158. * * the blue channel is the scattering intensity.
  68159. * * the alpha channel is the refraction intensity.
  68160. */
  68161. useMaskFromThicknessTexture: boolean;
  68162. /**
  68163. * Initialize the block and prepare the context for build
  68164. * @param state defines the state that will be used for the build
  68165. */
  68166. initialize(state: NodeMaterialBuildState): void;
  68167. /**
  68168. * Gets the current class name
  68169. * @returns the class name
  68170. */
  68171. getClassName(): string;
  68172. /**
  68173. * Gets the min thickness input component
  68174. */
  68175. get minThickness(): NodeMaterialConnectionPoint;
  68176. /**
  68177. * Gets the max thickness input component
  68178. */
  68179. get maxThickness(): NodeMaterialConnectionPoint;
  68180. /**
  68181. * Gets the thickness texture component
  68182. */
  68183. get thicknessTexture(): NodeMaterialConnectionPoint;
  68184. /**
  68185. * Gets the tint color input component
  68186. */
  68187. get tintColor(): NodeMaterialConnectionPoint;
  68188. /**
  68189. * Gets the translucency intensity input component
  68190. */
  68191. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68192. /**
  68193. * Gets the translucency diffusion distance input component
  68194. */
  68195. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68196. /**
  68197. * Gets the refraction object parameters
  68198. */
  68199. get refraction(): NodeMaterialConnectionPoint;
  68200. /**
  68201. * Gets the sub surface object output component
  68202. */
  68203. get subsurface(): NodeMaterialConnectionPoint;
  68204. autoConfigure(material: NodeMaterial): void;
  68205. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68206. /**
  68207. * Gets the main code of the block (fragment side)
  68208. * @param state current state of the node material building
  68209. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68210. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68211. * @param worldPosVarName name of the variable holding the world position
  68212. * @returns the shader code
  68213. */
  68214. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68215. protected _buildBlock(state: NodeMaterialBuildState): this;
  68216. }
  68217. }
  68218. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68219. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68220. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68221. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68222. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68223. import { Light } from "babylonjs/Lights/light";
  68224. import { Nullable } from "babylonjs/types";
  68225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68226. import { Effect } from "babylonjs/Materials/effect";
  68227. import { Mesh } from "babylonjs/Meshes/mesh";
  68228. import { Scene } from "babylonjs/scene";
  68229. /**
  68230. * Block used to implement the PBR metallic/roughness model
  68231. */
  68232. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68233. /**
  68234. * Gets or sets the light associated with this block
  68235. */
  68236. light: Nullable<Light>;
  68237. private _lightId;
  68238. private _scene;
  68239. private _environmentBRDFTexture;
  68240. private _environmentBrdfSamplerName;
  68241. private _vNormalWName;
  68242. private _invertNormalName;
  68243. /**
  68244. * Create a new ReflectionBlock
  68245. * @param name defines the block name
  68246. */
  68247. constructor(name: string);
  68248. /**
  68249. * Intensity of the direct lights e.g. the four lights available in your scene.
  68250. * This impacts both the direct diffuse and specular highlights.
  68251. */
  68252. directIntensity: number;
  68253. /**
  68254. * Intensity of the environment e.g. how much the environment will light the object
  68255. * either through harmonics for rough material or through the refelction for shiny ones.
  68256. */
  68257. environmentIntensity: number;
  68258. /**
  68259. * This is a special control allowing the reduction of the specular highlights coming from the
  68260. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68261. */
  68262. specularIntensity: number;
  68263. /**
  68264. * Defines the falloff type used in this material.
  68265. * It by default is Physical.
  68266. */
  68267. lightFalloff: number;
  68268. /**
  68269. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68270. */
  68271. useAlphaFromAlbedoTexture: boolean;
  68272. /**
  68273. * Specifies that alpha test should be used
  68274. */
  68275. useAlphaTest: boolean;
  68276. /**
  68277. * Defines the alpha limits in alpha test mode.
  68278. */
  68279. alphaTestCutoff: number;
  68280. /**
  68281. * Specifies that alpha blending should be used
  68282. */
  68283. useAlphaBlending: boolean;
  68284. /**
  68285. * Defines if the alpha value should be determined via the rgb values.
  68286. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68287. */
  68288. opacityRGB: boolean;
  68289. /**
  68290. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68291. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68292. */
  68293. useRadianceOverAlpha: boolean;
  68294. /**
  68295. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68296. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68297. */
  68298. useSpecularOverAlpha: boolean;
  68299. /**
  68300. * Enables specular anti aliasing in the PBR shader.
  68301. * It will both interacts on the Geometry for analytical and IBL lighting.
  68302. * It also prefilter the roughness map based on the bump values.
  68303. */
  68304. enableSpecularAntiAliasing: boolean;
  68305. /**
  68306. * Enables realtime filtering on the texture.
  68307. */
  68308. realTimeFiltering: boolean;
  68309. /**
  68310. * Quality switch for realtime filtering
  68311. */
  68312. realTimeFilteringQuality: number;
  68313. /**
  68314. * Defines if the material uses energy conservation.
  68315. */
  68316. useEnergyConservation: boolean;
  68317. /**
  68318. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68319. * too much the area relying on ambient texture to define their ambient occlusion.
  68320. */
  68321. useRadianceOcclusion: boolean;
  68322. /**
  68323. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68324. * makes the reflect vector face the model (under horizon).
  68325. */
  68326. useHorizonOcclusion: boolean;
  68327. /**
  68328. * If set to true, no lighting calculations will be applied.
  68329. */
  68330. unlit: boolean;
  68331. /**
  68332. * Force normal to face away from face.
  68333. */
  68334. forceNormalForward: boolean;
  68335. /**
  68336. * Defines the material debug mode.
  68337. * It helps seeing only some components of the material while troubleshooting.
  68338. */
  68339. debugMode: number;
  68340. /**
  68341. * Specify from where on screen the debug mode should start.
  68342. * The value goes from -1 (full screen) to 1 (not visible)
  68343. * It helps with side by side comparison against the final render
  68344. * This defaults to 0
  68345. */
  68346. debugLimit: number;
  68347. /**
  68348. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68349. * You can use the factor to better multiply the final value.
  68350. */
  68351. debugFactor: number;
  68352. /**
  68353. * Initialize the block and prepare the context for build
  68354. * @param state defines the state that will be used for the build
  68355. */
  68356. initialize(state: NodeMaterialBuildState): void;
  68357. /**
  68358. * Gets the current class name
  68359. * @returns the class name
  68360. */
  68361. getClassName(): string;
  68362. /**
  68363. * Gets the world position input component
  68364. */
  68365. get worldPosition(): NodeMaterialConnectionPoint;
  68366. /**
  68367. * Gets the world normal input component
  68368. */
  68369. get worldNormal(): NodeMaterialConnectionPoint;
  68370. /**
  68371. * Gets the perturbed normal input component
  68372. */
  68373. get perturbedNormal(): NodeMaterialConnectionPoint;
  68374. /**
  68375. * Gets the camera position input component
  68376. */
  68377. get cameraPosition(): NodeMaterialConnectionPoint;
  68378. /**
  68379. * Gets the base color input component
  68380. */
  68381. get baseColor(): NodeMaterialConnectionPoint;
  68382. /**
  68383. * Gets the opacity texture input component
  68384. */
  68385. get opacityTexture(): NodeMaterialConnectionPoint;
  68386. /**
  68387. * Gets the ambient color input component
  68388. */
  68389. get ambientColor(): NodeMaterialConnectionPoint;
  68390. /**
  68391. * Gets the reflectivity object parameters
  68392. */
  68393. get reflectivity(): NodeMaterialConnectionPoint;
  68394. /**
  68395. * Gets the ambient occlusion object parameters
  68396. */
  68397. get ambientOcc(): NodeMaterialConnectionPoint;
  68398. /**
  68399. * Gets the reflection object parameters
  68400. */
  68401. get reflection(): NodeMaterialConnectionPoint;
  68402. /**
  68403. * Gets the sheen object parameters
  68404. */
  68405. get sheen(): NodeMaterialConnectionPoint;
  68406. /**
  68407. * Gets the clear coat object parameters
  68408. */
  68409. get clearcoat(): NodeMaterialConnectionPoint;
  68410. /**
  68411. * Gets the sub surface object parameters
  68412. */
  68413. get subsurface(): NodeMaterialConnectionPoint;
  68414. /**
  68415. * Gets the anisotropy object parameters
  68416. */
  68417. get anisotropy(): NodeMaterialConnectionPoint;
  68418. /**
  68419. * Gets the ambient output component
  68420. */
  68421. get ambient(): NodeMaterialConnectionPoint;
  68422. /**
  68423. * Gets the diffuse output component
  68424. */
  68425. get diffuse(): NodeMaterialConnectionPoint;
  68426. /**
  68427. * Gets the specular output component
  68428. */
  68429. get specular(): NodeMaterialConnectionPoint;
  68430. /**
  68431. * Gets the sheen output component
  68432. */
  68433. get sheenDir(): NodeMaterialConnectionPoint;
  68434. /**
  68435. * Gets the clear coat output component
  68436. */
  68437. get clearcoatDir(): NodeMaterialConnectionPoint;
  68438. /**
  68439. * Gets the indirect diffuse output component
  68440. */
  68441. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68442. /**
  68443. * Gets the indirect specular output component
  68444. */
  68445. get specularIndirect(): NodeMaterialConnectionPoint;
  68446. /**
  68447. * Gets the indirect sheen output component
  68448. */
  68449. get sheenIndirect(): NodeMaterialConnectionPoint;
  68450. /**
  68451. * Gets the indirect clear coat output component
  68452. */
  68453. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68454. /**
  68455. * Gets the refraction output component
  68456. */
  68457. get refraction(): NodeMaterialConnectionPoint;
  68458. /**
  68459. * Gets the global lighting output component
  68460. */
  68461. get lighting(): NodeMaterialConnectionPoint;
  68462. /**
  68463. * Gets the shadow output component
  68464. */
  68465. get shadow(): NodeMaterialConnectionPoint;
  68466. /**
  68467. * Gets the alpha output component
  68468. */
  68469. get alpha(): NodeMaterialConnectionPoint;
  68470. autoConfigure(material: NodeMaterial): void;
  68471. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68472. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68473. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68474. private _injectVertexCode;
  68475. /**
  68476. * Gets the code corresponding to the albedo/opacity module
  68477. * @returns the shader code
  68478. */
  68479. getAlbedoOpacityCode(): string;
  68480. protected _buildBlock(state: NodeMaterialBuildState): this;
  68481. protected _dumpPropertiesCode(): string;
  68482. serialize(): any;
  68483. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68484. }
  68485. }
  68486. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68487. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68488. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68489. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68490. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68491. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68492. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68493. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68494. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68495. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68496. }
  68497. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68498. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68499. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68500. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68501. }
  68502. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68503. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68504. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68505. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68506. /**
  68507. * Block used to compute value of one parameter modulo another
  68508. */
  68509. export class ModBlock extends NodeMaterialBlock {
  68510. /**
  68511. * Creates a new ModBlock
  68512. * @param name defines the block name
  68513. */
  68514. constructor(name: string);
  68515. /**
  68516. * Gets the current class name
  68517. * @returns the class name
  68518. */
  68519. getClassName(): string;
  68520. /**
  68521. * Gets the left operand input component
  68522. */
  68523. get left(): NodeMaterialConnectionPoint;
  68524. /**
  68525. * Gets the right operand input component
  68526. */
  68527. get right(): NodeMaterialConnectionPoint;
  68528. /**
  68529. * Gets the output component
  68530. */
  68531. get output(): NodeMaterialConnectionPoint;
  68532. protected _buildBlock(state: NodeMaterialBuildState): this;
  68533. }
  68534. }
  68535. declare module "babylonjs/Materials/Node/Blocks/index" {
  68536. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68537. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68538. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68539. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68540. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68541. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68542. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68543. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68544. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68545. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68546. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68547. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68548. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68549. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68550. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68551. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68552. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68553. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68554. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68555. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68556. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68557. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68558. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68559. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68560. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68561. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68562. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68563. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68564. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68565. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68566. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68567. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68568. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68569. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68570. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68571. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68572. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68573. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68574. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68575. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68576. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68577. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68578. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68579. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68580. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68581. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68582. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68583. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68584. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68585. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68586. }
  68587. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68588. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68589. }
  68590. declare module "babylonjs/Materials/Node/index" {
  68591. export * from "babylonjs/Materials/Node/Enums/index";
  68592. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68593. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68594. export * from "babylonjs/Materials/Node/nodeMaterial";
  68595. export * from "babylonjs/Materials/Node/Blocks/index";
  68596. export * from "babylonjs/Materials/Node/Optimizers/index";
  68597. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68598. }
  68599. declare module "babylonjs/Materials/index" {
  68600. export * from "babylonjs/Materials/Background/index";
  68601. export * from "babylonjs/Materials/colorCurves";
  68602. export * from "babylonjs/Materials/iEffectFallbacks";
  68603. export * from "babylonjs/Materials/effectFallbacks";
  68604. export * from "babylonjs/Materials/effect";
  68605. export * from "babylonjs/Materials/fresnelParameters";
  68606. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68607. export * from "babylonjs/Materials/material";
  68608. export * from "babylonjs/Materials/materialDefines";
  68609. export * from "babylonjs/Materials/thinMaterialHelper";
  68610. export * from "babylonjs/Materials/materialHelper";
  68611. export * from "babylonjs/Materials/multiMaterial";
  68612. export * from "babylonjs/Materials/PBR/index";
  68613. export * from "babylonjs/Materials/pushMaterial";
  68614. export * from "babylonjs/Materials/shaderMaterial";
  68615. export * from "babylonjs/Materials/standardMaterial";
  68616. export * from "babylonjs/Materials/Textures/index";
  68617. export * from "babylonjs/Materials/uniformBuffer";
  68618. export * from "babylonjs/Materials/materialFlags";
  68619. export * from "babylonjs/Materials/Node/index";
  68620. export * from "babylonjs/Materials/effectRenderer";
  68621. export * from "babylonjs/Materials/shadowDepthWrapper";
  68622. }
  68623. declare module "babylonjs/Maths/index" {
  68624. export * from "babylonjs/Maths/math.scalar";
  68625. export * from "babylonjs/Maths/math";
  68626. export * from "babylonjs/Maths/sphericalPolynomial";
  68627. }
  68628. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68629. import { IDisposable } from "babylonjs/scene";
  68630. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68631. /**
  68632. * Configuration for Draco compression
  68633. */
  68634. export interface IDracoCompressionConfiguration {
  68635. /**
  68636. * Configuration for the decoder.
  68637. */
  68638. decoder: {
  68639. /**
  68640. * The url to the WebAssembly module.
  68641. */
  68642. wasmUrl?: string;
  68643. /**
  68644. * The url to the WebAssembly binary.
  68645. */
  68646. wasmBinaryUrl?: string;
  68647. /**
  68648. * The url to the fallback JavaScript module.
  68649. */
  68650. fallbackUrl?: string;
  68651. };
  68652. }
  68653. /**
  68654. * Draco compression (https://google.github.io/draco/)
  68655. *
  68656. * This class wraps the Draco module.
  68657. *
  68658. * **Encoder**
  68659. *
  68660. * The encoder is not currently implemented.
  68661. *
  68662. * **Decoder**
  68663. *
  68664. * 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.
  68665. *
  68666. * To update the configuration, use the following code:
  68667. * ```javascript
  68668. * DracoCompression.Configuration = {
  68669. * decoder: {
  68670. * wasmUrl: "<url to the WebAssembly library>",
  68671. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68672. * fallbackUrl: "<url to the fallback JavaScript library>",
  68673. * }
  68674. * };
  68675. * ```
  68676. *
  68677. * 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.
  68678. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68679. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68680. *
  68681. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68682. * ```javascript
  68683. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68684. * ```
  68685. *
  68686. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68687. */
  68688. export class DracoCompression implements IDisposable {
  68689. private _workerPoolPromise?;
  68690. private _decoderModulePromise?;
  68691. /**
  68692. * The configuration. Defaults to the following urls:
  68693. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68694. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68695. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68696. */
  68697. static Configuration: IDracoCompressionConfiguration;
  68698. /**
  68699. * Returns true if the decoder configuration is available.
  68700. */
  68701. static get DecoderAvailable(): boolean;
  68702. /**
  68703. * Default number of workers to create when creating the draco compression object.
  68704. */
  68705. static DefaultNumWorkers: number;
  68706. private static GetDefaultNumWorkers;
  68707. private static _Default;
  68708. /**
  68709. * Default instance for the draco compression object.
  68710. */
  68711. static get Default(): DracoCompression;
  68712. /**
  68713. * Constructor
  68714. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68715. */
  68716. constructor(numWorkers?: number);
  68717. /**
  68718. * Stop all async operations and release resources.
  68719. */
  68720. dispose(): void;
  68721. /**
  68722. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68723. * @returns a promise that resolves when ready
  68724. */
  68725. whenReadyAsync(): Promise<void>;
  68726. /**
  68727. * Decode Draco compressed mesh data to vertex data.
  68728. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68729. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68730. * @returns A promise that resolves with the decoded vertex data
  68731. */
  68732. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68733. [kind: string]: number;
  68734. }): Promise<VertexData>;
  68735. }
  68736. }
  68737. declare module "babylonjs/Meshes/Compression/index" {
  68738. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68739. }
  68740. declare module "babylonjs/Meshes/csg" {
  68741. import { Nullable } from "babylonjs/types";
  68742. import { Scene } from "babylonjs/scene";
  68743. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68744. import { Mesh } from "babylonjs/Meshes/mesh";
  68745. import { Material } from "babylonjs/Materials/material";
  68746. /**
  68747. * Class for building Constructive Solid Geometry
  68748. */
  68749. export class CSG {
  68750. private polygons;
  68751. /**
  68752. * The world matrix
  68753. */
  68754. matrix: Matrix;
  68755. /**
  68756. * Stores the position
  68757. */
  68758. position: Vector3;
  68759. /**
  68760. * Stores the rotation
  68761. */
  68762. rotation: Vector3;
  68763. /**
  68764. * Stores the rotation quaternion
  68765. */
  68766. rotationQuaternion: Nullable<Quaternion>;
  68767. /**
  68768. * Stores the scaling vector
  68769. */
  68770. scaling: Vector3;
  68771. /**
  68772. * Convert the Mesh to CSG
  68773. * @param mesh The Mesh to convert to CSG
  68774. * @returns A new CSG from the Mesh
  68775. */
  68776. static FromMesh(mesh: Mesh): CSG;
  68777. /**
  68778. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68779. * @param polygons Polygons used to construct a CSG solid
  68780. */
  68781. private static FromPolygons;
  68782. /**
  68783. * Clones, or makes a deep copy, of the CSG
  68784. * @returns A new CSG
  68785. */
  68786. clone(): CSG;
  68787. /**
  68788. * Unions this CSG with another CSG
  68789. * @param csg The CSG to union against this CSG
  68790. * @returns The unioned CSG
  68791. */
  68792. union(csg: CSG): CSG;
  68793. /**
  68794. * Unions this CSG with another CSG in place
  68795. * @param csg The CSG to union against this CSG
  68796. */
  68797. unionInPlace(csg: CSG): void;
  68798. /**
  68799. * Subtracts this CSG with another CSG
  68800. * @param csg The CSG to subtract against this CSG
  68801. * @returns A new CSG
  68802. */
  68803. subtract(csg: CSG): CSG;
  68804. /**
  68805. * Subtracts this CSG with another CSG in place
  68806. * @param csg The CSG to subtact against this CSG
  68807. */
  68808. subtractInPlace(csg: CSG): void;
  68809. /**
  68810. * Intersect this CSG with another CSG
  68811. * @param csg The CSG to intersect against this CSG
  68812. * @returns A new CSG
  68813. */
  68814. intersect(csg: CSG): CSG;
  68815. /**
  68816. * Intersects this CSG with another CSG in place
  68817. * @param csg The CSG to intersect against this CSG
  68818. */
  68819. intersectInPlace(csg: CSG): void;
  68820. /**
  68821. * Return a new CSG solid with solid and empty space switched. This solid is
  68822. * not modified.
  68823. * @returns A new CSG solid with solid and empty space switched
  68824. */
  68825. inverse(): CSG;
  68826. /**
  68827. * Inverses the CSG in place
  68828. */
  68829. inverseInPlace(): void;
  68830. /**
  68831. * This is used to keep meshes transformations so they can be restored
  68832. * when we build back a Babylon Mesh
  68833. * NB : All CSG operations are performed in world coordinates
  68834. * @param csg The CSG to copy the transform attributes from
  68835. * @returns This CSG
  68836. */
  68837. copyTransformAttributes(csg: CSG): CSG;
  68838. /**
  68839. * Build Raw mesh from CSG
  68840. * Coordinates here are in world space
  68841. * @param name The name of the mesh geometry
  68842. * @param scene The Scene
  68843. * @param keepSubMeshes Specifies if the submeshes should be kept
  68844. * @returns A new Mesh
  68845. */
  68846. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68847. /**
  68848. * Build Mesh from CSG taking material and transforms into account
  68849. * @param name The name of the Mesh
  68850. * @param material The material of the Mesh
  68851. * @param scene The Scene
  68852. * @param keepSubMeshes Specifies if submeshes should be kept
  68853. * @returns The new Mesh
  68854. */
  68855. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68856. }
  68857. }
  68858. declare module "babylonjs/Meshes/trailMesh" {
  68859. import { Mesh } from "babylonjs/Meshes/mesh";
  68860. import { Scene } from "babylonjs/scene";
  68861. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68862. /**
  68863. * Class used to create a trail following a mesh
  68864. */
  68865. export class TrailMesh extends Mesh {
  68866. private _generator;
  68867. private _autoStart;
  68868. private _running;
  68869. private _diameter;
  68870. private _length;
  68871. private _sectionPolygonPointsCount;
  68872. private _sectionVectors;
  68873. private _sectionNormalVectors;
  68874. private _beforeRenderObserver;
  68875. /**
  68876. * @constructor
  68877. * @param name The value used by scene.getMeshByName() to do a lookup.
  68878. * @param generator The mesh or transform node to generate a trail.
  68879. * @param scene The scene to add this mesh to.
  68880. * @param diameter Diameter of trailing mesh. Default is 1.
  68881. * @param length Length of trailing mesh. Default is 60.
  68882. * @param autoStart Automatically start trailing mesh. Default true.
  68883. */
  68884. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68885. /**
  68886. * "TrailMesh"
  68887. * @returns "TrailMesh"
  68888. */
  68889. getClassName(): string;
  68890. private _createMesh;
  68891. /**
  68892. * Start trailing mesh.
  68893. */
  68894. start(): void;
  68895. /**
  68896. * Stop trailing mesh.
  68897. */
  68898. stop(): void;
  68899. /**
  68900. * Update trailing mesh geometry.
  68901. */
  68902. update(): void;
  68903. /**
  68904. * Returns a new TrailMesh object.
  68905. * @param name is a string, the name given to the new mesh
  68906. * @param newGenerator use new generator object for cloned trail mesh
  68907. * @returns a new mesh
  68908. */
  68909. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68910. /**
  68911. * Serializes this trail mesh
  68912. * @param serializationObject object to write serialization to
  68913. */
  68914. serialize(serializationObject: any): void;
  68915. /**
  68916. * Parses a serialized trail mesh
  68917. * @param parsedMesh the serialized mesh
  68918. * @param scene the scene to create the trail mesh in
  68919. * @returns the created trail mesh
  68920. */
  68921. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68922. }
  68923. }
  68924. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68925. import { Nullable } from "babylonjs/types";
  68926. import { Scene } from "babylonjs/scene";
  68927. import { Vector4 } from "babylonjs/Maths/math.vector";
  68928. import { Color4 } from "babylonjs/Maths/math.color";
  68929. import { Mesh } from "babylonjs/Meshes/mesh";
  68930. /**
  68931. * Class containing static functions to help procedurally build meshes
  68932. */
  68933. export class TiledBoxBuilder {
  68934. /**
  68935. * Creates a box mesh
  68936. * 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)
  68937. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68941. * @param name defines the name of the mesh
  68942. * @param options defines the options used to create the mesh
  68943. * @param scene defines the hosting scene
  68944. * @returns the box mesh
  68945. */
  68946. static CreateTiledBox(name: string, options: {
  68947. pattern?: number;
  68948. width?: number;
  68949. height?: number;
  68950. depth?: number;
  68951. tileSize?: number;
  68952. tileWidth?: number;
  68953. tileHeight?: number;
  68954. alignHorizontal?: number;
  68955. alignVertical?: number;
  68956. faceUV?: Vector4[];
  68957. faceColors?: Color4[];
  68958. sideOrientation?: number;
  68959. updatable?: boolean;
  68960. }, scene?: Nullable<Scene>): Mesh;
  68961. }
  68962. }
  68963. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68964. import { Vector4 } from "babylonjs/Maths/math.vector";
  68965. import { Mesh } from "babylonjs/Meshes/mesh";
  68966. /**
  68967. * Class containing static functions to help procedurally build meshes
  68968. */
  68969. export class TorusKnotBuilder {
  68970. /**
  68971. * Creates a torus knot mesh
  68972. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68973. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68974. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68975. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68977. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68979. * @param name defines the name of the mesh
  68980. * @param options defines the options used to create the mesh
  68981. * @param scene defines the hosting scene
  68982. * @returns the torus knot mesh
  68983. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68984. */
  68985. static CreateTorusKnot(name: string, options: {
  68986. radius?: number;
  68987. tube?: number;
  68988. radialSegments?: number;
  68989. tubularSegments?: number;
  68990. p?: number;
  68991. q?: number;
  68992. updatable?: boolean;
  68993. sideOrientation?: number;
  68994. frontUVs?: Vector4;
  68995. backUVs?: Vector4;
  68996. }, scene: any): Mesh;
  68997. }
  68998. }
  68999. declare module "babylonjs/Meshes/polygonMesh" {
  69000. import { Scene } from "babylonjs/scene";
  69001. import { Vector2 } from "babylonjs/Maths/math.vector";
  69002. import { Mesh } from "babylonjs/Meshes/mesh";
  69003. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69004. import { Path2 } from "babylonjs/Maths/math.path";
  69005. /**
  69006. * Polygon
  69007. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69008. */
  69009. export class Polygon {
  69010. /**
  69011. * Creates a rectangle
  69012. * @param xmin bottom X coord
  69013. * @param ymin bottom Y coord
  69014. * @param xmax top X coord
  69015. * @param ymax top Y coord
  69016. * @returns points that make the resulting rectation
  69017. */
  69018. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69019. /**
  69020. * Creates a circle
  69021. * @param radius radius of circle
  69022. * @param cx scale in x
  69023. * @param cy scale in y
  69024. * @param numberOfSides number of sides that make up the circle
  69025. * @returns points that make the resulting circle
  69026. */
  69027. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69028. /**
  69029. * Creates a polygon from input string
  69030. * @param input Input polygon data
  69031. * @returns the parsed points
  69032. */
  69033. static Parse(input: string): Vector2[];
  69034. /**
  69035. * Starts building a polygon from x and y coordinates
  69036. * @param x x coordinate
  69037. * @param y y coordinate
  69038. * @returns the started path2
  69039. */
  69040. static StartingAt(x: number, y: number): Path2;
  69041. }
  69042. /**
  69043. * Builds a polygon
  69044. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69045. */
  69046. export class PolygonMeshBuilder {
  69047. private _points;
  69048. private _outlinepoints;
  69049. private _holes;
  69050. private _name;
  69051. private _scene;
  69052. private _epoints;
  69053. private _eholes;
  69054. private _addToepoint;
  69055. /**
  69056. * Babylon reference to the earcut plugin.
  69057. */
  69058. bjsEarcut: any;
  69059. /**
  69060. * Creates a PolygonMeshBuilder
  69061. * @param name name of the builder
  69062. * @param contours Path of the polygon
  69063. * @param scene scene to add to when creating the mesh
  69064. * @param earcutInjection can be used to inject your own earcut reference
  69065. */
  69066. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69067. /**
  69068. * Adds a whole within the polygon
  69069. * @param hole Array of points defining the hole
  69070. * @returns this
  69071. */
  69072. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69073. /**
  69074. * Creates the polygon
  69075. * @param updatable If the mesh should be updatable
  69076. * @param depth The depth of the mesh created
  69077. * @returns the created mesh
  69078. */
  69079. build(updatable?: boolean, depth?: number): Mesh;
  69080. /**
  69081. * Creates the polygon
  69082. * @param depth The depth of the mesh created
  69083. * @returns the created VertexData
  69084. */
  69085. buildVertexData(depth?: number): VertexData;
  69086. /**
  69087. * Adds a side to the polygon
  69088. * @param positions points that make the polygon
  69089. * @param normals normals of the polygon
  69090. * @param uvs uvs of the polygon
  69091. * @param indices indices of the polygon
  69092. * @param bounds bounds of the polygon
  69093. * @param points points of the polygon
  69094. * @param depth depth of the polygon
  69095. * @param flip flip of the polygon
  69096. */
  69097. private addSide;
  69098. }
  69099. }
  69100. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69101. import { Scene } from "babylonjs/scene";
  69102. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69103. import { Color4 } from "babylonjs/Maths/math.color";
  69104. import { Mesh } from "babylonjs/Meshes/mesh";
  69105. import { Nullable } from "babylonjs/types";
  69106. /**
  69107. * Class containing static functions to help procedurally build meshes
  69108. */
  69109. export class PolygonBuilder {
  69110. /**
  69111. * Creates a polygon mesh
  69112. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69113. * * 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
  69114. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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)
  69117. * * Remember you can only change the shape positions, not their number when updating a polygon
  69118. * @param name defines the name of the mesh
  69119. * @param options defines the options used to create the mesh
  69120. * @param scene defines the hosting scene
  69121. * @param earcutInjection can be used to inject your own earcut reference
  69122. * @returns the polygon mesh
  69123. */
  69124. static CreatePolygon(name: string, options: {
  69125. shape: Vector3[];
  69126. holes?: Vector3[][];
  69127. depth?: number;
  69128. faceUV?: Vector4[];
  69129. faceColors?: Color4[];
  69130. updatable?: boolean;
  69131. sideOrientation?: number;
  69132. frontUVs?: Vector4;
  69133. backUVs?: Vector4;
  69134. wrap?: boolean;
  69135. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69136. /**
  69137. * Creates an extruded polygon mesh, with depth in the Y direction.
  69138. * * 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)
  69139. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69140. * @param name defines the name of the mesh
  69141. * @param options defines the options used to create the mesh
  69142. * @param scene defines the hosting scene
  69143. * @param earcutInjection can be used to inject your own earcut reference
  69144. * @returns the polygon mesh
  69145. */
  69146. static ExtrudePolygon(name: string, options: {
  69147. shape: Vector3[];
  69148. holes?: Vector3[][];
  69149. depth?: number;
  69150. faceUV?: Vector4[];
  69151. faceColors?: Color4[];
  69152. updatable?: boolean;
  69153. sideOrientation?: number;
  69154. frontUVs?: Vector4;
  69155. backUVs?: Vector4;
  69156. wrap?: boolean;
  69157. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69158. }
  69159. }
  69160. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69161. import { Scene } from "babylonjs/scene";
  69162. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69163. import { Mesh } from "babylonjs/Meshes/mesh";
  69164. import { Nullable } from "babylonjs/types";
  69165. /**
  69166. * Class containing static functions to help procedurally build meshes
  69167. */
  69168. export class LatheBuilder {
  69169. /**
  69170. * Creates lathe mesh.
  69171. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69172. * * 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
  69173. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69174. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69175. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69176. * * 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
  69177. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69178. * * 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
  69179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69181. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69183. * @param name defines the name of the mesh
  69184. * @param options defines the options used to create the mesh
  69185. * @param scene defines the hosting scene
  69186. * @returns the lathe mesh
  69187. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69188. */
  69189. static CreateLathe(name: string, options: {
  69190. shape: Vector3[];
  69191. radius?: number;
  69192. tessellation?: number;
  69193. clip?: number;
  69194. arc?: number;
  69195. closed?: boolean;
  69196. updatable?: boolean;
  69197. sideOrientation?: number;
  69198. frontUVs?: Vector4;
  69199. backUVs?: Vector4;
  69200. cap?: number;
  69201. invertUV?: boolean;
  69202. }, scene?: Nullable<Scene>): Mesh;
  69203. }
  69204. }
  69205. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69206. import { Nullable } from "babylonjs/types";
  69207. import { Scene } from "babylonjs/scene";
  69208. import { Vector4 } from "babylonjs/Maths/math.vector";
  69209. import { Mesh } from "babylonjs/Meshes/mesh";
  69210. /**
  69211. * Class containing static functions to help procedurally build meshes
  69212. */
  69213. export class TiledPlaneBuilder {
  69214. /**
  69215. * Creates a tiled plane mesh
  69216. * * The parameter `pattern` will, depending on value, do nothing or
  69217. * * * flip (reflect about central vertical) alternate tiles across and up
  69218. * * * flip every tile on alternate rows
  69219. * * * rotate (180 degs) alternate tiles across and up
  69220. * * * rotate every tile on alternate rows
  69221. * * * flip and rotate alternate tiles across and up
  69222. * * * flip and rotate every tile on alternate rows
  69223. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69224. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69225. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69226. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69227. * * 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)
  69228. * * 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)
  69229. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69230. * @param name defines the name of the mesh
  69231. * @param options defines the options used to create the mesh
  69232. * @param scene defines the hosting scene
  69233. * @returns the box mesh
  69234. */
  69235. static CreateTiledPlane(name: string, options: {
  69236. pattern?: number;
  69237. tileSize?: number;
  69238. tileWidth?: number;
  69239. tileHeight?: number;
  69240. size?: number;
  69241. width?: number;
  69242. height?: number;
  69243. alignHorizontal?: number;
  69244. alignVertical?: number;
  69245. sideOrientation?: number;
  69246. frontUVs?: Vector4;
  69247. backUVs?: Vector4;
  69248. updatable?: boolean;
  69249. }, scene?: Nullable<Scene>): Mesh;
  69250. }
  69251. }
  69252. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69253. import { Nullable } from "babylonjs/types";
  69254. import { Scene } from "babylonjs/scene";
  69255. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69256. import { Mesh } from "babylonjs/Meshes/mesh";
  69257. /**
  69258. * Class containing static functions to help procedurally build meshes
  69259. */
  69260. export class TubeBuilder {
  69261. /**
  69262. * Creates a tube mesh.
  69263. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69264. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69265. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69266. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69267. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69268. * * 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)
  69269. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69270. * * 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
  69271. * * 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
  69272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69273. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69274. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69276. * @param name defines the name of the mesh
  69277. * @param options defines the options used to create the mesh
  69278. * @param scene defines the hosting scene
  69279. * @returns the tube mesh
  69280. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69281. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69282. */
  69283. static CreateTube(name: string, options: {
  69284. path: Vector3[];
  69285. radius?: number;
  69286. tessellation?: number;
  69287. radiusFunction?: {
  69288. (i: number, distance: number): number;
  69289. };
  69290. cap?: number;
  69291. arc?: number;
  69292. updatable?: boolean;
  69293. sideOrientation?: number;
  69294. frontUVs?: Vector4;
  69295. backUVs?: Vector4;
  69296. instance?: Mesh;
  69297. invertUV?: boolean;
  69298. }, scene?: Nullable<Scene>): Mesh;
  69299. }
  69300. }
  69301. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69302. import { Scene } from "babylonjs/scene";
  69303. import { Vector4 } from "babylonjs/Maths/math.vector";
  69304. import { Mesh } from "babylonjs/Meshes/mesh";
  69305. import { Nullable } from "babylonjs/types";
  69306. /**
  69307. * Class containing static functions to help procedurally build meshes
  69308. */
  69309. export class IcoSphereBuilder {
  69310. /**
  69311. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69312. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69313. * * 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`)
  69314. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69315. * * 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
  69316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69317. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69319. * @param name defines the name of the mesh
  69320. * @param options defines the options used to create the mesh
  69321. * @param scene defines the hosting scene
  69322. * @returns the icosahedron mesh
  69323. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69324. */
  69325. static CreateIcoSphere(name: string, options: {
  69326. radius?: number;
  69327. radiusX?: number;
  69328. radiusY?: number;
  69329. radiusZ?: number;
  69330. flat?: boolean;
  69331. subdivisions?: number;
  69332. sideOrientation?: number;
  69333. frontUVs?: Vector4;
  69334. backUVs?: Vector4;
  69335. updatable?: boolean;
  69336. }, scene?: Nullable<Scene>): Mesh;
  69337. }
  69338. }
  69339. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69340. import { Vector3 } from "babylonjs/Maths/math.vector";
  69341. import { Mesh } from "babylonjs/Meshes/mesh";
  69342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69343. /**
  69344. * Class containing static functions to help procedurally build meshes
  69345. */
  69346. export class DecalBuilder {
  69347. /**
  69348. * Creates a decal mesh.
  69349. * 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
  69350. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69351. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69352. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69353. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69354. * @param name defines the name of the mesh
  69355. * @param sourceMesh defines the mesh where the decal must be applied
  69356. * @param options defines the options used to create the mesh
  69357. * @param scene defines the hosting scene
  69358. * @returns the decal mesh
  69359. * @see https://doc.babylonjs.com/how_to/decals
  69360. */
  69361. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69362. position?: Vector3;
  69363. normal?: Vector3;
  69364. size?: Vector3;
  69365. angle?: number;
  69366. }): Mesh;
  69367. }
  69368. }
  69369. declare module "babylonjs/Meshes/meshBuilder" {
  69370. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69371. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69372. import { Nullable } from "babylonjs/types";
  69373. import { Scene } from "babylonjs/scene";
  69374. import { Mesh } from "babylonjs/Meshes/mesh";
  69375. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69376. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69378. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69379. import { Plane } from "babylonjs/Maths/math.plane";
  69380. /**
  69381. * Class containing static functions to help procedurally build meshes
  69382. */
  69383. export class MeshBuilder {
  69384. /**
  69385. * Creates a box mesh
  69386. * * The parameter `size` sets the size (float) of each box side (default 1)
  69387. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69388. * * 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)
  69389. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69391. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69393. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69394. * @param name defines the name of the mesh
  69395. * @param options defines the options used to create the mesh
  69396. * @param scene defines the hosting scene
  69397. * @returns the box mesh
  69398. */
  69399. static CreateBox(name: string, options: {
  69400. size?: number;
  69401. width?: number;
  69402. height?: number;
  69403. depth?: number;
  69404. faceUV?: Vector4[];
  69405. faceColors?: Color4[];
  69406. sideOrientation?: number;
  69407. frontUVs?: Vector4;
  69408. backUVs?: Vector4;
  69409. wrap?: boolean;
  69410. topBaseAt?: number;
  69411. bottomBaseAt?: number;
  69412. updatable?: boolean;
  69413. }, scene?: Nullable<Scene>): Mesh;
  69414. /**
  69415. * Creates a tiled box mesh
  69416. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69418. * @param name defines the name of the mesh
  69419. * @param options defines the options used to create the mesh
  69420. * @param scene defines the hosting scene
  69421. * @returns the tiled box mesh
  69422. */
  69423. static CreateTiledBox(name: string, options: {
  69424. pattern?: number;
  69425. size?: number;
  69426. width?: number;
  69427. height?: number;
  69428. depth: number;
  69429. tileSize?: number;
  69430. tileWidth?: number;
  69431. tileHeight?: number;
  69432. faceUV?: Vector4[];
  69433. faceColors?: Color4[];
  69434. alignHorizontal?: number;
  69435. alignVertical?: number;
  69436. sideOrientation?: number;
  69437. updatable?: boolean;
  69438. }, scene?: Nullable<Scene>): Mesh;
  69439. /**
  69440. * Creates a sphere mesh
  69441. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69442. * * 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`)
  69443. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69444. * * 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
  69445. * * 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)
  69446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69447. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69449. * @param name defines the name of the mesh
  69450. * @param options defines the options used to create the mesh
  69451. * @param scene defines the hosting scene
  69452. * @returns the sphere mesh
  69453. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69454. */
  69455. static CreateSphere(name: string, options: {
  69456. segments?: number;
  69457. diameter?: number;
  69458. diameterX?: number;
  69459. diameterY?: number;
  69460. diameterZ?: number;
  69461. arc?: number;
  69462. slice?: number;
  69463. sideOrientation?: number;
  69464. frontUVs?: Vector4;
  69465. backUVs?: Vector4;
  69466. updatable?: boolean;
  69467. }, scene?: Nullable<Scene>): Mesh;
  69468. /**
  69469. * Creates a plane polygonal mesh. By default, this is a disc
  69470. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69471. * * 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
  69472. * * 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
  69473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69474. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69476. * @param name defines the name of the mesh
  69477. * @param options defines the options used to create the mesh
  69478. * @param scene defines the hosting scene
  69479. * @returns the plane polygonal mesh
  69480. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69481. */
  69482. static CreateDisc(name: string, options: {
  69483. radius?: number;
  69484. tessellation?: number;
  69485. arc?: number;
  69486. updatable?: boolean;
  69487. sideOrientation?: number;
  69488. frontUVs?: Vector4;
  69489. backUVs?: Vector4;
  69490. }, scene?: Nullable<Scene>): Mesh;
  69491. /**
  69492. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69493. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69494. * * 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`)
  69495. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69496. * * 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
  69497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69500. * @param name defines the name of the mesh
  69501. * @param options defines the options used to create the mesh
  69502. * @param scene defines the hosting scene
  69503. * @returns the icosahedron mesh
  69504. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69505. */
  69506. static CreateIcoSphere(name: string, options: {
  69507. radius?: number;
  69508. radiusX?: number;
  69509. radiusY?: number;
  69510. radiusZ?: number;
  69511. flat?: boolean;
  69512. subdivisions?: number;
  69513. sideOrientation?: number;
  69514. frontUVs?: Vector4;
  69515. backUVs?: Vector4;
  69516. updatable?: boolean;
  69517. }, scene?: Nullable<Scene>): Mesh;
  69518. /**
  69519. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69520. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69521. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69522. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69523. * * 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
  69524. * * 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
  69525. * * 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
  69526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69527. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69528. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69529. * * 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
  69530. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69531. * * 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
  69532. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69534. * @param name defines the name of the mesh
  69535. * @param options defines the options used to create the mesh
  69536. * @param scene defines the hosting scene
  69537. * @returns the ribbon mesh
  69538. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69539. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69540. */
  69541. static CreateRibbon(name: string, options: {
  69542. pathArray: Vector3[][];
  69543. closeArray?: boolean;
  69544. closePath?: boolean;
  69545. offset?: number;
  69546. updatable?: boolean;
  69547. sideOrientation?: number;
  69548. frontUVs?: Vector4;
  69549. backUVs?: Vector4;
  69550. instance?: Mesh;
  69551. invertUV?: boolean;
  69552. uvs?: Vector2[];
  69553. colors?: Color4[];
  69554. }, scene?: Nullable<Scene>): Mesh;
  69555. /**
  69556. * Creates a cylinder or a cone mesh
  69557. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69558. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69559. * * 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.
  69560. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69561. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69562. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69563. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69564. * * 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).
  69565. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69566. * * 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).
  69567. * * 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
  69568. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69569. * * 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
  69570. * * 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.
  69571. * * If `enclose` is false, a ring surface is one element.
  69572. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69573. * * 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
  69574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69577. * @param name defines the name of the mesh
  69578. * @param options defines the options used to create the mesh
  69579. * @param scene defines the hosting scene
  69580. * @returns the cylinder mesh
  69581. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69582. */
  69583. static CreateCylinder(name: string, options: {
  69584. height?: number;
  69585. diameterTop?: number;
  69586. diameterBottom?: number;
  69587. diameter?: number;
  69588. tessellation?: number;
  69589. subdivisions?: number;
  69590. arc?: number;
  69591. faceColors?: Color4[];
  69592. faceUV?: Vector4[];
  69593. updatable?: boolean;
  69594. hasRings?: boolean;
  69595. enclose?: boolean;
  69596. cap?: number;
  69597. sideOrientation?: number;
  69598. frontUVs?: Vector4;
  69599. backUVs?: Vector4;
  69600. }, scene?: Nullable<Scene>): Mesh;
  69601. /**
  69602. * Creates a torus mesh
  69603. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69604. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69605. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69607. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69609. * @param name defines the name of the mesh
  69610. * @param options defines the options used to create the mesh
  69611. * @param scene defines the hosting scene
  69612. * @returns the torus mesh
  69613. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69614. */
  69615. static CreateTorus(name: string, options: {
  69616. diameter?: number;
  69617. thickness?: number;
  69618. tessellation?: number;
  69619. updatable?: boolean;
  69620. sideOrientation?: number;
  69621. frontUVs?: Vector4;
  69622. backUVs?: Vector4;
  69623. }, scene?: Nullable<Scene>): Mesh;
  69624. /**
  69625. * Creates a torus knot mesh
  69626. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69627. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69628. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69629. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69630. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69631. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69633. * @param name defines the name of the mesh
  69634. * @param options defines the options used to create the mesh
  69635. * @param scene defines the hosting scene
  69636. * @returns the torus knot mesh
  69637. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69638. */
  69639. static CreateTorusKnot(name: string, options: {
  69640. radius?: number;
  69641. tube?: number;
  69642. radialSegments?: number;
  69643. tubularSegments?: number;
  69644. p?: number;
  69645. q?: number;
  69646. updatable?: boolean;
  69647. sideOrientation?: number;
  69648. frontUVs?: Vector4;
  69649. backUVs?: Vector4;
  69650. }, scene?: Nullable<Scene>): Mesh;
  69651. /**
  69652. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69653. * * 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
  69654. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69655. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69656. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69657. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69658. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69659. * * 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
  69660. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69662. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69663. * @param name defines the name of the new line system
  69664. * @param options defines the options used to create the line system
  69665. * @param scene defines the hosting scene
  69666. * @returns a new line system mesh
  69667. */
  69668. static CreateLineSystem(name: string, options: {
  69669. lines: Vector3[][];
  69670. updatable?: boolean;
  69671. instance?: Nullable<LinesMesh>;
  69672. colors?: Nullable<Color4[][]>;
  69673. useVertexAlpha?: boolean;
  69674. }, scene: Nullable<Scene>): LinesMesh;
  69675. /**
  69676. * Creates a line mesh
  69677. * 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
  69678. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69679. * * The parameter `points` is an array successive Vector3
  69680. * * 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
  69681. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69682. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69683. * * When updating an instance, remember that only point positions can change, not the number of points
  69684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69685. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69686. * @param name defines the name of the new line system
  69687. * @param options defines the options used to create the line system
  69688. * @param scene defines the hosting scene
  69689. * @returns a new line mesh
  69690. */
  69691. static CreateLines(name: string, options: {
  69692. points: Vector3[];
  69693. updatable?: boolean;
  69694. instance?: Nullable<LinesMesh>;
  69695. colors?: Color4[];
  69696. useVertexAlpha?: boolean;
  69697. }, scene?: Nullable<Scene>): LinesMesh;
  69698. /**
  69699. * Creates a dashed line mesh
  69700. * * 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
  69701. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69702. * * The parameter `points` is an array successive Vector3
  69703. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69704. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69705. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69706. * * 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
  69707. * * When updating an instance, remember that only point positions can change, not the number of points
  69708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69709. * @param name defines the name of the mesh
  69710. * @param options defines the options used to create the mesh
  69711. * @param scene defines the hosting scene
  69712. * @returns the dashed line mesh
  69713. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69714. */
  69715. static CreateDashedLines(name: string, options: {
  69716. points: Vector3[];
  69717. dashSize?: number;
  69718. gapSize?: number;
  69719. dashNb?: number;
  69720. updatable?: boolean;
  69721. instance?: LinesMesh;
  69722. }, scene?: Nullable<Scene>): LinesMesh;
  69723. /**
  69724. * 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.
  69725. * * 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.
  69726. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69727. * * 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.
  69728. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69729. * * 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
  69730. * * 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
  69731. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69734. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69736. * @param name defines the name of the mesh
  69737. * @param options defines the options used to create the mesh
  69738. * @param scene defines the hosting scene
  69739. * @returns the extruded shape mesh
  69740. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69741. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69742. */
  69743. static ExtrudeShape(name: string, options: {
  69744. shape: Vector3[];
  69745. path: Vector3[];
  69746. scale?: number;
  69747. rotation?: number;
  69748. cap?: number;
  69749. updatable?: boolean;
  69750. sideOrientation?: number;
  69751. frontUVs?: Vector4;
  69752. backUVs?: Vector4;
  69753. instance?: Mesh;
  69754. invertUV?: boolean;
  69755. }, scene?: Nullable<Scene>): Mesh;
  69756. /**
  69757. * Creates an custom extruded shape mesh.
  69758. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69759. * * 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.
  69760. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69761. * * 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
  69762. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69763. * * 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
  69764. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69765. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69766. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69767. * * 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
  69768. * * 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
  69769. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69771. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69772. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69774. * @param name defines the name of the mesh
  69775. * @param options defines the options used to create the mesh
  69776. * @param scene defines the hosting scene
  69777. * @returns the custom extruded shape mesh
  69778. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69779. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69780. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69781. */
  69782. static ExtrudeShapeCustom(name: string, options: {
  69783. shape: Vector3[];
  69784. path: Vector3[];
  69785. scaleFunction?: any;
  69786. rotationFunction?: any;
  69787. ribbonCloseArray?: boolean;
  69788. ribbonClosePath?: boolean;
  69789. cap?: number;
  69790. updatable?: boolean;
  69791. sideOrientation?: number;
  69792. frontUVs?: Vector4;
  69793. backUVs?: Vector4;
  69794. instance?: Mesh;
  69795. invertUV?: boolean;
  69796. }, scene?: Nullable<Scene>): Mesh;
  69797. /**
  69798. * Creates lathe mesh.
  69799. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69800. * * 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
  69801. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69802. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69803. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69804. * * 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
  69805. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69806. * * 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
  69807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69808. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69809. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69811. * @param name defines the name of the mesh
  69812. * @param options defines the options used to create the mesh
  69813. * @param scene defines the hosting scene
  69814. * @returns the lathe mesh
  69815. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69816. */
  69817. static CreateLathe(name: string, options: {
  69818. shape: Vector3[];
  69819. radius?: number;
  69820. tessellation?: number;
  69821. clip?: number;
  69822. arc?: number;
  69823. closed?: boolean;
  69824. updatable?: boolean;
  69825. sideOrientation?: number;
  69826. frontUVs?: Vector4;
  69827. backUVs?: Vector4;
  69828. cap?: number;
  69829. invertUV?: boolean;
  69830. }, scene?: Nullable<Scene>): Mesh;
  69831. /**
  69832. * Creates a tiled plane mesh
  69833. * * You can set a limited pattern arrangement with the tiles
  69834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69835. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69837. * @param name defines the name of the mesh
  69838. * @param options defines the options used to create the mesh
  69839. * @param scene defines the hosting scene
  69840. * @returns the plane mesh
  69841. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69842. */
  69843. static CreateTiledPlane(name: string, options: {
  69844. pattern?: number;
  69845. tileSize?: number;
  69846. tileWidth?: number;
  69847. tileHeight?: number;
  69848. size?: number;
  69849. width?: number;
  69850. height?: number;
  69851. alignHorizontal?: number;
  69852. alignVertical?: number;
  69853. sideOrientation?: number;
  69854. frontUVs?: Vector4;
  69855. backUVs?: Vector4;
  69856. updatable?: boolean;
  69857. }, scene?: Nullable<Scene>): Mesh;
  69858. /**
  69859. * Creates a plane mesh
  69860. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69861. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69862. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69864. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69866. * @param name defines the name of the mesh
  69867. * @param options defines the options used to create the mesh
  69868. * @param scene defines the hosting scene
  69869. * @returns the plane mesh
  69870. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69871. */
  69872. static CreatePlane(name: string, options: {
  69873. size?: number;
  69874. width?: number;
  69875. height?: number;
  69876. sideOrientation?: number;
  69877. frontUVs?: Vector4;
  69878. backUVs?: Vector4;
  69879. updatable?: boolean;
  69880. sourcePlane?: Plane;
  69881. }, scene?: Nullable<Scene>): Mesh;
  69882. /**
  69883. * Creates a ground mesh
  69884. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69885. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69887. * @param name defines the name of the mesh
  69888. * @param options defines the options used to create the mesh
  69889. * @param scene defines the hosting scene
  69890. * @returns the ground mesh
  69891. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69892. */
  69893. static CreateGround(name: string, options: {
  69894. width?: number;
  69895. height?: number;
  69896. subdivisions?: number;
  69897. subdivisionsX?: number;
  69898. subdivisionsY?: number;
  69899. updatable?: boolean;
  69900. }, scene?: Nullable<Scene>): Mesh;
  69901. /**
  69902. * Creates a tiled ground mesh
  69903. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69904. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69905. * * 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
  69906. * * 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
  69907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69908. * @param name defines the name of the mesh
  69909. * @param options defines the options used to create the mesh
  69910. * @param scene defines the hosting scene
  69911. * @returns the tiled ground mesh
  69912. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69913. */
  69914. static CreateTiledGround(name: string, options: {
  69915. xmin: number;
  69916. zmin: number;
  69917. xmax: number;
  69918. zmax: number;
  69919. subdivisions?: {
  69920. w: number;
  69921. h: number;
  69922. };
  69923. precision?: {
  69924. w: number;
  69925. h: number;
  69926. };
  69927. updatable?: boolean;
  69928. }, scene?: Nullable<Scene>): Mesh;
  69929. /**
  69930. * Creates a ground mesh from a height map
  69931. * * The parameter `url` sets the URL of the height map image resource.
  69932. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69933. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69934. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69935. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69936. * * 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.
  69937. * * 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).
  69938. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69940. * @param name defines the name of the mesh
  69941. * @param url defines the url to the height map
  69942. * @param options defines the options used to create the mesh
  69943. * @param scene defines the hosting scene
  69944. * @returns the ground mesh
  69945. * @see https://doc.babylonjs.com/babylon101/height_map
  69946. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69947. */
  69948. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69949. width?: number;
  69950. height?: number;
  69951. subdivisions?: number;
  69952. minHeight?: number;
  69953. maxHeight?: number;
  69954. colorFilter?: Color3;
  69955. alphaFilter?: number;
  69956. updatable?: boolean;
  69957. onReady?: (mesh: GroundMesh) => void;
  69958. }, scene?: Nullable<Scene>): GroundMesh;
  69959. /**
  69960. * Creates a polygon mesh
  69961. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69962. * * 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
  69963. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69965. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69966. * * Remember you can only change the shape positions, not their number when updating a polygon
  69967. * @param name defines the name of the mesh
  69968. * @param options defines the options used to create the mesh
  69969. * @param scene defines the hosting scene
  69970. * @param earcutInjection can be used to inject your own earcut reference
  69971. * @returns the polygon mesh
  69972. */
  69973. static CreatePolygon(name: string, options: {
  69974. shape: Vector3[];
  69975. holes?: Vector3[][];
  69976. depth?: number;
  69977. faceUV?: Vector4[];
  69978. faceColors?: Color4[];
  69979. updatable?: boolean;
  69980. sideOrientation?: number;
  69981. frontUVs?: Vector4;
  69982. backUVs?: Vector4;
  69983. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69984. /**
  69985. * Creates an extruded polygon mesh, with depth in the Y direction.
  69986. * * 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)
  69987. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69988. * @param name defines the name of the mesh
  69989. * @param options defines the options used to create the mesh
  69990. * @param scene defines the hosting scene
  69991. * @param earcutInjection can be used to inject your own earcut reference
  69992. * @returns the polygon mesh
  69993. */
  69994. static ExtrudePolygon(name: string, options: {
  69995. shape: Vector3[];
  69996. holes?: Vector3[][];
  69997. depth?: number;
  69998. faceUV?: Vector4[];
  69999. faceColors?: Color4[];
  70000. updatable?: boolean;
  70001. sideOrientation?: number;
  70002. frontUVs?: Vector4;
  70003. backUVs?: Vector4;
  70004. wrap?: boolean;
  70005. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70006. /**
  70007. * Creates a tube mesh.
  70008. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70009. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70010. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70011. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70012. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70013. * * 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)
  70014. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70015. * * 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
  70016. * * 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
  70017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70018. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70019. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70021. * @param name defines the name of the mesh
  70022. * @param options defines the options used to create the mesh
  70023. * @param scene defines the hosting scene
  70024. * @returns the tube mesh
  70025. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70026. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70027. */
  70028. static CreateTube(name: string, options: {
  70029. path: Vector3[];
  70030. radius?: number;
  70031. tessellation?: number;
  70032. radiusFunction?: {
  70033. (i: number, distance: number): number;
  70034. };
  70035. cap?: number;
  70036. arc?: number;
  70037. updatable?: boolean;
  70038. sideOrientation?: number;
  70039. frontUVs?: Vector4;
  70040. backUVs?: Vector4;
  70041. instance?: Mesh;
  70042. invertUV?: boolean;
  70043. }, scene?: Nullable<Scene>): Mesh;
  70044. /**
  70045. * Creates a polyhedron mesh
  70046. * * 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
  70047. * * The parameter `size` (positive float, default 1) sets the polygon size
  70048. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70049. * * 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`
  70050. * * 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
  70051. * * 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)`)
  70052. * * 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
  70053. * * 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
  70054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70057. * @param name defines the name of the mesh
  70058. * @param options defines the options used to create the mesh
  70059. * @param scene defines the hosting scene
  70060. * @returns the polyhedron mesh
  70061. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70062. */
  70063. static CreatePolyhedron(name: string, options: {
  70064. type?: number;
  70065. size?: number;
  70066. sizeX?: number;
  70067. sizeY?: number;
  70068. sizeZ?: number;
  70069. custom?: any;
  70070. faceUV?: Vector4[];
  70071. faceColors?: Color4[];
  70072. flat?: boolean;
  70073. updatable?: boolean;
  70074. sideOrientation?: number;
  70075. frontUVs?: Vector4;
  70076. backUVs?: Vector4;
  70077. }, scene?: Nullable<Scene>): Mesh;
  70078. /**
  70079. * Creates a decal mesh.
  70080. * 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
  70081. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70082. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70083. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70084. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70085. * @param name defines the name of the mesh
  70086. * @param sourceMesh defines the mesh where the decal must be applied
  70087. * @param options defines the options used to create the mesh
  70088. * @param scene defines the hosting scene
  70089. * @returns the decal mesh
  70090. * @see https://doc.babylonjs.com/how_to/decals
  70091. */
  70092. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70093. position?: Vector3;
  70094. normal?: Vector3;
  70095. size?: Vector3;
  70096. angle?: number;
  70097. }): Mesh;
  70098. /**
  70099. * Creates a Capsule Mesh
  70100. * @param name defines the name of the mesh.
  70101. * @param options the constructors options used to shape the mesh.
  70102. * @param scene defines the scene the mesh is scoped to.
  70103. * @returns the capsule mesh
  70104. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70105. */
  70106. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70107. }
  70108. }
  70109. declare module "babylonjs/Meshes/meshSimplification" {
  70110. import { Mesh } from "babylonjs/Meshes/mesh";
  70111. /**
  70112. * A simplifier interface for future simplification implementations
  70113. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70114. */
  70115. export interface ISimplifier {
  70116. /**
  70117. * Simplification of a given mesh according to the given settings.
  70118. * Since this requires computation, it is assumed that the function runs async.
  70119. * @param settings The settings of the simplification, including quality and distance
  70120. * @param successCallback A callback that will be called after the mesh was simplified.
  70121. * @param errorCallback in case of an error, this callback will be called. optional.
  70122. */
  70123. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70124. }
  70125. /**
  70126. * Expected simplification settings.
  70127. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70128. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70129. */
  70130. export interface ISimplificationSettings {
  70131. /**
  70132. * Gets or sets the expected quality
  70133. */
  70134. quality: number;
  70135. /**
  70136. * Gets or sets the distance when this optimized version should be used
  70137. */
  70138. distance: number;
  70139. /**
  70140. * Gets an already optimized mesh
  70141. */
  70142. optimizeMesh?: boolean;
  70143. }
  70144. /**
  70145. * Class used to specify simplification options
  70146. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70147. */
  70148. export class SimplificationSettings implements ISimplificationSettings {
  70149. /** expected quality */
  70150. quality: number;
  70151. /** distance when this optimized version should be used */
  70152. distance: number;
  70153. /** already optimized mesh */
  70154. optimizeMesh?: boolean | undefined;
  70155. /**
  70156. * Creates a SimplificationSettings
  70157. * @param quality expected quality
  70158. * @param distance distance when this optimized version should be used
  70159. * @param optimizeMesh already optimized mesh
  70160. */
  70161. constructor(
  70162. /** expected quality */
  70163. quality: number,
  70164. /** distance when this optimized version should be used */
  70165. distance: number,
  70166. /** already optimized mesh */
  70167. optimizeMesh?: boolean | undefined);
  70168. }
  70169. /**
  70170. * Interface used to define a simplification task
  70171. */
  70172. export interface ISimplificationTask {
  70173. /**
  70174. * Array of settings
  70175. */
  70176. settings: Array<ISimplificationSettings>;
  70177. /**
  70178. * Simplification type
  70179. */
  70180. simplificationType: SimplificationType;
  70181. /**
  70182. * Mesh to simplify
  70183. */
  70184. mesh: Mesh;
  70185. /**
  70186. * Callback called on success
  70187. */
  70188. successCallback?: () => void;
  70189. /**
  70190. * Defines if parallel processing can be used
  70191. */
  70192. parallelProcessing: boolean;
  70193. }
  70194. /**
  70195. * Queue used to order the simplification tasks
  70196. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70197. */
  70198. export class SimplificationQueue {
  70199. private _simplificationArray;
  70200. /**
  70201. * Gets a boolean indicating that the process is still running
  70202. */
  70203. running: boolean;
  70204. /**
  70205. * Creates a new queue
  70206. */
  70207. constructor();
  70208. /**
  70209. * Adds a new simplification task
  70210. * @param task defines a task to add
  70211. */
  70212. addTask(task: ISimplificationTask): void;
  70213. /**
  70214. * Execute next task
  70215. */
  70216. executeNext(): void;
  70217. /**
  70218. * Execute a simplification task
  70219. * @param task defines the task to run
  70220. */
  70221. runSimplification(task: ISimplificationTask): void;
  70222. private getSimplifier;
  70223. }
  70224. /**
  70225. * The implemented types of simplification
  70226. * At the moment only Quadratic Error Decimation is implemented
  70227. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70228. */
  70229. export enum SimplificationType {
  70230. /** Quadratic error decimation */
  70231. QUADRATIC = 0
  70232. }
  70233. /**
  70234. * An implementation of the Quadratic Error simplification algorithm.
  70235. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70236. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70237. * @author RaananW
  70238. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70239. */
  70240. export class QuadraticErrorSimplification implements ISimplifier {
  70241. private _mesh;
  70242. private triangles;
  70243. private vertices;
  70244. private references;
  70245. private _reconstructedMesh;
  70246. /** Gets or sets the number pf sync interations */
  70247. syncIterations: number;
  70248. /** Gets or sets the aggressiveness of the simplifier */
  70249. aggressiveness: number;
  70250. /** Gets or sets the number of allowed iterations for decimation */
  70251. decimationIterations: number;
  70252. /** Gets or sets the espilon to use for bounding box computation */
  70253. boundingBoxEpsilon: number;
  70254. /**
  70255. * Creates a new QuadraticErrorSimplification
  70256. * @param _mesh defines the target mesh
  70257. */
  70258. constructor(_mesh: Mesh);
  70259. /**
  70260. * Simplification of a given mesh according to the given settings.
  70261. * Since this requires computation, it is assumed that the function runs async.
  70262. * @param settings The settings of the simplification, including quality and distance
  70263. * @param successCallback A callback that will be called after the mesh was simplified.
  70264. */
  70265. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70266. private runDecimation;
  70267. private initWithMesh;
  70268. private init;
  70269. private reconstructMesh;
  70270. private initDecimatedMesh;
  70271. private isFlipped;
  70272. private updateTriangles;
  70273. private identifyBorder;
  70274. private updateMesh;
  70275. private vertexError;
  70276. private calculateError;
  70277. }
  70278. }
  70279. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70280. import { Scene } from "babylonjs/scene";
  70281. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70282. import { ISceneComponent } from "babylonjs/sceneComponent";
  70283. module "babylonjs/scene" {
  70284. interface Scene {
  70285. /** @hidden (Backing field) */
  70286. _simplificationQueue: SimplificationQueue;
  70287. /**
  70288. * Gets or sets the simplification queue attached to the scene
  70289. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70290. */
  70291. simplificationQueue: SimplificationQueue;
  70292. }
  70293. }
  70294. module "babylonjs/Meshes/mesh" {
  70295. interface Mesh {
  70296. /**
  70297. * Simplify the mesh according to the given array of settings.
  70298. * Function will return immediately and will simplify async
  70299. * @param settings a collection of simplification settings
  70300. * @param parallelProcessing should all levels calculate parallel or one after the other
  70301. * @param simplificationType the type of simplification to run
  70302. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70303. * @returns the current mesh
  70304. */
  70305. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70306. }
  70307. }
  70308. /**
  70309. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70310. * created in a scene
  70311. */
  70312. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70313. /**
  70314. * The component name helpfull to identify the component in the list of scene components.
  70315. */
  70316. readonly name: string;
  70317. /**
  70318. * The scene the component belongs to.
  70319. */
  70320. scene: Scene;
  70321. /**
  70322. * Creates a new instance of the component for the given scene
  70323. * @param scene Defines the scene to register the component in
  70324. */
  70325. constructor(scene: Scene);
  70326. /**
  70327. * Registers the component in a given scene
  70328. */
  70329. register(): void;
  70330. /**
  70331. * Rebuilds the elements related to this component in case of
  70332. * context lost for instance.
  70333. */
  70334. rebuild(): void;
  70335. /**
  70336. * Disposes the component and the associated ressources
  70337. */
  70338. dispose(): void;
  70339. private _beforeCameraUpdate;
  70340. }
  70341. }
  70342. declare module "babylonjs/Meshes/Builders/index" {
  70343. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70344. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70345. export * from "babylonjs/Meshes/Builders/discBuilder";
  70346. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70347. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70348. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70349. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70350. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70351. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70352. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70353. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70354. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70355. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70356. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70357. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70358. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70359. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70360. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70361. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70362. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70363. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70364. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70365. }
  70366. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70367. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70368. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70369. import { Matrix } from "babylonjs/Maths/math.vector";
  70370. module "babylonjs/Meshes/mesh" {
  70371. interface Mesh {
  70372. /**
  70373. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70374. */
  70375. thinInstanceEnablePicking: boolean;
  70376. /**
  70377. * Creates a new thin instance
  70378. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70379. * @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
  70380. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70381. */
  70382. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70383. /**
  70384. * Adds the transformation (matrix) of the current mesh as a thin instance
  70385. * @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
  70386. * @returns the thin instance index number
  70387. */
  70388. thinInstanceAddSelf(refresh: boolean): number;
  70389. /**
  70390. * Registers a custom attribute to be used with thin instances
  70391. * @param kind name of the attribute
  70392. * @param stride size in floats of the attribute
  70393. */
  70394. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70395. /**
  70396. * Sets the matrix of a thin instance
  70397. * @param index index of the thin instance
  70398. * @param matrix matrix to set
  70399. * @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
  70400. */
  70401. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70402. /**
  70403. * Sets the value of a custom attribute for a thin instance
  70404. * @param kind name of the attribute
  70405. * @param index index of the thin instance
  70406. * @param value value to set
  70407. * @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
  70408. */
  70409. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70410. /**
  70411. * 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.
  70412. */
  70413. thinInstanceCount: number;
  70414. /**
  70415. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70416. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70417. * @param buffer buffer to set
  70418. * @param stride size in floats of each value of the buffer
  70419. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70420. */
  70421. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70422. /**
  70423. * Gets the list of world matrices
  70424. * @return an array containing all the world matrices from the thin instances
  70425. */
  70426. thinInstanceGetWorldMatrices(): Matrix[];
  70427. /**
  70428. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70429. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70430. */
  70431. thinInstanceBufferUpdated(kind: string): void;
  70432. /**
  70433. * Applies a partial update to a buffer directly on the GPU
  70434. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  70435. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70436. * @param data the data to set in the GPU buffer
  70437. * @param offset the offset in the GPU buffer where to update the data
  70438. */
  70439. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70440. /**
  70441. * Refreshes the bounding info, taking into account all the thin instances defined
  70442. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70443. */
  70444. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70445. /** @hidden */
  70446. _thinInstanceInitializeUserStorage(): void;
  70447. /** @hidden */
  70448. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70449. /** @hidden */
  70450. _userThinInstanceBuffersStorage: {
  70451. data: {
  70452. [key: string]: Float32Array;
  70453. };
  70454. sizes: {
  70455. [key: string]: number;
  70456. };
  70457. vertexBuffers: {
  70458. [key: string]: Nullable<VertexBuffer>;
  70459. };
  70460. strides: {
  70461. [key: string]: number;
  70462. };
  70463. };
  70464. }
  70465. }
  70466. }
  70467. declare module "babylonjs/Meshes/index" {
  70468. export * from "babylonjs/Meshes/abstractMesh";
  70469. export * from "babylonjs/Meshes/buffer";
  70470. export * from "babylonjs/Meshes/Compression/index";
  70471. export * from "babylonjs/Meshes/csg";
  70472. export * from "babylonjs/Meshes/geometry";
  70473. export * from "babylonjs/Meshes/groundMesh";
  70474. export * from "babylonjs/Meshes/trailMesh";
  70475. export * from "babylonjs/Meshes/instancedMesh";
  70476. export * from "babylonjs/Meshes/linesMesh";
  70477. export * from "babylonjs/Meshes/mesh";
  70478. export * from "babylonjs/Meshes/mesh.vertexData";
  70479. export * from "babylonjs/Meshes/meshBuilder";
  70480. export * from "babylonjs/Meshes/meshSimplification";
  70481. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70482. export * from "babylonjs/Meshes/polygonMesh";
  70483. export * from "babylonjs/Meshes/subMesh";
  70484. export * from "babylonjs/Meshes/meshLODLevel";
  70485. export * from "babylonjs/Meshes/transformNode";
  70486. export * from "babylonjs/Meshes/Builders/index";
  70487. export * from "babylonjs/Meshes/dataBuffer";
  70488. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70489. import "babylonjs/Meshes/thinInstanceMesh";
  70490. export * from "babylonjs/Meshes/thinInstanceMesh";
  70491. }
  70492. declare module "babylonjs/Morph/index" {
  70493. export * from "babylonjs/Morph/morphTarget";
  70494. export * from "babylonjs/Morph/morphTargetManager";
  70495. }
  70496. declare module "babylonjs/Navigation/INavigationEngine" {
  70497. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70498. import { Vector3 } from "babylonjs/Maths/math";
  70499. import { Mesh } from "babylonjs/Meshes/mesh";
  70500. import { Scene } from "babylonjs/scene";
  70501. /**
  70502. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70503. */
  70504. export interface INavigationEnginePlugin {
  70505. /**
  70506. * plugin name
  70507. */
  70508. name: string;
  70509. /**
  70510. * Creates a navigation mesh
  70511. * @param meshes array of all the geometry used to compute the navigatio mesh
  70512. * @param parameters bunch of parameters used to filter geometry
  70513. */
  70514. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70515. /**
  70516. * Create a navigation mesh debug mesh
  70517. * @param scene is where the mesh will be added
  70518. * @returns debug display mesh
  70519. */
  70520. createDebugNavMesh(scene: Scene): Mesh;
  70521. /**
  70522. * Get a navigation mesh constrained position, closest to the parameter position
  70523. * @param position world position
  70524. * @returns the closest point to position constrained by the navigation mesh
  70525. */
  70526. getClosestPoint(position: Vector3): Vector3;
  70527. /**
  70528. * Get a navigation mesh constrained position, closest to the parameter position
  70529. * @param position world position
  70530. * @param result output the closest point to position constrained by the navigation mesh
  70531. */
  70532. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70533. /**
  70534. * Get a navigation mesh constrained position, within a particular radius
  70535. * @param position world position
  70536. * @param maxRadius the maximum distance to the constrained world position
  70537. * @returns the closest point to position constrained by the navigation mesh
  70538. */
  70539. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70540. /**
  70541. * Get a navigation mesh constrained position, within a particular radius
  70542. * @param position world position
  70543. * @param maxRadius the maximum distance to the constrained world position
  70544. * @param result output the closest point to position constrained by the navigation mesh
  70545. */
  70546. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70547. /**
  70548. * Compute the final position from a segment made of destination-position
  70549. * @param position world position
  70550. * @param destination world position
  70551. * @returns the resulting point along the navmesh
  70552. */
  70553. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70554. /**
  70555. * Compute the final position from a segment made of destination-position
  70556. * @param position world position
  70557. * @param destination world position
  70558. * @param result output the resulting point along the navmesh
  70559. */
  70560. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70561. /**
  70562. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70563. * @param start world position
  70564. * @param end world position
  70565. * @returns array containing world position composing the path
  70566. */
  70567. computePath(start: Vector3, end: Vector3): Vector3[];
  70568. /**
  70569. * If this plugin is supported
  70570. * @returns true if plugin is supported
  70571. */
  70572. isSupported(): boolean;
  70573. /**
  70574. * Create a new Crowd so you can add agents
  70575. * @param maxAgents the maximum agent count in the crowd
  70576. * @param maxAgentRadius the maximum radius an agent can have
  70577. * @param scene to attach the crowd to
  70578. * @returns the crowd you can add agents to
  70579. */
  70580. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70581. /**
  70582. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70583. * The queries will try to find a solution within those bounds
  70584. * default is (1,1,1)
  70585. * @param extent x,y,z value that define the extent around the queries point of reference
  70586. */
  70587. setDefaultQueryExtent(extent: Vector3): void;
  70588. /**
  70589. * Get the Bounding box extent specified by setDefaultQueryExtent
  70590. * @returns the box extent values
  70591. */
  70592. getDefaultQueryExtent(): Vector3;
  70593. /**
  70594. * build the navmesh from a previously saved state using getNavmeshData
  70595. * @param data the Uint8Array returned by getNavmeshData
  70596. */
  70597. buildFromNavmeshData(data: Uint8Array): void;
  70598. /**
  70599. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70600. * @returns data the Uint8Array that can be saved and reused
  70601. */
  70602. getNavmeshData(): Uint8Array;
  70603. /**
  70604. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70605. * @param result output the box extent values
  70606. */
  70607. getDefaultQueryExtentToRef(result: Vector3): void;
  70608. /**
  70609. * Release all resources
  70610. */
  70611. dispose(): void;
  70612. }
  70613. /**
  70614. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70615. */
  70616. export interface ICrowd {
  70617. /**
  70618. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70619. * You can attach anything to that node. The node position is updated in the scene update tick.
  70620. * @param pos world position that will be constrained by the navigation mesh
  70621. * @param parameters agent parameters
  70622. * @param transform hooked to the agent that will be update by the scene
  70623. * @returns agent index
  70624. */
  70625. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70626. /**
  70627. * Returns the agent position in world space
  70628. * @param index agent index returned by addAgent
  70629. * @returns world space position
  70630. */
  70631. getAgentPosition(index: number): Vector3;
  70632. /**
  70633. * Gets the agent position result in world space
  70634. * @param index agent index returned by addAgent
  70635. * @param result output world space position
  70636. */
  70637. getAgentPositionToRef(index: number, result: Vector3): void;
  70638. /**
  70639. * Gets the agent velocity in world space
  70640. * @param index agent index returned by addAgent
  70641. * @returns world space velocity
  70642. */
  70643. getAgentVelocity(index: number): Vector3;
  70644. /**
  70645. * Gets the agent velocity result in world space
  70646. * @param index agent index returned by addAgent
  70647. * @param result output world space velocity
  70648. */
  70649. getAgentVelocityToRef(index: number, result: Vector3): void;
  70650. /**
  70651. * remove a particular agent previously created
  70652. * @param index agent index returned by addAgent
  70653. */
  70654. removeAgent(index: number): void;
  70655. /**
  70656. * get the list of all agents attached to this crowd
  70657. * @returns list of agent indices
  70658. */
  70659. getAgents(): number[];
  70660. /**
  70661. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70662. * @param deltaTime in seconds
  70663. */
  70664. update(deltaTime: number): void;
  70665. /**
  70666. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70667. * @param index agent index returned by addAgent
  70668. * @param destination targeted world position
  70669. */
  70670. agentGoto(index: number, destination: Vector3): void;
  70671. /**
  70672. * Teleport the agent to a new position
  70673. * @param index agent index returned by addAgent
  70674. * @param destination targeted world position
  70675. */
  70676. agentTeleport(index: number, destination: Vector3): void;
  70677. /**
  70678. * Update agent parameters
  70679. * @param index agent index returned by addAgent
  70680. * @param parameters agent parameters
  70681. */
  70682. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70683. /**
  70684. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70685. * The queries will try to find a solution within those bounds
  70686. * default is (1,1,1)
  70687. * @param extent x,y,z value that define the extent around the queries point of reference
  70688. */
  70689. setDefaultQueryExtent(extent: Vector3): void;
  70690. /**
  70691. * Get the Bounding box extent specified by setDefaultQueryExtent
  70692. * @returns the box extent values
  70693. */
  70694. getDefaultQueryExtent(): Vector3;
  70695. /**
  70696. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70697. * @param result output the box extent values
  70698. */
  70699. getDefaultQueryExtentToRef(result: Vector3): void;
  70700. /**
  70701. * Release all resources
  70702. */
  70703. dispose(): void;
  70704. }
  70705. /**
  70706. * Configures an agent
  70707. */
  70708. export interface IAgentParameters {
  70709. /**
  70710. * Agent radius. [Limit: >= 0]
  70711. */
  70712. radius: number;
  70713. /**
  70714. * Agent height. [Limit: > 0]
  70715. */
  70716. height: number;
  70717. /**
  70718. * Maximum allowed acceleration. [Limit: >= 0]
  70719. */
  70720. maxAcceleration: number;
  70721. /**
  70722. * Maximum allowed speed. [Limit: >= 0]
  70723. */
  70724. maxSpeed: number;
  70725. /**
  70726. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70727. */
  70728. collisionQueryRange: number;
  70729. /**
  70730. * The path visibility optimization range. [Limit: > 0]
  70731. */
  70732. pathOptimizationRange: number;
  70733. /**
  70734. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70735. */
  70736. separationWeight: number;
  70737. }
  70738. /**
  70739. * Configures the navigation mesh creation
  70740. */
  70741. export interface INavMeshParameters {
  70742. /**
  70743. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70744. */
  70745. cs: number;
  70746. /**
  70747. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70748. */
  70749. ch: number;
  70750. /**
  70751. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70752. */
  70753. walkableSlopeAngle: number;
  70754. /**
  70755. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70756. * be considered walkable. [Limit: >= 3] [Units: vx]
  70757. */
  70758. walkableHeight: number;
  70759. /**
  70760. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70761. */
  70762. walkableClimb: number;
  70763. /**
  70764. * The distance to erode/shrink the walkable area of the heightfield away from
  70765. * obstructions. [Limit: >=0] [Units: vx]
  70766. */
  70767. walkableRadius: number;
  70768. /**
  70769. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70770. */
  70771. maxEdgeLen: number;
  70772. /**
  70773. * The maximum distance a simplfied contour's border edges should deviate
  70774. * the original raw contour. [Limit: >=0] [Units: vx]
  70775. */
  70776. maxSimplificationError: number;
  70777. /**
  70778. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70779. */
  70780. minRegionArea: number;
  70781. /**
  70782. * Any regions with a span count smaller than this value will, if possible,
  70783. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70784. */
  70785. mergeRegionArea: number;
  70786. /**
  70787. * The maximum number of vertices allowed for polygons generated during the
  70788. * contour to polygon conversion process. [Limit: >= 3]
  70789. */
  70790. maxVertsPerPoly: number;
  70791. /**
  70792. * Sets the sampling distance to use when generating the detail mesh.
  70793. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70794. */
  70795. detailSampleDist: number;
  70796. /**
  70797. * The maximum distance the detail mesh surface should deviate from heightfield
  70798. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70799. */
  70800. detailSampleMaxError: number;
  70801. }
  70802. }
  70803. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70804. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70805. import { Mesh } from "babylonjs/Meshes/mesh";
  70806. import { Scene } from "babylonjs/scene";
  70807. import { Vector3 } from "babylonjs/Maths/math";
  70808. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70809. /**
  70810. * RecastJS navigation plugin
  70811. */
  70812. export class RecastJSPlugin implements INavigationEnginePlugin {
  70813. /**
  70814. * Reference to the Recast library
  70815. */
  70816. bjsRECAST: any;
  70817. /**
  70818. * plugin name
  70819. */
  70820. name: string;
  70821. /**
  70822. * the first navmesh created. We might extend this to support multiple navmeshes
  70823. */
  70824. navMesh: any;
  70825. /**
  70826. * Initializes the recastJS plugin
  70827. * @param recastInjection can be used to inject your own recast reference
  70828. */
  70829. constructor(recastInjection?: any);
  70830. /**
  70831. * Creates a navigation mesh
  70832. * @param meshes array of all the geometry used to compute the navigatio mesh
  70833. * @param parameters bunch of parameters used to filter geometry
  70834. */
  70835. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70836. /**
  70837. * Create a navigation mesh debug mesh
  70838. * @param scene is where the mesh will be added
  70839. * @returns debug display mesh
  70840. */
  70841. createDebugNavMesh(scene: Scene): Mesh;
  70842. /**
  70843. * Get a navigation mesh constrained position, closest to the parameter position
  70844. * @param position world position
  70845. * @returns the closest point to position constrained by the navigation mesh
  70846. */
  70847. getClosestPoint(position: Vector3): Vector3;
  70848. /**
  70849. * Get a navigation mesh constrained position, closest to the parameter position
  70850. * @param position world position
  70851. * @param result output the closest point to position constrained by the navigation mesh
  70852. */
  70853. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70854. /**
  70855. * Get a navigation mesh constrained position, within a particular radius
  70856. * @param position world position
  70857. * @param maxRadius the maximum distance to the constrained world position
  70858. * @returns the closest point to position constrained by the navigation mesh
  70859. */
  70860. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70861. /**
  70862. * Get a navigation mesh constrained position, within a particular radius
  70863. * @param position world position
  70864. * @param maxRadius the maximum distance to the constrained world position
  70865. * @param result output the closest point to position constrained by the navigation mesh
  70866. */
  70867. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70868. /**
  70869. * Compute the final position from a segment made of destination-position
  70870. * @param position world position
  70871. * @param destination world position
  70872. * @returns the resulting point along the navmesh
  70873. */
  70874. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70875. /**
  70876. * Compute the final position from a segment made of destination-position
  70877. * @param position world position
  70878. * @param destination world position
  70879. * @param result output the resulting point along the navmesh
  70880. */
  70881. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70882. /**
  70883. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70884. * @param start world position
  70885. * @param end world position
  70886. * @returns array containing world position composing the path
  70887. */
  70888. computePath(start: Vector3, end: Vector3): Vector3[];
  70889. /**
  70890. * Create a new Crowd so you can add agents
  70891. * @param maxAgents the maximum agent count in the crowd
  70892. * @param maxAgentRadius the maximum radius an agent can have
  70893. * @param scene to attach the crowd to
  70894. * @returns the crowd you can add agents to
  70895. */
  70896. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70897. /**
  70898. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70899. * The queries will try to find a solution within those bounds
  70900. * default is (1,1,1)
  70901. * @param extent x,y,z value that define the extent around the queries point of reference
  70902. */
  70903. setDefaultQueryExtent(extent: Vector3): void;
  70904. /**
  70905. * Get the Bounding box extent specified by setDefaultQueryExtent
  70906. * @returns the box extent values
  70907. */
  70908. getDefaultQueryExtent(): Vector3;
  70909. /**
  70910. * build the navmesh from a previously saved state using getNavmeshData
  70911. * @param data the Uint8Array returned by getNavmeshData
  70912. */
  70913. buildFromNavmeshData(data: Uint8Array): void;
  70914. /**
  70915. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70916. * @returns data the Uint8Array that can be saved and reused
  70917. */
  70918. getNavmeshData(): Uint8Array;
  70919. /**
  70920. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70921. * @param result output the box extent values
  70922. */
  70923. getDefaultQueryExtentToRef(result: Vector3): void;
  70924. /**
  70925. * Disposes
  70926. */
  70927. dispose(): void;
  70928. /**
  70929. * If this plugin is supported
  70930. * @returns true if plugin is supported
  70931. */
  70932. isSupported(): boolean;
  70933. }
  70934. /**
  70935. * Recast detour crowd implementation
  70936. */
  70937. export class RecastJSCrowd implements ICrowd {
  70938. /**
  70939. * Recast/detour plugin
  70940. */
  70941. bjsRECASTPlugin: RecastJSPlugin;
  70942. /**
  70943. * Link to the detour crowd
  70944. */
  70945. recastCrowd: any;
  70946. /**
  70947. * One transform per agent
  70948. */
  70949. transforms: TransformNode[];
  70950. /**
  70951. * All agents created
  70952. */
  70953. agents: number[];
  70954. /**
  70955. * Link to the scene is kept to unregister the crowd from the scene
  70956. */
  70957. private _scene;
  70958. /**
  70959. * Observer for crowd updates
  70960. */
  70961. private _onBeforeAnimationsObserver;
  70962. /**
  70963. * Constructor
  70964. * @param plugin recastJS plugin
  70965. * @param maxAgents the maximum agent count in the crowd
  70966. * @param maxAgentRadius the maximum radius an agent can have
  70967. * @param scene to attach the crowd to
  70968. * @returns the crowd you can add agents to
  70969. */
  70970. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70971. /**
  70972. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70973. * You can attach anything to that node. The node position is updated in the scene update tick.
  70974. * @param pos world position that will be constrained by the navigation mesh
  70975. * @param parameters agent parameters
  70976. * @param transform hooked to the agent that will be update by the scene
  70977. * @returns agent index
  70978. */
  70979. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70980. /**
  70981. * Returns the agent position in world space
  70982. * @param index agent index returned by addAgent
  70983. * @returns world space position
  70984. */
  70985. getAgentPosition(index: number): Vector3;
  70986. /**
  70987. * Returns the agent position result in world space
  70988. * @param index agent index returned by addAgent
  70989. * @param result output world space position
  70990. */
  70991. getAgentPositionToRef(index: number, result: Vector3): void;
  70992. /**
  70993. * Returns the agent velocity in world space
  70994. * @param index agent index returned by addAgent
  70995. * @returns world space velocity
  70996. */
  70997. getAgentVelocity(index: number): Vector3;
  70998. /**
  70999. * Returns the agent velocity result in world space
  71000. * @param index agent index returned by addAgent
  71001. * @param result output world space velocity
  71002. */
  71003. getAgentVelocityToRef(index: number, result: Vector3): void;
  71004. /**
  71005. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71006. * @param index agent index returned by addAgent
  71007. * @param destination targeted world position
  71008. */
  71009. agentGoto(index: number, destination: Vector3): void;
  71010. /**
  71011. * Teleport the agent to a new position
  71012. * @param index agent index returned by addAgent
  71013. * @param destination targeted world position
  71014. */
  71015. agentTeleport(index: number, destination: Vector3): void;
  71016. /**
  71017. * Update agent parameters
  71018. * @param index agent index returned by addAgent
  71019. * @param parameters agent parameters
  71020. */
  71021. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71022. /**
  71023. * remove a particular agent previously created
  71024. * @param index agent index returned by addAgent
  71025. */
  71026. removeAgent(index: number): void;
  71027. /**
  71028. * get the list of all agents attached to this crowd
  71029. * @returns list of agent indices
  71030. */
  71031. getAgents(): number[];
  71032. /**
  71033. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71034. * @param deltaTime in seconds
  71035. */
  71036. update(deltaTime: number): void;
  71037. /**
  71038. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71039. * The queries will try to find a solution within those bounds
  71040. * default is (1,1,1)
  71041. * @param extent x,y,z value that define the extent around the queries point of reference
  71042. */
  71043. setDefaultQueryExtent(extent: Vector3): void;
  71044. /**
  71045. * Get the Bounding box extent specified by setDefaultQueryExtent
  71046. * @returns the box extent values
  71047. */
  71048. getDefaultQueryExtent(): Vector3;
  71049. /**
  71050. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71051. * @param result output the box extent values
  71052. */
  71053. getDefaultQueryExtentToRef(result: Vector3): void;
  71054. /**
  71055. * Release all resources
  71056. */
  71057. dispose(): void;
  71058. }
  71059. }
  71060. declare module "babylonjs/Navigation/Plugins/index" {
  71061. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  71062. }
  71063. declare module "babylonjs/Navigation/index" {
  71064. export * from "babylonjs/Navigation/INavigationEngine";
  71065. export * from "babylonjs/Navigation/Plugins/index";
  71066. }
  71067. declare module "babylonjs/Offline/database" {
  71068. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  71069. /**
  71070. * Class used to enable access to IndexedDB
  71071. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71072. */
  71073. export class Database implements IOfflineProvider {
  71074. private _callbackManifestChecked;
  71075. private _currentSceneUrl;
  71076. private _db;
  71077. private _enableSceneOffline;
  71078. private _enableTexturesOffline;
  71079. private _manifestVersionFound;
  71080. private _mustUpdateRessources;
  71081. private _hasReachedQuota;
  71082. private _isSupported;
  71083. private _idbFactory;
  71084. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71085. private static IsUASupportingBlobStorage;
  71086. /**
  71087. * Gets a boolean indicating if Database storate is enabled (off by default)
  71088. */
  71089. static IDBStorageEnabled: boolean;
  71090. /**
  71091. * Gets a boolean indicating if scene must be saved in the database
  71092. */
  71093. get enableSceneOffline(): boolean;
  71094. /**
  71095. * Gets a boolean indicating if textures must be saved in the database
  71096. */
  71097. get enableTexturesOffline(): boolean;
  71098. /**
  71099. * Creates a new Database
  71100. * @param urlToScene defines the url to load the scene
  71101. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71102. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71103. */
  71104. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71105. private static _ParseURL;
  71106. private static _ReturnFullUrlLocation;
  71107. private _checkManifestFile;
  71108. /**
  71109. * Open the database and make it available
  71110. * @param successCallback defines the callback to call on success
  71111. * @param errorCallback defines the callback to call on error
  71112. */
  71113. open(successCallback: () => void, errorCallback: () => void): void;
  71114. /**
  71115. * Loads an image from the database
  71116. * @param url defines the url to load from
  71117. * @param image defines the target DOM image
  71118. */
  71119. loadImage(url: string, image: HTMLImageElement): void;
  71120. private _loadImageFromDBAsync;
  71121. private _saveImageIntoDBAsync;
  71122. private _checkVersionFromDB;
  71123. private _loadVersionFromDBAsync;
  71124. private _saveVersionIntoDBAsync;
  71125. /**
  71126. * Loads a file from database
  71127. * @param url defines the URL to load from
  71128. * @param sceneLoaded defines a callback to call on success
  71129. * @param progressCallBack defines a callback to call when progress changed
  71130. * @param errorCallback defines a callback to call on error
  71131. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71132. */
  71133. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71134. private _loadFileAsync;
  71135. private _saveFileAsync;
  71136. /**
  71137. * Validates if xhr data is correct
  71138. * @param xhr defines the request to validate
  71139. * @param dataType defines the expected data type
  71140. * @returns true if data is correct
  71141. */
  71142. private static _ValidateXHRData;
  71143. }
  71144. }
  71145. declare module "babylonjs/Offline/index" {
  71146. export * from "babylonjs/Offline/database";
  71147. export * from "babylonjs/Offline/IOfflineProvider";
  71148. }
  71149. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71150. /** @hidden */
  71151. export var gpuUpdateParticlesPixelShader: {
  71152. name: string;
  71153. shader: string;
  71154. };
  71155. }
  71156. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71157. /** @hidden */
  71158. export var gpuUpdateParticlesVertexShader: {
  71159. name: string;
  71160. shader: string;
  71161. };
  71162. }
  71163. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71164. /** @hidden */
  71165. export var clipPlaneFragmentDeclaration2: {
  71166. name: string;
  71167. shader: string;
  71168. };
  71169. }
  71170. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71171. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71172. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71173. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71174. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71175. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71176. /** @hidden */
  71177. export var gpuRenderParticlesPixelShader: {
  71178. name: string;
  71179. shader: string;
  71180. };
  71181. }
  71182. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71183. /** @hidden */
  71184. export var clipPlaneVertexDeclaration2: {
  71185. name: string;
  71186. shader: string;
  71187. };
  71188. }
  71189. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71190. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71191. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71192. /** @hidden */
  71193. export var gpuRenderParticlesVertexShader: {
  71194. name: string;
  71195. shader: string;
  71196. };
  71197. }
  71198. declare module "babylonjs/Particles/gpuParticleSystem" {
  71199. import { Nullable } from "babylonjs/types";
  71200. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71201. import { Observable } from "babylonjs/Misc/observable";
  71202. import { Matrix } from "babylonjs/Maths/math.vector";
  71203. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71204. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71205. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71206. import { IDisposable } from "babylonjs/scene";
  71207. import { Effect } from "babylonjs/Materials/effect";
  71208. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71209. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71210. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71211. import { Scene } from "babylonjs/scene";
  71212. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71213. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71214. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71215. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71216. /**
  71217. * This represents a GPU particle system in Babylon
  71218. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71219. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71220. */
  71221. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71222. /**
  71223. * The layer mask we are rendering the particles through.
  71224. */
  71225. layerMask: number;
  71226. private _capacity;
  71227. private _activeCount;
  71228. private _currentActiveCount;
  71229. private _accumulatedCount;
  71230. private _renderEffect;
  71231. private _updateEffect;
  71232. private _buffer0;
  71233. private _buffer1;
  71234. private _spriteBuffer;
  71235. private _updateVAO;
  71236. private _renderVAO;
  71237. private _targetIndex;
  71238. private _sourceBuffer;
  71239. private _targetBuffer;
  71240. private _currentRenderId;
  71241. private _started;
  71242. private _stopped;
  71243. private _timeDelta;
  71244. private _randomTexture;
  71245. private _randomTexture2;
  71246. private _attributesStrideSize;
  71247. private _updateEffectOptions;
  71248. private _randomTextureSize;
  71249. private _actualFrame;
  71250. private _customEffect;
  71251. private readonly _rawTextureWidth;
  71252. /**
  71253. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71254. */
  71255. static get IsSupported(): boolean;
  71256. /**
  71257. * An event triggered when the system is disposed.
  71258. */
  71259. onDisposeObservable: Observable<IParticleSystem>;
  71260. /**
  71261. * Gets the maximum number of particles active at the same time.
  71262. * @returns The max number of active particles.
  71263. */
  71264. getCapacity(): number;
  71265. /**
  71266. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71267. * to override the particles.
  71268. */
  71269. forceDepthWrite: boolean;
  71270. /**
  71271. * Gets or set the number of active particles
  71272. */
  71273. get activeParticleCount(): number;
  71274. set activeParticleCount(value: number);
  71275. private _preWarmDone;
  71276. /**
  71277. * Specifies if the particles are updated in emitter local space or world space.
  71278. */
  71279. isLocal: boolean;
  71280. /** Gets or sets a matrix to use to compute projection */
  71281. defaultProjectionMatrix: Matrix;
  71282. /**
  71283. * Is this system ready to be used/rendered
  71284. * @return true if the system is ready
  71285. */
  71286. isReady(): boolean;
  71287. /**
  71288. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71289. * @returns True if it has been started, otherwise false.
  71290. */
  71291. isStarted(): boolean;
  71292. /**
  71293. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71294. * @returns True if it has been stopped, otherwise false.
  71295. */
  71296. isStopped(): boolean;
  71297. /**
  71298. * Gets a boolean indicating that the system is stopping
  71299. * @returns true if the system is currently stopping
  71300. */
  71301. isStopping(): boolean;
  71302. /**
  71303. * Gets the number of particles active at the same time.
  71304. * @returns The number of active particles.
  71305. */
  71306. getActiveCount(): number;
  71307. /**
  71308. * Starts the particle system and begins to emit
  71309. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71310. */
  71311. start(delay?: number): void;
  71312. /**
  71313. * Stops the particle system.
  71314. */
  71315. stop(): void;
  71316. /**
  71317. * Remove all active particles
  71318. */
  71319. reset(): void;
  71320. /**
  71321. * Returns the string "GPUParticleSystem"
  71322. * @returns a string containing the class name
  71323. */
  71324. getClassName(): string;
  71325. /**
  71326. * Gets the custom effect used to render the particles
  71327. * @param blendMode Blend mode for which the effect should be retrieved
  71328. * @returns The effect
  71329. */
  71330. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71331. /**
  71332. * Sets the custom effect used to render the particles
  71333. * @param effect The effect to set
  71334. * @param blendMode Blend mode for which the effect should be set
  71335. */
  71336. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71337. /** @hidden */
  71338. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71339. /**
  71340. * Observable that will be called just before the particles are drawn
  71341. */
  71342. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71343. /**
  71344. * Gets the name of the particle vertex shader
  71345. */
  71346. get vertexShaderName(): string;
  71347. private _colorGradientsTexture;
  71348. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71349. /**
  71350. * Adds a new color gradient
  71351. * @param gradient defines the gradient to use (between 0 and 1)
  71352. * @param color1 defines the color to affect to the specified gradient
  71353. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71354. * @returns the current particle system
  71355. */
  71356. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71357. private _refreshColorGradient;
  71358. /** Force the system to rebuild all gradients that need to be resync */
  71359. forceRefreshGradients(): void;
  71360. /**
  71361. * Remove a specific color gradient
  71362. * @param gradient defines the gradient to remove
  71363. * @returns the current particle system
  71364. */
  71365. removeColorGradient(gradient: number): GPUParticleSystem;
  71366. private _angularSpeedGradientsTexture;
  71367. private _sizeGradientsTexture;
  71368. private _velocityGradientsTexture;
  71369. private _limitVelocityGradientsTexture;
  71370. private _dragGradientsTexture;
  71371. private _addFactorGradient;
  71372. /**
  71373. * Adds a new size gradient
  71374. * @param gradient defines the gradient to use (between 0 and 1)
  71375. * @param factor defines the size factor to affect to the specified gradient
  71376. * @returns the current particle system
  71377. */
  71378. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71379. /**
  71380. * Remove a specific size gradient
  71381. * @param gradient defines the gradient to remove
  71382. * @returns the current particle system
  71383. */
  71384. removeSizeGradient(gradient: number): GPUParticleSystem;
  71385. private _refreshFactorGradient;
  71386. /**
  71387. * Adds a new angular speed gradient
  71388. * @param gradient defines the gradient to use (between 0 and 1)
  71389. * @param factor defines the angular speed to affect to the specified gradient
  71390. * @returns the current particle system
  71391. */
  71392. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71393. /**
  71394. * Remove a specific angular speed gradient
  71395. * @param gradient defines the gradient to remove
  71396. * @returns the current particle system
  71397. */
  71398. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71399. /**
  71400. * Adds a new velocity gradient
  71401. * @param gradient defines the gradient to use (between 0 and 1)
  71402. * @param factor defines the velocity to affect to the specified gradient
  71403. * @returns the current particle system
  71404. */
  71405. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71406. /**
  71407. * Remove a specific velocity gradient
  71408. * @param gradient defines the gradient to remove
  71409. * @returns the current particle system
  71410. */
  71411. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71412. /**
  71413. * Adds a new limit velocity gradient
  71414. * @param gradient defines the gradient to use (between 0 and 1)
  71415. * @param factor defines the limit velocity value to affect to the specified gradient
  71416. * @returns the current particle system
  71417. */
  71418. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71419. /**
  71420. * Remove a specific limit velocity gradient
  71421. * @param gradient defines the gradient to remove
  71422. * @returns the current particle system
  71423. */
  71424. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71425. /**
  71426. * Adds a new drag gradient
  71427. * @param gradient defines the gradient to use (between 0 and 1)
  71428. * @param factor defines the drag value to affect to the specified gradient
  71429. * @returns the current particle system
  71430. */
  71431. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71432. /**
  71433. * Remove a specific drag gradient
  71434. * @param gradient defines the gradient to remove
  71435. * @returns the current particle system
  71436. */
  71437. removeDragGradient(gradient: number): GPUParticleSystem;
  71438. /**
  71439. * Not supported by GPUParticleSystem
  71440. * @param gradient defines the gradient to use (between 0 and 1)
  71441. * @param factor defines the emit rate value to affect to the specified gradient
  71442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71443. * @returns the current particle system
  71444. */
  71445. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71446. /**
  71447. * Not supported by GPUParticleSystem
  71448. * @param gradient defines the gradient to remove
  71449. * @returns the current particle system
  71450. */
  71451. removeEmitRateGradient(gradient: number): IParticleSystem;
  71452. /**
  71453. * Not supported by GPUParticleSystem
  71454. * @param gradient defines the gradient to use (between 0 and 1)
  71455. * @param factor defines the start size value to affect to the specified gradient
  71456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71457. * @returns the current particle system
  71458. */
  71459. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71460. /**
  71461. * Not supported by GPUParticleSystem
  71462. * @param gradient defines the gradient to remove
  71463. * @returns the current particle system
  71464. */
  71465. removeStartSizeGradient(gradient: number): IParticleSystem;
  71466. /**
  71467. * Not supported by GPUParticleSystem
  71468. * @param gradient defines the gradient to use (between 0 and 1)
  71469. * @param min defines the color remap minimal range
  71470. * @param max defines the color remap maximal range
  71471. * @returns the current particle system
  71472. */
  71473. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71474. /**
  71475. * Not supported by GPUParticleSystem
  71476. * @param gradient defines the gradient to remove
  71477. * @returns the current particle system
  71478. */
  71479. removeColorRemapGradient(): IParticleSystem;
  71480. /**
  71481. * Not supported by GPUParticleSystem
  71482. * @param gradient defines the gradient to use (between 0 and 1)
  71483. * @param min defines the alpha remap minimal range
  71484. * @param max defines the alpha remap maximal range
  71485. * @returns the current particle system
  71486. */
  71487. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71488. /**
  71489. * Not supported by GPUParticleSystem
  71490. * @param gradient defines the gradient to remove
  71491. * @returns the current particle system
  71492. */
  71493. removeAlphaRemapGradient(): IParticleSystem;
  71494. /**
  71495. * Not supported by GPUParticleSystem
  71496. * @param gradient defines the gradient to use (between 0 and 1)
  71497. * @param color defines the color to affect to the specified gradient
  71498. * @returns the current particle system
  71499. */
  71500. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71501. /**
  71502. * Not supported by GPUParticleSystem
  71503. * @param gradient defines the gradient to remove
  71504. * @returns the current particle system
  71505. */
  71506. removeRampGradient(): IParticleSystem;
  71507. /**
  71508. * Not supported by GPUParticleSystem
  71509. * @returns the list of ramp gradients
  71510. */
  71511. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71512. /**
  71513. * Not supported by GPUParticleSystem
  71514. * Gets or sets a boolean indicating that ramp gradients must be used
  71515. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71516. */
  71517. get useRampGradients(): boolean;
  71518. set useRampGradients(value: boolean);
  71519. /**
  71520. * Not supported by GPUParticleSystem
  71521. * @param gradient defines the gradient to use (between 0 and 1)
  71522. * @param factor defines the life time factor to affect to the specified gradient
  71523. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71524. * @returns the current particle system
  71525. */
  71526. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71527. /**
  71528. * Not supported by GPUParticleSystem
  71529. * @param gradient defines the gradient to remove
  71530. * @returns the current particle system
  71531. */
  71532. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71533. /**
  71534. * Instantiates a GPU particle system.
  71535. * 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.
  71536. * @param name The name of the particle system
  71537. * @param options The options used to create the system
  71538. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71539. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71540. * @param customEffect a custom effect used to change the way particles are rendered by default
  71541. */
  71542. constructor(name: string, options: Partial<{
  71543. capacity: number;
  71544. randomTextureSize: number;
  71545. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71546. protected _reset(): void;
  71547. private _createUpdateVAO;
  71548. private _createRenderVAO;
  71549. private _initialize;
  71550. /** @hidden */
  71551. _recreateUpdateEffect(): void;
  71552. private _getEffect;
  71553. /**
  71554. * Fill the defines array according to the current settings of the particle system
  71555. * @param defines Array to be updated
  71556. * @param blendMode blend mode to take into account when updating the array
  71557. */
  71558. fillDefines(defines: Array<string>, blendMode?: number): void;
  71559. /**
  71560. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71561. * @param uniforms Uniforms array to fill
  71562. * @param attributes Attributes array to fill
  71563. * @param samplers Samplers array to fill
  71564. */
  71565. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71566. /** @hidden */
  71567. _recreateRenderEffect(): Effect;
  71568. /**
  71569. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71570. * @param preWarm defines if we are in the pre-warmimg phase
  71571. */
  71572. animate(preWarm?: boolean): void;
  71573. private _createFactorGradientTexture;
  71574. private _createSizeGradientTexture;
  71575. private _createAngularSpeedGradientTexture;
  71576. private _createVelocityGradientTexture;
  71577. private _createLimitVelocityGradientTexture;
  71578. private _createDragGradientTexture;
  71579. private _createColorGradientTexture;
  71580. /**
  71581. * Renders the particle system in its current state
  71582. * @param preWarm defines if the system should only update the particles but not render them
  71583. * @returns the current number of particles
  71584. */
  71585. render(preWarm?: boolean): number;
  71586. /**
  71587. * Rebuilds the particle system
  71588. */
  71589. rebuild(): void;
  71590. private _releaseBuffers;
  71591. private _releaseVAOs;
  71592. /**
  71593. * Disposes the particle system and free the associated resources
  71594. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71595. */
  71596. dispose(disposeTexture?: boolean): void;
  71597. /**
  71598. * Clones the particle system.
  71599. * @param name The name of the cloned object
  71600. * @param newEmitter The new emitter to use
  71601. * @returns the cloned particle system
  71602. */
  71603. clone(name: string, newEmitter: any): GPUParticleSystem;
  71604. /**
  71605. * Serializes the particle system to a JSON object
  71606. * @param serializeTexture defines if the texture must be serialized as well
  71607. * @returns the JSON object
  71608. */
  71609. serialize(serializeTexture?: boolean): any;
  71610. /**
  71611. * Parses a JSON object to create a GPU particle system.
  71612. * @param parsedParticleSystem The JSON object to parse
  71613. * @param sceneOrEngine The scene or the engine to create the particle system in
  71614. * @param rootUrl The root url to use to load external dependencies like texture
  71615. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71616. * @returns the parsed GPU particle system
  71617. */
  71618. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71619. }
  71620. }
  71621. declare module "babylonjs/Particles/particleSystemSet" {
  71622. import { Nullable } from "babylonjs/types";
  71623. import { Color3 } from "babylonjs/Maths/math.color";
  71624. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71626. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71627. import { Scene, IDisposable } from "babylonjs/scene";
  71628. /**
  71629. * Represents a set of particle systems working together to create a specific effect
  71630. */
  71631. export class ParticleSystemSet implements IDisposable {
  71632. /**
  71633. * Gets or sets base Assets URL
  71634. */
  71635. static BaseAssetsUrl: string;
  71636. private _emitterCreationOptions;
  71637. private _emitterNode;
  71638. /**
  71639. * Gets the particle system list
  71640. */
  71641. systems: IParticleSystem[];
  71642. /**
  71643. * Gets the emitter node used with this set
  71644. */
  71645. get emitterNode(): Nullable<TransformNode>;
  71646. /**
  71647. * Creates a new emitter mesh as a sphere
  71648. * @param options defines the options used to create the sphere
  71649. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71650. * @param scene defines the hosting scene
  71651. */
  71652. setEmitterAsSphere(options: {
  71653. diameter: number;
  71654. segments: number;
  71655. color: Color3;
  71656. }, renderingGroupId: number, scene: Scene): void;
  71657. /**
  71658. * Starts all particle systems of the set
  71659. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71660. */
  71661. start(emitter?: AbstractMesh): void;
  71662. /**
  71663. * Release all associated resources
  71664. */
  71665. dispose(): void;
  71666. /**
  71667. * Serialize the set into a JSON compatible object
  71668. * @param serializeTexture defines if the texture must be serialized as well
  71669. * @returns a JSON compatible representation of the set
  71670. */
  71671. serialize(serializeTexture?: boolean): any;
  71672. /**
  71673. * Parse a new ParticleSystemSet from a serialized source
  71674. * @param data defines a JSON compatible representation of the set
  71675. * @param scene defines the hosting scene
  71676. * @param gpu defines if we want GPU particles or CPU particles
  71677. * @returns a new ParticleSystemSet
  71678. */
  71679. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71680. }
  71681. }
  71682. declare module "babylonjs/Particles/particleHelper" {
  71683. import { Nullable } from "babylonjs/types";
  71684. import { Scene } from "babylonjs/scene";
  71685. import { Vector3 } from "babylonjs/Maths/math.vector";
  71686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71687. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71688. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71689. /**
  71690. * This class is made for on one-liner static method to help creating particle system set.
  71691. */
  71692. export class ParticleHelper {
  71693. /**
  71694. * Gets or sets base Assets URL
  71695. */
  71696. static BaseAssetsUrl: string;
  71697. /** Define the Url to load snippets */
  71698. static SnippetUrl: string;
  71699. /**
  71700. * Create a default particle system that you can tweak
  71701. * @param emitter defines the emitter to use
  71702. * @param capacity defines the system capacity (default is 500 particles)
  71703. * @param scene defines the hosting scene
  71704. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71705. * @returns the new Particle system
  71706. */
  71707. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71708. /**
  71709. * This is the main static method (one-liner) of this helper to create different particle systems
  71710. * @param type This string represents the type to the particle system to create
  71711. * @param scene The scene where the particle system should live
  71712. * @param gpu If the system will use gpu
  71713. * @returns the ParticleSystemSet created
  71714. */
  71715. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71716. /**
  71717. * Static function used to export a particle system to a ParticleSystemSet variable.
  71718. * Please note that the emitter shape is not exported
  71719. * @param systems defines the particle systems to export
  71720. * @returns the created particle system set
  71721. */
  71722. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71723. /**
  71724. * Creates a particle system from a snippet saved in a remote file
  71725. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71726. * @param url defines the url to load from
  71727. * @param scene defines the hosting scene
  71728. * @param gpu If the system will use gpu
  71729. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71730. * @returns a promise that will resolve to the new particle system
  71731. */
  71732. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71733. /**
  71734. * Creates a particle system from a snippet saved by the particle system editor
  71735. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71736. * @param scene defines the hosting scene
  71737. * @param gpu If the system will use gpu
  71738. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71739. * @returns a promise that will resolve to the new particle system
  71740. */
  71741. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71742. }
  71743. }
  71744. declare module "babylonjs/Particles/particleSystemComponent" {
  71745. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71746. import { Effect } from "babylonjs/Materials/effect";
  71747. import "babylonjs/Shaders/particles.vertex";
  71748. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71749. module "babylonjs/Engines/engine" {
  71750. interface Engine {
  71751. /**
  71752. * Create an effect to use with particle systems.
  71753. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71754. * the particle system for which you want to create a custom effect in the last parameter
  71755. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71756. * @param uniformsNames defines a list of attribute names
  71757. * @param samplers defines an array of string used to represent textures
  71758. * @param defines defines the string containing the defines to use to compile the shaders
  71759. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71760. * @param onCompiled defines a function to call when the effect creation is successful
  71761. * @param onError defines a function to call when the effect creation has failed
  71762. * @param particleSystem the particle system you want to create the effect for
  71763. * @returns the new Effect
  71764. */
  71765. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71766. }
  71767. }
  71768. module "babylonjs/Meshes/mesh" {
  71769. interface Mesh {
  71770. /**
  71771. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71772. * @returns an array of IParticleSystem
  71773. */
  71774. getEmittedParticleSystems(): IParticleSystem[];
  71775. /**
  71776. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71777. * @returns an array of IParticleSystem
  71778. */
  71779. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71780. }
  71781. }
  71782. }
  71783. declare module "babylonjs/Particles/pointsCloudSystem" {
  71784. import { Color4 } from "babylonjs/Maths/math";
  71785. import { Mesh } from "babylonjs/Meshes/mesh";
  71786. import { Scene, IDisposable } from "babylonjs/scene";
  71787. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71788. /** Defines the 4 color options */
  71789. export enum PointColor {
  71790. /** color value */
  71791. Color = 2,
  71792. /** uv value */
  71793. UV = 1,
  71794. /** random value */
  71795. Random = 0,
  71796. /** stated value */
  71797. Stated = 3
  71798. }
  71799. /**
  71800. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71801. * 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.
  71802. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71803. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71804. *
  71805. * Full documentation here : TO BE ENTERED
  71806. */
  71807. export class PointsCloudSystem implements IDisposable {
  71808. /**
  71809. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71810. * Example : var p = SPS.particles[i];
  71811. */
  71812. particles: CloudPoint[];
  71813. /**
  71814. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71815. */
  71816. nbParticles: number;
  71817. /**
  71818. * This a counter for your own usage. It's not set by any SPS functions.
  71819. */
  71820. counter: number;
  71821. /**
  71822. * The PCS name. This name is also given to the underlying mesh.
  71823. */
  71824. name: string;
  71825. /**
  71826. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71827. */
  71828. mesh: Mesh;
  71829. /**
  71830. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71831. * Please read :
  71832. */
  71833. vars: any;
  71834. /**
  71835. * @hidden
  71836. */
  71837. _size: number;
  71838. private _scene;
  71839. private _promises;
  71840. private _positions;
  71841. private _indices;
  71842. private _normals;
  71843. private _colors;
  71844. private _uvs;
  71845. private _indices32;
  71846. private _positions32;
  71847. private _colors32;
  71848. private _uvs32;
  71849. private _updatable;
  71850. private _isVisibilityBoxLocked;
  71851. private _alwaysVisible;
  71852. private _groups;
  71853. private _groupCounter;
  71854. private _computeParticleColor;
  71855. private _computeParticleTexture;
  71856. private _computeParticleRotation;
  71857. private _computeBoundingBox;
  71858. private _isReady;
  71859. /**
  71860. * Creates a PCS (Points Cloud System) object
  71861. * @param name (String) is the PCS name, this will be the underlying mesh name
  71862. * @param pointSize (number) is the size for each point
  71863. * @param scene (Scene) is the scene in which the PCS is added
  71864. * @param options defines the options of the PCS e.g.
  71865. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71866. */
  71867. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71868. updatable?: boolean;
  71869. });
  71870. /**
  71871. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71872. * If no points were added to the PCS, the returned mesh is just a single point.
  71873. * @returns a promise for the created mesh
  71874. */
  71875. buildMeshAsync(): Promise<Mesh>;
  71876. /**
  71877. * @hidden
  71878. */
  71879. private _buildMesh;
  71880. private _addParticle;
  71881. private _randomUnitVector;
  71882. private _getColorIndicesForCoord;
  71883. private _setPointsColorOrUV;
  71884. private _colorFromTexture;
  71885. private _calculateDensity;
  71886. /**
  71887. * Adds points to the PCS in random positions within a unit sphere
  71888. * @param nb (positive integer) the number of particles to be created from this model
  71889. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71890. * @returns the number of groups in the system
  71891. */
  71892. addPoints(nb: number, pointFunction?: any): number;
  71893. /**
  71894. * Adds points to the PCS from the surface of the model shape
  71895. * @param mesh is any Mesh object that will be used as a surface model for the points
  71896. * @param nb (positive integer) the number of particles to be created from this model
  71897. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71898. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71899. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71900. * @returns the number of groups in the system
  71901. */
  71902. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71903. /**
  71904. * Adds points to the PCS inside the model shape
  71905. * @param mesh is any Mesh object that will be used as a surface model for the points
  71906. * @param nb (positive integer) the number of particles to be created from this model
  71907. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71908. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71909. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71910. * @returns the number of groups in the system
  71911. */
  71912. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71913. /**
  71914. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71915. * This method calls `updateParticle()` for each particle of the SPS.
  71916. * For an animated SPS, it is usually called within the render loop.
  71917. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71918. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71919. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71920. * @returns the PCS.
  71921. */
  71922. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71923. /**
  71924. * Disposes the PCS.
  71925. */
  71926. dispose(): void;
  71927. /**
  71928. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71929. * doc :
  71930. * @returns the PCS.
  71931. */
  71932. refreshVisibleSize(): PointsCloudSystem;
  71933. /**
  71934. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71935. * @param size the size (float) of the visibility box
  71936. * note : this doesn't lock the PCS mesh bounding box.
  71937. * doc :
  71938. */
  71939. setVisibilityBox(size: number): void;
  71940. /**
  71941. * Gets whether the PCS is always visible or not
  71942. * doc :
  71943. */
  71944. get isAlwaysVisible(): boolean;
  71945. /**
  71946. * Sets the PCS as always visible or not
  71947. * doc :
  71948. */
  71949. set isAlwaysVisible(val: boolean);
  71950. /**
  71951. * Tells to `setParticles()` to compute the particle rotations or not
  71952. * Default value : false. The PCS is faster when it's set to false
  71953. * Note : particle rotations are only applied to parent particles
  71954. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71955. */
  71956. set computeParticleRotation(val: boolean);
  71957. /**
  71958. * Tells to `setParticles()` to compute the particle colors or not.
  71959. * Default value : true. The PCS is faster when it's set to false.
  71960. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71961. */
  71962. set computeParticleColor(val: boolean);
  71963. set computeParticleTexture(val: boolean);
  71964. /**
  71965. * Gets if `setParticles()` computes the particle colors or not.
  71966. * Default value : false. The PCS is faster when it's set to false.
  71967. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71968. */
  71969. get computeParticleColor(): boolean;
  71970. /**
  71971. * Gets if `setParticles()` computes the particle textures or not.
  71972. * Default value : false. The PCS is faster when it's set to false.
  71973. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71974. */
  71975. get computeParticleTexture(): boolean;
  71976. /**
  71977. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71978. */
  71979. set computeBoundingBox(val: boolean);
  71980. /**
  71981. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71982. */
  71983. get computeBoundingBox(): boolean;
  71984. /**
  71985. * This function does nothing. It may be overwritten to set all the particle first values.
  71986. * The PCS doesn't call this function, you may have to call it by your own.
  71987. * doc :
  71988. */
  71989. initParticles(): void;
  71990. /**
  71991. * This function does nothing. It may be overwritten to recycle a particle
  71992. * The PCS doesn't call this function, you can to call it
  71993. * doc :
  71994. * @param particle The particle to recycle
  71995. * @returns the recycled particle
  71996. */
  71997. recycleParticle(particle: CloudPoint): CloudPoint;
  71998. /**
  71999. * Updates a particle : this function should be overwritten by the user.
  72000. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72001. * doc :
  72002. * @example : just set a particle position or velocity and recycle conditions
  72003. * @param particle The particle to update
  72004. * @returns the updated particle
  72005. */
  72006. updateParticle(particle: CloudPoint): CloudPoint;
  72007. /**
  72008. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72009. * This does nothing and may be overwritten by the user.
  72010. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72011. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72012. * @param update the boolean update value actually passed to setParticles()
  72013. */
  72014. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72015. /**
  72016. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72017. * This will be passed three parameters.
  72018. * This does nothing and may be overwritten by the user.
  72019. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72020. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72021. * @param update the boolean update value actually passed to setParticles()
  72022. */
  72023. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72024. }
  72025. }
  72026. declare module "babylonjs/Particles/cloudPoint" {
  72027. import { Nullable } from "babylonjs/types";
  72028. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  72029. import { Mesh } from "babylonjs/Meshes/mesh";
  72030. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  72031. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  72032. /**
  72033. * Represents one particle of a points cloud system.
  72034. */
  72035. export class CloudPoint {
  72036. /**
  72037. * particle global index
  72038. */
  72039. idx: number;
  72040. /**
  72041. * The color of the particle
  72042. */
  72043. color: Nullable<Color4>;
  72044. /**
  72045. * The world space position of the particle.
  72046. */
  72047. position: Vector3;
  72048. /**
  72049. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72050. */
  72051. rotation: Vector3;
  72052. /**
  72053. * The world space rotation quaternion of the particle.
  72054. */
  72055. rotationQuaternion: Nullable<Quaternion>;
  72056. /**
  72057. * The uv of the particle.
  72058. */
  72059. uv: Nullable<Vector2>;
  72060. /**
  72061. * The current speed of the particle.
  72062. */
  72063. velocity: Vector3;
  72064. /**
  72065. * The pivot point in the particle local space.
  72066. */
  72067. pivot: Vector3;
  72068. /**
  72069. * Must the particle be translated from its pivot point in its local space ?
  72070. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72071. * Default : false
  72072. */
  72073. translateFromPivot: boolean;
  72074. /**
  72075. * Index of this particle in the global "positions" array (Internal use)
  72076. * @hidden
  72077. */
  72078. _pos: number;
  72079. /**
  72080. * @hidden Index of this particle in the global "indices" array (Internal use)
  72081. */
  72082. _ind: number;
  72083. /**
  72084. * Group this particle belongs to
  72085. */
  72086. _group: PointsGroup;
  72087. /**
  72088. * Group id of this particle
  72089. */
  72090. groupId: number;
  72091. /**
  72092. * Index of the particle in its group id (Internal use)
  72093. */
  72094. idxInGroup: number;
  72095. /**
  72096. * @hidden Particle BoundingInfo object (Internal use)
  72097. */
  72098. _boundingInfo: BoundingInfo;
  72099. /**
  72100. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72101. */
  72102. _pcs: PointsCloudSystem;
  72103. /**
  72104. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72105. */
  72106. _stillInvisible: boolean;
  72107. /**
  72108. * @hidden Last computed particle rotation matrix
  72109. */
  72110. _rotationMatrix: number[];
  72111. /**
  72112. * Parent particle Id, if any.
  72113. * Default null.
  72114. */
  72115. parentId: Nullable<number>;
  72116. /**
  72117. * @hidden Internal global position in the PCS.
  72118. */
  72119. _globalPosition: Vector3;
  72120. /**
  72121. * Creates a Point Cloud object.
  72122. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72123. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72124. * @param group (PointsGroup) is the group the particle belongs to
  72125. * @param groupId (integer) is the group identifier in the PCS.
  72126. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72127. * @param pcs defines the PCS it is associated to
  72128. */
  72129. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72130. /**
  72131. * get point size
  72132. */
  72133. get size(): Vector3;
  72134. /**
  72135. * Set point size
  72136. */
  72137. set size(scale: Vector3);
  72138. /**
  72139. * Legacy support, changed quaternion to rotationQuaternion
  72140. */
  72141. get quaternion(): Nullable<Quaternion>;
  72142. /**
  72143. * Legacy support, changed quaternion to rotationQuaternion
  72144. */
  72145. set quaternion(q: Nullable<Quaternion>);
  72146. /**
  72147. * Returns a boolean. True if the particle intersects a mesh, else false
  72148. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72149. * @param target is the object (point or mesh) what the intersection is computed against
  72150. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72151. * @returns true if it intersects
  72152. */
  72153. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72154. /**
  72155. * get the rotation matrix of the particle
  72156. * @hidden
  72157. */
  72158. getRotationMatrix(m: Matrix): void;
  72159. }
  72160. /**
  72161. * Represents a group of points in a points cloud system
  72162. * * PCS internal tool, don't use it manually.
  72163. */
  72164. export class PointsGroup {
  72165. /**
  72166. * The group id
  72167. * @hidden
  72168. */
  72169. groupID: number;
  72170. /**
  72171. * image data for group (internal use)
  72172. * @hidden
  72173. */
  72174. _groupImageData: Nullable<ArrayBufferView>;
  72175. /**
  72176. * Image Width (internal use)
  72177. * @hidden
  72178. */
  72179. _groupImgWidth: number;
  72180. /**
  72181. * Image Height (internal use)
  72182. * @hidden
  72183. */
  72184. _groupImgHeight: number;
  72185. /**
  72186. * Custom position function (internal use)
  72187. * @hidden
  72188. */
  72189. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72190. /**
  72191. * density per facet for surface points
  72192. * @hidden
  72193. */
  72194. _groupDensity: number[];
  72195. /**
  72196. * Only when points are colored by texture carries pointer to texture list array
  72197. * @hidden
  72198. */
  72199. _textureNb: number;
  72200. /**
  72201. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72202. * PCS internal tool, don't use it manually.
  72203. * @hidden
  72204. */
  72205. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72206. }
  72207. }
  72208. declare module "babylonjs/Particles/index" {
  72209. export * from "babylonjs/Particles/baseParticleSystem";
  72210. export * from "babylonjs/Particles/EmitterTypes/index";
  72211. export * from "babylonjs/Particles/gpuParticleSystem";
  72212. export * from "babylonjs/Particles/IParticleSystem";
  72213. export * from "babylonjs/Particles/particle";
  72214. export * from "babylonjs/Particles/particleHelper";
  72215. export * from "babylonjs/Particles/particleSystem";
  72216. import "babylonjs/Particles/particleSystemComponent";
  72217. export * from "babylonjs/Particles/particleSystemComponent";
  72218. export * from "babylonjs/Particles/particleSystemSet";
  72219. export * from "babylonjs/Particles/solidParticle";
  72220. export * from "babylonjs/Particles/solidParticleSystem";
  72221. export * from "babylonjs/Particles/cloudPoint";
  72222. export * from "babylonjs/Particles/pointsCloudSystem";
  72223. export * from "babylonjs/Particles/subEmitter";
  72224. }
  72225. declare module "babylonjs/Physics/physicsEngineComponent" {
  72226. import { Nullable } from "babylonjs/types";
  72227. import { Observable, Observer } from "babylonjs/Misc/observable";
  72228. import { Vector3 } from "babylonjs/Maths/math.vector";
  72229. import { Mesh } from "babylonjs/Meshes/mesh";
  72230. import { ISceneComponent } from "babylonjs/sceneComponent";
  72231. import { Scene } from "babylonjs/scene";
  72232. import { Node } from "babylonjs/node";
  72233. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72234. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72235. module "babylonjs/scene" {
  72236. interface Scene {
  72237. /** @hidden (Backing field) */
  72238. _physicsEngine: Nullable<IPhysicsEngine>;
  72239. /** @hidden */
  72240. _physicsTimeAccumulator: number;
  72241. /**
  72242. * Gets the current physics engine
  72243. * @returns a IPhysicsEngine or null if none attached
  72244. */
  72245. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72246. /**
  72247. * Enables physics to the current scene
  72248. * @param gravity defines the scene's gravity for the physics engine
  72249. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72250. * @return a boolean indicating if the physics engine was initialized
  72251. */
  72252. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72253. /**
  72254. * Disables and disposes the physics engine associated with the scene
  72255. */
  72256. disablePhysicsEngine(): void;
  72257. /**
  72258. * Gets a boolean indicating if there is an active physics engine
  72259. * @returns a boolean indicating if there is an active physics engine
  72260. */
  72261. isPhysicsEnabled(): boolean;
  72262. /**
  72263. * Deletes a physics compound impostor
  72264. * @param compound defines the compound to delete
  72265. */
  72266. deleteCompoundImpostor(compound: any): void;
  72267. /**
  72268. * An event triggered when physic simulation is about to be run
  72269. */
  72270. onBeforePhysicsObservable: Observable<Scene>;
  72271. /**
  72272. * An event triggered when physic simulation has been done
  72273. */
  72274. onAfterPhysicsObservable: Observable<Scene>;
  72275. }
  72276. }
  72277. module "babylonjs/Meshes/abstractMesh" {
  72278. interface AbstractMesh {
  72279. /** @hidden */
  72280. _physicsImpostor: Nullable<PhysicsImpostor>;
  72281. /**
  72282. * Gets or sets impostor used for physic simulation
  72283. * @see https://doc.babylonjs.com/features/physics_engine
  72284. */
  72285. physicsImpostor: Nullable<PhysicsImpostor>;
  72286. /**
  72287. * Gets the current physics impostor
  72288. * @see https://doc.babylonjs.com/features/physics_engine
  72289. * @returns a physics impostor or null
  72290. */
  72291. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72292. /** Apply a physic impulse to the mesh
  72293. * @param force defines the force to apply
  72294. * @param contactPoint defines where to apply the force
  72295. * @returns the current mesh
  72296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72297. */
  72298. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72299. /**
  72300. * Creates a physic joint between two meshes
  72301. * @param otherMesh defines the other mesh to use
  72302. * @param pivot1 defines the pivot to use on this mesh
  72303. * @param pivot2 defines the pivot to use on the other mesh
  72304. * @param options defines additional options (can be plugin dependent)
  72305. * @returns the current mesh
  72306. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72307. */
  72308. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72309. /** @hidden */
  72310. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72311. }
  72312. }
  72313. /**
  72314. * Defines the physics engine scene component responsible to manage a physics engine
  72315. */
  72316. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72317. /**
  72318. * The component name helpful to identify the component in the list of scene components.
  72319. */
  72320. readonly name: string;
  72321. /**
  72322. * The scene the component belongs to.
  72323. */
  72324. scene: Scene;
  72325. /**
  72326. * Creates a new instance of the component for the given scene
  72327. * @param scene Defines the scene to register the component in
  72328. */
  72329. constructor(scene: Scene);
  72330. /**
  72331. * Registers the component in a given scene
  72332. */
  72333. register(): void;
  72334. /**
  72335. * Rebuilds the elements related to this component in case of
  72336. * context lost for instance.
  72337. */
  72338. rebuild(): void;
  72339. /**
  72340. * Disposes the component and the associated ressources
  72341. */
  72342. dispose(): void;
  72343. }
  72344. }
  72345. declare module "babylonjs/Physics/physicsHelper" {
  72346. import { Nullable } from "babylonjs/types";
  72347. import { Vector3 } from "babylonjs/Maths/math.vector";
  72348. import { Mesh } from "babylonjs/Meshes/mesh";
  72349. import { Scene } from "babylonjs/scene";
  72350. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72351. /**
  72352. * A helper for physics simulations
  72353. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72354. */
  72355. export class PhysicsHelper {
  72356. private _scene;
  72357. private _physicsEngine;
  72358. /**
  72359. * Initializes the Physics helper
  72360. * @param scene Babylon.js scene
  72361. */
  72362. constructor(scene: Scene);
  72363. /**
  72364. * Applies a radial explosion impulse
  72365. * @param origin the origin of the explosion
  72366. * @param radiusOrEventOptions the radius or the options of radial explosion
  72367. * @param strength the explosion strength
  72368. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72369. * @returns A physics radial explosion event, or null
  72370. */
  72371. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72372. /**
  72373. * Applies a radial explosion force
  72374. * @param origin the origin of the explosion
  72375. * @param radiusOrEventOptions the radius or the options of radial explosion
  72376. * @param strength the explosion strength
  72377. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72378. * @returns A physics radial explosion event, or null
  72379. */
  72380. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72381. /**
  72382. * Creates a gravitational field
  72383. * @param origin the origin of the explosion
  72384. * @param radiusOrEventOptions the radius or the options of radial explosion
  72385. * @param strength the explosion strength
  72386. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72387. * @returns A physics gravitational field event, or null
  72388. */
  72389. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72390. /**
  72391. * Creates a physics updraft event
  72392. * @param origin the origin of the updraft
  72393. * @param radiusOrEventOptions the radius or the options of the updraft
  72394. * @param strength the strength of the updraft
  72395. * @param height the height of the updraft
  72396. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72397. * @returns A physics updraft event, or null
  72398. */
  72399. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72400. /**
  72401. * Creates a physics vortex event
  72402. * @param origin the of the vortex
  72403. * @param radiusOrEventOptions the radius or the options of the vortex
  72404. * @param strength the strength of the vortex
  72405. * @param height the height of the vortex
  72406. * @returns a Physics vortex event, or null
  72407. * A physics vortex event or null
  72408. */
  72409. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72410. }
  72411. /**
  72412. * Represents a physics radial explosion event
  72413. */
  72414. class PhysicsRadialExplosionEvent {
  72415. private _scene;
  72416. private _options;
  72417. private _sphere;
  72418. private _dataFetched;
  72419. /**
  72420. * Initializes a radial explosioin event
  72421. * @param _scene BabylonJS scene
  72422. * @param _options The options for the vortex event
  72423. */
  72424. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72425. /**
  72426. * Returns the data related to the radial explosion event (sphere).
  72427. * @returns The radial explosion event data
  72428. */
  72429. getData(): PhysicsRadialExplosionEventData;
  72430. /**
  72431. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72432. * @param impostor A physics imposter
  72433. * @param origin the origin of the explosion
  72434. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72435. */
  72436. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72437. /**
  72438. * Triggers affecterd impostors callbacks
  72439. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72440. */
  72441. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72442. /**
  72443. * Disposes the sphere.
  72444. * @param force Specifies if the sphere should be disposed by force
  72445. */
  72446. dispose(force?: boolean): void;
  72447. /*** Helpers ***/
  72448. private _prepareSphere;
  72449. private _intersectsWithSphere;
  72450. }
  72451. /**
  72452. * Represents a gravitational field event
  72453. */
  72454. class PhysicsGravitationalFieldEvent {
  72455. private _physicsHelper;
  72456. private _scene;
  72457. private _origin;
  72458. private _options;
  72459. private _tickCallback;
  72460. private _sphere;
  72461. private _dataFetched;
  72462. /**
  72463. * Initializes the physics gravitational field event
  72464. * @param _physicsHelper A physics helper
  72465. * @param _scene BabylonJS scene
  72466. * @param _origin The origin position of the gravitational field event
  72467. * @param _options The options for the vortex event
  72468. */
  72469. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72470. /**
  72471. * Returns the data related to the gravitational field event (sphere).
  72472. * @returns A gravitational field event
  72473. */
  72474. getData(): PhysicsGravitationalFieldEventData;
  72475. /**
  72476. * Enables the gravitational field.
  72477. */
  72478. enable(): void;
  72479. /**
  72480. * Disables the gravitational field.
  72481. */
  72482. disable(): void;
  72483. /**
  72484. * Disposes the sphere.
  72485. * @param force The force to dispose from the gravitational field event
  72486. */
  72487. dispose(force?: boolean): void;
  72488. private _tick;
  72489. }
  72490. /**
  72491. * Represents a physics updraft event
  72492. */
  72493. class PhysicsUpdraftEvent {
  72494. private _scene;
  72495. private _origin;
  72496. private _options;
  72497. private _physicsEngine;
  72498. private _originTop;
  72499. private _originDirection;
  72500. private _tickCallback;
  72501. private _cylinder;
  72502. private _cylinderPosition;
  72503. private _dataFetched;
  72504. /**
  72505. * Initializes the physics updraft event
  72506. * @param _scene BabylonJS scene
  72507. * @param _origin The origin position of the updraft
  72508. * @param _options The options for the updraft event
  72509. */
  72510. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72511. /**
  72512. * Returns the data related to the updraft event (cylinder).
  72513. * @returns A physics updraft event
  72514. */
  72515. getData(): PhysicsUpdraftEventData;
  72516. /**
  72517. * Enables the updraft.
  72518. */
  72519. enable(): void;
  72520. /**
  72521. * Disables the updraft.
  72522. */
  72523. disable(): void;
  72524. /**
  72525. * Disposes the cylinder.
  72526. * @param force Specifies if the updraft should be disposed by force
  72527. */
  72528. dispose(force?: boolean): void;
  72529. private getImpostorHitData;
  72530. private _tick;
  72531. /*** Helpers ***/
  72532. private _prepareCylinder;
  72533. private _intersectsWithCylinder;
  72534. }
  72535. /**
  72536. * Represents a physics vortex event
  72537. */
  72538. class PhysicsVortexEvent {
  72539. private _scene;
  72540. private _origin;
  72541. private _options;
  72542. private _physicsEngine;
  72543. private _originTop;
  72544. private _tickCallback;
  72545. private _cylinder;
  72546. private _cylinderPosition;
  72547. private _dataFetched;
  72548. /**
  72549. * Initializes the physics vortex event
  72550. * @param _scene The BabylonJS scene
  72551. * @param _origin The origin position of the vortex
  72552. * @param _options The options for the vortex event
  72553. */
  72554. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72555. /**
  72556. * Returns the data related to the vortex event (cylinder).
  72557. * @returns The physics vortex event data
  72558. */
  72559. getData(): PhysicsVortexEventData;
  72560. /**
  72561. * Enables the vortex.
  72562. */
  72563. enable(): void;
  72564. /**
  72565. * Disables the cortex.
  72566. */
  72567. disable(): void;
  72568. /**
  72569. * Disposes the sphere.
  72570. * @param force
  72571. */
  72572. dispose(force?: boolean): void;
  72573. private getImpostorHitData;
  72574. private _tick;
  72575. /*** Helpers ***/
  72576. private _prepareCylinder;
  72577. private _intersectsWithCylinder;
  72578. }
  72579. /**
  72580. * Options fot the radial explosion event
  72581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72582. */
  72583. export class PhysicsRadialExplosionEventOptions {
  72584. /**
  72585. * The radius of the sphere for the radial explosion.
  72586. */
  72587. radius: number;
  72588. /**
  72589. * The strenth of the explosion.
  72590. */
  72591. strength: number;
  72592. /**
  72593. * The strenght of the force in correspondence to the distance of the affected object
  72594. */
  72595. falloff: PhysicsRadialImpulseFalloff;
  72596. /**
  72597. * Sphere options for the radial explosion.
  72598. */
  72599. sphere: {
  72600. segments: number;
  72601. diameter: number;
  72602. };
  72603. /**
  72604. * Sphere options for the radial explosion.
  72605. */
  72606. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72607. }
  72608. /**
  72609. * Options fot the updraft event
  72610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72611. */
  72612. export class PhysicsUpdraftEventOptions {
  72613. /**
  72614. * The radius of the cylinder for the vortex
  72615. */
  72616. radius: number;
  72617. /**
  72618. * The strenth of the updraft.
  72619. */
  72620. strength: number;
  72621. /**
  72622. * The height of the cylinder for the updraft.
  72623. */
  72624. height: number;
  72625. /**
  72626. * The mode for the the updraft.
  72627. */
  72628. updraftMode: PhysicsUpdraftMode;
  72629. }
  72630. /**
  72631. * Options fot the vortex event
  72632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72633. */
  72634. export class PhysicsVortexEventOptions {
  72635. /**
  72636. * The radius of the cylinder for the vortex
  72637. */
  72638. radius: number;
  72639. /**
  72640. * The strenth of the vortex.
  72641. */
  72642. strength: number;
  72643. /**
  72644. * The height of the cylinder for the vortex.
  72645. */
  72646. height: number;
  72647. /**
  72648. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72649. */
  72650. centripetalForceThreshold: number;
  72651. /**
  72652. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72653. */
  72654. centripetalForceMultiplier: number;
  72655. /**
  72656. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72657. */
  72658. centrifugalForceMultiplier: number;
  72659. /**
  72660. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72661. */
  72662. updraftForceMultiplier: number;
  72663. }
  72664. /**
  72665. * The strenght of the force in correspondence to the distance of the affected object
  72666. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72667. */
  72668. export enum PhysicsRadialImpulseFalloff {
  72669. /** Defines that impulse is constant in strength across it's whole radius */
  72670. Constant = 0,
  72671. /** Defines that impulse gets weaker if it's further from the origin */
  72672. Linear = 1
  72673. }
  72674. /**
  72675. * The strength of the force in correspondence to the distance of the affected object
  72676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72677. */
  72678. export enum PhysicsUpdraftMode {
  72679. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72680. Center = 0,
  72681. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72682. Perpendicular = 1
  72683. }
  72684. /**
  72685. * Interface for a physics hit data
  72686. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72687. */
  72688. export interface PhysicsHitData {
  72689. /**
  72690. * The force applied at the contact point
  72691. */
  72692. force: Vector3;
  72693. /**
  72694. * The contact point
  72695. */
  72696. contactPoint: Vector3;
  72697. /**
  72698. * The distance from the origin to the contact point
  72699. */
  72700. distanceFromOrigin: number;
  72701. }
  72702. /**
  72703. * Interface for radial explosion event data
  72704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72705. */
  72706. export interface PhysicsRadialExplosionEventData {
  72707. /**
  72708. * A sphere used for the radial explosion event
  72709. */
  72710. sphere: Mesh;
  72711. }
  72712. /**
  72713. * Interface for gravitational field event data
  72714. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72715. */
  72716. export interface PhysicsGravitationalFieldEventData {
  72717. /**
  72718. * A sphere mesh used for the gravitational field event
  72719. */
  72720. sphere: Mesh;
  72721. }
  72722. /**
  72723. * Interface for updraft event data
  72724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72725. */
  72726. export interface PhysicsUpdraftEventData {
  72727. /**
  72728. * A cylinder used for the updraft event
  72729. */
  72730. cylinder: Mesh;
  72731. }
  72732. /**
  72733. * Interface for vortex event data
  72734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72735. */
  72736. export interface PhysicsVortexEventData {
  72737. /**
  72738. * A cylinder used for the vortex event
  72739. */
  72740. cylinder: Mesh;
  72741. }
  72742. /**
  72743. * Interface for an affected physics impostor
  72744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72745. */
  72746. export interface PhysicsAffectedImpostorWithData {
  72747. /**
  72748. * The impostor affected by the effect
  72749. */
  72750. impostor: PhysicsImpostor;
  72751. /**
  72752. * The data about the hit/horce from the explosion
  72753. */
  72754. hitData: PhysicsHitData;
  72755. }
  72756. }
  72757. declare module "babylonjs/Physics/Plugins/index" {
  72758. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72759. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72760. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72761. }
  72762. declare module "babylonjs/Physics/index" {
  72763. export * from "babylonjs/Physics/IPhysicsEngine";
  72764. export * from "babylonjs/Physics/physicsEngine";
  72765. export * from "babylonjs/Physics/physicsEngineComponent";
  72766. export * from "babylonjs/Physics/physicsHelper";
  72767. export * from "babylonjs/Physics/physicsImpostor";
  72768. export * from "babylonjs/Physics/physicsJoint";
  72769. export * from "babylonjs/Physics/Plugins/index";
  72770. }
  72771. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72772. /** @hidden */
  72773. export var blackAndWhitePixelShader: {
  72774. name: string;
  72775. shader: string;
  72776. };
  72777. }
  72778. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72779. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72780. import { Camera } from "babylonjs/Cameras/camera";
  72781. import { Engine } from "babylonjs/Engines/engine";
  72782. import "babylonjs/Shaders/blackAndWhite.fragment";
  72783. import { Nullable } from "babylonjs/types";
  72784. import { Scene } from "babylonjs/scene";
  72785. /**
  72786. * Post process used to render in black and white
  72787. */
  72788. export class BlackAndWhitePostProcess extends PostProcess {
  72789. /**
  72790. * Linear about to convert he result to black and white (default: 1)
  72791. */
  72792. degree: number;
  72793. /**
  72794. * Gets a string identifying the name of the class
  72795. * @returns "BlackAndWhitePostProcess" string
  72796. */
  72797. getClassName(): string;
  72798. /**
  72799. * Creates a black and white post process
  72800. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72801. * @param name The name of the effect.
  72802. * @param options The required width/height ratio to downsize to before computing the render pass.
  72803. * @param camera The camera to apply the render pass to.
  72804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72805. * @param engine The engine which the post process will be applied. (default: current engine)
  72806. * @param reusable If the post process can be reused on the same frame. (default: false)
  72807. */
  72808. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72809. /** @hidden */
  72810. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  72811. }
  72812. }
  72813. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72814. import { Nullable } from "babylonjs/types";
  72815. import { Camera } from "babylonjs/Cameras/camera";
  72816. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72817. import { Engine } from "babylonjs/Engines/engine";
  72818. /**
  72819. * This represents a set of one or more post processes in Babylon.
  72820. * A post process can be used to apply a shader to a texture after it is rendered.
  72821. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72822. */
  72823. export class PostProcessRenderEffect {
  72824. private _postProcesses;
  72825. private _getPostProcesses;
  72826. private _singleInstance;
  72827. private _cameras;
  72828. private _indicesForCamera;
  72829. /**
  72830. * Name of the effect
  72831. * @hidden
  72832. */
  72833. _name: string;
  72834. /**
  72835. * Instantiates a post process render effect.
  72836. * A post process can be used to apply a shader to a texture after it is rendered.
  72837. * @param engine The engine the effect is tied to
  72838. * @param name The name of the effect
  72839. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72840. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72841. */
  72842. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72843. /**
  72844. * Checks if all the post processes in the effect are supported.
  72845. */
  72846. get isSupported(): boolean;
  72847. /**
  72848. * Updates the current state of the effect
  72849. * @hidden
  72850. */
  72851. _update(): void;
  72852. /**
  72853. * Attaches the effect on cameras
  72854. * @param cameras The camera to attach to.
  72855. * @hidden
  72856. */
  72857. _attachCameras(cameras: Camera): void;
  72858. /**
  72859. * Attaches the effect on cameras
  72860. * @param cameras The camera to attach to.
  72861. * @hidden
  72862. */
  72863. _attachCameras(cameras: Camera[]): void;
  72864. /**
  72865. * Detaches the effect on cameras
  72866. * @param cameras The camera to detatch from.
  72867. * @hidden
  72868. */
  72869. _detachCameras(cameras: Camera): void;
  72870. /**
  72871. * Detatches the effect on cameras
  72872. * @param cameras The camera to detatch from.
  72873. * @hidden
  72874. */
  72875. _detachCameras(cameras: Camera[]): void;
  72876. /**
  72877. * Enables the effect on given cameras
  72878. * @param cameras The camera to enable.
  72879. * @hidden
  72880. */
  72881. _enable(cameras: Camera): void;
  72882. /**
  72883. * Enables the effect on given cameras
  72884. * @param cameras The camera to enable.
  72885. * @hidden
  72886. */
  72887. _enable(cameras: Nullable<Camera[]>): void;
  72888. /**
  72889. * Disables the effect on the given cameras
  72890. * @param cameras The camera to disable.
  72891. * @hidden
  72892. */
  72893. _disable(cameras: Camera): void;
  72894. /**
  72895. * Disables the effect on the given cameras
  72896. * @param cameras The camera to disable.
  72897. * @hidden
  72898. */
  72899. _disable(cameras: Nullable<Camera[]>): void;
  72900. /**
  72901. * Gets a list of the post processes contained in the effect.
  72902. * @param camera The camera to get the post processes on.
  72903. * @returns The list of the post processes in the effect.
  72904. */
  72905. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72906. }
  72907. }
  72908. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72909. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72910. /** @hidden */
  72911. export var extractHighlightsPixelShader: {
  72912. name: string;
  72913. shader: string;
  72914. };
  72915. }
  72916. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72917. import { Nullable } from "babylonjs/types";
  72918. import { Camera } from "babylonjs/Cameras/camera";
  72919. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72920. import { Engine } from "babylonjs/Engines/engine";
  72921. import "babylonjs/Shaders/extractHighlights.fragment";
  72922. /**
  72923. * 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.
  72924. */
  72925. export class ExtractHighlightsPostProcess extends PostProcess {
  72926. /**
  72927. * The luminance threshold, pixels below this value will be set to black.
  72928. */
  72929. threshold: number;
  72930. /** @hidden */
  72931. _exposure: number;
  72932. /**
  72933. * Post process which has the input texture to be used when performing highlight extraction
  72934. * @hidden
  72935. */
  72936. _inputPostProcess: Nullable<PostProcess>;
  72937. /**
  72938. * Gets a string identifying the name of the class
  72939. * @returns "ExtractHighlightsPostProcess" string
  72940. */
  72941. getClassName(): string;
  72942. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72943. }
  72944. }
  72945. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72946. /** @hidden */
  72947. export var bloomMergePixelShader: {
  72948. name: string;
  72949. shader: string;
  72950. };
  72951. }
  72952. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72953. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72954. import { Nullable } from "babylonjs/types";
  72955. import { Engine } from "babylonjs/Engines/engine";
  72956. import { Camera } from "babylonjs/Cameras/camera";
  72957. import "babylonjs/Shaders/bloomMerge.fragment";
  72958. /**
  72959. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72960. */
  72961. export class BloomMergePostProcess extends PostProcess {
  72962. /** Weight of the bloom to be added to the original input. */
  72963. weight: number;
  72964. /**
  72965. * Gets a string identifying the name of the class
  72966. * @returns "BloomMergePostProcess" string
  72967. */
  72968. getClassName(): string;
  72969. /**
  72970. * Creates a new instance of @see BloomMergePostProcess
  72971. * @param name The name of the effect.
  72972. * @param originalFromInput Post process which's input will be used for the merge.
  72973. * @param blurred Blurred highlights post process which's output will be used.
  72974. * @param weight Weight of the bloom to be added to the original input.
  72975. * @param options The required width/height ratio to downsize to before computing the render pass.
  72976. * @param camera The camera to apply the render pass to.
  72977. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72978. * @param engine The engine which the post process will be applied. (default: current engine)
  72979. * @param reusable If the post process can be reused on the same frame. (default: false)
  72980. * @param textureType Type of textures used when performing the post process. (default: 0)
  72981. * @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)
  72982. */
  72983. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72984. /** Weight of the bloom to be added to the original input. */
  72985. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72986. }
  72987. }
  72988. declare module "babylonjs/PostProcesses/bloomEffect" {
  72989. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72990. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72991. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72992. import { Camera } from "babylonjs/Cameras/camera";
  72993. import { Scene } from "babylonjs/scene";
  72994. /**
  72995. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72996. */
  72997. export class BloomEffect extends PostProcessRenderEffect {
  72998. private bloomScale;
  72999. /**
  73000. * @hidden Internal
  73001. */
  73002. _effects: Array<PostProcess>;
  73003. /**
  73004. * @hidden Internal
  73005. */
  73006. _downscale: ExtractHighlightsPostProcess;
  73007. private _blurX;
  73008. private _blurY;
  73009. private _merge;
  73010. /**
  73011. * The luminance threshold to find bright areas of the image to bloom.
  73012. */
  73013. get threshold(): number;
  73014. set threshold(value: number);
  73015. /**
  73016. * The strength of the bloom.
  73017. */
  73018. get weight(): number;
  73019. set weight(value: number);
  73020. /**
  73021. * Specifies the size of the bloom blur kernel, relative to the final output size
  73022. */
  73023. get kernel(): number;
  73024. set kernel(value: number);
  73025. /**
  73026. * Creates a new instance of @see BloomEffect
  73027. * @param scene The scene the effect belongs to.
  73028. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73029. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73030. * @param bloomWeight The the strength of bloom.
  73031. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73032. * @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)
  73033. */
  73034. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73035. /**
  73036. * Disposes each of the internal effects for a given camera.
  73037. * @param camera The camera to dispose the effect on.
  73038. */
  73039. disposeEffects(camera: Camera): void;
  73040. /**
  73041. * @hidden Internal
  73042. */
  73043. _updateEffects(): void;
  73044. /**
  73045. * Internal
  73046. * @returns if all the contained post processes are ready.
  73047. * @hidden
  73048. */
  73049. _isReady(): boolean;
  73050. }
  73051. }
  73052. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  73053. /** @hidden */
  73054. export var chromaticAberrationPixelShader: {
  73055. name: string;
  73056. shader: string;
  73057. };
  73058. }
  73059. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  73060. import { Vector2 } from "babylonjs/Maths/math.vector";
  73061. import { Nullable } from "babylonjs/types";
  73062. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73063. import { Camera } from "babylonjs/Cameras/camera";
  73064. import { Engine } from "babylonjs/Engines/engine";
  73065. import "babylonjs/Shaders/chromaticAberration.fragment";
  73066. import { Scene } from "babylonjs/scene";
  73067. /**
  73068. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73069. */
  73070. export class ChromaticAberrationPostProcess extends PostProcess {
  73071. /**
  73072. * The amount of seperation of rgb channels (default: 30)
  73073. */
  73074. aberrationAmount: number;
  73075. /**
  73076. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73077. */
  73078. radialIntensity: number;
  73079. /**
  73080. * 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))
  73081. */
  73082. direction: Vector2;
  73083. /**
  73084. * 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))
  73085. */
  73086. centerPosition: Vector2;
  73087. /** The width of the screen to apply the effect on */
  73088. screenWidth: number;
  73089. /** The height of the screen to apply the effect on */
  73090. screenHeight: number;
  73091. /**
  73092. * Gets a string identifying the name of the class
  73093. * @returns "ChromaticAberrationPostProcess" string
  73094. */
  73095. getClassName(): string;
  73096. /**
  73097. * Creates a new instance ChromaticAberrationPostProcess
  73098. * @param name The name of the effect.
  73099. * @param screenWidth The width of the screen to apply the effect on.
  73100. * @param screenHeight The height of the screen to apply the effect on.
  73101. * @param options The required width/height ratio to downsize to before computing the render pass.
  73102. * @param camera The camera to apply the render pass to.
  73103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73104. * @param engine The engine which the post process will be applied. (default: current engine)
  73105. * @param reusable If the post process can be reused on the same frame. (default: false)
  73106. * @param textureType Type of textures used when performing the post process. (default: 0)
  73107. * @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)
  73108. */
  73109. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73110. /** @hidden */
  73111. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73112. }
  73113. }
  73114. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73115. /** @hidden */
  73116. export var circleOfConfusionPixelShader: {
  73117. name: string;
  73118. shader: string;
  73119. };
  73120. }
  73121. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73122. import { Nullable } from "babylonjs/types";
  73123. import { Engine } from "babylonjs/Engines/engine";
  73124. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73125. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73126. import { Camera } from "babylonjs/Cameras/camera";
  73127. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73128. /**
  73129. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73130. */
  73131. export class CircleOfConfusionPostProcess extends PostProcess {
  73132. /**
  73133. * 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.
  73134. */
  73135. lensSize: number;
  73136. /**
  73137. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73138. */
  73139. fStop: number;
  73140. /**
  73141. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73142. */
  73143. focusDistance: number;
  73144. /**
  73145. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73146. */
  73147. focalLength: number;
  73148. /**
  73149. * Gets a string identifying the name of the class
  73150. * @returns "CircleOfConfusionPostProcess" string
  73151. */
  73152. getClassName(): string;
  73153. private _depthTexture;
  73154. /**
  73155. * Creates a new instance CircleOfConfusionPostProcess
  73156. * @param name The name of the effect.
  73157. * @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.
  73158. * @param options The required width/height ratio to downsize to before computing the render pass.
  73159. * @param camera The camera to apply the render pass to.
  73160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73161. * @param engine The engine which the post process will be applied. (default: current engine)
  73162. * @param reusable If the post process can be reused on the same frame. (default: false)
  73163. * @param textureType Type of textures used when performing the post process. (default: 0)
  73164. * @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)
  73165. */
  73166. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73167. /**
  73168. * 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.
  73169. */
  73170. set depthTexture(value: RenderTargetTexture);
  73171. }
  73172. }
  73173. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73174. /** @hidden */
  73175. export var colorCorrectionPixelShader: {
  73176. name: string;
  73177. shader: string;
  73178. };
  73179. }
  73180. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73181. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73182. import { Engine } from "babylonjs/Engines/engine";
  73183. import { Camera } from "babylonjs/Cameras/camera";
  73184. import "babylonjs/Shaders/colorCorrection.fragment";
  73185. import { Nullable } from "babylonjs/types";
  73186. import { Scene } from "babylonjs/scene";
  73187. /**
  73188. *
  73189. * This post-process allows the modification of rendered colors by using
  73190. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73191. *
  73192. * The object needs to be provided an url to a texture containing the color
  73193. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73194. * Use an image editing software to tweak the LUT to match your needs.
  73195. *
  73196. * For an example of a color LUT, see here:
  73197. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73198. * For explanations on color grading, see here:
  73199. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73200. *
  73201. */
  73202. export class ColorCorrectionPostProcess extends PostProcess {
  73203. private _colorTableTexture;
  73204. /**
  73205. * Gets the color table url used to create the LUT texture
  73206. */
  73207. colorTableUrl: string;
  73208. /**
  73209. * Gets a string identifying the name of the class
  73210. * @returns "ColorCorrectionPostProcess" string
  73211. */
  73212. getClassName(): string;
  73213. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73214. /** @hidden */
  73215. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73216. }
  73217. }
  73218. declare module "babylonjs/Shaders/convolution.fragment" {
  73219. /** @hidden */
  73220. export var convolutionPixelShader: {
  73221. name: string;
  73222. shader: string;
  73223. };
  73224. }
  73225. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73226. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73227. import { Nullable } from "babylonjs/types";
  73228. import { Camera } from "babylonjs/Cameras/camera";
  73229. import { Engine } from "babylonjs/Engines/engine";
  73230. import "babylonjs/Shaders/convolution.fragment";
  73231. import { Scene } from "babylonjs/scene";
  73232. /**
  73233. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73234. * input texture to perform effects such as edge detection or sharpening
  73235. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73236. */
  73237. export class ConvolutionPostProcess extends PostProcess {
  73238. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73239. kernel: number[];
  73240. /**
  73241. * Gets a string identifying the name of the class
  73242. * @returns "ConvolutionPostProcess" string
  73243. */
  73244. getClassName(): string;
  73245. /**
  73246. * Creates a new instance ConvolutionPostProcess
  73247. * @param name The name of the effect.
  73248. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73249. * @param options The required width/height ratio to downsize to before computing the render pass.
  73250. * @param camera The camera to apply the render pass to.
  73251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73252. * @param engine The engine which the post process will be applied. (default: current engine)
  73253. * @param reusable If the post process can be reused on the same frame. (default: false)
  73254. * @param textureType Type of textures used when performing the post process. (default: 0)
  73255. */
  73256. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73257. /** @hidden */
  73258. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73259. /**
  73260. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73261. */
  73262. static EdgeDetect0Kernel: number[];
  73263. /**
  73264. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73265. */
  73266. static EdgeDetect1Kernel: number[];
  73267. /**
  73268. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73269. */
  73270. static EdgeDetect2Kernel: number[];
  73271. /**
  73272. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73273. */
  73274. static SharpenKernel: number[];
  73275. /**
  73276. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73277. */
  73278. static EmbossKernel: number[];
  73279. /**
  73280. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73281. */
  73282. static GaussianKernel: number[];
  73283. }
  73284. }
  73285. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73286. import { Nullable } from "babylonjs/types";
  73287. import { Vector2 } from "babylonjs/Maths/math.vector";
  73288. import { Camera } from "babylonjs/Cameras/camera";
  73289. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73290. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73291. import { Engine } from "babylonjs/Engines/engine";
  73292. import { Scene } from "babylonjs/scene";
  73293. /**
  73294. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73295. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73296. * based on samples that have a large difference in distance than the center pixel.
  73297. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73298. */
  73299. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73300. /**
  73301. * The direction the blur should be applied
  73302. */
  73303. direction: Vector2;
  73304. /**
  73305. * Gets a string identifying the name of the class
  73306. * @returns "DepthOfFieldBlurPostProcess" string
  73307. */
  73308. getClassName(): string;
  73309. /**
  73310. * Creates a new instance CircleOfConfusionPostProcess
  73311. * @param name The name of the effect.
  73312. * @param scene The scene the effect belongs to.
  73313. * @param direction The direction the blur should be applied.
  73314. * @param kernel The size of the kernel used to blur.
  73315. * @param options The required width/height ratio to downsize to before computing the render pass.
  73316. * @param camera The camera to apply the render pass to.
  73317. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73318. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73319. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73320. * @param engine The engine which the post process will be applied. (default: current engine)
  73321. * @param reusable If the post process can be reused on the same frame. (default: false)
  73322. * @param textureType Type of textures used when performing the post process. (default: 0)
  73323. * @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)
  73324. */
  73325. 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);
  73326. }
  73327. }
  73328. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73329. /** @hidden */
  73330. export var depthOfFieldMergePixelShader: {
  73331. name: string;
  73332. shader: string;
  73333. };
  73334. }
  73335. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73336. import { Nullable } from "babylonjs/types";
  73337. import { Camera } from "babylonjs/Cameras/camera";
  73338. import { Effect } from "babylonjs/Materials/effect";
  73339. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73340. import { Engine } from "babylonjs/Engines/engine";
  73341. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73342. /**
  73343. * Options to be set when merging outputs from the default pipeline.
  73344. */
  73345. export class DepthOfFieldMergePostProcessOptions {
  73346. /**
  73347. * The original image to merge on top of
  73348. */
  73349. originalFromInput: PostProcess;
  73350. /**
  73351. * Parameters to perform the merge of the depth of field effect
  73352. */
  73353. depthOfField?: {
  73354. circleOfConfusion: PostProcess;
  73355. blurSteps: Array<PostProcess>;
  73356. };
  73357. /**
  73358. * Parameters to perform the merge of bloom effect
  73359. */
  73360. bloom?: {
  73361. blurred: PostProcess;
  73362. weight: number;
  73363. };
  73364. }
  73365. /**
  73366. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73367. */
  73368. export class DepthOfFieldMergePostProcess extends PostProcess {
  73369. private blurSteps;
  73370. /**
  73371. * Gets a string identifying the name of the class
  73372. * @returns "DepthOfFieldMergePostProcess" string
  73373. */
  73374. getClassName(): string;
  73375. /**
  73376. * Creates a new instance of DepthOfFieldMergePostProcess
  73377. * @param name The name of the effect.
  73378. * @param originalFromInput Post process which's input will be used for the merge.
  73379. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73380. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73381. * @param options The required width/height ratio to downsize to before computing the render pass.
  73382. * @param camera The camera to apply the render pass to.
  73383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73384. * @param engine The engine which the post process will be applied. (default: current engine)
  73385. * @param reusable If the post process can be reused on the same frame. (default: false)
  73386. * @param textureType Type of textures used when performing the post process. (default: 0)
  73387. * @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)
  73388. */
  73389. 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);
  73390. /**
  73391. * Updates the effect with the current post process compile time values and recompiles the shader.
  73392. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73393. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73394. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73395. * @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
  73396. * @param onCompiled Called when the shader has been compiled.
  73397. * @param onError Called if there is an error when compiling a shader.
  73398. */
  73399. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73400. }
  73401. }
  73402. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73403. import { Nullable } from "babylonjs/types";
  73404. import { Camera } from "babylonjs/Cameras/camera";
  73405. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73406. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73407. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73408. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73409. import { Scene } from "babylonjs/scene";
  73410. /**
  73411. * Specifies the level of max blur that should be applied when using the depth of field effect
  73412. */
  73413. export enum DepthOfFieldEffectBlurLevel {
  73414. /**
  73415. * Subtle blur
  73416. */
  73417. Low = 0,
  73418. /**
  73419. * Medium blur
  73420. */
  73421. Medium = 1,
  73422. /**
  73423. * Large blur
  73424. */
  73425. High = 2
  73426. }
  73427. /**
  73428. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73429. */
  73430. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73431. private _circleOfConfusion;
  73432. /**
  73433. * @hidden Internal, blurs from high to low
  73434. */
  73435. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73436. private _depthOfFieldBlurY;
  73437. private _dofMerge;
  73438. /**
  73439. * @hidden Internal post processes in depth of field effect
  73440. */
  73441. _effects: Array<PostProcess>;
  73442. /**
  73443. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73444. */
  73445. set focalLength(value: number);
  73446. get focalLength(): number;
  73447. /**
  73448. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73449. */
  73450. set fStop(value: number);
  73451. get fStop(): number;
  73452. /**
  73453. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73454. */
  73455. set focusDistance(value: number);
  73456. get focusDistance(): number;
  73457. /**
  73458. * 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.
  73459. */
  73460. set lensSize(value: number);
  73461. get lensSize(): number;
  73462. /**
  73463. * Creates a new instance DepthOfFieldEffect
  73464. * @param scene The scene the effect belongs to.
  73465. * @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.
  73466. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73467. * @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)
  73468. */
  73469. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73470. /**
  73471. * Get the current class name of the current effet
  73472. * @returns "DepthOfFieldEffect"
  73473. */
  73474. getClassName(): string;
  73475. /**
  73476. * 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.
  73477. */
  73478. set depthTexture(value: RenderTargetTexture);
  73479. /**
  73480. * Disposes each of the internal effects for a given camera.
  73481. * @param camera The camera to dispose the effect on.
  73482. */
  73483. disposeEffects(camera: Camera): void;
  73484. /**
  73485. * @hidden Internal
  73486. */
  73487. _updateEffects(): void;
  73488. /**
  73489. * Internal
  73490. * @returns if all the contained post processes are ready.
  73491. * @hidden
  73492. */
  73493. _isReady(): boolean;
  73494. }
  73495. }
  73496. declare module "babylonjs/Shaders/displayPass.fragment" {
  73497. /** @hidden */
  73498. export var displayPassPixelShader: {
  73499. name: string;
  73500. shader: string;
  73501. };
  73502. }
  73503. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73504. import { Nullable } from "babylonjs/types";
  73505. import { Camera } from "babylonjs/Cameras/camera";
  73506. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73507. import { Engine } from "babylonjs/Engines/engine";
  73508. import "babylonjs/Shaders/displayPass.fragment";
  73509. import { Scene } from "babylonjs/scene";
  73510. /**
  73511. * DisplayPassPostProcess which produces an output the same as it's input
  73512. */
  73513. export class DisplayPassPostProcess extends PostProcess {
  73514. /**
  73515. * Gets a string identifying the name of the class
  73516. * @returns "DisplayPassPostProcess" string
  73517. */
  73518. getClassName(): string;
  73519. /**
  73520. * Creates the DisplayPassPostProcess
  73521. * @param name The name of the effect.
  73522. * @param options The required width/height ratio to downsize to before computing the render pass.
  73523. * @param camera The camera to apply the render pass to.
  73524. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73525. * @param engine The engine which the post process will be applied. (default: current engine)
  73526. * @param reusable If the post process can be reused on the same frame. (default: false)
  73527. */
  73528. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73529. /** @hidden */
  73530. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73531. }
  73532. }
  73533. declare module "babylonjs/Shaders/filter.fragment" {
  73534. /** @hidden */
  73535. export var filterPixelShader: {
  73536. name: string;
  73537. shader: string;
  73538. };
  73539. }
  73540. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73541. import { Nullable } from "babylonjs/types";
  73542. import { Matrix } from "babylonjs/Maths/math.vector";
  73543. import { Camera } from "babylonjs/Cameras/camera";
  73544. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73545. import { Engine } from "babylonjs/Engines/engine";
  73546. import "babylonjs/Shaders/filter.fragment";
  73547. import { Scene } from "babylonjs/scene";
  73548. /**
  73549. * Applies a kernel filter to the image
  73550. */
  73551. export class FilterPostProcess extends PostProcess {
  73552. /** The matrix to be applied to the image */
  73553. kernelMatrix: Matrix;
  73554. /**
  73555. * Gets a string identifying the name of the class
  73556. * @returns "FilterPostProcess" string
  73557. */
  73558. getClassName(): string;
  73559. /**
  73560. *
  73561. * @param name The name of the effect.
  73562. * @param kernelMatrix The matrix to be applied to the image
  73563. * @param options The required width/height ratio to downsize to before computing the render pass.
  73564. * @param camera The camera to apply the render pass to.
  73565. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73566. * @param engine The engine which the post process will be applied. (default: current engine)
  73567. * @param reusable If the post process can be reused on the same frame. (default: false)
  73568. */
  73569. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73570. /** @hidden */
  73571. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73572. }
  73573. }
  73574. declare module "babylonjs/Shaders/fxaa.fragment" {
  73575. /** @hidden */
  73576. export var fxaaPixelShader: {
  73577. name: string;
  73578. shader: string;
  73579. };
  73580. }
  73581. declare module "babylonjs/Shaders/fxaa.vertex" {
  73582. /** @hidden */
  73583. export var fxaaVertexShader: {
  73584. name: string;
  73585. shader: string;
  73586. };
  73587. }
  73588. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  73589. import { Nullable } from "babylonjs/types";
  73590. import { Camera } from "babylonjs/Cameras/camera";
  73591. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73592. import { Engine } from "babylonjs/Engines/engine";
  73593. import "babylonjs/Shaders/fxaa.fragment";
  73594. import "babylonjs/Shaders/fxaa.vertex";
  73595. import { Scene } from "babylonjs/scene";
  73596. /**
  73597. * Fxaa post process
  73598. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73599. */
  73600. export class FxaaPostProcess extends PostProcess {
  73601. /**
  73602. * Gets a string identifying the name of the class
  73603. * @returns "FxaaPostProcess" string
  73604. */
  73605. getClassName(): string;
  73606. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73607. private _getDefines;
  73608. /** @hidden */
  73609. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73610. }
  73611. }
  73612. declare module "babylonjs/Shaders/grain.fragment" {
  73613. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73614. /** @hidden */
  73615. export var grainPixelShader: {
  73616. name: string;
  73617. shader: string;
  73618. };
  73619. }
  73620. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73621. import { Nullable } from "babylonjs/types";
  73622. import { Camera } from "babylonjs/Cameras/camera";
  73623. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73624. import { Engine } from "babylonjs/Engines/engine";
  73625. import "babylonjs/Shaders/grain.fragment";
  73626. import { Scene } from "babylonjs/scene";
  73627. /**
  73628. * The GrainPostProcess adds noise to the image at mid luminance levels
  73629. */
  73630. export class GrainPostProcess extends PostProcess {
  73631. /**
  73632. * The intensity of the grain added (default: 30)
  73633. */
  73634. intensity: number;
  73635. /**
  73636. * If the grain should be randomized on every frame
  73637. */
  73638. animated: boolean;
  73639. /**
  73640. * Gets a string identifying the name of the class
  73641. * @returns "GrainPostProcess" string
  73642. */
  73643. getClassName(): string;
  73644. /**
  73645. * Creates a new instance of @see GrainPostProcess
  73646. * @param name The name of the effect.
  73647. * @param options The required width/height ratio to downsize to before computing the render pass.
  73648. * @param camera The camera to apply the render pass to.
  73649. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73650. * @param engine The engine which the post process will be applied. (default: current engine)
  73651. * @param reusable If the post process can be reused on the same frame. (default: false)
  73652. * @param textureType Type of textures used when performing the post process. (default: 0)
  73653. * @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)
  73654. */
  73655. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73656. /** @hidden */
  73657. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73658. }
  73659. }
  73660. declare module "babylonjs/Shaders/highlights.fragment" {
  73661. /** @hidden */
  73662. export var highlightsPixelShader: {
  73663. name: string;
  73664. shader: string;
  73665. };
  73666. }
  73667. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73668. import { Nullable } from "babylonjs/types";
  73669. import { Camera } from "babylonjs/Cameras/camera";
  73670. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73671. import { Engine } from "babylonjs/Engines/engine";
  73672. import "babylonjs/Shaders/highlights.fragment";
  73673. /**
  73674. * Extracts highlights from the image
  73675. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73676. */
  73677. export class HighlightsPostProcess extends PostProcess {
  73678. /**
  73679. * Gets a string identifying the name of the class
  73680. * @returns "HighlightsPostProcess" string
  73681. */
  73682. getClassName(): string;
  73683. /**
  73684. * Extracts highlights from the image
  73685. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73686. * @param name The name of the effect.
  73687. * @param options The required width/height ratio to downsize to before computing the render pass.
  73688. * @param camera The camera to apply the render pass to.
  73689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73690. * @param engine The engine which the post process will be applied. (default: current engine)
  73691. * @param reusable If the post process can be reused on the same frame. (default: false)
  73692. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73693. */
  73694. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73695. }
  73696. }
  73697. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73698. /** @hidden */
  73699. export var mrtFragmentDeclaration: {
  73700. name: string;
  73701. shader: string;
  73702. };
  73703. }
  73704. declare module "babylonjs/Shaders/geometry.fragment" {
  73705. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73706. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73707. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73708. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73709. /** @hidden */
  73710. export var geometryPixelShader: {
  73711. name: string;
  73712. shader: string;
  73713. };
  73714. }
  73715. declare module "babylonjs/Shaders/geometry.vertex" {
  73716. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73717. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73718. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73719. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73720. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73721. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73722. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73723. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73724. /** @hidden */
  73725. export var geometryVertexShader: {
  73726. name: string;
  73727. shader: string;
  73728. };
  73729. }
  73730. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73731. import { Matrix } from "babylonjs/Maths/math.vector";
  73732. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73733. import { Mesh } from "babylonjs/Meshes/mesh";
  73734. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73735. import { Effect } from "babylonjs/Materials/effect";
  73736. import { Scene } from "babylonjs/scene";
  73737. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73738. import "babylonjs/Shaders/geometry.fragment";
  73739. import "babylonjs/Shaders/geometry.vertex";
  73740. /** @hidden */
  73741. interface ISavedTransformationMatrix {
  73742. world: Matrix;
  73743. viewProjection: Matrix;
  73744. }
  73745. /**
  73746. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73747. */
  73748. export class GeometryBufferRenderer {
  73749. /**
  73750. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73751. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73752. */
  73753. static readonly POSITION_TEXTURE_TYPE: number;
  73754. /**
  73755. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73756. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73757. */
  73758. static readonly VELOCITY_TEXTURE_TYPE: number;
  73759. /**
  73760. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73761. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73762. */
  73763. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73764. /**
  73765. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73766. * in order to compute objects velocities when enableVelocity is set to "true"
  73767. * @hidden
  73768. */
  73769. _previousTransformationMatrices: {
  73770. [index: number]: ISavedTransformationMatrix;
  73771. };
  73772. /**
  73773. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73774. * in order to compute objects velocities when enableVelocity is set to "true"
  73775. * @hidden
  73776. */
  73777. _previousBonesTransformationMatrices: {
  73778. [index: number]: Float32Array;
  73779. };
  73780. /**
  73781. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73782. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73783. */
  73784. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73785. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73786. renderTransparentMeshes: boolean;
  73787. private _scene;
  73788. private _resizeObserver;
  73789. private _multiRenderTarget;
  73790. private _ratio;
  73791. private _enablePosition;
  73792. private _enableVelocity;
  73793. private _enableReflectivity;
  73794. private _positionIndex;
  73795. private _velocityIndex;
  73796. private _reflectivityIndex;
  73797. protected _effect: Effect;
  73798. protected _cachedDefines: string;
  73799. /**
  73800. * Set the render list (meshes to be rendered) used in the G buffer.
  73801. */
  73802. set renderList(meshes: Mesh[]);
  73803. /**
  73804. * Gets wether or not G buffer are supported by the running hardware.
  73805. * This requires draw buffer supports
  73806. */
  73807. get isSupported(): boolean;
  73808. /**
  73809. * Returns the index of the given texture type in the G-Buffer textures array
  73810. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73811. * @returns the index of the given texture type in the G-Buffer textures array
  73812. */
  73813. getTextureIndex(textureType: number): number;
  73814. /**
  73815. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73816. */
  73817. get enablePosition(): boolean;
  73818. /**
  73819. * Sets whether or not objects positions are enabled for the G buffer.
  73820. */
  73821. set enablePosition(enable: boolean);
  73822. /**
  73823. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73824. */
  73825. get enableVelocity(): boolean;
  73826. /**
  73827. * Sets wether or not objects velocities are enabled for the G buffer.
  73828. */
  73829. set enableVelocity(enable: boolean);
  73830. /**
  73831. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73832. */
  73833. get enableReflectivity(): boolean;
  73834. /**
  73835. * Sets wether or not objects roughness are enabled for the G buffer.
  73836. */
  73837. set enableReflectivity(enable: boolean);
  73838. /**
  73839. * Gets the scene associated with the buffer.
  73840. */
  73841. get scene(): Scene;
  73842. /**
  73843. * Gets the ratio used by the buffer during its creation.
  73844. * How big is the buffer related to the main canvas.
  73845. */
  73846. get ratio(): number;
  73847. /** @hidden */
  73848. static _SceneComponentInitialization: (scene: Scene) => void;
  73849. /**
  73850. * Creates a new G Buffer for the scene
  73851. * @param scene The scene the buffer belongs to
  73852. * @param ratio How big is the buffer related to the main canvas.
  73853. */
  73854. constructor(scene: Scene, ratio?: number);
  73855. /**
  73856. * Checks wether everything is ready to render a submesh to the G buffer.
  73857. * @param subMesh the submesh to check readiness for
  73858. * @param useInstances is the mesh drawn using instance or not
  73859. * @returns true if ready otherwise false
  73860. */
  73861. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73862. /**
  73863. * Gets the current underlying G Buffer.
  73864. * @returns the buffer
  73865. */
  73866. getGBuffer(): MultiRenderTarget;
  73867. /**
  73868. * Gets the number of samples used to render the buffer (anti aliasing).
  73869. */
  73870. get samples(): number;
  73871. /**
  73872. * Sets the number of samples used to render the buffer (anti aliasing).
  73873. */
  73874. set samples(value: number);
  73875. /**
  73876. * Disposes the renderer and frees up associated resources.
  73877. */
  73878. dispose(): void;
  73879. protected _createRenderTargets(): void;
  73880. private _copyBonesTransformationMatrices;
  73881. }
  73882. }
  73883. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73884. import { Nullable } from "babylonjs/types";
  73885. import { Scene } from "babylonjs/scene";
  73886. import { ISceneComponent } from "babylonjs/sceneComponent";
  73887. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73888. module "babylonjs/scene" {
  73889. interface Scene {
  73890. /** @hidden (Backing field) */
  73891. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73892. /**
  73893. * Gets or Sets the current geometry buffer associated to the scene.
  73894. */
  73895. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73896. /**
  73897. * Enables a GeometryBufferRender and associates it with the scene
  73898. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73899. * @returns the GeometryBufferRenderer
  73900. */
  73901. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73902. /**
  73903. * Disables the GeometryBufferRender associated with the scene
  73904. */
  73905. disableGeometryBufferRenderer(): void;
  73906. }
  73907. }
  73908. /**
  73909. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73910. * in several rendering techniques.
  73911. */
  73912. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73913. /**
  73914. * The component name helpful to identify the component in the list of scene components.
  73915. */
  73916. readonly name: string;
  73917. /**
  73918. * The scene the component belongs to.
  73919. */
  73920. scene: Scene;
  73921. /**
  73922. * Creates a new instance of the component for the given scene
  73923. * @param scene Defines the scene to register the component in
  73924. */
  73925. constructor(scene: Scene);
  73926. /**
  73927. * Registers the component in a given scene
  73928. */
  73929. register(): void;
  73930. /**
  73931. * Rebuilds the elements related to this component in case of
  73932. * context lost for instance.
  73933. */
  73934. rebuild(): void;
  73935. /**
  73936. * Disposes the component and the associated ressources
  73937. */
  73938. dispose(): void;
  73939. private _gatherRenderTargets;
  73940. }
  73941. }
  73942. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73943. /** @hidden */
  73944. export var motionBlurPixelShader: {
  73945. name: string;
  73946. shader: string;
  73947. };
  73948. }
  73949. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73950. import { Nullable } from "babylonjs/types";
  73951. import { Camera } from "babylonjs/Cameras/camera";
  73952. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73953. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73954. import "babylonjs/Animations/animatable";
  73955. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73956. import "babylonjs/Shaders/motionBlur.fragment";
  73957. import { Engine } from "babylonjs/Engines/engine";
  73958. import { Scene } from "babylonjs/scene";
  73959. /**
  73960. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73961. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73962. * As an example, all you have to do is to create the post-process:
  73963. * var mb = new BABYLON.MotionBlurPostProcess(
  73964. * 'mb', // The name of the effect.
  73965. * scene, // The scene containing the objects to blur according to their velocity.
  73966. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73967. * camera // The camera to apply the render pass to.
  73968. * );
  73969. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73970. */
  73971. export class MotionBlurPostProcess extends PostProcess {
  73972. /**
  73973. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73974. */
  73975. motionStrength: number;
  73976. /**
  73977. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73978. */
  73979. get motionBlurSamples(): number;
  73980. /**
  73981. * Sets the number of iterations to be used for motion blur quality
  73982. */
  73983. set motionBlurSamples(samples: number);
  73984. private _motionBlurSamples;
  73985. private _geometryBufferRenderer;
  73986. /**
  73987. * Gets a string identifying the name of the class
  73988. * @returns "MotionBlurPostProcess" string
  73989. */
  73990. getClassName(): string;
  73991. /**
  73992. * Creates a new instance MotionBlurPostProcess
  73993. * @param name The name of the effect.
  73994. * @param scene The scene containing the objects to blur according to their velocity.
  73995. * @param options The required width/height ratio to downsize to before computing the render pass.
  73996. * @param camera The camera to apply the render pass to.
  73997. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73998. * @param engine The engine which the post process will be applied. (default: current engine)
  73999. * @param reusable If the post process can be reused on the same frame. (default: false)
  74000. * @param textureType Type of textures used when performing the post process. (default: 0)
  74001. * @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)
  74002. */
  74003. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74004. /**
  74005. * Excludes the given skinned mesh from computing bones velocities.
  74006. * 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.
  74007. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74008. */
  74009. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74010. /**
  74011. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74012. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74013. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74014. */
  74015. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74016. /**
  74017. * Disposes the post process.
  74018. * @param camera The camera to dispose the post process on.
  74019. */
  74020. dispose(camera?: Camera): void;
  74021. /** @hidden */
  74022. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74023. }
  74024. }
  74025. declare module "babylonjs/Shaders/refraction.fragment" {
  74026. /** @hidden */
  74027. export var refractionPixelShader: {
  74028. name: string;
  74029. shader: string;
  74030. };
  74031. }
  74032. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  74033. import { Color3 } from "babylonjs/Maths/math.color";
  74034. import { Camera } from "babylonjs/Cameras/camera";
  74035. import { Texture } from "babylonjs/Materials/Textures/texture";
  74036. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74037. import { Engine } from "babylonjs/Engines/engine";
  74038. import "babylonjs/Shaders/refraction.fragment";
  74039. import { Scene } from "babylonjs/scene";
  74040. /**
  74041. * Post process which applies a refractin texture
  74042. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74043. */
  74044. export class RefractionPostProcess extends PostProcess {
  74045. private _refTexture;
  74046. private _ownRefractionTexture;
  74047. /** the base color of the refraction (used to taint the rendering) */
  74048. color: Color3;
  74049. /** simulated refraction depth */
  74050. depth: number;
  74051. /** the coefficient of the base color (0 to remove base color tainting) */
  74052. colorLevel: number;
  74053. /** Gets the url used to load the refraction texture */
  74054. refractionTextureUrl: string;
  74055. /**
  74056. * Gets or sets the refraction texture
  74057. * Please note that you are responsible for disposing the texture if you set it manually
  74058. */
  74059. get refractionTexture(): Texture;
  74060. set refractionTexture(value: Texture);
  74061. /**
  74062. * Gets a string identifying the name of the class
  74063. * @returns "RefractionPostProcess" string
  74064. */
  74065. getClassName(): string;
  74066. /**
  74067. * Initializes the RefractionPostProcess
  74068. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74069. * @param name The name of the effect.
  74070. * @param refractionTextureUrl Url of the refraction texture to use
  74071. * @param color the base color of the refraction (used to taint the rendering)
  74072. * @param depth simulated refraction depth
  74073. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74074. * @param camera The camera to apply the render pass to.
  74075. * @param options The required width/height ratio to downsize to before computing the render pass.
  74076. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74077. * @param engine The engine which the post process will be applied. (default: current engine)
  74078. * @param reusable If the post process can be reused on the same frame. (default: false)
  74079. */
  74080. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74081. /**
  74082. * Disposes of the post process
  74083. * @param camera Camera to dispose post process on
  74084. */
  74085. dispose(camera: Camera): void;
  74086. /** @hidden */
  74087. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74088. }
  74089. }
  74090. declare module "babylonjs/Shaders/sharpen.fragment" {
  74091. /** @hidden */
  74092. export var sharpenPixelShader: {
  74093. name: string;
  74094. shader: string;
  74095. };
  74096. }
  74097. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74098. import { Nullable } from "babylonjs/types";
  74099. import { Camera } from "babylonjs/Cameras/camera";
  74100. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74101. import "babylonjs/Shaders/sharpen.fragment";
  74102. import { Engine } from "babylonjs/Engines/engine";
  74103. import { Scene } from "babylonjs/scene";
  74104. /**
  74105. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74106. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74107. */
  74108. export class SharpenPostProcess extends PostProcess {
  74109. /**
  74110. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74111. */
  74112. colorAmount: number;
  74113. /**
  74114. * How much sharpness should be applied (default: 0.3)
  74115. */
  74116. edgeAmount: number;
  74117. /**
  74118. * Gets a string identifying the name of the class
  74119. * @returns "SharpenPostProcess" string
  74120. */
  74121. getClassName(): string;
  74122. /**
  74123. * Creates a new instance ConvolutionPostProcess
  74124. * @param name The name of the effect.
  74125. * @param options The required width/height ratio to downsize to before computing the render pass.
  74126. * @param camera The camera to apply the render pass to.
  74127. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74128. * @param engine The engine which the post process will be applied. (default: current engine)
  74129. * @param reusable If the post process can be reused on the same frame. (default: false)
  74130. * @param textureType Type of textures used when performing the post process. (default: 0)
  74131. * @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)
  74132. */
  74133. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74134. /** @hidden */
  74135. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74136. }
  74137. }
  74138. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74139. import { Nullable } from "babylonjs/types";
  74140. import { Camera } from "babylonjs/Cameras/camera";
  74141. import { Engine } from "babylonjs/Engines/engine";
  74142. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74143. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74144. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74145. /**
  74146. * PostProcessRenderPipeline
  74147. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74148. */
  74149. export class PostProcessRenderPipeline {
  74150. private engine;
  74151. private _renderEffects;
  74152. private _renderEffectsForIsolatedPass;
  74153. /**
  74154. * List of inspectable custom properties (used by the Inspector)
  74155. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74156. */
  74157. inspectableCustomProperties: IInspectable[];
  74158. /**
  74159. * @hidden
  74160. */
  74161. protected _cameras: Camera[];
  74162. /** @hidden */
  74163. _name: string;
  74164. /**
  74165. * Gets pipeline name
  74166. */
  74167. get name(): string;
  74168. /** Gets the list of attached cameras */
  74169. get cameras(): Camera[];
  74170. /**
  74171. * Initializes a PostProcessRenderPipeline
  74172. * @param engine engine to add the pipeline to
  74173. * @param name name of the pipeline
  74174. */
  74175. constructor(engine: Engine, name: string);
  74176. /**
  74177. * Gets the class name
  74178. * @returns "PostProcessRenderPipeline"
  74179. */
  74180. getClassName(): string;
  74181. /**
  74182. * If all the render effects in the pipeline are supported
  74183. */
  74184. get isSupported(): boolean;
  74185. /**
  74186. * Adds an effect to the pipeline
  74187. * @param renderEffect the effect to add
  74188. */
  74189. addEffect(renderEffect: PostProcessRenderEffect): void;
  74190. /** @hidden */
  74191. _rebuild(): void;
  74192. /** @hidden */
  74193. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74194. /** @hidden */
  74195. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74196. /** @hidden */
  74197. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74198. /** @hidden */
  74199. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74200. /** @hidden */
  74201. _attachCameras(cameras: Camera, unique: boolean): void;
  74202. /** @hidden */
  74203. _attachCameras(cameras: Camera[], unique: boolean): void;
  74204. /** @hidden */
  74205. _detachCameras(cameras: Camera): void;
  74206. /** @hidden */
  74207. _detachCameras(cameras: Nullable<Camera[]>): void;
  74208. /** @hidden */
  74209. _update(): void;
  74210. /** @hidden */
  74211. _reset(): void;
  74212. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74213. /**
  74214. * Sets the required values to the prepass renderer.
  74215. * @param prePassRenderer defines the prepass renderer to setup.
  74216. * @returns true if the pre pass is needed.
  74217. */
  74218. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74219. /**
  74220. * Disposes of the pipeline
  74221. */
  74222. dispose(): void;
  74223. }
  74224. }
  74225. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74226. import { Camera } from "babylonjs/Cameras/camera";
  74227. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74228. /**
  74229. * PostProcessRenderPipelineManager class
  74230. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74231. */
  74232. export class PostProcessRenderPipelineManager {
  74233. private _renderPipelines;
  74234. /**
  74235. * Initializes a PostProcessRenderPipelineManager
  74236. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74237. */
  74238. constructor();
  74239. /**
  74240. * Gets the list of supported render pipelines
  74241. */
  74242. get supportedPipelines(): PostProcessRenderPipeline[];
  74243. /**
  74244. * Adds a pipeline to the manager
  74245. * @param renderPipeline The pipeline to add
  74246. */
  74247. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74248. /**
  74249. * Attaches a camera to the pipeline
  74250. * @param renderPipelineName The name of the pipeline to attach to
  74251. * @param cameras the camera to attach
  74252. * @param unique if the camera can be attached multiple times to the pipeline
  74253. */
  74254. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74255. /**
  74256. * Detaches a camera from the pipeline
  74257. * @param renderPipelineName The name of the pipeline to detach from
  74258. * @param cameras the camera to detach
  74259. */
  74260. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74261. /**
  74262. * Enables an effect by name on a pipeline
  74263. * @param renderPipelineName the name of the pipeline to enable the effect in
  74264. * @param renderEffectName the name of the effect to enable
  74265. * @param cameras the cameras that the effect should be enabled on
  74266. */
  74267. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74268. /**
  74269. * Disables an effect by name on a pipeline
  74270. * @param renderPipelineName the name of the pipeline to disable the effect in
  74271. * @param renderEffectName the name of the effect to disable
  74272. * @param cameras the cameras that the effect should be disabled on
  74273. */
  74274. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74275. /**
  74276. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74277. */
  74278. update(): void;
  74279. /** @hidden */
  74280. _rebuild(): void;
  74281. /**
  74282. * Disposes of the manager and pipelines
  74283. */
  74284. dispose(): void;
  74285. }
  74286. }
  74287. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74288. import { ISceneComponent } from "babylonjs/sceneComponent";
  74289. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74290. import { Scene } from "babylonjs/scene";
  74291. module "babylonjs/scene" {
  74292. interface Scene {
  74293. /** @hidden (Backing field) */
  74294. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74295. /**
  74296. * Gets the postprocess render pipeline manager
  74297. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74298. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74299. */
  74300. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74301. }
  74302. }
  74303. /**
  74304. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74305. */
  74306. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74307. /**
  74308. * The component name helpfull to identify the component in the list of scene components.
  74309. */
  74310. readonly name: string;
  74311. /**
  74312. * The scene the component belongs to.
  74313. */
  74314. scene: Scene;
  74315. /**
  74316. * Creates a new instance of the component for the given scene
  74317. * @param scene Defines the scene to register the component in
  74318. */
  74319. constructor(scene: Scene);
  74320. /**
  74321. * Registers the component in a given scene
  74322. */
  74323. register(): void;
  74324. /**
  74325. * Rebuilds the elements related to this component in case of
  74326. * context lost for instance.
  74327. */
  74328. rebuild(): void;
  74329. /**
  74330. * Disposes the component and the associated ressources
  74331. */
  74332. dispose(): void;
  74333. private _gatherRenderTargets;
  74334. }
  74335. }
  74336. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74337. import { Nullable } from "babylonjs/types";
  74338. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74339. import { Camera } from "babylonjs/Cameras/camera";
  74340. import { IDisposable } from "babylonjs/scene";
  74341. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74342. import { Scene } from "babylonjs/scene";
  74343. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74344. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74345. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74346. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74347. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74348. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74349. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74350. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74351. import { Animation } from "babylonjs/Animations/animation";
  74352. /**
  74353. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74354. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74355. */
  74356. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74357. private _scene;
  74358. private _camerasToBeAttached;
  74359. /**
  74360. * ID of the sharpen post process,
  74361. */
  74362. private readonly SharpenPostProcessId;
  74363. /**
  74364. * @ignore
  74365. * ID of the image processing post process;
  74366. */
  74367. readonly ImageProcessingPostProcessId: string;
  74368. /**
  74369. * @ignore
  74370. * ID of the Fast Approximate Anti-Aliasing post process;
  74371. */
  74372. readonly FxaaPostProcessId: string;
  74373. /**
  74374. * ID of the chromatic aberration post process,
  74375. */
  74376. private readonly ChromaticAberrationPostProcessId;
  74377. /**
  74378. * ID of the grain post process
  74379. */
  74380. private readonly GrainPostProcessId;
  74381. /**
  74382. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74383. */
  74384. sharpen: SharpenPostProcess;
  74385. private _sharpenEffect;
  74386. private bloom;
  74387. /**
  74388. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74389. */
  74390. depthOfField: DepthOfFieldEffect;
  74391. /**
  74392. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74393. */
  74394. fxaa: FxaaPostProcess;
  74395. /**
  74396. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74397. */
  74398. imageProcessing: ImageProcessingPostProcess;
  74399. /**
  74400. * Chromatic aberration post process which will shift rgb colors in the image
  74401. */
  74402. chromaticAberration: ChromaticAberrationPostProcess;
  74403. private _chromaticAberrationEffect;
  74404. /**
  74405. * Grain post process which add noise to the image
  74406. */
  74407. grain: GrainPostProcess;
  74408. private _grainEffect;
  74409. /**
  74410. * Glow post process which adds a glow to emissive areas of the image
  74411. */
  74412. private _glowLayer;
  74413. /**
  74414. * Animations which can be used to tweak settings over a period of time
  74415. */
  74416. animations: Animation[];
  74417. private _imageProcessingConfigurationObserver;
  74418. private _sharpenEnabled;
  74419. private _bloomEnabled;
  74420. private _depthOfFieldEnabled;
  74421. private _depthOfFieldBlurLevel;
  74422. private _fxaaEnabled;
  74423. private _imageProcessingEnabled;
  74424. private _defaultPipelineTextureType;
  74425. private _bloomScale;
  74426. private _chromaticAberrationEnabled;
  74427. private _grainEnabled;
  74428. private _buildAllowed;
  74429. /**
  74430. * Gets active scene
  74431. */
  74432. get scene(): Scene;
  74433. /**
  74434. * Enable or disable the sharpen process from the pipeline
  74435. */
  74436. set sharpenEnabled(enabled: boolean);
  74437. get sharpenEnabled(): boolean;
  74438. private _resizeObserver;
  74439. private _hardwareScaleLevel;
  74440. private _bloomKernel;
  74441. /**
  74442. * Specifies the size of the bloom blur kernel, relative to the final output size
  74443. */
  74444. get bloomKernel(): number;
  74445. set bloomKernel(value: number);
  74446. /**
  74447. * Specifies the weight of the bloom in the final rendering
  74448. */
  74449. private _bloomWeight;
  74450. /**
  74451. * Specifies the luma threshold for the area that will be blurred by the bloom
  74452. */
  74453. private _bloomThreshold;
  74454. private _hdr;
  74455. /**
  74456. * The strength of the bloom.
  74457. */
  74458. set bloomWeight(value: number);
  74459. get bloomWeight(): number;
  74460. /**
  74461. * The strength of the bloom.
  74462. */
  74463. set bloomThreshold(value: number);
  74464. get bloomThreshold(): number;
  74465. /**
  74466. * The scale of the bloom, lower value will provide better performance.
  74467. */
  74468. set bloomScale(value: number);
  74469. get bloomScale(): number;
  74470. /**
  74471. * Enable or disable the bloom from the pipeline
  74472. */
  74473. set bloomEnabled(enabled: boolean);
  74474. get bloomEnabled(): boolean;
  74475. private _rebuildBloom;
  74476. /**
  74477. * If the depth of field is enabled.
  74478. */
  74479. get depthOfFieldEnabled(): boolean;
  74480. set depthOfFieldEnabled(enabled: boolean);
  74481. /**
  74482. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74483. */
  74484. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74485. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74486. /**
  74487. * If the anti aliasing is enabled.
  74488. */
  74489. set fxaaEnabled(enabled: boolean);
  74490. get fxaaEnabled(): boolean;
  74491. private _samples;
  74492. /**
  74493. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74494. */
  74495. set samples(sampleCount: number);
  74496. get samples(): number;
  74497. /**
  74498. * If image processing is enabled.
  74499. */
  74500. set imageProcessingEnabled(enabled: boolean);
  74501. get imageProcessingEnabled(): boolean;
  74502. /**
  74503. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74504. */
  74505. set glowLayerEnabled(enabled: boolean);
  74506. get glowLayerEnabled(): boolean;
  74507. /**
  74508. * Gets the glow layer (or null if not defined)
  74509. */
  74510. get glowLayer(): Nullable<GlowLayer>;
  74511. /**
  74512. * Enable or disable the chromaticAberration process from the pipeline
  74513. */
  74514. set chromaticAberrationEnabled(enabled: boolean);
  74515. get chromaticAberrationEnabled(): boolean;
  74516. /**
  74517. * Enable or disable the grain process from the pipeline
  74518. */
  74519. set grainEnabled(enabled: boolean);
  74520. get grainEnabled(): boolean;
  74521. /**
  74522. * @constructor
  74523. * @param name - The rendering pipeline name (default: "")
  74524. * @param hdr - If high dynamic range textures should be used (default: true)
  74525. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74526. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74527. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74528. */
  74529. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74530. /**
  74531. * Get the class name
  74532. * @returns "DefaultRenderingPipeline"
  74533. */
  74534. getClassName(): string;
  74535. /**
  74536. * Force the compilation of the entire pipeline.
  74537. */
  74538. prepare(): void;
  74539. private _hasCleared;
  74540. private _prevPostProcess;
  74541. private _prevPrevPostProcess;
  74542. private _setAutoClearAndTextureSharing;
  74543. private _depthOfFieldSceneObserver;
  74544. private _buildPipeline;
  74545. private _disposePostProcesses;
  74546. /**
  74547. * Adds a camera to the pipeline
  74548. * @param camera the camera to be added
  74549. */
  74550. addCamera(camera: Camera): void;
  74551. /**
  74552. * Removes a camera from the pipeline
  74553. * @param camera the camera to remove
  74554. */
  74555. removeCamera(camera: Camera): void;
  74556. /**
  74557. * Dispose of the pipeline and stop all post processes
  74558. */
  74559. dispose(): void;
  74560. /**
  74561. * Serialize the rendering pipeline (Used when exporting)
  74562. * @returns the serialized object
  74563. */
  74564. serialize(): any;
  74565. /**
  74566. * Parse the serialized pipeline
  74567. * @param source Source pipeline.
  74568. * @param scene The scene to load the pipeline to.
  74569. * @param rootUrl The URL of the serialized pipeline.
  74570. * @returns An instantiated pipeline from the serialized object.
  74571. */
  74572. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74573. }
  74574. }
  74575. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74576. /** @hidden */
  74577. export var lensHighlightsPixelShader: {
  74578. name: string;
  74579. shader: string;
  74580. };
  74581. }
  74582. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74583. /** @hidden */
  74584. export var depthOfFieldPixelShader: {
  74585. name: string;
  74586. shader: string;
  74587. };
  74588. }
  74589. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74590. import { Camera } from "babylonjs/Cameras/camera";
  74591. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74592. import { Scene } from "babylonjs/scene";
  74593. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74594. import "babylonjs/Shaders/chromaticAberration.fragment";
  74595. import "babylonjs/Shaders/lensHighlights.fragment";
  74596. import "babylonjs/Shaders/depthOfField.fragment";
  74597. /**
  74598. * BABYLON.JS Chromatic Aberration GLSL Shader
  74599. * Author: Olivier Guyot
  74600. * Separates very slightly R, G and B colors on the edges of the screen
  74601. * Inspired by Francois Tarlier & Martins Upitis
  74602. */
  74603. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74604. /**
  74605. * @ignore
  74606. * The chromatic aberration PostProcess id in the pipeline
  74607. */
  74608. LensChromaticAberrationEffect: string;
  74609. /**
  74610. * @ignore
  74611. * The highlights enhancing PostProcess id in the pipeline
  74612. */
  74613. HighlightsEnhancingEffect: string;
  74614. /**
  74615. * @ignore
  74616. * The depth-of-field PostProcess id in the pipeline
  74617. */
  74618. LensDepthOfFieldEffect: string;
  74619. private _scene;
  74620. private _depthTexture;
  74621. private _grainTexture;
  74622. private _chromaticAberrationPostProcess;
  74623. private _highlightsPostProcess;
  74624. private _depthOfFieldPostProcess;
  74625. private _edgeBlur;
  74626. private _grainAmount;
  74627. private _chromaticAberration;
  74628. private _distortion;
  74629. private _highlightsGain;
  74630. private _highlightsThreshold;
  74631. private _dofDistance;
  74632. private _dofAperture;
  74633. private _dofDarken;
  74634. private _dofPentagon;
  74635. private _blurNoise;
  74636. /**
  74637. * @constructor
  74638. *
  74639. * Effect parameters are as follow:
  74640. * {
  74641. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74642. * edge_blur: number; // from 0 to x (1 for realism)
  74643. * distortion: number; // from 0 to x (1 for realism)
  74644. * grain_amount: number; // from 0 to 1
  74645. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74646. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74647. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74648. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74649. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74650. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74651. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74652. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74653. * }
  74654. * Note: if an effect parameter is unset, effect is disabled
  74655. *
  74656. * @param name The rendering pipeline name
  74657. * @param parameters - An object containing all parameters (see above)
  74658. * @param scene The scene linked to this pipeline
  74659. * @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)
  74660. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74661. */
  74662. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74663. /**
  74664. * Get the class name
  74665. * @returns "LensRenderingPipeline"
  74666. */
  74667. getClassName(): string;
  74668. /**
  74669. * Gets associated scene
  74670. */
  74671. get scene(): Scene;
  74672. /**
  74673. * Gets or sets the edge blur
  74674. */
  74675. get edgeBlur(): number;
  74676. set edgeBlur(value: number);
  74677. /**
  74678. * Gets or sets the grain amount
  74679. */
  74680. get grainAmount(): number;
  74681. set grainAmount(value: number);
  74682. /**
  74683. * Gets or sets the chromatic aberration amount
  74684. */
  74685. get chromaticAberration(): number;
  74686. set chromaticAberration(value: number);
  74687. /**
  74688. * Gets or sets the depth of field aperture
  74689. */
  74690. get dofAperture(): number;
  74691. set dofAperture(value: number);
  74692. /**
  74693. * Gets or sets the edge distortion
  74694. */
  74695. get edgeDistortion(): number;
  74696. set edgeDistortion(value: number);
  74697. /**
  74698. * Gets or sets the depth of field distortion
  74699. */
  74700. get dofDistortion(): number;
  74701. set dofDistortion(value: number);
  74702. /**
  74703. * Gets or sets the darken out of focus amount
  74704. */
  74705. get darkenOutOfFocus(): number;
  74706. set darkenOutOfFocus(value: number);
  74707. /**
  74708. * Gets or sets a boolean indicating if blur noise is enabled
  74709. */
  74710. get blurNoise(): boolean;
  74711. set blurNoise(value: boolean);
  74712. /**
  74713. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74714. */
  74715. get pentagonBokeh(): boolean;
  74716. set pentagonBokeh(value: boolean);
  74717. /**
  74718. * Gets or sets the highlight grain amount
  74719. */
  74720. get highlightsGain(): number;
  74721. set highlightsGain(value: number);
  74722. /**
  74723. * Gets or sets the highlight threshold
  74724. */
  74725. get highlightsThreshold(): number;
  74726. set highlightsThreshold(value: number);
  74727. /**
  74728. * Sets the amount of blur at the edges
  74729. * @param amount blur amount
  74730. */
  74731. setEdgeBlur(amount: number): void;
  74732. /**
  74733. * Sets edge blur to 0
  74734. */
  74735. disableEdgeBlur(): void;
  74736. /**
  74737. * Sets the amout of grain
  74738. * @param amount Amount of grain
  74739. */
  74740. setGrainAmount(amount: number): void;
  74741. /**
  74742. * Set grain amount to 0
  74743. */
  74744. disableGrain(): void;
  74745. /**
  74746. * Sets the chromatic aberration amount
  74747. * @param amount amount of chromatic aberration
  74748. */
  74749. setChromaticAberration(amount: number): void;
  74750. /**
  74751. * Sets chromatic aberration amount to 0
  74752. */
  74753. disableChromaticAberration(): void;
  74754. /**
  74755. * Sets the EdgeDistortion amount
  74756. * @param amount amount of EdgeDistortion
  74757. */
  74758. setEdgeDistortion(amount: number): void;
  74759. /**
  74760. * Sets edge distortion to 0
  74761. */
  74762. disableEdgeDistortion(): void;
  74763. /**
  74764. * Sets the FocusDistance amount
  74765. * @param amount amount of FocusDistance
  74766. */
  74767. setFocusDistance(amount: number): void;
  74768. /**
  74769. * Disables depth of field
  74770. */
  74771. disableDepthOfField(): void;
  74772. /**
  74773. * Sets the Aperture amount
  74774. * @param amount amount of Aperture
  74775. */
  74776. setAperture(amount: number): void;
  74777. /**
  74778. * Sets the DarkenOutOfFocus amount
  74779. * @param amount amount of DarkenOutOfFocus
  74780. */
  74781. setDarkenOutOfFocus(amount: number): void;
  74782. private _pentagonBokehIsEnabled;
  74783. /**
  74784. * Creates a pentagon bokeh effect
  74785. */
  74786. enablePentagonBokeh(): void;
  74787. /**
  74788. * Disables the pentagon bokeh effect
  74789. */
  74790. disablePentagonBokeh(): void;
  74791. /**
  74792. * Enables noise blur
  74793. */
  74794. enableNoiseBlur(): void;
  74795. /**
  74796. * Disables noise blur
  74797. */
  74798. disableNoiseBlur(): void;
  74799. /**
  74800. * Sets the HighlightsGain amount
  74801. * @param amount amount of HighlightsGain
  74802. */
  74803. setHighlightsGain(amount: number): void;
  74804. /**
  74805. * Sets the HighlightsThreshold amount
  74806. * @param amount amount of HighlightsThreshold
  74807. */
  74808. setHighlightsThreshold(amount: number): void;
  74809. /**
  74810. * Disables highlights
  74811. */
  74812. disableHighlights(): void;
  74813. /**
  74814. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74815. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74816. */
  74817. dispose(disableDepthRender?: boolean): void;
  74818. private _createChromaticAberrationPostProcess;
  74819. private _createHighlightsPostProcess;
  74820. private _createDepthOfFieldPostProcess;
  74821. private _createGrainTexture;
  74822. }
  74823. }
  74824. declare module "babylonjs/Rendering/ssao2Configuration" {
  74825. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74826. /**
  74827. * Contains all parameters needed for the prepass to perform
  74828. * screen space subsurface scattering
  74829. */
  74830. export class SSAO2Configuration implements PrePassEffectConfiguration {
  74831. /**
  74832. * Is subsurface enabled
  74833. */
  74834. enabled: boolean;
  74835. /**
  74836. * Name of the configuration
  74837. */
  74838. name: string;
  74839. /**
  74840. * Textures that should be present in the MRT for this effect to work
  74841. */
  74842. readonly texturesRequired: number[];
  74843. /**
  74844. * Builds a ssao2 configuration object
  74845. * @param scene The scene
  74846. */
  74847. constructor();
  74848. /**
  74849. * Disposes the configuration
  74850. */
  74851. dispose(): void;
  74852. }
  74853. }
  74854. declare module "babylonjs/Shaders/ssao2.fragment" {
  74855. /** @hidden */
  74856. export var ssao2PixelShader: {
  74857. name: string;
  74858. shader: string;
  74859. };
  74860. }
  74861. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74862. /** @hidden */
  74863. export var ssaoCombinePixelShader: {
  74864. name: string;
  74865. shader: string;
  74866. };
  74867. }
  74868. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74869. import { Camera } from "babylonjs/Cameras/camera";
  74870. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74871. import { Scene } from "babylonjs/scene";
  74872. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74873. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74874. import "babylonjs/Shaders/ssao2.fragment";
  74875. import "babylonjs/Shaders/ssaoCombine.fragment";
  74876. /**
  74877. * Render pipeline to produce ssao effect
  74878. */
  74879. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74880. /**
  74881. * @ignore
  74882. * The PassPostProcess id in the pipeline that contains the original scene color
  74883. */
  74884. SSAOOriginalSceneColorEffect: string;
  74885. /**
  74886. * @ignore
  74887. * The SSAO PostProcess id in the pipeline
  74888. */
  74889. SSAORenderEffect: string;
  74890. /**
  74891. * @ignore
  74892. * The horizontal blur PostProcess id in the pipeline
  74893. */
  74894. SSAOBlurHRenderEffect: string;
  74895. /**
  74896. * @ignore
  74897. * The vertical blur PostProcess id in the pipeline
  74898. */
  74899. SSAOBlurVRenderEffect: string;
  74900. /**
  74901. * @ignore
  74902. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74903. */
  74904. SSAOCombineRenderEffect: string;
  74905. /**
  74906. * The output strength of the SSAO post-process. Default value is 1.0.
  74907. */
  74908. totalStrength: number;
  74909. /**
  74910. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74911. */
  74912. maxZ: number;
  74913. /**
  74914. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74915. */
  74916. minZAspect: number;
  74917. private _samples;
  74918. /**
  74919. * Number of samples used for the SSAO calculations. Default value is 8
  74920. */
  74921. set samples(n: number);
  74922. get samples(): number;
  74923. private _textureSamples;
  74924. /**
  74925. * Number of samples to use for antialiasing
  74926. */
  74927. set textureSamples(n: number);
  74928. get textureSamples(): number;
  74929. /**
  74930. * Force rendering the geometry through geometry buffer
  74931. */
  74932. private _forceGeometryBuffer;
  74933. /**
  74934. * Ratio object used for SSAO ratio and blur ratio
  74935. */
  74936. private _ratio;
  74937. /**
  74938. * Dynamically generated sphere sampler.
  74939. */
  74940. private _sampleSphere;
  74941. private _ssao2PrePassConfiguration;
  74942. /**
  74943. * Blur filter offsets
  74944. */
  74945. private _samplerOffsets;
  74946. private _expensiveBlur;
  74947. /**
  74948. * If bilateral blur should be used
  74949. */
  74950. set expensiveBlur(b: boolean);
  74951. get expensiveBlur(): boolean;
  74952. /**
  74953. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74954. */
  74955. radius: number;
  74956. /**
  74957. * The base color of the SSAO post-process
  74958. * The final result is "base + ssao" between [0, 1]
  74959. */
  74960. base: number;
  74961. /**
  74962. * Support test.
  74963. */
  74964. static get IsSupported(): boolean;
  74965. private _scene;
  74966. private _randomTexture;
  74967. private _originalColorPostProcess;
  74968. private _ssaoPostProcess;
  74969. private _blurHPostProcess;
  74970. private _blurVPostProcess;
  74971. private _ssaoCombinePostProcess;
  74972. private _prePassRenderer;
  74973. /**
  74974. * Gets active scene
  74975. */
  74976. get scene(): Scene;
  74977. /**
  74978. * @constructor
  74979. * @param name The rendering pipeline name
  74980. * @param scene The scene linked to this pipeline
  74981. * @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 }
  74982. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74983. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74984. */
  74985. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74986. /**
  74987. * Get the class name
  74988. * @returns "SSAO2RenderingPipeline"
  74989. */
  74990. getClassName(): string;
  74991. /**
  74992. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74993. */
  74994. dispose(disableGeometryBufferRenderer?: boolean): void;
  74995. private _createBlurPostProcess;
  74996. /** @hidden */
  74997. _rebuild(): void;
  74998. private _bits;
  74999. private _radicalInverse_VdC;
  75000. private _hammersley;
  75001. private _hemisphereSample_uniform;
  75002. private _generateHemisphere;
  75003. private _getDefinesForSSAO;
  75004. private _createSSAOPostProcess;
  75005. private _createSSAOCombinePostProcess;
  75006. private _createRandomTexture;
  75007. /**
  75008. * Serialize the rendering pipeline (Used when exporting)
  75009. * @returns the serialized object
  75010. */
  75011. serialize(): any;
  75012. /**
  75013. * Parse the serialized pipeline
  75014. * @param source Source pipeline.
  75015. * @param scene The scene to load the pipeline to.
  75016. * @param rootUrl The URL of the serialized pipeline.
  75017. * @returns An instantiated pipeline from the serialized object.
  75018. */
  75019. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75020. /**
  75021. * Sets the required values to the prepass renderer.
  75022. * @param prePassRenderer defines the prepass renderer to setup
  75023. * @returns true if the pre pass is needed.
  75024. */
  75025. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  75026. }
  75027. }
  75028. declare module "babylonjs/Shaders/ssao.fragment" {
  75029. /** @hidden */
  75030. export var ssaoPixelShader: {
  75031. name: string;
  75032. shader: string;
  75033. };
  75034. }
  75035. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  75036. import { Camera } from "babylonjs/Cameras/camera";
  75037. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75038. import { Scene } from "babylonjs/scene";
  75039. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75040. import "babylonjs/Shaders/ssao.fragment";
  75041. import "babylonjs/Shaders/ssaoCombine.fragment";
  75042. /**
  75043. * Render pipeline to produce ssao effect
  75044. */
  75045. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75046. /**
  75047. * @ignore
  75048. * The PassPostProcess id in the pipeline that contains the original scene color
  75049. */
  75050. SSAOOriginalSceneColorEffect: string;
  75051. /**
  75052. * @ignore
  75053. * The SSAO PostProcess id in the pipeline
  75054. */
  75055. SSAORenderEffect: string;
  75056. /**
  75057. * @ignore
  75058. * The horizontal blur PostProcess id in the pipeline
  75059. */
  75060. SSAOBlurHRenderEffect: string;
  75061. /**
  75062. * @ignore
  75063. * The vertical blur PostProcess id in the pipeline
  75064. */
  75065. SSAOBlurVRenderEffect: string;
  75066. /**
  75067. * @ignore
  75068. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75069. */
  75070. SSAOCombineRenderEffect: string;
  75071. /**
  75072. * The output strength of the SSAO post-process. Default value is 1.0.
  75073. */
  75074. totalStrength: number;
  75075. /**
  75076. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75077. */
  75078. radius: number;
  75079. /**
  75080. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75081. * Must not be equal to fallOff and superior to fallOff.
  75082. * Default value is 0.0075
  75083. */
  75084. area: number;
  75085. /**
  75086. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75087. * Must not be equal to area and inferior to area.
  75088. * Default value is 0.000001
  75089. */
  75090. fallOff: number;
  75091. /**
  75092. * The base color of the SSAO post-process
  75093. * The final result is "base + ssao" between [0, 1]
  75094. */
  75095. base: number;
  75096. private _scene;
  75097. private _depthTexture;
  75098. private _randomTexture;
  75099. private _originalColorPostProcess;
  75100. private _ssaoPostProcess;
  75101. private _blurHPostProcess;
  75102. private _blurVPostProcess;
  75103. private _ssaoCombinePostProcess;
  75104. private _firstUpdate;
  75105. /**
  75106. * Gets active scene
  75107. */
  75108. get scene(): Scene;
  75109. /**
  75110. * @constructor
  75111. * @param name - The rendering pipeline name
  75112. * @param scene - The scene linked to this pipeline
  75113. * @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 }
  75114. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75115. */
  75116. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75117. /**
  75118. * Get the class name
  75119. * @returns "SSAORenderingPipeline"
  75120. */
  75121. getClassName(): string;
  75122. /**
  75123. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75124. */
  75125. dispose(disableDepthRender?: boolean): void;
  75126. private _createBlurPostProcess;
  75127. /** @hidden */
  75128. _rebuild(): void;
  75129. private _createSSAOPostProcess;
  75130. private _createSSAOCombinePostProcess;
  75131. private _createRandomTexture;
  75132. }
  75133. }
  75134. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75135. /** @hidden */
  75136. export var screenSpaceReflectionPixelShader: {
  75137. name: string;
  75138. shader: string;
  75139. };
  75140. }
  75141. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75142. import { Nullable } from "babylonjs/types";
  75143. import { Camera } from "babylonjs/Cameras/camera";
  75144. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75145. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75146. import { Engine } from "babylonjs/Engines/engine";
  75147. import { Scene } from "babylonjs/scene";
  75148. /**
  75149. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75150. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75151. */
  75152. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75153. /**
  75154. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75155. */
  75156. threshold: number;
  75157. /**
  75158. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75159. */
  75160. strength: number;
  75161. /**
  75162. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75163. */
  75164. reflectionSpecularFalloffExponent: number;
  75165. /**
  75166. * 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]
  75167. */
  75168. step: number;
  75169. /**
  75170. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75171. */
  75172. roughnessFactor: number;
  75173. private _geometryBufferRenderer;
  75174. private _enableSmoothReflections;
  75175. private _reflectionSamples;
  75176. private _smoothSteps;
  75177. /**
  75178. * Gets a string identifying the name of the class
  75179. * @returns "ScreenSpaceReflectionPostProcess" string
  75180. */
  75181. getClassName(): string;
  75182. /**
  75183. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75184. * @param name The name of the effect.
  75185. * @param scene The scene containing the objects to calculate reflections.
  75186. * @param options The required width/height ratio to downsize to before computing the render pass.
  75187. * @param camera The camera to apply the render pass to.
  75188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75189. * @param engine The engine which the post process will be applied. (default: current engine)
  75190. * @param reusable If the post process can be reused on the same frame. (default: false)
  75191. * @param textureType Type of textures used when performing the post process. (default: 0)
  75192. * @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)
  75193. */
  75194. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75195. /**
  75196. * Gets wether or not smoothing reflections is enabled.
  75197. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75198. */
  75199. get enableSmoothReflections(): boolean;
  75200. /**
  75201. * Sets wether or not smoothing reflections is enabled.
  75202. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75203. */
  75204. set enableSmoothReflections(enabled: boolean);
  75205. /**
  75206. * Gets the number of samples taken while computing reflections. More samples count is high,
  75207. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75208. */
  75209. get reflectionSamples(): number;
  75210. /**
  75211. * Sets the number of samples taken while computing reflections. More samples count is high,
  75212. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75213. */
  75214. set reflectionSamples(samples: number);
  75215. /**
  75216. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75217. * more the post-process will require GPU power and can generate a drop in FPS.
  75218. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75219. */
  75220. get smoothSteps(): number;
  75221. set smoothSteps(steps: number);
  75222. private _updateEffectDefines;
  75223. /** @hidden */
  75224. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75225. }
  75226. }
  75227. declare module "babylonjs/Shaders/standard.fragment" {
  75228. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75229. /** @hidden */
  75230. export var standardPixelShader: {
  75231. name: string;
  75232. shader: string;
  75233. };
  75234. }
  75235. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75236. import { Nullable } from "babylonjs/types";
  75237. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75238. import { Camera } from "babylonjs/Cameras/camera";
  75239. import { Texture } from "babylonjs/Materials/Textures/texture";
  75240. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75241. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75242. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75243. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75244. import { IDisposable } from "babylonjs/scene";
  75245. import { SpotLight } from "babylonjs/Lights/spotLight";
  75246. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75247. import { Scene } from "babylonjs/scene";
  75248. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75249. import { Animation } from "babylonjs/Animations/animation";
  75250. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75251. import "babylonjs/Shaders/standard.fragment";
  75252. /**
  75253. * Standard rendering pipeline
  75254. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75255. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75256. */
  75257. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75258. /**
  75259. * Public members
  75260. */
  75261. /**
  75262. * Post-process which contains the original scene color before the pipeline applies all the effects
  75263. */
  75264. originalPostProcess: Nullable<PostProcess>;
  75265. /**
  75266. * Post-process used to down scale an image x4
  75267. */
  75268. downSampleX4PostProcess: Nullable<PostProcess>;
  75269. /**
  75270. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75271. */
  75272. brightPassPostProcess: Nullable<PostProcess>;
  75273. /**
  75274. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75275. */
  75276. blurHPostProcesses: PostProcess[];
  75277. /**
  75278. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75279. */
  75280. blurVPostProcesses: PostProcess[];
  75281. /**
  75282. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75283. */
  75284. textureAdderPostProcess: Nullable<PostProcess>;
  75285. /**
  75286. * Post-process used to create volumetric lighting effect
  75287. */
  75288. volumetricLightPostProcess: Nullable<PostProcess>;
  75289. /**
  75290. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75291. */
  75292. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75293. /**
  75294. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75295. */
  75296. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75297. /**
  75298. * Post-process used to merge the volumetric light effect and the real scene color
  75299. */
  75300. volumetricLightMergePostProces: Nullable<PostProcess>;
  75301. /**
  75302. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75303. */
  75304. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75305. /**
  75306. * Base post-process used to calculate the average luminance of the final image for HDR
  75307. */
  75308. luminancePostProcess: Nullable<PostProcess>;
  75309. /**
  75310. * Post-processes used to create down sample post-processes in order to get
  75311. * the average luminance of the final image for HDR
  75312. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75313. */
  75314. luminanceDownSamplePostProcesses: PostProcess[];
  75315. /**
  75316. * Post-process used to create a HDR effect (light adaptation)
  75317. */
  75318. hdrPostProcess: Nullable<PostProcess>;
  75319. /**
  75320. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75321. */
  75322. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75323. /**
  75324. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75325. */
  75326. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75327. /**
  75328. * Post-process used to merge the final HDR post-process and the real scene color
  75329. */
  75330. hdrFinalPostProcess: Nullable<PostProcess>;
  75331. /**
  75332. * Post-process used to create a lens flare effect
  75333. */
  75334. lensFlarePostProcess: Nullable<PostProcess>;
  75335. /**
  75336. * Post-process that merges the result of the lens flare post-process and the real scene color
  75337. */
  75338. lensFlareComposePostProcess: Nullable<PostProcess>;
  75339. /**
  75340. * Post-process used to create a motion blur effect
  75341. */
  75342. motionBlurPostProcess: Nullable<PostProcess>;
  75343. /**
  75344. * Post-process used to create a depth of field effect
  75345. */
  75346. depthOfFieldPostProcess: Nullable<PostProcess>;
  75347. /**
  75348. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75349. */
  75350. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75351. /**
  75352. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75353. */
  75354. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75355. /**
  75356. * Represents the brightness threshold in order to configure the illuminated surfaces
  75357. */
  75358. brightThreshold: number;
  75359. /**
  75360. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75361. */
  75362. blurWidth: number;
  75363. /**
  75364. * Sets if the blur for highlighted surfaces must be only horizontal
  75365. */
  75366. horizontalBlur: boolean;
  75367. /**
  75368. * Gets the overall exposure used by the pipeline
  75369. */
  75370. get exposure(): number;
  75371. /**
  75372. * Sets the overall exposure used by the pipeline
  75373. */
  75374. set exposure(value: number);
  75375. /**
  75376. * Texture used typically to simulate "dirty" on camera lens
  75377. */
  75378. lensTexture: Nullable<Texture>;
  75379. /**
  75380. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75381. */
  75382. volumetricLightCoefficient: number;
  75383. /**
  75384. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75385. */
  75386. volumetricLightPower: number;
  75387. /**
  75388. * Used the set the blur intensity to smooth the volumetric lights
  75389. */
  75390. volumetricLightBlurScale: number;
  75391. /**
  75392. * Light (spot or directional) used to generate the volumetric lights rays
  75393. * The source light must have a shadow generate so the pipeline can get its
  75394. * depth map
  75395. */
  75396. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75397. /**
  75398. * For eye adaptation, represents the minimum luminance the eye can see
  75399. */
  75400. hdrMinimumLuminance: number;
  75401. /**
  75402. * For eye adaptation, represents the decrease luminance speed
  75403. */
  75404. hdrDecreaseRate: number;
  75405. /**
  75406. * For eye adaptation, represents the increase luminance speed
  75407. */
  75408. hdrIncreaseRate: number;
  75409. /**
  75410. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75411. */
  75412. get hdrAutoExposure(): boolean;
  75413. /**
  75414. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75415. */
  75416. set hdrAutoExposure(value: boolean);
  75417. /**
  75418. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75419. */
  75420. lensColorTexture: Nullable<Texture>;
  75421. /**
  75422. * The overall strengh for the lens flare effect
  75423. */
  75424. lensFlareStrength: number;
  75425. /**
  75426. * Dispersion coefficient for lens flare ghosts
  75427. */
  75428. lensFlareGhostDispersal: number;
  75429. /**
  75430. * Main lens flare halo width
  75431. */
  75432. lensFlareHaloWidth: number;
  75433. /**
  75434. * Based on the lens distortion effect, defines how much the lens flare result
  75435. * is distorted
  75436. */
  75437. lensFlareDistortionStrength: number;
  75438. /**
  75439. * Configures the blur intensity used for for lens flare (halo)
  75440. */
  75441. lensFlareBlurWidth: number;
  75442. /**
  75443. * Lens star texture must be used to simulate rays on the flares and is available
  75444. * in the documentation
  75445. */
  75446. lensStarTexture: Nullable<Texture>;
  75447. /**
  75448. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75449. * flare effect by taking account of the dirt texture
  75450. */
  75451. lensFlareDirtTexture: Nullable<Texture>;
  75452. /**
  75453. * Represents the focal length for the depth of field effect
  75454. */
  75455. depthOfFieldDistance: number;
  75456. /**
  75457. * Represents the blur intensity for the blurred part of the depth of field effect
  75458. */
  75459. depthOfFieldBlurWidth: number;
  75460. /**
  75461. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75462. */
  75463. get motionStrength(): number;
  75464. /**
  75465. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75466. */
  75467. set motionStrength(strength: number);
  75468. /**
  75469. * Gets wether or not the motion blur post-process is object based or screen based.
  75470. */
  75471. get objectBasedMotionBlur(): boolean;
  75472. /**
  75473. * Sets wether or not the motion blur post-process should be object based or screen based
  75474. */
  75475. set objectBasedMotionBlur(value: boolean);
  75476. /**
  75477. * List of animations for the pipeline (IAnimatable implementation)
  75478. */
  75479. animations: Animation[];
  75480. /**
  75481. * Private members
  75482. */
  75483. private _scene;
  75484. private _currentDepthOfFieldSource;
  75485. private _basePostProcess;
  75486. private _fixedExposure;
  75487. private _currentExposure;
  75488. private _hdrAutoExposure;
  75489. private _hdrCurrentLuminance;
  75490. private _motionStrength;
  75491. private _isObjectBasedMotionBlur;
  75492. private _floatTextureType;
  75493. private _camerasToBeAttached;
  75494. private _ratio;
  75495. private _bloomEnabled;
  75496. private _depthOfFieldEnabled;
  75497. private _vlsEnabled;
  75498. private _lensFlareEnabled;
  75499. private _hdrEnabled;
  75500. private _motionBlurEnabled;
  75501. private _fxaaEnabled;
  75502. private _screenSpaceReflectionsEnabled;
  75503. private _motionBlurSamples;
  75504. private _volumetricLightStepsCount;
  75505. private _samples;
  75506. /**
  75507. * @ignore
  75508. * Specifies if the bloom pipeline is enabled
  75509. */
  75510. get BloomEnabled(): boolean;
  75511. set BloomEnabled(enabled: boolean);
  75512. /**
  75513. * @ignore
  75514. * Specifies if the depth of field pipeline is enabed
  75515. */
  75516. get DepthOfFieldEnabled(): boolean;
  75517. set DepthOfFieldEnabled(enabled: boolean);
  75518. /**
  75519. * @ignore
  75520. * Specifies if the lens flare pipeline is enabed
  75521. */
  75522. get LensFlareEnabled(): boolean;
  75523. set LensFlareEnabled(enabled: boolean);
  75524. /**
  75525. * @ignore
  75526. * Specifies if the HDR pipeline is enabled
  75527. */
  75528. get HDREnabled(): boolean;
  75529. set HDREnabled(enabled: boolean);
  75530. /**
  75531. * @ignore
  75532. * Specifies if the volumetric lights scattering effect is enabled
  75533. */
  75534. get VLSEnabled(): boolean;
  75535. set VLSEnabled(enabled: boolean);
  75536. /**
  75537. * @ignore
  75538. * Specifies if the motion blur effect is enabled
  75539. */
  75540. get MotionBlurEnabled(): boolean;
  75541. set MotionBlurEnabled(enabled: boolean);
  75542. /**
  75543. * Specifies if anti-aliasing is enabled
  75544. */
  75545. get fxaaEnabled(): boolean;
  75546. set fxaaEnabled(enabled: boolean);
  75547. /**
  75548. * Specifies if screen space reflections are enabled.
  75549. */
  75550. get screenSpaceReflectionsEnabled(): boolean;
  75551. set screenSpaceReflectionsEnabled(enabled: boolean);
  75552. /**
  75553. * Specifies the number of steps used to calculate the volumetric lights
  75554. * Typically in interval [50, 200]
  75555. */
  75556. get volumetricLightStepsCount(): number;
  75557. set volumetricLightStepsCount(count: number);
  75558. /**
  75559. * Specifies the number of samples used for the motion blur effect
  75560. * Typically in interval [16, 64]
  75561. */
  75562. get motionBlurSamples(): number;
  75563. set motionBlurSamples(samples: number);
  75564. /**
  75565. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75566. */
  75567. get samples(): number;
  75568. set samples(sampleCount: number);
  75569. /**
  75570. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75571. * @constructor
  75572. * @param name The rendering pipeline name
  75573. * @param scene The scene linked to this pipeline
  75574. * @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)
  75575. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75576. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75577. */
  75578. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75579. private _buildPipeline;
  75580. private _createDownSampleX4PostProcess;
  75581. private _createBrightPassPostProcess;
  75582. private _createBlurPostProcesses;
  75583. private _createTextureAdderPostProcess;
  75584. private _createVolumetricLightPostProcess;
  75585. private _createLuminancePostProcesses;
  75586. private _createHdrPostProcess;
  75587. private _createLensFlarePostProcess;
  75588. private _createDepthOfFieldPostProcess;
  75589. private _createMotionBlurPostProcess;
  75590. private _getDepthTexture;
  75591. private _disposePostProcesses;
  75592. /**
  75593. * Dispose of the pipeline and stop all post processes
  75594. */
  75595. dispose(): void;
  75596. /**
  75597. * Serialize the rendering pipeline (Used when exporting)
  75598. * @returns the serialized object
  75599. */
  75600. serialize(): any;
  75601. /**
  75602. * Parse the serialized pipeline
  75603. * @param source Source pipeline.
  75604. * @param scene The scene to load the pipeline to.
  75605. * @param rootUrl The URL of the serialized pipeline.
  75606. * @returns An instantiated pipeline from the serialized object.
  75607. */
  75608. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75609. /**
  75610. * Luminance steps
  75611. */
  75612. static LuminanceSteps: number;
  75613. }
  75614. }
  75615. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75616. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75617. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75618. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75619. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75620. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75621. }
  75622. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75623. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75624. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75625. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75626. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75627. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75628. }
  75629. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75630. /** @hidden */
  75631. export var stereoscopicInterlacePixelShader: {
  75632. name: string;
  75633. shader: string;
  75634. };
  75635. }
  75636. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75637. import { Camera } from "babylonjs/Cameras/camera";
  75638. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75639. import { Engine } from "babylonjs/Engines/engine";
  75640. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75641. /**
  75642. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75643. */
  75644. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75645. private _stepSize;
  75646. private _passedProcess;
  75647. /**
  75648. * Gets a string identifying the name of the class
  75649. * @returns "StereoscopicInterlacePostProcessI" string
  75650. */
  75651. getClassName(): string;
  75652. /**
  75653. * Initializes a StereoscopicInterlacePostProcessI
  75654. * @param name The name of the effect.
  75655. * @param rigCameras The rig cameras to be appled to the post process
  75656. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75657. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75658. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75659. * @param engine The engine which the post process will be applied. (default: current engine)
  75660. * @param reusable If the post process can be reused on the same frame. (default: false)
  75661. */
  75662. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75663. }
  75664. /**
  75665. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75666. */
  75667. export class StereoscopicInterlacePostProcess extends PostProcess {
  75668. private _stepSize;
  75669. private _passedProcess;
  75670. /**
  75671. * Gets a string identifying the name of the class
  75672. * @returns "StereoscopicInterlacePostProcess" string
  75673. */
  75674. getClassName(): string;
  75675. /**
  75676. * Initializes a StereoscopicInterlacePostProcess
  75677. * @param name The name of the effect.
  75678. * @param rigCameras The rig cameras to be appled to the post process
  75679. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75681. * @param engine The engine which the post process will be applied. (default: current engine)
  75682. * @param reusable If the post process can be reused on the same frame. (default: false)
  75683. */
  75684. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75685. }
  75686. }
  75687. declare module "babylonjs/Shaders/tonemap.fragment" {
  75688. /** @hidden */
  75689. export var tonemapPixelShader: {
  75690. name: string;
  75691. shader: string;
  75692. };
  75693. }
  75694. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75695. import { Camera } from "babylonjs/Cameras/camera";
  75696. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75697. import "babylonjs/Shaders/tonemap.fragment";
  75698. import { Engine } from "babylonjs/Engines/engine";
  75699. /** Defines operator used for tonemapping */
  75700. export enum TonemappingOperator {
  75701. /** Hable */
  75702. Hable = 0,
  75703. /** Reinhard */
  75704. Reinhard = 1,
  75705. /** HejiDawson */
  75706. HejiDawson = 2,
  75707. /** Photographic */
  75708. Photographic = 3
  75709. }
  75710. /**
  75711. * Defines a post process to apply tone mapping
  75712. */
  75713. export class TonemapPostProcess extends PostProcess {
  75714. private _operator;
  75715. /** Defines the required exposure adjustement */
  75716. exposureAdjustment: number;
  75717. /**
  75718. * Gets a string identifying the name of the class
  75719. * @returns "TonemapPostProcess" string
  75720. */
  75721. getClassName(): string;
  75722. /**
  75723. * Creates a new TonemapPostProcess
  75724. * @param name defines the name of the postprocess
  75725. * @param _operator defines the operator to use
  75726. * @param exposureAdjustment defines the required exposure adjustement
  75727. * @param camera defines the camera to use (can be null)
  75728. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75729. * @param engine defines the hosting engine (can be ignore if camera is set)
  75730. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75731. */
  75732. constructor(name: string, _operator: TonemappingOperator,
  75733. /** Defines the required exposure adjustement */
  75734. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75735. }
  75736. }
  75737. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75738. /** @hidden */
  75739. export var volumetricLightScatteringPixelShader: {
  75740. name: string;
  75741. shader: string;
  75742. };
  75743. }
  75744. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75745. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75746. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75747. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75748. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75749. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75750. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75751. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75752. /** @hidden */
  75753. export var volumetricLightScatteringPassVertexShader: {
  75754. name: string;
  75755. shader: string;
  75756. };
  75757. }
  75758. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75759. /** @hidden */
  75760. export var volumetricLightScatteringPassPixelShader: {
  75761. name: string;
  75762. shader: string;
  75763. };
  75764. }
  75765. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75766. import { Vector3 } from "babylonjs/Maths/math.vector";
  75767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75768. import { Mesh } from "babylonjs/Meshes/mesh";
  75769. import { Camera } from "babylonjs/Cameras/camera";
  75770. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75771. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75772. import { Scene } from "babylonjs/scene";
  75773. import "babylonjs/Meshes/Builders/planeBuilder";
  75774. import "babylonjs/Shaders/depth.vertex";
  75775. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75776. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75777. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75778. import { Engine } from "babylonjs/Engines/engine";
  75779. /**
  75780. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75781. */
  75782. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75783. private _volumetricLightScatteringPass;
  75784. private _volumetricLightScatteringRTT;
  75785. private _viewPort;
  75786. private _screenCoordinates;
  75787. private _cachedDefines;
  75788. /**
  75789. * If not undefined, the mesh position is computed from the attached node position
  75790. */
  75791. attachedNode: {
  75792. position: Vector3;
  75793. };
  75794. /**
  75795. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75796. */
  75797. customMeshPosition: Vector3;
  75798. /**
  75799. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75800. */
  75801. useCustomMeshPosition: boolean;
  75802. /**
  75803. * If the post-process should inverse the light scattering direction
  75804. */
  75805. invert: boolean;
  75806. /**
  75807. * The internal mesh used by the post-process
  75808. */
  75809. mesh: Mesh;
  75810. /**
  75811. * @hidden
  75812. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75813. */
  75814. get useDiffuseColor(): boolean;
  75815. set useDiffuseColor(useDiffuseColor: boolean);
  75816. /**
  75817. * Array containing the excluded meshes not rendered in the internal pass
  75818. */
  75819. excludedMeshes: AbstractMesh[];
  75820. /**
  75821. * Controls the overall intensity of the post-process
  75822. */
  75823. exposure: number;
  75824. /**
  75825. * Dissipates each sample's contribution in range [0, 1]
  75826. */
  75827. decay: number;
  75828. /**
  75829. * Controls the overall intensity of each sample
  75830. */
  75831. weight: number;
  75832. /**
  75833. * Controls the density of each sample
  75834. */
  75835. density: number;
  75836. /**
  75837. * @constructor
  75838. * @param name The post-process name
  75839. * @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)
  75840. * @param camera The camera that the post-process will be attached to
  75841. * @param mesh The mesh used to create the light scattering
  75842. * @param samples The post-process quality, default 100
  75843. * @param samplingModeThe post-process filtering mode
  75844. * @param engine The babylon engine
  75845. * @param reusable If the post-process is reusable
  75846. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75847. */
  75848. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75849. /**
  75850. * Returns the string "VolumetricLightScatteringPostProcess"
  75851. * @returns "VolumetricLightScatteringPostProcess"
  75852. */
  75853. getClassName(): string;
  75854. private _isReady;
  75855. /**
  75856. * Sets the new light position for light scattering effect
  75857. * @param position The new custom light position
  75858. */
  75859. setCustomMeshPosition(position: Vector3): void;
  75860. /**
  75861. * Returns the light position for light scattering effect
  75862. * @return Vector3 The custom light position
  75863. */
  75864. getCustomMeshPosition(): Vector3;
  75865. /**
  75866. * Disposes the internal assets and detaches the post-process from the camera
  75867. */
  75868. dispose(camera: Camera): void;
  75869. /**
  75870. * Returns the render target texture used by the post-process
  75871. * @return the render target texture used by the post-process
  75872. */
  75873. getPass(): RenderTargetTexture;
  75874. private _meshExcluded;
  75875. private _createPass;
  75876. private _updateMeshScreenCoordinates;
  75877. /**
  75878. * Creates a default mesh for the Volumeric Light Scattering post-process
  75879. * @param name The mesh name
  75880. * @param scene The scene where to create the mesh
  75881. * @return the default mesh
  75882. */
  75883. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75884. }
  75885. }
  75886. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75887. /** @hidden */
  75888. export var screenSpaceCurvaturePixelShader: {
  75889. name: string;
  75890. shader: string;
  75891. };
  75892. }
  75893. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75894. import { Nullable } from "babylonjs/types";
  75895. import { Camera } from "babylonjs/Cameras/camera";
  75896. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75897. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75898. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75899. import { Engine } from "babylonjs/Engines/engine";
  75900. import { Scene } from "babylonjs/scene";
  75901. /**
  75902. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75903. */
  75904. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75905. /**
  75906. * Defines how much ridge the curvature effect displays.
  75907. */
  75908. ridge: number;
  75909. /**
  75910. * Defines how much valley the curvature effect displays.
  75911. */
  75912. valley: number;
  75913. private _geometryBufferRenderer;
  75914. /**
  75915. * Gets a string identifying the name of the class
  75916. * @returns "ScreenSpaceCurvaturePostProcess" string
  75917. */
  75918. getClassName(): string;
  75919. /**
  75920. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75921. * @param name The name of the effect.
  75922. * @param scene The scene containing the objects to blur according to their velocity.
  75923. * @param options The required width/height ratio to downsize to before computing the render pass.
  75924. * @param camera The camera to apply the render pass to.
  75925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75926. * @param engine The engine which the post process will be applied. (default: current engine)
  75927. * @param reusable If the post process can be reused on the same frame. (default: false)
  75928. * @param textureType Type of textures used when performing the post process. (default: 0)
  75929. * @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)
  75930. */
  75931. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75932. /**
  75933. * Support test.
  75934. */
  75935. static get IsSupported(): boolean;
  75936. /** @hidden */
  75937. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  75938. }
  75939. }
  75940. declare module "babylonjs/PostProcesses/index" {
  75941. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75942. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75943. export * from "babylonjs/PostProcesses/bloomEffect";
  75944. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75945. export * from "babylonjs/PostProcesses/blurPostProcess";
  75946. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75947. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75948. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75949. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75950. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75951. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75952. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75953. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75954. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75955. export * from "babylonjs/PostProcesses/filterPostProcess";
  75956. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75957. export * from "babylonjs/PostProcesses/grainPostProcess";
  75958. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75959. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75960. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75961. export * from "babylonjs/PostProcesses/passPostProcess";
  75962. export * from "babylonjs/PostProcesses/postProcess";
  75963. export * from "babylonjs/PostProcesses/postProcessManager";
  75964. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75965. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75966. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75967. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75968. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75969. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75970. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75971. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75972. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75973. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75974. }
  75975. declare module "babylonjs/Probes/index" {
  75976. export * from "babylonjs/Probes/reflectionProbe";
  75977. }
  75978. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75979. import { Scene } from "babylonjs/scene";
  75980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75981. import { SmartArray } from "babylonjs/Misc/smartArray";
  75982. import { ISceneComponent } from "babylonjs/sceneComponent";
  75983. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75984. import "babylonjs/Meshes/Builders/boxBuilder";
  75985. import "babylonjs/Shaders/color.fragment";
  75986. import "babylonjs/Shaders/color.vertex";
  75987. import { Color3 } from "babylonjs/Maths/math.color";
  75988. import { Observable } from "babylonjs/Misc/observable";
  75989. module "babylonjs/scene" {
  75990. interface Scene {
  75991. /** @hidden (Backing field) */
  75992. _boundingBoxRenderer: BoundingBoxRenderer;
  75993. /** @hidden (Backing field) */
  75994. _forceShowBoundingBoxes: boolean;
  75995. /**
  75996. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75997. */
  75998. forceShowBoundingBoxes: boolean;
  75999. /**
  76000. * Gets the bounding box renderer associated with the scene
  76001. * @returns a BoundingBoxRenderer
  76002. */
  76003. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76004. }
  76005. }
  76006. module "babylonjs/Meshes/abstractMesh" {
  76007. interface AbstractMesh {
  76008. /** @hidden (Backing field) */
  76009. _showBoundingBox: boolean;
  76010. /**
  76011. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76012. */
  76013. showBoundingBox: boolean;
  76014. }
  76015. }
  76016. /**
  76017. * Component responsible of rendering the bounding box of the meshes in a scene.
  76018. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76019. */
  76020. export class BoundingBoxRenderer implements ISceneComponent {
  76021. /**
  76022. * The component name helpfull to identify the component in the list of scene components.
  76023. */
  76024. readonly name: string;
  76025. /**
  76026. * The scene the component belongs to.
  76027. */
  76028. scene: Scene;
  76029. /**
  76030. * Color of the bounding box lines placed in front of an object
  76031. */
  76032. frontColor: Color3;
  76033. /**
  76034. * Color of the bounding box lines placed behind an object
  76035. */
  76036. backColor: Color3;
  76037. /**
  76038. * Defines if the renderer should show the back lines or not
  76039. */
  76040. showBackLines: boolean;
  76041. /**
  76042. * Observable raised before rendering a bounding box
  76043. */
  76044. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76045. /**
  76046. * Observable raised after rendering a bounding box
  76047. */
  76048. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76049. /**
  76050. * @hidden
  76051. */
  76052. renderList: SmartArray<BoundingBox>;
  76053. private _colorShader;
  76054. private _vertexBuffers;
  76055. private _indexBuffer;
  76056. private _fillIndexBuffer;
  76057. private _fillIndexData;
  76058. /**
  76059. * Instantiates a new bounding box renderer in a scene.
  76060. * @param scene the scene the renderer renders in
  76061. */
  76062. constructor(scene: Scene);
  76063. /**
  76064. * Registers the component in a given scene
  76065. */
  76066. register(): void;
  76067. private _evaluateSubMesh;
  76068. private _activeMesh;
  76069. private _prepareRessources;
  76070. private _createIndexBuffer;
  76071. /**
  76072. * Rebuilds the elements related to this component in case of
  76073. * context lost for instance.
  76074. */
  76075. rebuild(): void;
  76076. /**
  76077. * @hidden
  76078. */
  76079. reset(): void;
  76080. /**
  76081. * Render the bounding boxes of a specific rendering group
  76082. * @param renderingGroupId defines the rendering group to render
  76083. */
  76084. render(renderingGroupId: number): void;
  76085. /**
  76086. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76087. * @param mesh Define the mesh to render the occlusion bounding box for
  76088. */
  76089. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76090. /**
  76091. * Dispose and release the resources attached to this renderer.
  76092. */
  76093. dispose(): void;
  76094. }
  76095. }
  76096. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76097. import { Nullable } from "babylonjs/types";
  76098. import { Scene } from "babylonjs/scene";
  76099. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76100. import { Camera } from "babylonjs/Cameras/camera";
  76101. import { ISceneComponent } from "babylonjs/sceneComponent";
  76102. module "babylonjs/scene" {
  76103. interface Scene {
  76104. /** @hidden (Backing field) */
  76105. _depthRenderer: {
  76106. [id: string]: DepthRenderer;
  76107. };
  76108. /**
  76109. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76110. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76111. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76112. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76113. * @returns the created depth renderer
  76114. */
  76115. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76116. /**
  76117. * Disables a depth renderer for a given camera
  76118. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76119. */
  76120. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76121. }
  76122. }
  76123. /**
  76124. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76125. * in several rendering techniques.
  76126. */
  76127. export class DepthRendererSceneComponent implements ISceneComponent {
  76128. /**
  76129. * The component name helpfull to identify the component in the list of scene components.
  76130. */
  76131. readonly name: string;
  76132. /**
  76133. * The scene the component belongs to.
  76134. */
  76135. scene: Scene;
  76136. /**
  76137. * Creates a new instance of the component for the given scene
  76138. * @param scene Defines the scene to register the component in
  76139. */
  76140. constructor(scene: Scene);
  76141. /**
  76142. * Registers the component in a given scene
  76143. */
  76144. register(): void;
  76145. /**
  76146. * Rebuilds the elements related to this component in case of
  76147. * context lost for instance.
  76148. */
  76149. rebuild(): void;
  76150. /**
  76151. * Disposes the component and the associated ressources
  76152. */
  76153. dispose(): void;
  76154. private _gatherRenderTargets;
  76155. private _gatherActiveCameraRenderTargets;
  76156. }
  76157. }
  76158. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76159. import { Nullable } from "babylonjs/types";
  76160. import { Scene } from "babylonjs/scene";
  76161. import { ISceneComponent } from "babylonjs/sceneComponent";
  76162. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76163. module "babylonjs/abstractScene" {
  76164. interface AbstractScene {
  76165. /** @hidden (Backing field) */
  76166. _prePassRenderer: Nullable<PrePassRenderer>;
  76167. /**
  76168. * Gets or Sets the current prepass renderer associated to the scene.
  76169. */
  76170. prePassRenderer: Nullable<PrePassRenderer>;
  76171. /**
  76172. * Enables the prepass and associates it with the scene
  76173. * @returns the PrePassRenderer
  76174. */
  76175. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76176. /**
  76177. * Disables the prepass associated with the scene
  76178. */
  76179. disablePrePassRenderer(): void;
  76180. }
  76181. }
  76182. /**
  76183. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76184. * in several rendering techniques.
  76185. */
  76186. export class PrePassRendererSceneComponent implements ISceneComponent {
  76187. /**
  76188. * The component name helpful to identify the component in the list of scene components.
  76189. */
  76190. readonly name: string;
  76191. /**
  76192. * The scene the component belongs to.
  76193. */
  76194. scene: Scene;
  76195. /**
  76196. * Creates a new instance of the component for the given scene
  76197. * @param scene Defines the scene to register the component in
  76198. */
  76199. constructor(scene: Scene);
  76200. /**
  76201. * Registers the component in a given scene
  76202. */
  76203. register(): void;
  76204. private _beforeCameraDraw;
  76205. private _afterCameraDraw;
  76206. private _beforeClearStage;
  76207. /**
  76208. * Rebuilds the elements related to this component in case of
  76209. * context lost for instance.
  76210. */
  76211. rebuild(): void;
  76212. /**
  76213. * Disposes the component and the associated ressources
  76214. */
  76215. dispose(): void;
  76216. }
  76217. }
  76218. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  76219. /** @hidden */
  76220. export var fibonacci: {
  76221. name: string;
  76222. shader: string;
  76223. };
  76224. }
  76225. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  76226. /** @hidden */
  76227. export var diffusionProfile: {
  76228. name: string;
  76229. shader: string;
  76230. };
  76231. }
  76232. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  76233. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  76234. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  76235. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  76236. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  76237. /** @hidden */
  76238. export var subSurfaceScatteringPixelShader: {
  76239. name: string;
  76240. shader: string;
  76241. };
  76242. }
  76243. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  76244. import { Nullable } from "babylonjs/types";
  76245. import { Camera } from "babylonjs/Cameras/camera";
  76246. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76247. import { Engine } from "babylonjs/Engines/engine";
  76248. import { Scene } from "babylonjs/scene";
  76249. import "babylonjs/Shaders/imageProcessing.fragment";
  76250. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  76251. import "babylonjs/Shaders/postprocess.vertex";
  76252. /**
  76253. * Sub surface scattering post process
  76254. */
  76255. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76256. /**
  76257. * Gets a string identifying the name of the class
  76258. * @returns "SubSurfaceScatteringPostProcess" string
  76259. */
  76260. getClassName(): string;
  76261. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76262. }
  76263. }
  76264. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  76265. import { Scene } from "babylonjs/scene";
  76266. import { Color3 } from "babylonjs/Maths/math.color";
  76267. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  76268. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76269. /**
  76270. * Contains all parameters needed for the prepass to perform
  76271. * screen space subsurface scattering
  76272. */
  76273. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76274. /** @hidden */
  76275. static _SceneComponentInitialization: (scene: Scene) => void;
  76276. private _ssDiffusionS;
  76277. private _ssFilterRadii;
  76278. private _ssDiffusionD;
  76279. /**
  76280. * Post process to attach for screen space subsurface scattering
  76281. */
  76282. postProcess: SubSurfaceScatteringPostProcess;
  76283. /**
  76284. * Diffusion profile color for subsurface scattering
  76285. */
  76286. get ssDiffusionS(): number[];
  76287. /**
  76288. * Diffusion profile max color channel value for subsurface scattering
  76289. */
  76290. get ssDiffusionD(): number[];
  76291. /**
  76292. * Diffusion profile filter radius for subsurface scattering
  76293. */
  76294. get ssFilterRadii(): number[];
  76295. /**
  76296. * Is subsurface enabled
  76297. */
  76298. enabled: boolean;
  76299. /**
  76300. * Name of the configuration
  76301. */
  76302. name: string;
  76303. /**
  76304. * Diffusion profile colors for subsurface scattering
  76305. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76306. * See ...
  76307. * Note that you can only store up to 5 of them
  76308. */
  76309. ssDiffusionProfileColors: Color3[];
  76310. /**
  76311. * Defines the ratio real world => scene units.
  76312. * Used for subsurface scattering
  76313. */
  76314. metersPerUnit: number;
  76315. /**
  76316. * Textures that should be present in the MRT for this effect to work
  76317. */
  76318. readonly texturesRequired: number[];
  76319. private _scene;
  76320. /**
  76321. * Builds a subsurface configuration object
  76322. * @param scene The scene
  76323. */
  76324. constructor(scene: Scene);
  76325. /**
  76326. * Adds a new diffusion profile.
  76327. * Useful for more realistic subsurface scattering on diverse materials.
  76328. * @param color The color of the diffusion profile. Should be the average color of the material.
  76329. * @return The index of the diffusion profile for the material subsurface configuration
  76330. */
  76331. addDiffusionProfile(color: Color3): number;
  76332. /**
  76333. * Creates the sss post process
  76334. * @return The created post process
  76335. */
  76336. createPostProcess(): SubSurfaceScatteringPostProcess;
  76337. /**
  76338. * Deletes all diffusion profiles.
  76339. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76340. */
  76341. clearAllDiffusionProfiles(): void;
  76342. /**
  76343. * Disposes this object
  76344. */
  76345. dispose(): void;
  76346. /**
  76347. * @hidden
  76348. * https://zero-radiance.github.io/post/sampling-diffusion/
  76349. *
  76350. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76351. * ------------------------------------------------------------------------------------
  76352. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76353. * PDF[r, phi, s] = r * R[r, phi, s]
  76354. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76355. * ------------------------------------------------------------------------------------
  76356. * We importance sample the color channel with the widest scattering distance.
  76357. */
  76358. getDiffusionProfileParameters(color: Color3): number;
  76359. /**
  76360. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76361. * 'u' is the random number (the value of the CDF): [0, 1).
  76362. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76363. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76364. */
  76365. private _sampleBurleyDiffusionProfile;
  76366. }
  76367. }
  76368. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  76369. import { Nullable } from "babylonjs/types";
  76370. import { Scene } from "babylonjs/scene";
  76371. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76372. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  76373. import { AbstractScene } from "babylonjs/abstractScene";
  76374. module "babylonjs/abstractScene" {
  76375. interface AbstractScene {
  76376. /** @hidden (Backing field) */
  76377. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76378. /**
  76379. * Gets or Sets the current prepass renderer associated to the scene.
  76380. */
  76381. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76382. /**
  76383. * Enables the subsurface effect for prepass
  76384. * @returns the SubSurfaceConfiguration
  76385. */
  76386. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76387. /**
  76388. * Disables the subsurface effect for prepass
  76389. */
  76390. disableSubSurfaceForPrePass(): void;
  76391. }
  76392. }
  76393. /**
  76394. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76395. * in several rendering techniques.
  76396. */
  76397. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76398. /**
  76399. * The component name helpful to identify the component in the list of scene components.
  76400. */
  76401. readonly name: string;
  76402. /**
  76403. * The scene the component belongs to.
  76404. */
  76405. scene: Scene;
  76406. /**
  76407. * Creates a new instance of the component for the given scene
  76408. * @param scene Defines the scene to register the component in
  76409. */
  76410. constructor(scene: Scene);
  76411. /**
  76412. * Registers the component in a given scene
  76413. */
  76414. register(): void;
  76415. /**
  76416. * Serializes the component data to the specified json object
  76417. * @param serializationObject The object to serialize to
  76418. */
  76419. serialize(serializationObject: any): void;
  76420. /**
  76421. * Adds all the elements from the container to the scene
  76422. * @param container the container holding the elements
  76423. */
  76424. addFromContainer(container: AbstractScene): void;
  76425. /**
  76426. * Removes all the elements in the container from the scene
  76427. * @param container contains the elements to remove
  76428. * @param dispose if the removed element should be disposed (default: false)
  76429. */
  76430. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76431. /**
  76432. * Rebuilds the elements related to this component in case of
  76433. * context lost for instance.
  76434. */
  76435. rebuild(): void;
  76436. /**
  76437. * Disposes the component and the associated ressources
  76438. */
  76439. dispose(): void;
  76440. }
  76441. }
  76442. declare module "babylonjs/Shaders/outline.fragment" {
  76443. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76444. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76445. /** @hidden */
  76446. export var outlinePixelShader: {
  76447. name: string;
  76448. shader: string;
  76449. };
  76450. }
  76451. declare module "babylonjs/Shaders/outline.vertex" {
  76452. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76453. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76454. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76455. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76456. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76457. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76458. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76459. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76460. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76461. /** @hidden */
  76462. export var outlineVertexShader: {
  76463. name: string;
  76464. shader: string;
  76465. };
  76466. }
  76467. declare module "babylonjs/Rendering/outlineRenderer" {
  76468. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76469. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76470. import { Scene } from "babylonjs/scene";
  76471. import { ISceneComponent } from "babylonjs/sceneComponent";
  76472. import "babylonjs/Shaders/outline.fragment";
  76473. import "babylonjs/Shaders/outline.vertex";
  76474. module "babylonjs/scene" {
  76475. interface Scene {
  76476. /** @hidden */
  76477. _outlineRenderer: OutlineRenderer;
  76478. /**
  76479. * Gets the outline renderer associated with the scene
  76480. * @returns a OutlineRenderer
  76481. */
  76482. getOutlineRenderer(): OutlineRenderer;
  76483. }
  76484. }
  76485. module "babylonjs/Meshes/abstractMesh" {
  76486. interface AbstractMesh {
  76487. /** @hidden (Backing field) */
  76488. _renderOutline: boolean;
  76489. /**
  76490. * Gets or sets a boolean indicating if the outline must be rendered as well
  76491. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76492. */
  76493. renderOutline: boolean;
  76494. /** @hidden (Backing field) */
  76495. _renderOverlay: boolean;
  76496. /**
  76497. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76498. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76499. */
  76500. renderOverlay: boolean;
  76501. }
  76502. }
  76503. /**
  76504. * This class is responsible to draw bothe outline/overlay of meshes.
  76505. * It should not be used directly but through the available method on mesh.
  76506. */
  76507. export class OutlineRenderer implements ISceneComponent {
  76508. /**
  76509. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76510. */
  76511. private static _StencilReference;
  76512. /**
  76513. * The name of the component. Each component must have a unique name.
  76514. */
  76515. name: string;
  76516. /**
  76517. * The scene the component belongs to.
  76518. */
  76519. scene: Scene;
  76520. /**
  76521. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76522. */
  76523. zOffset: number;
  76524. private _engine;
  76525. private _effect;
  76526. private _cachedDefines;
  76527. private _savedDepthWrite;
  76528. /**
  76529. * Instantiates a new outline renderer. (There could be only one per scene).
  76530. * @param scene Defines the scene it belongs to
  76531. */
  76532. constructor(scene: Scene);
  76533. /**
  76534. * Register the component to one instance of a scene.
  76535. */
  76536. register(): void;
  76537. /**
  76538. * Rebuilds the elements related to this component in case of
  76539. * context lost for instance.
  76540. */
  76541. rebuild(): void;
  76542. /**
  76543. * Disposes the component and the associated ressources.
  76544. */
  76545. dispose(): void;
  76546. /**
  76547. * Renders the outline in the canvas.
  76548. * @param subMesh Defines the sumesh to render
  76549. * @param batch Defines the batch of meshes in case of instances
  76550. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76551. */
  76552. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76553. /**
  76554. * Returns whether or not the outline renderer is ready for a given submesh.
  76555. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76556. * @param subMesh Defines the submesh to check readyness for
  76557. * @param useInstances Defines wheter wee are trying to render instances or not
  76558. * @returns true if ready otherwise false
  76559. */
  76560. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76561. private _beforeRenderingMesh;
  76562. private _afterRenderingMesh;
  76563. }
  76564. }
  76565. declare module "babylonjs/Rendering/index" {
  76566. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76567. export * from "babylonjs/Rendering/depthRenderer";
  76568. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76569. export * from "babylonjs/Rendering/edgesRenderer";
  76570. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76571. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76572. export * from "babylonjs/Rendering/prePassRenderer";
  76573. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76574. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  76575. export * from "babylonjs/Rendering/outlineRenderer";
  76576. export * from "babylonjs/Rendering/renderingGroup";
  76577. export * from "babylonjs/Rendering/renderingManager";
  76578. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76579. }
  76580. declare module "babylonjs/Sprites/ISprites" {
  76581. /**
  76582. * Defines the basic options interface of a Sprite Frame Source Size.
  76583. */
  76584. export interface ISpriteJSONSpriteSourceSize {
  76585. /**
  76586. * number of the original width of the Frame
  76587. */
  76588. w: number;
  76589. /**
  76590. * number of the original height of the Frame
  76591. */
  76592. h: number;
  76593. }
  76594. /**
  76595. * Defines the basic options interface of a Sprite Frame Data.
  76596. */
  76597. export interface ISpriteJSONSpriteFrameData {
  76598. /**
  76599. * number of the x offset of the Frame
  76600. */
  76601. x: number;
  76602. /**
  76603. * number of the y offset of the Frame
  76604. */
  76605. y: number;
  76606. /**
  76607. * number of the width of the Frame
  76608. */
  76609. w: number;
  76610. /**
  76611. * number of the height of the Frame
  76612. */
  76613. h: number;
  76614. }
  76615. /**
  76616. * Defines the basic options interface of a JSON Sprite.
  76617. */
  76618. export interface ISpriteJSONSprite {
  76619. /**
  76620. * string name of the Frame
  76621. */
  76622. filename: string;
  76623. /**
  76624. * ISpriteJSONSpriteFrame basic object of the frame data
  76625. */
  76626. frame: ISpriteJSONSpriteFrameData;
  76627. /**
  76628. * boolean to flag is the frame was rotated.
  76629. */
  76630. rotated: boolean;
  76631. /**
  76632. * boolean to flag is the frame was trimmed.
  76633. */
  76634. trimmed: boolean;
  76635. /**
  76636. * ISpriteJSONSpriteFrame basic object of the source data
  76637. */
  76638. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76639. /**
  76640. * ISpriteJSONSpriteFrame basic object of the source data
  76641. */
  76642. sourceSize: ISpriteJSONSpriteSourceSize;
  76643. }
  76644. /**
  76645. * Defines the basic options interface of a JSON atlas.
  76646. */
  76647. export interface ISpriteJSONAtlas {
  76648. /**
  76649. * Array of objects that contain the frame data.
  76650. */
  76651. frames: Array<ISpriteJSONSprite>;
  76652. /**
  76653. * object basic object containing the sprite meta data.
  76654. */
  76655. meta?: object;
  76656. }
  76657. }
  76658. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76659. /** @hidden */
  76660. export var spriteMapPixelShader: {
  76661. name: string;
  76662. shader: string;
  76663. };
  76664. }
  76665. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76666. /** @hidden */
  76667. export var spriteMapVertexShader: {
  76668. name: string;
  76669. shader: string;
  76670. };
  76671. }
  76672. declare module "babylonjs/Sprites/spriteMap" {
  76673. import { IDisposable, Scene } from "babylonjs/scene";
  76674. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76675. import { Texture } from "babylonjs/Materials/Textures/texture";
  76676. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76677. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76678. import "babylonjs/Meshes/Builders/planeBuilder";
  76679. import "babylonjs/Shaders/spriteMap.fragment";
  76680. import "babylonjs/Shaders/spriteMap.vertex";
  76681. /**
  76682. * Defines the basic options interface of a SpriteMap
  76683. */
  76684. export interface ISpriteMapOptions {
  76685. /**
  76686. * Vector2 of the number of cells in the grid.
  76687. */
  76688. stageSize?: Vector2;
  76689. /**
  76690. * Vector2 of the size of the output plane in World Units.
  76691. */
  76692. outputSize?: Vector2;
  76693. /**
  76694. * Vector3 of the position of the output plane in World Units.
  76695. */
  76696. outputPosition?: Vector3;
  76697. /**
  76698. * Vector3 of the rotation of the output plane.
  76699. */
  76700. outputRotation?: Vector3;
  76701. /**
  76702. * number of layers that the system will reserve in resources.
  76703. */
  76704. layerCount?: number;
  76705. /**
  76706. * number of max animation frames a single cell will reserve in resources.
  76707. */
  76708. maxAnimationFrames?: number;
  76709. /**
  76710. * number cell index of the base tile when the system compiles.
  76711. */
  76712. baseTile?: number;
  76713. /**
  76714. * boolean flip the sprite after its been repositioned by the framing data.
  76715. */
  76716. flipU?: boolean;
  76717. /**
  76718. * Vector3 scalar of the global RGB values of the SpriteMap.
  76719. */
  76720. colorMultiply?: Vector3;
  76721. }
  76722. /**
  76723. * Defines the IDisposable interface in order to be cleanable from resources.
  76724. */
  76725. export interface ISpriteMap extends IDisposable {
  76726. /**
  76727. * String name of the SpriteMap.
  76728. */
  76729. name: string;
  76730. /**
  76731. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76732. */
  76733. atlasJSON: ISpriteJSONAtlas;
  76734. /**
  76735. * Texture of the SpriteMap.
  76736. */
  76737. spriteSheet: Texture;
  76738. /**
  76739. * The parameters to initialize the SpriteMap with.
  76740. */
  76741. options: ISpriteMapOptions;
  76742. }
  76743. /**
  76744. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76745. */
  76746. export class SpriteMap implements ISpriteMap {
  76747. /** The Name of the spriteMap */
  76748. name: string;
  76749. /** The JSON file with the frame and meta data */
  76750. atlasJSON: ISpriteJSONAtlas;
  76751. /** The systems Sprite Sheet Texture */
  76752. spriteSheet: Texture;
  76753. /** Arguments passed with the Constructor */
  76754. options: ISpriteMapOptions;
  76755. /** Public Sprite Storage array, parsed from atlasJSON */
  76756. sprites: Array<ISpriteJSONSprite>;
  76757. /** Returns the Number of Sprites in the System */
  76758. get spriteCount(): number;
  76759. /** Returns the Position of Output Plane*/
  76760. get position(): Vector3;
  76761. /** Returns the Position of Output Plane*/
  76762. set position(v: Vector3);
  76763. /** Returns the Rotation of Output Plane*/
  76764. get rotation(): Vector3;
  76765. /** Returns the Rotation of Output Plane*/
  76766. set rotation(v: Vector3);
  76767. /** Sets the AnimationMap*/
  76768. get animationMap(): RawTexture;
  76769. /** Sets the AnimationMap*/
  76770. set animationMap(v: RawTexture);
  76771. /** Scene that the SpriteMap was created in */
  76772. private _scene;
  76773. /** Texture Buffer of Float32 that holds tile frame data*/
  76774. private _frameMap;
  76775. /** Texture Buffers of Float32 that holds tileMap data*/
  76776. private _tileMaps;
  76777. /** Texture Buffer of Float32 that holds Animation Data*/
  76778. private _animationMap;
  76779. /** Custom ShaderMaterial Central to the System*/
  76780. private _material;
  76781. /** Custom ShaderMaterial Central to the System*/
  76782. private _output;
  76783. /** Systems Time Ticker*/
  76784. private _time;
  76785. /**
  76786. * Creates a new SpriteMap
  76787. * @param name defines the SpriteMaps Name
  76788. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76789. * @param spriteSheet is the Texture that the Sprites are on.
  76790. * @param options a basic deployment configuration
  76791. * @param scene The Scene that the map is deployed on
  76792. */
  76793. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76794. /**
  76795. * Returns tileID location
  76796. * @returns Vector2 the cell position ID
  76797. */
  76798. getTileID(): Vector2;
  76799. /**
  76800. * Gets the UV location of the mouse over the SpriteMap.
  76801. * @returns Vector2 the UV position of the mouse interaction
  76802. */
  76803. getMousePosition(): Vector2;
  76804. /**
  76805. * Creates the "frame" texture Buffer
  76806. * -------------------------------------
  76807. * Structure of frames
  76808. * "filename": "Falling-Water-2.png",
  76809. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76810. * "rotated": true,
  76811. * "trimmed": true,
  76812. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76813. * "sourceSize": {"w":32,"h":32}
  76814. * @returns RawTexture of the frameMap
  76815. */
  76816. private _createFrameBuffer;
  76817. /**
  76818. * Creates the tileMap texture Buffer
  76819. * @param buffer normally and array of numbers, or a false to generate from scratch
  76820. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76821. * @returns RawTexture of the tileMap
  76822. */
  76823. private _createTileBuffer;
  76824. /**
  76825. * Modifies the data of the tileMaps
  76826. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76827. * @param pos is the iVector2 Coordinates of the Tile
  76828. * @param tile The SpriteIndex of the new Tile
  76829. */
  76830. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76831. /**
  76832. * Creates the animationMap texture Buffer
  76833. * @param buffer normally and array of numbers, or a false to generate from scratch
  76834. * @returns RawTexture of the animationMap
  76835. */
  76836. private _createTileAnimationBuffer;
  76837. /**
  76838. * Modifies the data of the animationMap
  76839. * @param cellID is the Index of the Sprite
  76840. * @param _frame is the target Animation frame
  76841. * @param toCell is the Target Index of the next frame of the animation
  76842. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76843. * @param speed is a global scalar of the time variable on the map.
  76844. */
  76845. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76846. /**
  76847. * Exports the .tilemaps file
  76848. */
  76849. saveTileMaps(): void;
  76850. /**
  76851. * Imports the .tilemaps file
  76852. * @param url of the .tilemaps file
  76853. */
  76854. loadTileMaps(url: string): void;
  76855. /**
  76856. * Release associated resources
  76857. */
  76858. dispose(): void;
  76859. }
  76860. }
  76861. declare module "babylonjs/Sprites/spritePackedManager" {
  76862. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  76863. import { Scene } from "babylonjs/scene";
  76864. /**
  76865. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76866. * @see https://doc.babylonjs.com/babylon101/sprites
  76867. */
  76868. export class SpritePackedManager extends SpriteManager {
  76869. /** defines the packed manager's name */
  76870. name: string;
  76871. /**
  76872. * Creates a new sprite manager from a packed sprite sheet
  76873. * @param name defines the manager's name
  76874. * @param imgUrl defines the sprite sheet url
  76875. * @param capacity defines the maximum allowed number of sprites
  76876. * @param scene defines the hosting scene
  76877. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76878. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76879. * @param samplingMode defines the smapling mode to use with spritesheet
  76880. * @param fromPacked set to true; do not alter
  76881. */
  76882. constructor(
  76883. /** defines the packed manager's name */
  76884. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76885. }
  76886. }
  76887. declare module "babylonjs/Sprites/index" {
  76888. export * from "babylonjs/Sprites/sprite";
  76889. export * from "babylonjs/Sprites/ISprites";
  76890. export * from "babylonjs/Sprites/spriteManager";
  76891. export * from "babylonjs/Sprites/spriteMap";
  76892. export * from "babylonjs/Sprites/spritePackedManager";
  76893. export * from "babylonjs/Sprites/spriteSceneComponent";
  76894. }
  76895. declare module "babylonjs/States/index" {
  76896. export * from "babylonjs/States/alphaCullingState";
  76897. export * from "babylonjs/States/depthCullingState";
  76898. export * from "babylonjs/States/stencilState";
  76899. }
  76900. declare module "babylonjs/Misc/assetsManager" {
  76901. import { Scene } from "babylonjs/scene";
  76902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76903. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76904. import { Skeleton } from "babylonjs/Bones/skeleton";
  76905. import { Observable } from "babylonjs/Misc/observable";
  76906. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  76907. import { Texture } from "babylonjs/Materials/Textures/texture";
  76908. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  76909. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  76910. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  76911. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  76912. import { AssetContainer } from "babylonjs/assetContainer";
  76913. /**
  76914. * Defines the list of states available for a task inside a AssetsManager
  76915. */
  76916. export enum AssetTaskState {
  76917. /**
  76918. * Initialization
  76919. */
  76920. INIT = 0,
  76921. /**
  76922. * Running
  76923. */
  76924. RUNNING = 1,
  76925. /**
  76926. * Done
  76927. */
  76928. DONE = 2,
  76929. /**
  76930. * Error
  76931. */
  76932. ERROR = 3
  76933. }
  76934. /**
  76935. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76936. */
  76937. export abstract class AbstractAssetTask {
  76938. /**
  76939. * Task name
  76940. */ name: string;
  76941. /**
  76942. * Callback called when the task is successful
  76943. */
  76944. onSuccess: (task: any) => void;
  76945. /**
  76946. * Callback called when the task is not successful
  76947. */
  76948. onError: (task: any, message?: string, exception?: any) => void;
  76949. /**
  76950. * Creates a new AssetsManager
  76951. * @param name defines the name of the task
  76952. */
  76953. constructor(
  76954. /**
  76955. * Task name
  76956. */ name: string);
  76957. private _isCompleted;
  76958. private _taskState;
  76959. private _errorObject;
  76960. /**
  76961. * Get if the task is completed
  76962. */
  76963. get isCompleted(): boolean;
  76964. /**
  76965. * Gets the current state of the task
  76966. */
  76967. get taskState(): AssetTaskState;
  76968. /**
  76969. * Gets the current error object (if task is in error)
  76970. */
  76971. get errorObject(): {
  76972. message?: string;
  76973. exception?: any;
  76974. };
  76975. /**
  76976. * Internal only
  76977. * @hidden
  76978. */
  76979. _setErrorObject(message?: string, exception?: any): void;
  76980. /**
  76981. * Execute the current task
  76982. * @param scene defines the scene where you want your assets to be loaded
  76983. * @param onSuccess is a callback called when the task is successfully executed
  76984. * @param onError is a callback called if an error occurs
  76985. */
  76986. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76987. /**
  76988. * Execute the current task
  76989. * @param scene defines the scene where you want your assets to be loaded
  76990. * @param onSuccess is a callback called when the task is successfully executed
  76991. * @param onError is a callback called if an error occurs
  76992. */
  76993. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76994. /**
  76995. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76996. * This can be used with failed tasks that have the reason for failure fixed.
  76997. */
  76998. reset(): void;
  76999. private onErrorCallback;
  77000. private onDoneCallback;
  77001. }
  77002. /**
  77003. * Define the interface used by progress events raised during assets loading
  77004. */
  77005. export interface IAssetsProgressEvent {
  77006. /**
  77007. * Defines the number of remaining tasks to process
  77008. */
  77009. remainingCount: number;
  77010. /**
  77011. * Defines the total number of tasks
  77012. */
  77013. totalCount: number;
  77014. /**
  77015. * Defines the task that was just processed
  77016. */
  77017. task: AbstractAssetTask;
  77018. }
  77019. /**
  77020. * Class used to share progress information about assets loading
  77021. */
  77022. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77023. /**
  77024. * Defines the number of remaining tasks to process
  77025. */
  77026. remainingCount: number;
  77027. /**
  77028. * Defines the total number of tasks
  77029. */
  77030. totalCount: number;
  77031. /**
  77032. * Defines the task that was just processed
  77033. */
  77034. task: AbstractAssetTask;
  77035. /**
  77036. * Creates a AssetsProgressEvent
  77037. * @param remainingCount defines the number of remaining tasks to process
  77038. * @param totalCount defines the total number of tasks
  77039. * @param task defines the task that was just processed
  77040. */
  77041. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77042. }
  77043. /**
  77044. * Define a task used by AssetsManager to load assets into a container
  77045. */
  77046. export class ContainerAssetTask extends AbstractAssetTask {
  77047. /**
  77048. * Defines the name of the task
  77049. */
  77050. name: string;
  77051. /**
  77052. * Defines the list of mesh's names you want to load
  77053. */
  77054. meshesNames: any;
  77055. /**
  77056. * Defines the root url to use as a base to load your meshes and associated resources
  77057. */
  77058. rootUrl: string;
  77059. /**
  77060. * Defines the filename or File of the scene to load from
  77061. */
  77062. sceneFilename: string | File;
  77063. /**
  77064. * Get the loaded asset container
  77065. */
  77066. loadedContainer: AssetContainer;
  77067. /**
  77068. * Gets the list of loaded meshes
  77069. */
  77070. loadedMeshes: Array<AbstractMesh>;
  77071. /**
  77072. * Gets the list of loaded particle systems
  77073. */
  77074. loadedParticleSystems: Array<IParticleSystem>;
  77075. /**
  77076. * Gets the list of loaded skeletons
  77077. */
  77078. loadedSkeletons: Array<Skeleton>;
  77079. /**
  77080. * Gets the list of loaded animation groups
  77081. */
  77082. loadedAnimationGroups: Array<AnimationGroup>;
  77083. /**
  77084. * Callback called when the task is successful
  77085. */
  77086. onSuccess: (task: ContainerAssetTask) => void;
  77087. /**
  77088. * Callback called when the task is successful
  77089. */
  77090. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77091. /**
  77092. * Creates a new ContainerAssetTask
  77093. * @param name defines the name of the task
  77094. * @param meshesNames defines the list of mesh's names you want to load
  77095. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77096. * @param sceneFilename defines the filename or File of the scene to load from
  77097. */
  77098. constructor(
  77099. /**
  77100. * Defines the name of the task
  77101. */
  77102. name: string,
  77103. /**
  77104. * Defines the list of mesh's names you want to load
  77105. */
  77106. meshesNames: any,
  77107. /**
  77108. * Defines the root url to use as a base to load your meshes and associated resources
  77109. */
  77110. rootUrl: string,
  77111. /**
  77112. * Defines the filename or File of the scene to load from
  77113. */
  77114. sceneFilename: string | File);
  77115. /**
  77116. * Execute the current task
  77117. * @param scene defines the scene where you want your assets to be loaded
  77118. * @param onSuccess is a callback called when the task is successfully executed
  77119. * @param onError is a callback called if an error occurs
  77120. */
  77121. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77122. }
  77123. /**
  77124. * Define a task used by AssetsManager to load meshes
  77125. */
  77126. export class MeshAssetTask extends AbstractAssetTask {
  77127. /**
  77128. * Defines the name of the task
  77129. */
  77130. name: string;
  77131. /**
  77132. * Defines the list of mesh's names you want to load
  77133. */
  77134. meshesNames: any;
  77135. /**
  77136. * Defines the root url to use as a base to load your meshes and associated resources
  77137. */
  77138. rootUrl: string;
  77139. /**
  77140. * Defines the filename or File of the scene to load from
  77141. */
  77142. sceneFilename: string | File;
  77143. /**
  77144. * Gets the list of loaded meshes
  77145. */
  77146. loadedMeshes: Array<AbstractMesh>;
  77147. /**
  77148. * Gets the list of loaded particle systems
  77149. */
  77150. loadedParticleSystems: Array<IParticleSystem>;
  77151. /**
  77152. * Gets the list of loaded skeletons
  77153. */
  77154. loadedSkeletons: Array<Skeleton>;
  77155. /**
  77156. * Gets the list of loaded animation groups
  77157. */
  77158. loadedAnimationGroups: Array<AnimationGroup>;
  77159. /**
  77160. * Callback called when the task is successful
  77161. */
  77162. onSuccess: (task: MeshAssetTask) => void;
  77163. /**
  77164. * Callback called when the task is successful
  77165. */
  77166. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77167. /**
  77168. * Creates a new MeshAssetTask
  77169. * @param name defines the name of the task
  77170. * @param meshesNames defines the list of mesh's names you want to load
  77171. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77172. * @param sceneFilename defines the filename or File of the scene to load from
  77173. */
  77174. constructor(
  77175. /**
  77176. * Defines the name of the task
  77177. */
  77178. name: string,
  77179. /**
  77180. * Defines the list of mesh's names you want to load
  77181. */
  77182. meshesNames: any,
  77183. /**
  77184. * Defines the root url to use as a base to load your meshes and associated resources
  77185. */
  77186. rootUrl: string,
  77187. /**
  77188. * Defines the filename or File of the scene to load from
  77189. */
  77190. sceneFilename: string | File);
  77191. /**
  77192. * Execute the current task
  77193. * @param scene defines the scene where you want your assets to be loaded
  77194. * @param onSuccess is a callback called when the task is successfully executed
  77195. * @param onError is a callback called if an error occurs
  77196. */
  77197. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77198. }
  77199. /**
  77200. * Define a task used by AssetsManager to load text content
  77201. */
  77202. export class TextFileAssetTask extends AbstractAssetTask {
  77203. /**
  77204. * Defines the name of the task
  77205. */
  77206. name: string;
  77207. /**
  77208. * Defines the location of the file to load
  77209. */
  77210. url: string;
  77211. /**
  77212. * Gets the loaded text string
  77213. */
  77214. text: string;
  77215. /**
  77216. * Callback called when the task is successful
  77217. */
  77218. onSuccess: (task: TextFileAssetTask) => void;
  77219. /**
  77220. * Callback called when the task is successful
  77221. */
  77222. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77223. /**
  77224. * Creates a new TextFileAssetTask object
  77225. * @param name defines the name of the task
  77226. * @param url defines the location of the file to load
  77227. */
  77228. constructor(
  77229. /**
  77230. * Defines the name of the task
  77231. */
  77232. name: string,
  77233. /**
  77234. * Defines the location of the file to load
  77235. */
  77236. url: string);
  77237. /**
  77238. * Execute the current task
  77239. * @param scene defines the scene where you want your assets to be loaded
  77240. * @param onSuccess is a callback called when the task is successfully executed
  77241. * @param onError is a callback called if an error occurs
  77242. */
  77243. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77244. }
  77245. /**
  77246. * Define a task used by AssetsManager to load binary data
  77247. */
  77248. export class BinaryFileAssetTask extends AbstractAssetTask {
  77249. /**
  77250. * Defines the name of the task
  77251. */
  77252. name: string;
  77253. /**
  77254. * Defines the location of the file to load
  77255. */
  77256. url: string;
  77257. /**
  77258. * Gets the lodaded data (as an array buffer)
  77259. */
  77260. data: ArrayBuffer;
  77261. /**
  77262. * Callback called when the task is successful
  77263. */
  77264. onSuccess: (task: BinaryFileAssetTask) => void;
  77265. /**
  77266. * Callback called when the task is successful
  77267. */
  77268. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77269. /**
  77270. * Creates a new BinaryFileAssetTask object
  77271. * @param name defines the name of the new task
  77272. * @param url defines the location of the file to load
  77273. */
  77274. constructor(
  77275. /**
  77276. * Defines the name of the task
  77277. */
  77278. name: string,
  77279. /**
  77280. * Defines the location of the file to load
  77281. */
  77282. url: string);
  77283. /**
  77284. * Execute the current task
  77285. * @param scene defines the scene where you want your assets to be loaded
  77286. * @param onSuccess is a callback called when the task is successfully executed
  77287. * @param onError is a callback called if an error occurs
  77288. */
  77289. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77290. }
  77291. /**
  77292. * Define a task used by AssetsManager to load images
  77293. */
  77294. export class ImageAssetTask extends AbstractAssetTask {
  77295. /**
  77296. * Defines the name of the task
  77297. */
  77298. name: string;
  77299. /**
  77300. * Defines the location of the image to load
  77301. */
  77302. url: string;
  77303. /**
  77304. * Gets the loaded images
  77305. */
  77306. image: HTMLImageElement;
  77307. /**
  77308. * Callback called when the task is successful
  77309. */
  77310. onSuccess: (task: ImageAssetTask) => void;
  77311. /**
  77312. * Callback called when the task is successful
  77313. */
  77314. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77315. /**
  77316. * Creates a new ImageAssetTask
  77317. * @param name defines the name of the task
  77318. * @param url defines the location of the image to load
  77319. */
  77320. constructor(
  77321. /**
  77322. * Defines the name of the task
  77323. */
  77324. name: string,
  77325. /**
  77326. * Defines the location of the image to load
  77327. */
  77328. url: string);
  77329. /**
  77330. * Execute the current task
  77331. * @param scene defines the scene where you want your assets to be loaded
  77332. * @param onSuccess is a callback called when the task is successfully executed
  77333. * @param onError is a callback called if an error occurs
  77334. */
  77335. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77336. }
  77337. /**
  77338. * Defines the interface used by texture loading tasks
  77339. */
  77340. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77341. /**
  77342. * Gets the loaded texture
  77343. */
  77344. texture: TEX;
  77345. }
  77346. /**
  77347. * Define a task used by AssetsManager to load 2D textures
  77348. */
  77349. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77350. /**
  77351. * Defines the name of the task
  77352. */
  77353. name: string;
  77354. /**
  77355. * Defines the location of the file to load
  77356. */
  77357. url: string;
  77358. /**
  77359. * Defines if mipmap should not be generated (default is false)
  77360. */
  77361. noMipmap?: boolean | undefined;
  77362. /**
  77363. * Defines if texture must be inverted on Y axis (default is true)
  77364. */
  77365. invertY: boolean;
  77366. /**
  77367. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77368. */
  77369. samplingMode: number;
  77370. /**
  77371. * Gets the loaded texture
  77372. */
  77373. texture: Texture;
  77374. /**
  77375. * Callback called when the task is successful
  77376. */
  77377. onSuccess: (task: TextureAssetTask) => void;
  77378. /**
  77379. * Callback called when the task is successful
  77380. */
  77381. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77382. /**
  77383. * Creates a new TextureAssetTask object
  77384. * @param name defines the name of the task
  77385. * @param url defines the location of the file to load
  77386. * @param noMipmap defines if mipmap should not be generated (default is false)
  77387. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77388. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77389. */
  77390. constructor(
  77391. /**
  77392. * Defines the name of the task
  77393. */
  77394. name: string,
  77395. /**
  77396. * Defines the location of the file to load
  77397. */
  77398. url: string,
  77399. /**
  77400. * Defines if mipmap should not be generated (default is false)
  77401. */
  77402. noMipmap?: boolean | undefined,
  77403. /**
  77404. * Defines if texture must be inverted on Y axis (default is true)
  77405. */
  77406. invertY?: boolean,
  77407. /**
  77408. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77409. */
  77410. samplingMode?: number);
  77411. /**
  77412. * Execute the current task
  77413. * @param scene defines the scene where you want your assets to be loaded
  77414. * @param onSuccess is a callback called when the task is successfully executed
  77415. * @param onError is a callback called if an error occurs
  77416. */
  77417. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77418. }
  77419. /**
  77420. * Define a task used by AssetsManager to load cube textures
  77421. */
  77422. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77423. /**
  77424. * Defines the name of the task
  77425. */
  77426. name: string;
  77427. /**
  77428. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77429. */
  77430. url: string;
  77431. /**
  77432. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77433. */
  77434. extensions?: string[] | undefined;
  77435. /**
  77436. * Defines if mipmaps should not be generated (default is false)
  77437. */
  77438. noMipmap?: boolean | undefined;
  77439. /**
  77440. * Defines the explicit list of files (undefined by default)
  77441. */
  77442. files?: string[] | undefined;
  77443. /**
  77444. * Gets the loaded texture
  77445. */
  77446. texture: CubeTexture;
  77447. /**
  77448. * Callback called when the task is successful
  77449. */
  77450. onSuccess: (task: CubeTextureAssetTask) => void;
  77451. /**
  77452. * Callback called when the task is successful
  77453. */
  77454. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77455. /**
  77456. * Creates a new CubeTextureAssetTask
  77457. * @param name defines the name of the task
  77458. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77459. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77460. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77461. * @param files defines the explicit list of files (undefined by default)
  77462. */
  77463. constructor(
  77464. /**
  77465. * Defines the name of the task
  77466. */
  77467. name: string,
  77468. /**
  77469. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77470. */
  77471. url: string,
  77472. /**
  77473. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77474. */
  77475. extensions?: string[] | undefined,
  77476. /**
  77477. * Defines if mipmaps should not be generated (default is false)
  77478. */
  77479. noMipmap?: boolean | undefined,
  77480. /**
  77481. * Defines the explicit list of files (undefined by default)
  77482. */
  77483. files?: string[] | undefined);
  77484. /**
  77485. * Execute the current task
  77486. * @param scene defines the scene where you want your assets to be loaded
  77487. * @param onSuccess is a callback called when the task is successfully executed
  77488. * @param onError is a callback called if an error occurs
  77489. */
  77490. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77491. }
  77492. /**
  77493. * Define a task used by AssetsManager to load HDR cube textures
  77494. */
  77495. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77496. /**
  77497. * Defines the name of the task
  77498. */
  77499. name: string;
  77500. /**
  77501. * Defines the location of the file to load
  77502. */
  77503. url: string;
  77504. /**
  77505. * Defines the desired size (the more it increases the longer the generation will be)
  77506. */
  77507. size: number;
  77508. /**
  77509. * Defines if mipmaps should not be generated (default is false)
  77510. */
  77511. noMipmap: boolean;
  77512. /**
  77513. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77514. */
  77515. generateHarmonics: boolean;
  77516. /**
  77517. * 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)
  77518. */
  77519. gammaSpace: boolean;
  77520. /**
  77521. * Internal Use Only
  77522. */
  77523. reserved: boolean;
  77524. /**
  77525. * Gets the loaded texture
  77526. */
  77527. texture: HDRCubeTexture;
  77528. /**
  77529. * Callback called when the task is successful
  77530. */
  77531. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77532. /**
  77533. * Callback called when the task is successful
  77534. */
  77535. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77536. /**
  77537. * Creates a new HDRCubeTextureAssetTask object
  77538. * @param name defines the name of the task
  77539. * @param url defines the location of the file to load
  77540. * @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.
  77541. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77542. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77543. * @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)
  77544. * @param reserved Internal use only
  77545. */
  77546. constructor(
  77547. /**
  77548. * Defines the name of the task
  77549. */
  77550. name: string,
  77551. /**
  77552. * Defines the location of the file to load
  77553. */
  77554. url: string,
  77555. /**
  77556. * Defines the desired size (the more it increases the longer the generation will be)
  77557. */
  77558. size: number,
  77559. /**
  77560. * Defines if mipmaps should not be generated (default is false)
  77561. */
  77562. noMipmap?: boolean,
  77563. /**
  77564. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77565. */
  77566. generateHarmonics?: boolean,
  77567. /**
  77568. * 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)
  77569. */
  77570. gammaSpace?: boolean,
  77571. /**
  77572. * Internal Use Only
  77573. */
  77574. reserved?: boolean);
  77575. /**
  77576. * Execute the current task
  77577. * @param scene defines the scene where you want your assets to be loaded
  77578. * @param onSuccess is a callback called when the task is successfully executed
  77579. * @param onError is a callback called if an error occurs
  77580. */
  77581. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77582. }
  77583. /**
  77584. * Define a task used by AssetsManager to load Equirectangular cube textures
  77585. */
  77586. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77587. /**
  77588. * Defines the name of the task
  77589. */
  77590. name: string;
  77591. /**
  77592. * Defines the location of the file to load
  77593. */
  77594. url: string;
  77595. /**
  77596. * Defines the desired size (the more it increases the longer the generation will be)
  77597. */
  77598. size: number;
  77599. /**
  77600. * Defines if mipmaps should not be generated (default is false)
  77601. */
  77602. noMipmap: boolean;
  77603. /**
  77604. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77605. * but the standard material would require them in Gamma space) (default is true)
  77606. */
  77607. gammaSpace: boolean;
  77608. /**
  77609. * Gets the loaded texture
  77610. */
  77611. texture: EquiRectangularCubeTexture;
  77612. /**
  77613. * Callback called when the task is successful
  77614. */
  77615. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77616. /**
  77617. * Callback called when the task is successful
  77618. */
  77619. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77620. /**
  77621. * Creates a new EquiRectangularCubeTextureAssetTask object
  77622. * @param name defines the name of the task
  77623. * @param url defines the location of the file to load
  77624. * @param size defines the desired size (the more it increases the longer the generation will be)
  77625. * If the size is omitted this implies you are using a preprocessed cubemap.
  77626. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77627. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77628. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77629. * (default is true)
  77630. */
  77631. constructor(
  77632. /**
  77633. * Defines the name of the task
  77634. */
  77635. name: string,
  77636. /**
  77637. * Defines the location of the file to load
  77638. */
  77639. url: string,
  77640. /**
  77641. * Defines the desired size (the more it increases the longer the generation will be)
  77642. */
  77643. size: number,
  77644. /**
  77645. * Defines if mipmaps should not be generated (default is false)
  77646. */
  77647. noMipmap?: boolean,
  77648. /**
  77649. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77650. * but the standard material would require them in Gamma space) (default is true)
  77651. */
  77652. gammaSpace?: boolean);
  77653. /**
  77654. * Execute the current task
  77655. * @param scene defines the scene where you want your assets to be loaded
  77656. * @param onSuccess is a callback called when the task is successfully executed
  77657. * @param onError is a callback called if an error occurs
  77658. */
  77659. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77660. }
  77661. /**
  77662. * This class can be used to easily import assets into a scene
  77663. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77664. */
  77665. export class AssetsManager {
  77666. private _scene;
  77667. private _isLoading;
  77668. protected _tasks: AbstractAssetTask[];
  77669. protected _waitingTasksCount: number;
  77670. protected _totalTasksCount: number;
  77671. /**
  77672. * Callback called when all tasks are processed
  77673. */
  77674. onFinish: (tasks: AbstractAssetTask[]) => void;
  77675. /**
  77676. * Callback called when a task is successful
  77677. */
  77678. onTaskSuccess: (task: AbstractAssetTask) => void;
  77679. /**
  77680. * Callback called when a task had an error
  77681. */
  77682. onTaskError: (task: AbstractAssetTask) => void;
  77683. /**
  77684. * Callback called when a task is done (whatever the result is)
  77685. */
  77686. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77687. /**
  77688. * Observable called when all tasks are processed
  77689. */
  77690. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77691. /**
  77692. * Observable called when a task had an error
  77693. */
  77694. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77695. /**
  77696. * Observable called when all tasks were executed
  77697. */
  77698. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77699. /**
  77700. * Observable called when a task is done (whatever the result is)
  77701. */
  77702. onProgressObservable: Observable<IAssetsProgressEvent>;
  77703. /**
  77704. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77705. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77706. */
  77707. useDefaultLoadingScreen: boolean;
  77708. /**
  77709. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77710. * when all assets have been downloaded.
  77711. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77712. */
  77713. autoHideLoadingUI: boolean;
  77714. /**
  77715. * Creates a new AssetsManager
  77716. * @param scene defines the scene to work on
  77717. */
  77718. constructor(scene: Scene);
  77719. /**
  77720. * Add a ContainerAssetTask to the list of active tasks
  77721. * @param taskName defines the name of the new task
  77722. * @param meshesNames defines the name of meshes to load
  77723. * @param rootUrl defines the root url to use to locate files
  77724. * @param sceneFilename defines the filename of the scene file
  77725. * @returns a new ContainerAssetTask object
  77726. */
  77727. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77728. /**
  77729. * Add a MeshAssetTask to the list of active tasks
  77730. * @param taskName defines the name of the new task
  77731. * @param meshesNames defines the name of meshes to load
  77732. * @param rootUrl defines the root url to use to locate files
  77733. * @param sceneFilename defines the filename of the scene file
  77734. * @returns a new MeshAssetTask object
  77735. */
  77736. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77737. /**
  77738. * Add a TextFileAssetTask to the list of active tasks
  77739. * @param taskName defines the name of the new task
  77740. * @param url defines the url of the file to load
  77741. * @returns a new TextFileAssetTask object
  77742. */
  77743. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77744. /**
  77745. * Add a BinaryFileAssetTask to the list of active tasks
  77746. * @param taskName defines the name of the new task
  77747. * @param url defines the url of the file to load
  77748. * @returns a new BinaryFileAssetTask object
  77749. */
  77750. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77751. /**
  77752. * Add a ImageAssetTask to the list of active tasks
  77753. * @param taskName defines the name of the new task
  77754. * @param url defines the url of the file to load
  77755. * @returns a new ImageAssetTask object
  77756. */
  77757. addImageTask(taskName: string, url: string): ImageAssetTask;
  77758. /**
  77759. * Add a TextureAssetTask to the list of active tasks
  77760. * @param taskName defines the name of the new task
  77761. * @param url defines the url of the file to load
  77762. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77763. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77764. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77765. * @returns a new TextureAssetTask object
  77766. */
  77767. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77768. /**
  77769. * Add a CubeTextureAssetTask to the list of active tasks
  77770. * @param taskName defines the name of the new task
  77771. * @param url defines the url of the file to load
  77772. * @param extensions defines the extension to use to load the cube map (can be null)
  77773. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77774. * @param files defines the list of files to load (can be null)
  77775. * @returns a new CubeTextureAssetTask object
  77776. */
  77777. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77778. /**
  77779. *
  77780. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77781. * @param taskName defines the name of the new task
  77782. * @param url defines the url of the file to load
  77783. * @param size defines the size you want for the cubemap (can be null)
  77784. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77785. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77786. * @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)
  77787. * @param reserved Internal use only
  77788. * @returns a new HDRCubeTextureAssetTask object
  77789. */
  77790. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77791. /**
  77792. *
  77793. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77794. * @param taskName defines the name of the new task
  77795. * @param url defines the url of the file to load
  77796. * @param size defines the size you want for the cubemap (can be null)
  77797. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77798. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77799. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77800. * @returns a new EquiRectangularCubeTextureAssetTask object
  77801. */
  77802. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77803. /**
  77804. * Remove a task from the assets manager.
  77805. * @param task the task to remove
  77806. */
  77807. removeTask(task: AbstractAssetTask): void;
  77808. private _decreaseWaitingTasksCount;
  77809. private _runTask;
  77810. /**
  77811. * Reset the AssetsManager and remove all tasks
  77812. * @return the current instance of the AssetsManager
  77813. */
  77814. reset(): AssetsManager;
  77815. /**
  77816. * Start the loading process
  77817. * @return the current instance of the AssetsManager
  77818. */
  77819. load(): AssetsManager;
  77820. /**
  77821. * Start the loading process as an async operation
  77822. * @return a promise returning the list of failed tasks
  77823. */
  77824. loadAsync(): Promise<void>;
  77825. }
  77826. }
  77827. declare module "babylonjs/Misc/deferred" {
  77828. /**
  77829. * Wrapper class for promise with external resolve and reject.
  77830. */
  77831. export class Deferred<T> {
  77832. /**
  77833. * The promise associated with this deferred object.
  77834. */
  77835. readonly promise: Promise<T>;
  77836. private _resolve;
  77837. private _reject;
  77838. /**
  77839. * The resolve method of the promise associated with this deferred object.
  77840. */
  77841. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  77842. /**
  77843. * The reject method of the promise associated with this deferred object.
  77844. */
  77845. get reject(): (reason?: any) => void;
  77846. /**
  77847. * Constructor for this deferred object.
  77848. */
  77849. constructor();
  77850. }
  77851. }
  77852. declare module "babylonjs/Misc/meshExploder" {
  77853. import { Mesh } from "babylonjs/Meshes/mesh";
  77854. /**
  77855. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77856. */
  77857. export class MeshExploder {
  77858. private _centerMesh;
  77859. private _meshes;
  77860. private _meshesOrigins;
  77861. private _toCenterVectors;
  77862. private _scaledDirection;
  77863. private _newPosition;
  77864. private _centerPosition;
  77865. /**
  77866. * Explodes meshes from a center mesh.
  77867. * @param meshes The meshes to explode.
  77868. * @param centerMesh The mesh to be center of explosion.
  77869. */
  77870. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77871. private _setCenterMesh;
  77872. /**
  77873. * Get class name
  77874. * @returns "MeshExploder"
  77875. */
  77876. getClassName(): string;
  77877. /**
  77878. * "Exploded meshes"
  77879. * @returns Array of meshes with the centerMesh at index 0.
  77880. */
  77881. getMeshes(): Array<Mesh>;
  77882. /**
  77883. * Explodes meshes giving a specific direction
  77884. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77885. */
  77886. explode(direction?: number): void;
  77887. }
  77888. }
  77889. declare module "babylonjs/Misc/filesInput" {
  77890. import { Engine } from "babylonjs/Engines/engine";
  77891. import { Scene } from "babylonjs/scene";
  77892. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  77893. import { Nullable } from "babylonjs/types";
  77894. /**
  77895. * Class used to help managing file picking and drag'n'drop
  77896. */
  77897. export class FilesInput {
  77898. /**
  77899. * List of files ready to be loaded
  77900. */
  77901. static get FilesToLoad(): {
  77902. [key: string]: File;
  77903. };
  77904. /**
  77905. * Callback called when a file is processed
  77906. */
  77907. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  77908. private _engine;
  77909. private _currentScene;
  77910. private _sceneLoadedCallback;
  77911. private _progressCallback;
  77912. private _additionalRenderLoopLogicCallback;
  77913. private _textureLoadingCallback;
  77914. private _startingProcessingFilesCallback;
  77915. private _onReloadCallback;
  77916. private _errorCallback;
  77917. private _elementToMonitor;
  77918. private _sceneFileToLoad;
  77919. private _filesToLoad;
  77920. /**
  77921. * Creates a new FilesInput
  77922. * @param engine defines the rendering engine
  77923. * @param scene defines the hosting scene
  77924. * @param sceneLoadedCallback callback called when scene is loaded
  77925. * @param progressCallback callback called to track progress
  77926. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77927. * @param textureLoadingCallback callback called when a texture is loading
  77928. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77929. * @param onReloadCallback callback called when a reload is requested
  77930. * @param errorCallback callback call if an error occurs
  77931. */
  77932. 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>);
  77933. private _dragEnterHandler;
  77934. private _dragOverHandler;
  77935. private _dropHandler;
  77936. /**
  77937. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77938. * @param elementToMonitor defines the DOM element to track
  77939. */
  77940. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77941. /** Gets the current list of files to load */
  77942. get filesToLoad(): File[];
  77943. /**
  77944. * Release all associated resources
  77945. */
  77946. dispose(): void;
  77947. private renderFunction;
  77948. private drag;
  77949. private drop;
  77950. private _traverseFolder;
  77951. private _processFiles;
  77952. /**
  77953. * Load files from a drop event
  77954. * @param event defines the drop event to use as source
  77955. */
  77956. loadFiles(event: any): void;
  77957. private _processReload;
  77958. /**
  77959. * Reload the current scene from the loaded files
  77960. */
  77961. reload(): void;
  77962. }
  77963. }
  77964. declare module "babylonjs/Misc/HighDynamicRange/index" {
  77965. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  77966. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  77967. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  77968. }
  77969. declare module "babylonjs/Misc/sceneOptimizer" {
  77970. import { Scene, IDisposable } from "babylonjs/scene";
  77971. import { Observable } from "babylonjs/Misc/observable";
  77972. /**
  77973. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77974. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77975. */
  77976. export class SceneOptimization {
  77977. /**
  77978. * Defines the priority of this optimization (0 by default which means first in the list)
  77979. */
  77980. priority: number;
  77981. /**
  77982. * Gets a string describing the action executed by the current optimization
  77983. * @returns description string
  77984. */
  77985. getDescription(): string;
  77986. /**
  77987. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77988. * @param scene defines the current scene where to apply this optimization
  77989. * @param optimizer defines the current optimizer
  77990. * @returns true if everything that can be done was applied
  77991. */
  77992. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77993. /**
  77994. * Creates the SceneOptimization object
  77995. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77996. * @param desc defines the description associated with the optimization
  77997. */
  77998. constructor(
  77999. /**
  78000. * Defines the priority of this optimization (0 by default which means first in the list)
  78001. */
  78002. priority?: number);
  78003. }
  78004. /**
  78005. * Defines an optimization used to reduce the size of render target textures
  78006. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78007. */
  78008. export class TextureOptimization extends SceneOptimization {
  78009. /**
  78010. * Defines the priority of this optimization (0 by default which means first in the list)
  78011. */
  78012. priority: number;
  78013. /**
  78014. * 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
  78015. */
  78016. maximumSize: number;
  78017. /**
  78018. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78019. */
  78020. step: number;
  78021. /**
  78022. * Gets a string describing the action executed by the current optimization
  78023. * @returns description string
  78024. */
  78025. getDescription(): string;
  78026. /**
  78027. * Creates the TextureOptimization object
  78028. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78029. * @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
  78030. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78031. */
  78032. constructor(
  78033. /**
  78034. * Defines the priority of this optimization (0 by default which means first in the list)
  78035. */
  78036. priority?: number,
  78037. /**
  78038. * 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
  78039. */
  78040. maximumSize?: number,
  78041. /**
  78042. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78043. */
  78044. step?: number);
  78045. /**
  78046. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78047. * @param scene defines the current scene where to apply this optimization
  78048. * @param optimizer defines the current optimizer
  78049. * @returns true if everything that can be done was applied
  78050. */
  78051. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78052. }
  78053. /**
  78054. * Defines an optimization used to increase or decrease the rendering resolution
  78055. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78056. */
  78057. export class HardwareScalingOptimization extends SceneOptimization {
  78058. /**
  78059. * Defines the priority of this optimization (0 by default which means first in the list)
  78060. */
  78061. priority: number;
  78062. /**
  78063. * Defines the maximum scale to use (2 by default)
  78064. */
  78065. maximumScale: number;
  78066. /**
  78067. * Defines the step to use between two passes (0.5 by default)
  78068. */
  78069. step: number;
  78070. private _currentScale;
  78071. private _directionOffset;
  78072. /**
  78073. * Gets a string describing the action executed by the current optimization
  78074. * @return description string
  78075. */
  78076. getDescription(): string;
  78077. /**
  78078. * Creates the HardwareScalingOptimization object
  78079. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78080. * @param maximumScale defines the maximum scale to use (2 by default)
  78081. * @param step defines the step to use between two passes (0.5 by default)
  78082. */
  78083. constructor(
  78084. /**
  78085. * Defines the priority of this optimization (0 by default which means first in the list)
  78086. */
  78087. priority?: number,
  78088. /**
  78089. * Defines the maximum scale to use (2 by default)
  78090. */
  78091. maximumScale?: number,
  78092. /**
  78093. * Defines the step to use between two passes (0.5 by default)
  78094. */
  78095. step?: number);
  78096. /**
  78097. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78098. * @param scene defines the current scene where to apply this optimization
  78099. * @param optimizer defines the current optimizer
  78100. * @returns true if everything that can be done was applied
  78101. */
  78102. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78103. }
  78104. /**
  78105. * Defines an optimization used to remove shadows
  78106. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78107. */
  78108. export class ShadowsOptimization extends SceneOptimization {
  78109. /**
  78110. * Gets a string describing the action executed by the current optimization
  78111. * @return description string
  78112. */
  78113. getDescription(): string;
  78114. /**
  78115. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78116. * @param scene defines the current scene where to apply this optimization
  78117. * @param optimizer defines the current optimizer
  78118. * @returns true if everything that can be done was applied
  78119. */
  78120. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78121. }
  78122. /**
  78123. * Defines an optimization used to turn post-processes off
  78124. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78125. */
  78126. export class PostProcessesOptimization extends SceneOptimization {
  78127. /**
  78128. * Gets a string describing the action executed by the current optimization
  78129. * @return description string
  78130. */
  78131. getDescription(): string;
  78132. /**
  78133. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78134. * @param scene defines the current scene where to apply this optimization
  78135. * @param optimizer defines the current optimizer
  78136. * @returns true if everything that can be done was applied
  78137. */
  78138. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78139. }
  78140. /**
  78141. * Defines an optimization used to turn lens flares off
  78142. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78143. */
  78144. export class LensFlaresOptimization extends SceneOptimization {
  78145. /**
  78146. * Gets a string describing the action executed by the current optimization
  78147. * @return description string
  78148. */
  78149. getDescription(): string;
  78150. /**
  78151. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78152. * @param scene defines the current scene where to apply this optimization
  78153. * @param optimizer defines the current optimizer
  78154. * @returns true if everything that can be done was applied
  78155. */
  78156. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78157. }
  78158. /**
  78159. * Defines an optimization based on user defined callback.
  78160. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78161. */
  78162. export class CustomOptimization extends SceneOptimization {
  78163. /**
  78164. * Callback called to apply the custom optimization.
  78165. */
  78166. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78167. /**
  78168. * Callback called to get custom description
  78169. */
  78170. onGetDescription: () => string;
  78171. /**
  78172. * Gets a string describing the action executed by the current optimization
  78173. * @returns description string
  78174. */
  78175. getDescription(): string;
  78176. /**
  78177. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78178. * @param scene defines the current scene where to apply this optimization
  78179. * @param optimizer defines the current optimizer
  78180. * @returns true if everything that can be done was applied
  78181. */
  78182. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78183. }
  78184. /**
  78185. * Defines an optimization used to turn particles off
  78186. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78187. */
  78188. export class ParticlesOptimization extends SceneOptimization {
  78189. /**
  78190. * Gets a string describing the action executed by the current optimization
  78191. * @return description string
  78192. */
  78193. getDescription(): string;
  78194. /**
  78195. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78196. * @param scene defines the current scene where to apply this optimization
  78197. * @param optimizer defines the current optimizer
  78198. * @returns true if everything that can be done was applied
  78199. */
  78200. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78201. }
  78202. /**
  78203. * Defines an optimization used to turn render targets off
  78204. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78205. */
  78206. export class RenderTargetsOptimization extends SceneOptimization {
  78207. /**
  78208. * Gets a string describing the action executed by the current optimization
  78209. * @return description string
  78210. */
  78211. getDescription(): string;
  78212. /**
  78213. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78214. * @param scene defines the current scene where to apply this optimization
  78215. * @param optimizer defines the current optimizer
  78216. * @returns true if everything that can be done was applied
  78217. */
  78218. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78219. }
  78220. /**
  78221. * Defines an optimization used to merge meshes with compatible materials
  78222. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78223. */
  78224. export class MergeMeshesOptimization extends SceneOptimization {
  78225. private static _UpdateSelectionTree;
  78226. /**
  78227. * Gets or sets a boolean which defines if optimization octree has to be updated
  78228. */
  78229. static get UpdateSelectionTree(): boolean;
  78230. /**
  78231. * Gets or sets a boolean which defines if optimization octree has to be updated
  78232. */
  78233. static set UpdateSelectionTree(value: boolean);
  78234. /**
  78235. * Gets a string describing the action executed by the current optimization
  78236. * @return description string
  78237. */
  78238. getDescription(): string;
  78239. private _canBeMerged;
  78240. /**
  78241. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78242. * @param scene defines the current scene where to apply this optimization
  78243. * @param optimizer defines the current optimizer
  78244. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78245. * @returns true if everything that can be done was applied
  78246. */
  78247. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78248. }
  78249. /**
  78250. * Defines a list of options used by SceneOptimizer
  78251. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78252. */
  78253. export class SceneOptimizerOptions {
  78254. /**
  78255. * Defines the target frame rate to reach (60 by default)
  78256. */
  78257. targetFrameRate: number;
  78258. /**
  78259. * Defines the interval between two checkes (2000ms by default)
  78260. */
  78261. trackerDuration: number;
  78262. /**
  78263. * Gets the list of optimizations to apply
  78264. */
  78265. optimizations: SceneOptimization[];
  78266. /**
  78267. * Creates a new list of options used by SceneOptimizer
  78268. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78269. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78270. */
  78271. constructor(
  78272. /**
  78273. * Defines the target frame rate to reach (60 by default)
  78274. */
  78275. targetFrameRate?: number,
  78276. /**
  78277. * Defines the interval between two checkes (2000ms by default)
  78278. */
  78279. trackerDuration?: number);
  78280. /**
  78281. * Add a new optimization
  78282. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78283. * @returns the current SceneOptimizerOptions
  78284. */
  78285. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78286. /**
  78287. * Add a new custom optimization
  78288. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78289. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78290. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78291. * @returns the current SceneOptimizerOptions
  78292. */
  78293. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78294. /**
  78295. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78296. * @param targetFrameRate defines the target frame rate (60 by default)
  78297. * @returns a SceneOptimizerOptions object
  78298. */
  78299. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78300. /**
  78301. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78302. * @param targetFrameRate defines the target frame rate (60 by default)
  78303. * @returns a SceneOptimizerOptions object
  78304. */
  78305. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78306. /**
  78307. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78308. * @param targetFrameRate defines the target frame rate (60 by default)
  78309. * @returns a SceneOptimizerOptions object
  78310. */
  78311. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78312. }
  78313. /**
  78314. * Class used to run optimizations in order to reach a target frame rate
  78315. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78316. */
  78317. export class SceneOptimizer implements IDisposable {
  78318. private _isRunning;
  78319. private _options;
  78320. private _scene;
  78321. private _currentPriorityLevel;
  78322. private _targetFrameRate;
  78323. private _trackerDuration;
  78324. private _currentFrameRate;
  78325. private _sceneDisposeObserver;
  78326. private _improvementMode;
  78327. /**
  78328. * Defines an observable called when the optimizer reaches the target frame rate
  78329. */
  78330. onSuccessObservable: Observable<SceneOptimizer>;
  78331. /**
  78332. * Defines an observable called when the optimizer enables an optimization
  78333. */
  78334. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78335. /**
  78336. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78337. */
  78338. onFailureObservable: Observable<SceneOptimizer>;
  78339. /**
  78340. * Gets a boolean indicating if the optimizer is in improvement mode
  78341. */
  78342. get isInImprovementMode(): boolean;
  78343. /**
  78344. * Gets the current priority level (0 at start)
  78345. */
  78346. get currentPriorityLevel(): number;
  78347. /**
  78348. * Gets the current frame rate checked by the SceneOptimizer
  78349. */
  78350. get currentFrameRate(): number;
  78351. /**
  78352. * Gets or sets the current target frame rate (60 by default)
  78353. */
  78354. get targetFrameRate(): number;
  78355. /**
  78356. * Gets or sets the current target frame rate (60 by default)
  78357. */
  78358. set targetFrameRate(value: number);
  78359. /**
  78360. * Gets or sets the current interval between two checks (every 2000ms by default)
  78361. */
  78362. get trackerDuration(): number;
  78363. /**
  78364. * Gets or sets the current interval between two checks (every 2000ms by default)
  78365. */
  78366. set trackerDuration(value: number);
  78367. /**
  78368. * Gets the list of active optimizations
  78369. */
  78370. get optimizations(): SceneOptimization[];
  78371. /**
  78372. * Creates a new SceneOptimizer
  78373. * @param scene defines the scene to work on
  78374. * @param options defines the options to use with the SceneOptimizer
  78375. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78376. * @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)
  78377. */
  78378. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78379. /**
  78380. * Stops the current optimizer
  78381. */
  78382. stop(): void;
  78383. /**
  78384. * Reset the optimizer to initial step (current priority level = 0)
  78385. */
  78386. reset(): void;
  78387. /**
  78388. * Start the optimizer. By default it will try to reach a specific framerate
  78389. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78390. */
  78391. start(): void;
  78392. private _checkCurrentState;
  78393. /**
  78394. * Release all resources
  78395. */
  78396. dispose(): void;
  78397. /**
  78398. * Helper function to create a SceneOptimizer with one single line of code
  78399. * @param scene defines the scene to work on
  78400. * @param options defines the options to use with the SceneOptimizer
  78401. * @param onSuccess defines a callback to call on success
  78402. * @param onFailure defines a callback to call on failure
  78403. * @returns the new SceneOptimizer object
  78404. */
  78405. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78406. }
  78407. }
  78408. declare module "babylonjs/Misc/sceneSerializer" {
  78409. import { Scene } from "babylonjs/scene";
  78410. /**
  78411. * Class used to serialize a scene into a string
  78412. */
  78413. export class SceneSerializer {
  78414. /**
  78415. * Clear cache used by a previous serialization
  78416. */
  78417. static ClearCache(): void;
  78418. /**
  78419. * Serialize a scene into a JSON compatible object
  78420. * @param scene defines the scene to serialize
  78421. * @returns a JSON compatible object
  78422. */
  78423. static Serialize(scene: Scene): any;
  78424. /**
  78425. * Serialize a mesh into a JSON compatible object
  78426. * @param toSerialize defines the mesh to serialize
  78427. * @param withParents defines if parents must be serialized as well
  78428. * @param withChildren defines if children must be serialized as well
  78429. * @returns a JSON compatible object
  78430. */
  78431. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78432. }
  78433. }
  78434. declare module "babylonjs/Misc/textureTools" {
  78435. import { Texture } from "babylonjs/Materials/Textures/texture";
  78436. /**
  78437. * Class used to host texture specific utilities
  78438. */
  78439. export class TextureTools {
  78440. /**
  78441. * Uses the GPU to create a copy texture rescaled at a given size
  78442. * @param texture Texture to copy from
  78443. * @param width defines the desired width
  78444. * @param height defines the desired height
  78445. * @param useBilinearMode defines if bilinear mode has to be used
  78446. * @return the generated texture
  78447. */
  78448. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78449. }
  78450. }
  78451. declare module "babylonjs/Misc/videoRecorder" {
  78452. import { Nullable } from "babylonjs/types";
  78453. import { Engine } from "babylonjs/Engines/engine";
  78454. /**
  78455. * This represents the different options available for the video capture.
  78456. */
  78457. export interface VideoRecorderOptions {
  78458. /** Defines the mime type of the video. */
  78459. mimeType: string;
  78460. /** Defines the FPS the video should be recorded at. */
  78461. fps: number;
  78462. /** Defines the chunk size for the recording data. */
  78463. recordChunckSize: number;
  78464. /** The audio tracks to attach to the recording. */
  78465. audioTracks?: MediaStreamTrack[];
  78466. }
  78467. /**
  78468. * This can help with recording videos from BabylonJS.
  78469. * This is based on the available WebRTC functionalities of the browser.
  78470. *
  78471. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78472. */
  78473. export class VideoRecorder {
  78474. private static readonly _defaultOptions;
  78475. /**
  78476. * Returns whether or not the VideoRecorder is available in your browser.
  78477. * @param engine Defines the Babylon Engine.
  78478. * @returns true if supported otherwise false.
  78479. */
  78480. static IsSupported(engine: Engine): boolean;
  78481. private readonly _options;
  78482. private _canvas;
  78483. private _mediaRecorder;
  78484. private _recordedChunks;
  78485. private _fileName;
  78486. private _resolve;
  78487. private _reject;
  78488. /**
  78489. * True when a recording is already in progress.
  78490. */
  78491. get isRecording(): boolean;
  78492. /**
  78493. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78494. * @param engine Defines the BabylonJS Engine you wish to record.
  78495. * @param options Defines options that can be used to customize the capture.
  78496. */
  78497. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78498. /**
  78499. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78500. */
  78501. stopRecording(): void;
  78502. /**
  78503. * Starts recording the canvas for a max duration specified in parameters.
  78504. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78505. * If null no automatic download will start and you can rely on the promise to get the data back.
  78506. * @param maxDuration Defines the maximum recording time in seconds.
  78507. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78508. * @return A promise callback at the end of the recording with the video data in Blob.
  78509. */
  78510. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78511. /**
  78512. * Releases internal resources used during the recording.
  78513. */
  78514. dispose(): void;
  78515. private _handleDataAvailable;
  78516. private _handleError;
  78517. private _handleStop;
  78518. }
  78519. }
  78520. declare module "babylonjs/Misc/screenshotTools" {
  78521. import { Camera } from "babylonjs/Cameras/camera";
  78522. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78523. import { Engine } from "babylonjs/Engines/engine";
  78524. /**
  78525. * Class containing a set of static utilities functions for screenshots
  78526. */
  78527. export class ScreenshotTools {
  78528. /**
  78529. * Captures a screenshot of the current rendering
  78530. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78531. * @param engine defines the rendering engine
  78532. * @param camera defines the source camera
  78533. * @param size This parameter can be set to a single number or to an object with the
  78534. * following (optional) properties: precision, width, height. If a single number is passed,
  78535. * it will be used for both width and height. If an object is passed, the screenshot size
  78536. * will be derived from the parameters. The precision property is a multiplier allowing
  78537. * rendering at a higher or lower resolution
  78538. * @param successCallback defines the callback receives a single parameter which contains the
  78539. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78540. * src parameter of an <img> to display it
  78541. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78542. * Check your browser for supported MIME types
  78543. */
  78544. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78545. /**
  78546. * Captures a screenshot of the current rendering
  78547. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78548. * @param engine defines the rendering engine
  78549. * @param camera defines the source camera
  78550. * @param size This parameter can be set to a single number or to an object with the
  78551. * following (optional) properties: precision, width, height. If a single number is passed,
  78552. * it will be used for both width and height. If an object is passed, the screenshot size
  78553. * will be derived from the parameters. The precision property is a multiplier allowing
  78554. * rendering at a higher or lower resolution
  78555. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78556. * Check your browser for supported MIME types
  78557. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78558. * to the src parameter of an <img> to display it
  78559. */
  78560. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78561. /**
  78562. * Generates an image screenshot from the specified camera.
  78563. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78564. * @param engine The engine to use for rendering
  78565. * @param camera The camera to use for rendering
  78566. * @param size This parameter can be set to a single number or to an object with the
  78567. * following (optional) properties: precision, width, height. If a single number is passed,
  78568. * it will be used for both width and height. If an object is passed, the screenshot size
  78569. * will be derived from the parameters. The precision property is a multiplier allowing
  78570. * rendering at a higher or lower resolution
  78571. * @param successCallback The callback receives a single parameter which contains the
  78572. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78573. * src parameter of an <img> to display it
  78574. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78575. * Check your browser for supported MIME types
  78576. * @param samples Texture samples (default: 1)
  78577. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78578. * @param fileName A name for for the downloaded file.
  78579. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78580. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78581. */
  78582. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  78583. /**
  78584. * Generates an image screenshot from the specified camera.
  78585. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78586. * @param engine The engine to use for rendering
  78587. * @param camera The camera to use for rendering
  78588. * @param size This parameter can be set to a single number or to an object with the
  78589. * following (optional) properties: precision, width, height. If a single number is passed,
  78590. * it will be used for both width and height. If an object is passed, the screenshot size
  78591. * will be derived from the parameters. The precision property is a multiplier allowing
  78592. * rendering at a higher or lower resolution
  78593. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78594. * Check your browser for supported MIME types
  78595. * @param samples Texture samples (default: 1)
  78596. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78597. * @param fileName A name for for the downloaded file.
  78598. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78599. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78600. * to the src parameter of an <img> to display it
  78601. */
  78602. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78603. /**
  78604. * Gets height and width for screenshot size
  78605. * @private
  78606. */
  78607. private static _getScreenshotSize;
  78608. }
  78609. }
  78610. declare module "babylonjs/Misc/dataReader" {
  78611. /**
  78612. * Interface for a data buffer
  78613. */
  78614. export interface IDataBuffer {
  78615. /**
  78616. * Reads bytes from the data buffer.
  78617. * @param byteOffset The byte offset to read
  78618. * @param byteLength The byte length to read
  78619. * @returns A promise that resolves when the bytes are read
  78620. */
  78621. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78622. /**
  78623. * The byte length of the buffer.
  78624. */
  78625. readonly byteLength: number;
  78626. }
  78627. /**
  78628. * Utility class for reading from a data buffer
  78629. */
  78630. export class DataReader {
  78631. /**
  78632. * The data buffer associated with this data reader.
  78633. */
  78634. readonly buffer: IDataBuffer;
  78635. /**
  78636. * The current byte offset from the beginning of the data buffer.
  78637. */
  78638. byteOffset: number;
  78639. private _dataView;
  78640. private _dataByteOffset;
  78641. /**
  78642. * Constructor
  78643. * @param buffer The buffer to read
  78644. */
  78645. constructor(buffer: IDataBuffer);
  78646. /**
  78647. * Loads the given byte length.
  78648. * @param byteLength The byte length to load
  78649. * @returns A promise that resolves when the load is complete
  78650. */
  78651. loadAsync(byteLength: number): Promise<void>;
  78652. /**
  78653. * Read a unsigned 32-bit integer from the currently loaded data range.
  78654. * @returns The 32-bit integer read
  78655. */
  78656. readUint32(): number;
  78657. /**
  78658. * Read a byte array from the currently loaded data range.
  78659. * @param byteLength The byte length to read
  78660. * @returns The byte array read
  78661. */
  78662. readUint8Array(byteLength: number): Uint8Array;
  78663. /**
  78664. * Read a string from the currently loaded data range.
  78665. * @param byteLength The byte length to read
  78666. * @returns The string read
  78667. */
  78668. readString(byteLength: number): string;
  78669. /**
  78670. * Skips the given byte length the currently loaded data range.
  78671. * @param byteLength The byte length to skip
  78672. */
  78673. skipBytes(byteLength: number): void;
  78674. }
  78675. }
  78676. declare module "babylonjs/Misc/dataStorage" {
  78677. /**
  78678. * Class for storing data to local storage if available or in-memory storage otherwise
  78679. */
  78680. export class DataStorage {
  78681. private static _Storage;
  78682. private static _GetStorage;
  78683. /**
  78684. * Reads a string from the data storage
  78685. * @param key The key to read
  78686. * @param defaultValue The value if the key doesn't exist
  78687. * @returns The string value
  78688. */
  78689. static ReadString(key: string, defaultValue: string): string;
  78690. /**
  78691. * Writes a string to the data storage
  78692. * @param key The key to write
  78693. * @param value The value to write
  78694. */
  78695. static WriteString(key: string, value: string): void;
  78696. /**
  78697. * Reads a boolean from the data storage
  78698. * @param key The key to read
  78699. * @param defaultValue The value if the key doesn't exist
  78700. * @returns The boolean value
  78701. */
  78702. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78703. /**
  78704. * Writes a boolean to the data storage
  78705. * @param key The key to write
  78706. * @param value The value to write
  78707. */
  78708. static WriteBoolean(key: string, value: boolean): void;
  78709. /**
  78710. * Reads a number from the data storage
  78711. * @param key The key to read
  78712. * @param defaultValue The value if the key doesn't exist
  78713. * @returns The number value
  78714. */
  78715. static ReadNumber(key: string, defaultValue: number): number;
  78716. /**
  78717. * Writes a number to the data storage
  78718. * @param key The key to write
  78719. * @param value The value to write
  78720. */
  78721. static WriteNumber(key: string, value: number): void;
  78722. }
  78723. }
  78724. declare module "babylonjs/Misc/sceneRecorder" {
  78725. import { Scene } from "babylonjs/scene";
  78726. /**
  78727. * Class used to record delta files between 2 scene states
  78728. */
  78729. export class SceneRecorder {
  78730. private _trackedScene;
  78731. private _savedJSON;
  78732. /**
  78733. * Track a given scene. This means the current scene state will be considered the original state
  78734. * @param scene defines the scene to track
  78735. */
  78736. track(scene: Scene): void;
  78737. /**
  78738. * Get the delta between current state and original state
  78739. * @returns a string containing the delta
  78740. */
  78741. getDelta(): any;
  78742. private _compareArray;
  78743. private _compareObjects;
  78744. private _compareCollections;
  78745. private static GetShadowGeneratorById;
  78746. /**
  78747. * Apply a given delta to a given scene
  78748. * @param deltaJSON defines the JSON containing the delta
  78749. * @param scene defines the scene to apply the delta to
  78750. */
  78751. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78752. private static _ApplyPropertiesToEntity;
  78753. private static _ApplyDeltaForEntity;
  78754. }
  78755. }
  78756. declare module "babylonjs/Misc/trajectoryClassifier" {
  78757. import { DeepImmutable, Nullable } from "babylonjs/types";
  78758. import { Vector3 } from "babylonjs/Maths/math.vector";
  78759. /**
  78760. * A 3D trajectory consisting of an order list of vectors describing a
  78761. * path of motion through 3D space.
  78762. */
  78763. export class Trajectory {
  78764. private _points;
  78765. private readonly _segmentLength;
  78766. /**
  78767. * Serialize to JSON.
  78768. * @returns serialized JSON string
  78769. */
  78770. serialize(): string;
  78771. /**
  78772. * Deserialize from JSON.
  78773. * @param json serialized JSON string
  78774. * @returns deserialized Trajectory
  78775. */
  78776. static Deserialize(json: string): Trajectory;
  78777. /**
  78778. * Create a new empty Trajectory.
  78779. * @param segmentLength radius of discretization for Trajectory points
  78780. */
  78781. constructor(segmentLength?: number);
  78782. /**
  78783. * Get the length of the Trajectory.
  78784. * @returns length of the Trajectory
  78785. */
  78786. getLength(): number;
  78787. /**
  78788. * Append a new point to the Trajectory.
  78789. * NOTE: This implementation has many allocations.
  78790. * @param point point to append to the Trajectory
  78791. */
  78792. add(point: DeepImmutable<Vector3>): void;
  78793. /**
  78794. * Create a new Trajectory with a segment length chosen to make it
  78795. * probable that the new Trajectory will have a specified number of
  78796. * segments. This operation is imprecise.
  78797. * @param targetResolution number of segments desired
  78798. * @returns new Trajectory with approximately the requested number of segments
  78799. */
  78800. resampleAtTargetResolution(targetResolution: number): Trajectory;
  78801. /**
  78802. * Convert Trajectory segments into tokenized representation. This
  78803. * representation is an array of numbers where each nth number is the
  78804. * index of the token which is most similar to the nth segment of the
  78805. * Trajectory.
  78806. * @param tokens list of vectors which serve as discrete tokens
  78807. * @returns list of indices of most similar token per segment
  78808. */
  78809. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  78810. private static _forwardDir;
  78811. private static _inverseFromVec;
  78812. private static _upDir;
  78813. private static _fromToVec;
  78814. private static _lookMatrix;
  78815. /**
  78816. * Transform the rotation (i.e., direction) of a segment to isolate
  78817. * the relative transformation represented by the segment. This operation
  78818. * may or may not succeed due to singularities in the equations that define
  78819. * motion relativity in this context.
  78820. * @param priorVec the origin of the prior segment
  78821. * @param fromVec the origin of the current segment
  78822. * @param toVec the destination of the current segment
  78823. * @param result reference to output variable
  78824. * @returns whether or not transformation was successful
  78825. */
  78826. private static _transformSegmentDirToRef;
  78827. private static _bestMatch;
  78828. private static _score;
  78829. private static _bestScore;
  78830. /**
  78831. * Determine which token vector is most similar to the
  78832. * segment vector.
  78833. * @param segment segment vector
  78834. * @param tokens token vector list
  78835. * @returns index of the most similar token to the segment
  78836. */
  78837. private static _tokenizeSegment;
  78838. }
  78839. /**
  78840. * Class representing a set of known, named trajectories to which Trajectories can be
  78841. * added and using which Trajectories can be recognized.
  78842. */
  78843. export class TrajectoryClassifier {
  78844. private _maximumAllowableMatchCost;
  78845. private _vector3Alphabet;
  78846. private _levenshteinAlphabet;
  78847. private _nameToDescribedTrajectory;
  78848. /**
  78849. * Serialize to JSON.
  78850. * @returns JSON serialization
  78851. */
  78852. serialize(): string;
  78853. /**
  78854. * Deserialize from JSON.
  78855. * @param json JSON serialization
  78856. * @returns deserialized TrajectorySet
  78857. */
  78858. static Deserialize(json: string): TrajectoryClassifier;
  78859. /**
  78860. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  78861. * VERY naive, need to be generating these things from known
  78862. * sets. Better version later, probably eliminating this one.
  78863. * @returns auto-generated TrajectorySet
  78864. */
  78865. static Generate(): TrajectoryClassifier;
  78866. private constructor();
  78867. /**
  78868. * Add a new Trajectory to the set with a given name.
  78869. * @param trajectory new Trajectory to be added
  78870. * @param classification name to which to add the Trajectory
  78871. */
  78872. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  78873. /**
  78874. * Remove a known named trajectory and all Trajectories associated with it.
  78875. * @param classification name to remove
  78876. * @returns whether anything was removed
  78877. */
  78878. deleteClassification(classification: string): boolean;
  78879. /**
  78880. * Attempt to recognize a Trajectory from among all the classifications
  78881. * already known to the classifier.
  78882. * @param trajectory Trajectory to be recognized
  78883. * @returns classification of Trajectory if recognized, null otherwise
  78884. */
  78885. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  78886. }
  78887. }
  78888. declare module "babylonjs/Misc/index" {
  78889. export * from "babylonjs/Misc/andOrNotEvaluator";
  78890. export * from "babylonjs/Misc/assetsManager";
  78891. export * from "babylonjs/Misc/basis";
  78892. export * from "babylonjs/Misc/dds";
  78893. export * from "babylonjs/Misc/decorators";
  78894. export * from "babylonjs/Misc/deferred";
  78895. export * from "babylonjs/Misc/environmentTextureTools";
  78896. export * from "babylonjs/Misc/meshExploder";
  78897. export * from "babylonjs/Misc/filesInput";
  78898. export * from "babylonjs/Misc/HighDynamicRange/index";
  78899. export * from "babylonjs/Misc/khronosTextureContainer";
  78900. export * from "babylonjs/Misc/observable";
  78901. export * from "babylonjs/Misc/performanceMonitor";
  78902. export * from "babylonjs/Misc/promise";
  78903. export * from "babylonjs/Misc/sceneOptimizer";
  78904. export * from "babylonjs/Misc/sceneSerializer";
  78905. export * from "babylonjs/Misc/smartArray";
  78906. export * from "babylonjs/Misc/stringDictionary";
  78907. export * from "babylonjs/Misc/tags";
  78908. export * from "babylonjs/Misc/textureTools";
  78909. export * from "babylonjs/Misc/tga";
  78910. export * from "babylonjs/Misc/tools";
  78911. export * from "babylonjs/Misc/videoRecorder";
  78912. export * from "babylonjs/Misc/virtualJoystick";
  78913. export * from "babylonjs/Misc/workerPool";
  78914. export * from "babylonjs/Misc/logger";
  78915. export * from "babylonjs/Misc/typeStore";
  78916. export * from "babylonjs/Misc/filesInputStore";
  78917. export * from "babylonjs/Misc/deepCopier";
  78918. export * from "babylonjs/Misc/pivotTools";
  78919. export * from "babylonjs/Misc/precisionDate";
  78920. export * from "babylonjs/Misc/screenshotTools";
  78921. export * from "babylonjs/Misc/typeStore";
  78922. export * from "babylonjs/Misc/webRequest";
  78923. export * from "babylonjs/Misc/iInspectable";
  78924. export * from "babylonjs/Misc/brdfTextureTools";
  78925. export * from "babylonjs/Misc/rgbdTextureTools";
  78926. export * from "babylonjs/Misc/gradients";
  78927. export * from "babylonjs/Misc/perfCounter";
  78928. export * from "babylonjs/Misc/fileRequest";
  78929. export * from "babylonjs/Misc/customAnimationFrameRequester";
  78930. export * from "babylonjs/Misc/retryStrategy";
  78931. export * from "babylonjs/Misc/interfaces/screenshotSize";
  78932. export * from "babylonjs/Misc/canvasGenerator";
  78933. export * from "babylonjs/Misc/fileTools";
  78934. export * from "babylonjs/Misc/stringTools";
  78935. export * from "babylonjs/Misc/dataReader";
  78936. export * from "babylonjs/Misc/minMaxReducer";
  78937. export * from "babylonjs/Misc/depthReducer";
  78938. export * from "babylonjs/Misc/dataStorage";
  78939. export * from "babylonjs/Misc/sceneRecorder";
  78940. export * from "babylonjs/Misc/khronosTextureContainer2";
  78941. export * from "babylonjs/Misc/trajectoryClassifier";
  78942. }
  78943. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  78944. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  78945. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78946. import { Observable } from "babylonjs/Misc/observable";
  78947. import { Matrix } from "babylonjs/Maths/math.vector";
  78948. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78949. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78950. /**
  78951. * An interface for all Hit test features
  78952. */
  78953. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78954. /**
  78955. * Triggered when new babylon (transformed) hit test results are available
  78956. */
  78957. onHitTestResultObservable: Observable<T[]>;
  78958. }
  78959. /**
  78960. * Options used for hit testing
  78961. */
  78962. export interface IWebXRLegacyHitTestOptions {
  78963. /**
  78964. * Only test when user interacted with the scene. Default - hit test every frame
  78965. */
  78966. testOnPointerDownOnly?: boolean;
  78967. /**
  78968. * The node to use to transform the local results to world coordinates
  78969. */
  78970. worldParentNode?: TransformNode;
  78971. }
  78972. /**
  78973. * Interface defining the babylon result of raycasting/hit-test
  78974. */
  78975. export interface IWebXRLegacyHitResult {
  78976. /**
  78977. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78978. */
  78979. transformationMatrix: Matrix;
  78980. /**
  78981. * The native hit test result
  78982. */
  78983. xrHitResult: XRHitResult | XRHitTestResult;
  78984. }
  78985. /**
  78986. * The currently-working hit-test module.
  78987. * Hit test (or Ray-casting) is used to interact with the real world.
  78988. * For further information read here - https://github.com/immersive-web/hit-test
  78989. */
  78990. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78991. /**
  78992. * options to use when constructing this feature
  78993. */
  78994. readonly options: IWebXRLegacyHitTestOptions;
  78995. private _direction;
  78996. private _mat;
  78997. private _onSelectEnabled;
  78998. private _origin;
  78999. /**
  79000. * The module's name
  79001. */
  79002. static readonly Name: string;
  79003. /**
  79004. * The (Babylon) version of this module.
  79005. * This is an integer representing the implementation version.
  79006. * This number does not correspond to the WebXR specs version
  79007. */
  79008. static readonly Version: number;
  79009. /**
  79010. * Populated with the last native XR Hit Results
  79011. */
  79012. lastNativeXRHitResults: XRHitResult[];
  79013. /**
  79014. * Triggered when new babylon (transformed) hit test results are available
  79015. */
  79016. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79017. /**
  79018. * Creates a new instance of the (legacy version) hit test feature
  79019. * @param _xrSessionManager an instance of WebXRSessionManager
  79020. * @param options options to use when constructing this feature
  79021. */
  79022. constructor(_xrSessionManager: WebXRSessionManager,
  79023. /**
  79024. * options to use when constructing this feature
  79025. */
  79026. options?: IWebXRLegacyHitTestOptions);
  79027. /**
  79028. * execute a hit test with an XR Ray
  79029. *
  79030. * @param xrSession a native xrSession that will execute this hit test
  79031. * @param xrRay the ray (position and direction) to use for ray-casting
  79032. * @param referenceSpace native XR reference space to use for the hit-test
  79033. * @param filter filter function that will filter the results
  79034. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79035. */
  79036. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79037. /**
  79038. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79039. * @param event the (select) event to use to select with
  79040. * @param referenceSpace the reference space to use for this hit test
  79041. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79042. */
  79043. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79044. /**
  79045. * attach this feature
  79046. * Will usually be called by the features manager
  79047. *
  79048. * @returns true if successful.
  79049. */
  79050. attach(): boolean;
  79051. /**
  79052. * detach this feature.
  79053. * Will usually be called by the features manager
  79054. *
  79055. * @returns true if successful.
  79056. */
  79057. detach(): boolean;
  79058. /**
  79059. * Dispose this feature and all of the resources attached
  79060. */
  79061. dispose(): void;
  79062. protected _onXRFrame(frame: XRFrame): void;
  79063. private _onHitTestResults;
  79064. private _onSelect;
  79065. }
  79066. }
  79067. declare module "babylonjs/XR/features/WebXRHitTest" {
  79068. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79069. import { Observable } from "babylonjs/Misc/observable";
  79070. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79071. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79072. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79073. /**
  79074. * Options used for hit testing (version 2)
  79075. */
  79076. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79077. /**
  79078. * Do not create a permanent hit test. Will usually be used when only
  79079. * transient inputs are needed.
  79080. */
  79081. disablePermanentHitTest?: boolean;
  79082. /**
  79083. * Enable transient (for example touch-based) hit test inspections
  79084. */
  79085. enableTransientHitTest?: boolean;
  79086. /**
  79087. * Offset ray for the permanent hit test
  79088. */
  79089. offsetRay?: Vector3;
  79090. /**
  79091. * Offset ray for the transient hit test
  79092. */
  79093. transientOffsetRay?: Vector3;
  79094. /**
  79095. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79096. */
  79097. useReferenceSpace?: boolean;
  79098. /**
  79099. * Override the default entity type(s) of the hit-test result
  79100. */
  79101. entityTypes?: XRHitTestTrackableType[];
  79102. }
  79103. /**
  79104. * Interface defining the babylon result of hit-test
  79105. */
  79106. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79107. /**
  79108. * The input source that generated this hit test (if transient)
  79109. */
  79110. inputSource?: XRInputSource;
  79111. /**
  79112. * Is this a transient hit test
  79113. */
  79114. isTransient?: boolean;
  79115. /**
  79116. * Position of the hit test result
  79117. */
  79118. position: Vector3;
  79119. /**
  79120. * Rotation of the hit test result
  79121. */
  79122. rotationQuaternion: Quaternion;
  79123. /**
  79124. * The native hit test result
  79125. */
  79126. xrHitResult: XRHitTestResult;
  79127. }
  79128. /**
  79129. * The currently-working hit-test module.
  79130. * Hit test (or Ray-casting) is used to interact with the real world.
  79131. * For further information read here - https://github.com/immersive-web/hit-test
  79132. *
  79133. * Tested on chrome (mobile) 80.
  79134. */
  79135. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79136. /**
  79137. * options to use when constructing this feature
  79138. */
  79139. readonly options: IWebXRHitTestOptions;
  79140. private _tmpMat;
  79141. private _tmpPos;
  79142. private _tmpQuat;
  79143. private _transientXrHitTestSource;
  79144. private _xrHitTestSource;
  79145. private initHitTestSource;
  79146. /**
  79147. * The module's name
  79148. */
  79149. static readonly Name: string;
  79150. /**
  79151. * The (Babylon) version of this module.
  79152. * This is an integer representing the implementation version.
  79153. * This number does not correspond to the WebXR specs version
  79154. */
  79155. static readonly Version: number;
  79156. /**
  79157. * When set to true, each hit test will have its own position/rotation objects
  79158. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79159. * the developers will clone them or copy them as they see fit.
  79160. */
  79161. autoCloneTransformation: boolean;
  79162. /**
  79163. * Triggered when new babylon (transformed) hit test results are available
  79164. * Note - this will be called when results come back from the device. It can be an empty array!!
  79165. */
  79166. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79167. /**
  79168. * Use this to temporarily pause hit test checks.
  79169. */
  79170. paused: boolean;
  79171. /**
  79172. * Creates a new instance of the hit test feature
  79173. * @param _xrSessionManager an instance of WebXRSessionManager
  79174. * @param options options to use when constructing this feature
  79175. */
  79176. constructor(_xrSessionManager: WebXRSessionManager,
  79177. /**
  79178. * options to use when constructing this feature
  79179. */
  79180. options?: IWebXRHitTestOptions);
  79181. /**
  79182. * attach this feature
  79183. * Will usually be called by the features manager
  79184. *
  79185. * @returns true if successful.
  79186. */
  79187. attach(): boolean;
  79188. /**
  79189. * detach this feature.
  79190. * Will usually be called by the features manager
  79191. *
  79192. * @returns true if successful.
  79193. */
  79194. detach(): boolean;
  79195. /**
  79196. * Dispose this feature and all of the resources attached
  79197. */
  79198. dispose(): void;
  79199. protected _onXRFrame(frame: XRFrame): void;
  79200. private _processWebXRHitTestResult;
  79201. }
  79202. }
  79203. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  79204. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79205. import { Observable } from "babylonjs/Misc/observable";
  79206. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79207. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79208. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79209. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  79210. /**
  79211. * Configuration options of the anchor system
  79212. */
  79213. export interface IWebXRAnchorSystemOptions {
  79214. /**
  79215. * a node that will be used to convert local to world coordinates
  79216. */
  79217. worldParentNode?: TransformNode;
  79218. /**
  79219. * If set to true a reference of the created anchors will be kept until the next session starts
  79220. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79221. */
  79222. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79223. }
  79224. /**
  79225. * A babylon container for an XR Anchor
  79226. */
  79227. export interface IWebXRAnchor {
  79228. /**
  79229. * A babylon-assigned ID for this anchor
  79230. */
  79231. id: number;
  79232. /**
  79233. * Transformation matrix to apply to an object attached to this anchor
  79234. */
  79235. transformationMatrix: Matrix;
  79236. /**
  79237. * The native anchor object
  79238. */
  79239. xrAnchor: XRAnchor;
  79240. /**
  79241. * if defined, this object will be constantly updated by the anchor's position and rotation
  79242. */
  79243. attachedNode?: TransformNode;
  79244. }
  79245. /**
  79246. * An implementation of the anchor system for WebXR.
  79247. * For further information see https://github.com/immersive-web/anchors/
  79248. */
  79249. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79250. private _options;
  79251. private _lastFrameDetected;
  79252. private _trackedAnchors;
  79253. private _referenceSpaceForFrameAnchors;
  79254. private _futureAnchors;
  79255. /**
  79256. * The module's name
  79257. */
  79258. static readonly Name: string;
  79259. /**
  79260. * The (Babylon) version of this module.
  79261. * This is an integer representing the implementation version.
  79262. * This number does not correspond to the WebXR specs version
  79263. */
  79264. static readonly Version: number;
  79265. /**
  79266. * Observers registered here will be executed when a new anchor was added to the session
  79267. */
  79268. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79269. /**
  79270. * Observers registered here will be executed when an anchor was removed from the session
  79271. */
  79272. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79273. /**
  79274. * Observers registered here will be executed when an existing anchor updates
  79275. * This can execute N times every frame
  79276. */
  79277. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79278. /**
  79279. * Set the reference space to use for anchor creation, when not using a hit test.
  79280. * Will default to the session's reference space if not defined
  79281. */
  79282. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79283. /**
  79284. * constructs a new anchor system
  79285. * @param _xrSessionManager an instance of WebXRSessionManager
  79286. * @param _options configuration object for this feature
  79287. */
  79288. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79289. private _tmpVector;
  79290. private _tmpQuaternion;
  79291. private _populateTmpTransformation;
  79292. /**
  79293. * Create a new anchor point using a hit test result at a specific point in the scene
  79294. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79295. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79296. *
  79297. * @param hitTestResult The hit test result to use for this anchor creation
  79298. * @param position an optional position offset for this anchor
  79299. * @param rotationQuaternion an optional rotation offset for this anchor
  79300. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79301. */
  79302. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  79303. /**
  79304. * Add a new anchor at a specific position and rotation
  79305. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79306. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79307. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79308. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79309. *
  79310. * @param position the position in which to add an anchor
  79311. * @param rotationQuaternion an optional rotation for the anchor transformation
  79312. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79313. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79314. */
  79315. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  79316. /**
  79317. * detach this feature.
  79318. * Will usually be called by the features manager
  79319. *
  79320. * @returns true if successful.
  79321. */
  79322. detach(): boolean;
  79323. /**
  79324. * Dispose this feature and all of the resources attached
  79325. */
  79326. dispose(): void;
  79327. protected _onXRFrame(frame: XRFrame): void;
  79328. /**
  79329. * avoiding using Array.find for global support.
  79330. * @param xrAnchor the plane to find in the array
  79331. */
  79332. private _findIndexInAnchorArray;
  79333. private _updateAnchorWithXRFrame;
  79334. private _createAnchorAtTransformation;
  79335. }
  79336. }
  79337. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  79338. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79339. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79340. import { Observable } from "babylonjs/Misc/observable";
  79341. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  79342. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79343. /**
  79344. * Options used in the plane detector module
  79345. */
  79346. export interface IWebXRPlaneDetectorOptions {
  79347. /**
  79348. * The node to use to transform the local results to world coordinates
  79349. */
  79350. worldParentNode?: TransformNode;
  79351. /**
  79352. * If set to true a reference of the created planes will be kept until the next session starts
  79353. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79354. */
  79355. doNotRemovePlanesOnSessionEnded?: boolean;
  79356. }
  79357. /**
  79358. * A babylon interface for a WebXR plane.
  79359. * A Plane is actually a polygon, built from N points in space
  79360. *
  79361. * Supported in chrome 79, not supported in canary 81 ATM
  79362. */
  79363. export interface IWebXRPlane {
  79364. /**
  79365. * a babylon-assigned ID for this polygon
  79366. */
  79367. id: number;
  79368. /**
  79369. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79370. */
  79371. polygonDefinition: Array<Vector3>;
  79372. /**
  79373. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79374. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79375. */
  79376. transformationMatrix: Matrix;
  79377. /**
  79378. * the native xr-plane object
  79379. */
  79380. xrPlane: XRPlane;
  79381. }
  79382. /**
  79383. * The plane detector is used to detect planes in the real world when in AR
  79384. * For more information see https://github.com/immersive-web/real-world-geometry/
  79385. */
  79386. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79387. private _options;
  79388. private _detectedPlanes;
  79389. private _enabled;
  79390. private _lastFrameDetected;
  79391. /**
  79392. * The module's name
  79393. */
  79394. static readonly Name: string;
  79395. /**
  79396. * The (Babylon) version of this module.
  79397. * This is an integer representing the implementation version.
  79398. * This number does not correspond to the WebXR specs version
  79399. */
  79400. static readonly Version: number;
  79401. /**
  79402. * Observers registered here will be executed when a new plane was added to the session
  79403. */
  79404. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79405. /**
  79406. * Observers registered here will be executed when a plane is no longer detected in the session
  79407. */
  79408. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79409. /**
  79410. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79411. * This can execute N times every frame
  79412. */
  79413. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79414. /**
  79415. * construct a new Plane Detector
  79416. * @param _xrSessionManager an instance of xr Session manager
  79417. * @param _options configuration to use when constructing this feature
  79418. */
  79419. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79420. /**
  79421. * detach this feature.
  79422. * Will usually be called by the features manager
  79423. *
  79424. * @returns true if successful.
  79425. */
  79426. detach(): boolean;
  79427. /**
  79428. * Dispose this feature and all of the resources attached
  79429. */
  79430. dispose(): void;
  79431. protected _onXRFrame(frame: XRFrame): void;
  79432. private _init;
  79433. private _updatePlaneWithXRPlane;
  79434. /**
  79435. * avoiding using Array.find for global support.
  79436. * @param xrPlane the plane to find in the array
  79437. */
  79438. private findIndexInPlaneArray;
  79439. }
  79440. }
  79441. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79442. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79444. import { Observable } from "babylonjs/Misc/observable";
  79445. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79446. /**
  79447. * Options interface for the background remover plugin
  79448. */
  79449. export interface IWebXRBackgroundRemoverOptions {
  79450. /**
  79451. * Further background meshes to disable when entering AR
  79452. */
  79453. backgroundMeshes?: AbstractMesh[];
  79454. /**
  79455. * flags to configure the removal of the environment helper.
  79456. * If not set, the entire background will be removed. If set, flags should be set as well.
  79457. */
  79458. environmentHelperRemovalFlags?: {
  79459. /**
  79460. * Should the skybox be removed (default false)
  79461. */
  79462. skyBox?: boolean;
  79463. /**
  79464. * Should the ground be removed (default false)
  79465. */
  79466. ground?: boolean;
  79467. };
  79468. /**
  79469. * don't disable the environment helper
  79470. */
  79471. ignoreEnvironmentHelper?: boolean;
  79472. }
  79473. /**
  79474. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79475. */
  79476. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79477. /**
  79478. * read-only options to be used in this module
  79479. */
  79480. readonly options: IWebXRBackgroundRemoverOptions;
  79481. /**
  79482. * The module's name
  79483. */
  79484. static readonly Name: string;
  79485. /**
  79486. * The (Babylon) version of this module.
  79487. * This is an integer representing the implementation version.
  79488. * This number does not correspond to the WebXR specs version
  79489. */
  79490. static readonly Version: number;
  79491. /**
  79492. * registered observers will be triggered when the background state changes
  79493. */
  79494. onBackgroundStateChangedObservable: Observable<boolean>;
  79495. /**
  79496. * constructs a new background remover module
  79497. * @param _xrSessionManager the session manager for this module
  79498. * @param options read-only options to be used in this module
  79499. */
  79500. constructor(_xrSessionManager: WebXRSessionManager,
  79501. /**
  79502. * read-only options to be used in this module
  79503. */
  79504. options?: IWebXRBackgroundRemoverOptions);
  79505. /**
  79506. * attach this feature
  79507. * Will usually be called by the features manager
  79508. *
  79509. * @returns true if successful.
  79510. */
  79511. attach(): boolean;
  79512. /**
  79513. * detach this feature.
  79514. * Will usually be called by the features manager
  79515. *
  79516. * @returns true if successful.
  79517. */
  79518. detach(): boolean;
  79519. /**
  79520. * Dispose this feature and all of the resources attached
  79521. */
  79522. dispose(): void;
  79523. protected _onXRFrame(_xrFrame: XRFrame): void;
  79524. private _setBackgroundState;
  79525. }
  79526. }
  79527. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  79528. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79529. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79530. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  79531. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79532. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79533. import { Nullable } from "babylonjs/types";
  79534. /**
  79535. * Options for the controller physics feature
  79536. */
  79537. export class IWebXRControllerPhysicsOptions {
  79538. /**
  79539. * Should the headset get its own impostor
  79540. */
  79541. enableHeadsetImpostor?: boolean;
  79542. /**
  79543. * Optional parameters for the headset impostor
  79544. */
  79545. headsetImpostorParams?: {
  79546. /**
  79547. * The type of impostor to create. Default is sphere
  79548. */
  79549. impostorType: number;
  79550. /**
  79551. * the size of the impostor. Defaults to 10cm
  79552. */
  79553. impostorSize?: number | {
  79554. width: number;
  79555. height: number;
  79556. depth: number;
  79557. };
  79558. /**
  79559. * Friction definitions
  79560. */
  79561. friction?: number;
  79562. /**
  79563. * Restitution
  79564. */
  79565. restitution?: number;
  79566. };
  79567. /**
  79568. * The physics properties of the future impostors
  79569. */
  79570. physicsProperties?: {
  79571. /**
  79572. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79573. * Note that this requires a physics engine that supports mesh impostors!
  79574. */
  79575. useControllerMesh?: boolean;
  79576. /**
  79577. * The type of impostor to create. Default is sphere
  79578. */
  79579. impostorType?: number;
  79580. /**
  79581. * the size of the impostor. Defaults to 10cm
  79582. */
  79583. impostorSize?: number | {
  79584. width: number;
  79585. height: number;
  79586. depth: number;
  79587. };
  79588. /**
  79589. * Friction definitions
  79590. */
  79591. friction?: number;
  79592. /**
  79593. * Restitution
  79594. */
  79595. restitution?: number;
  79596. };
  79597. /**
  79598. * the xr input to use with this pointer selection
  79599. */
  79600. xrInput: WebXRInput;
  79601. }
  79602. /**
  79603. * Add physics impostor to your webxr controllers,
  79604. * including naive calculation of their linear and angular velocity
  79605. */
  79606. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79607. private readonly _options;
  79608. private _attachController;
  79609. private _controllers;
  79610. private _debugMode;
  79611. private _delta;
  79612. private _headsetImpostor?;
  79613. private _headsetMesh?;
  79614. private _lastTimestamp;
  79615. private _tmpQuaternion;
  79616. private _tmpVector;
  79617. /**
  79618. * The module's name
  79619. */
  79620. static readonly Name: string;
  79621. /**
  79622. * The (Babylon) version of this module.
  79623. * This is an integer representing the implementation version.
  79624. * This number does not correspond to the webxr specs version
  79625. */
  79626. static readonly Version: number;
  79627. /**
  79628. * Construct a new Controller Physics Feature
  79629. * @param _xrSessionManager the corresponding xr session manager
  79630. * @param _options options to create this feature with
  79631. */
  79632. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79633. /**
  79634. * @hidden
  79635. * enable debugging - will show console outputs and the impostor mesh
  79636. */
  79637. _enablePhysicsDebug(): void;
  79638. /**
  79639. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79640. * @param xrController the controller to add
  79641. */
  79642. addController(xrController: WebXRInputSource): void;
  79643. /**
  79644. * attach this feature
  79645. * Will usually be called by the features manager
  79646. *
  79647. * @returns true if successful.
  79648. */
  79649. attach(): boolean;
  79650. /**
  79651. * detach this feature.
  79652. * Will usually be called by the features manager
  79653. *
  79654. * @returns true if successful.
  79655. */
  79656. detach(): boolean;
  79657. /**
  79658. * Get the headset impostor, if enabled
  79659. * @returns the impostor
  79660. */
  79661. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79662. /**
  79663. * Get the physics impostor of a specific controller.
  79664. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79665. * @param controller the controller or the controller id of which to get the impostor
  79666. * @returns the impostor or null
  79667. */
  79668. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79669. /**
  79670. * Update the physics properties provided in the constructor
  79671. * @param newProperties the new properties object
  79672. */
  79673. setPhysicsProperties(newProperties: {
  79674. impostorType?: number;
  79675. impostorSize?: number | {
  79676. width: number;
  79677. height: number;
  79678. depth: number;
  79679. };
  79680. friction?: number;
  79681. restitution?: number;
  79682. }): void;
  79683. protected _onXRFrame(_xrFrame: any): void;
  79684. private _detachController;
  79685. }
  79686. }
  79687. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  79688. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79689. import { Observable } from "babylonjs/Misc/observable";
  79690. import { Vector3 } from "babylonjs/Maths/math.vector";
  79691. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79692. /**
  79693. * A babylon interface for a "WebXR" feature point.
  79694. * Represents the position and confidence value of a given feature point.
  79695. */
  79696. export interface IWebXRFeaturePoint {
  79697. /**
  79698. * Represents the position of the feature point in world space.
  79699. */
  79700. position: Vector3;
  79701. /**
  79702. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79703. */
  79704. confidenceValue: number;
  79705. }
  79706. /**
  79707. * The feature point system is used to detect feature points from real world geometry.
  79708. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79709. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79710. */
  79711. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79712. private _enabled;
  79713. private _featurePointCloud;
  79714. /**
  79715. * The module's name
  79716. */
  79717. static readonly Name: string;
  79718. /**
  79719. * The (Babylon) version of this module.
  79720. * This is an integer representing the implementation version.
  79721. * This number does not correspond to the WebXR specs version
  79722. */
  79723. static readonly Version: number;
  79724. /**
  79725. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79726. * Will notify the observers about which feature points have been added.
  79727. */
  79728. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79729. /**
  79730. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79731. * Will notify the observers about which feature points have been updated.
  79732. */
  79733. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79734. /**
  79735. * The current feature point cloud maintained across frames.
  79736. */
  79737. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79738. /**
  79739. * construct the feature point system
  79740. * @param _xrSessionManager an instance of xr Session manager
  79741. */
  79742. constructor(_xrSessionManager: WebXRSessionManager);
  79743. /**
  79744. * Detach this feature.
  79745. * Will usually be called by the features manager
  79746. *
  79747. * @returns true if successful.
  79748. */
  79749. detach(): boolean;
  79750. /**
  79751. * Dispose this feature and all of the resources attached
  79752. */
  79753. dispose(): void;
  79754. /**
  79755. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79756. */
  79757. protected _onXRFrame(frame: XRFrame): void;
  79758. /**
  79759. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79760. */
  79761. private _init;
  79762. }
  79763. }
  79764. declare module "babylonjs/XR/features/WebXRHandTracking" {
  79765. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79766. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79768. import { Mesh } from "babylonjs/Meshes/mesh";
  79769. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79770. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79771. import { Nullable } from "babylonjs/types";
  79772. import { IDisposable } from "babylonjs/scene";
  79773. import { Observable } from "babylonjs/Misc/observable";
  79774. /**
  79775. * Configuration interface for the hand tracking feature
  79776. */
  79777. export interface IWebXRHandTrackingOptions {
  79778. /**
  79779. * The xrInput that will be used as source for new hands
  79780. */
  79781. xrInput: WebXRInput;
  79782. /**
  79783. * Configuration object for the joint meshes
  79784. */
  79785. jointMeshes?: {
  79786. /**
  79787. * Should the meshes created be invisible (defaults to false)
  79788. */
  79789. invisible?: boolean;
  79790. /**
  79791. * A source mesh to be used to create instances. Defaults to a sphere.
  79792. * This mesh will be the source for all other (25) meshes.
  79793. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79794. */
  79795. sourceMesh?: Mesh;
  79796. /**
  79797. * Should the source mesh stay visible. Defaults to false
  79798. */
  79799. keepOriginalVisible?: boolean;
  79800. /**
  79801. * Scale factor for all instances (defaults to 2)
  79802. */
  79803. scaleFactor?: number;
  79804. /**
  79805. * Should each instance have its own physics impostor
  79806. */
  79807. enablePhysics?: boolean;
  79808. /**
  79809. * If enabled, override default physics properties
  79810. */
  79811. physicsProps?: {
  79812. friction?: number;
  79813. restitution?: number;
  79814. impostorType?: number;
  79815. };
  79816. /**
  79817. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  79818. */
  79819. handMesh?: AbstractMesh;
  79820. };
  79821. }
  79822. /**
  79823. * Parts of the hands divided to writs and finger names
  79824. */
  79825. export const enum HandPart {
  79826. /**
  79827. * HandPart - Wrist
  79828. */
  79829. WRIST = "wrist",
  79830. /**
  79831. * HandPart - The THumb
  79832. */
  79833. THUMB = "thumb",
  79834. /**
  79835. * HandPart - Index finger
  79836. */
  79837. INDEX = "index",
  79838. /**
  79839. * HandPart - Middle finger
  79840. */
  79841. MIDDLE = "middle",
  79842. /**
  79843. * HandPart - Ring finger
  79844. */
  79845. RING = "ring",
  79846. /**
  79847. * HandPart - Little finger
  79848. */
  79849. LITTLE = "little"
  79850. }
  79851. /**
  79852. * Representing a single hand (with its corresponding native XRHand object)
  79853. */
  79854. export class WebXRHand implements IDisposable {
  79855. /** the controller to which the hand correlates */
  79856. readonly xrController: WebXRInputSource;
  79857. /** the meshes to be used to track the hand joints */
  79858. readonly trackedMeshes: AbstractMesh[];
  79859. /**
  79860. * Hand-parts definition (key is HandPart)
  79861. */
  79862. handPartsDefinition: {
  79863. [key: string]: number[];
  79864. };
  79865. /**
  79866. * Populate the HandPartsDefinition object.
  79867. * This is called as a side effect since certain browsers don't have XRHand defined.
  79868. */
  79869. private generateHandPartsDefinition;
  79870. /**
  79871. * Construct a new hand object
  79872. * @param xrController the controller to which the hand correlates
  79873. * @param trackedMeshes the meshes to be used to track the hand joints
  79874. */
  79875. constructor(
  79876. /** the controller to which the hand correlates */
  79877. xrController: WebXRInputSource,
  79878. /** the meshes to be used to track the hand joints */
  79879. trackedMeshes: AbstractMesh[]);
  79880. /**
  79881. * Update this hand from the latest xr frame
  79882. * @param xrFrame xrFrame to update from
  79883. * @param referenceSpace The current viewer reference space
  79884. * @param scaleFactor optional scale factor for the meshes
  79885. */
  79886. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79887. /**
  79888. * Get meshes of part of the hand
  79889. * @param part the part of hand to get
  79890. * @returns An array of meshes that correlate to the hand part requested
  79891. */
  79892. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79893. /**
  79894. * Dispose this Hand object
  79895. */
  79896. dispose(): void;
  79897. }
  79898. /**
  79899. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79900. */
  79901. export class WebXRHandTracking extends WebXRAbstractFeature {
  79902. /**
  79903. * options to use when constructing this feature
  79904. */
  79905. readonly options: IWebXRHandTrackingOptions;
  79906. private static _idCounter;
  79907. /**
  79908. * The module's name
  79909. */
  79910. static readonly Name: string;
  79911. /**
  79912. * The (Babylon) version of this module.
  79913. * This is an integer representing the implementation version.
  79914. * This number does not correspond to the WebXR specs version
  79915. */
  79916. static readonly Version: number;
  79917. /**
  79918. * This observable will notify registered observers when a new hand object was added and initialized
  79919. */
  79920. onHandAddedObservable: Observable<WebXRHand>;
  79921. /**
  79922. * This observable will notify its observers right before the hand object is disposed
  79923. */
  79924. onHandRemovedObservable: Observable<WebXRHand>;
  79925. private _hands;
  79926. /**
  79927. * Creates a new instance of the hit test feature
  79928. * @param _xrSessionManager an instance of WebXRSessionManager
  79929. * @param options options to use when constructing this feature
  79930. */
  79931. constructor(_xrSessionManager: WebXRSessionManager,
  79932. /**
  79933. * options to use when constructing this feature
  79934. */
  79935. options: IWebXRHandTrackingOptions);
  79936. /**
  79937. * Check if the needed objects are defined.
  79938. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79939. */
  79940. isCompatible(): boolean;
  79941. /**
  79942. * attach this feature
  79943. * Will usually be called by the features manager
  79944. *
  79945. * @returns true if successful.
  79946. */
  79947. attach(): boolean;
  79948. /**
  79949. * detach this feature.
  79950. * Will usually be called by the features manager
  79951. *
  79952. * @returns true if successful.
  79953. */
  79954. detach(): boolean;
  79955. /**
  79956. * Dispose this feature and all of the resources attached
  79957. */
  79958. dispose(): void;
  79959. /**
  79960. * Get the hand object according to the controller id
  79961. * @param controllerId the controller id to which we want to get the hand
  79962. * @returns null if not found or the WebXRHand object if found
  79963. */
  79964. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79965. /**
  79966. * Get a hand object according to the requested handedness
  79967. * @param handedness the handedness to request
  79968. * @returns null if not found or the WebXRHand object if found
  79969. */
  79970. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79971. protected _onXRFrame(_xrFrame: XRFrame): void;
  79972. private _attachHand;
  79973. private _detachHand;
  79974. }
  79975. }
  79976. declare module "babylonjs/XR/features/index" {
  79977. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  79978. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  79979. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  79980. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  79981. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  79982. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  79983. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  79984. export * from "babylonjs/XR/features/WebXRHitTest";
  79985. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  79986. export * from "babylonjs/XR/features/WebXRHandTracking";
  79987. }
  79988. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  79989. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79991. import { Scene } from "babylonjs/scene";
  79992. /**
  79993. * The motion controller class for all microsoft mixed reality controllers
  79994. */
  79995. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  79996. protected readonly _mapping: {
  79997. defaultButton: {
  79998. valueNodeName: string;
  79999. unpressedNodeName: string;
  80000. pressedNodeName: string;
  80001. };
  80002. defaultAxis: {
  80003. valueNodeName: string;
  80004. minNodeName: string;
  80005. maxNodeName: string;
  80006. };
  80007. buttons: {
  80008. "xr-standard-trigger": {
  80009. rootNodeName: string;
  80010. componentProperty: string;
  80011. states: string[];
  80012. };
  80013. "xr-standard-squeeze": {
  80014. rootNodeName: string;
  80015. componentProperty: string;
  80016. states: string[];
  80017. };
  80018. "xr-standard-touchpad": {
  80019. rootNodeName: string;
  80020. labelAnchorNodeName: string;
  80021. touchPointNodeName: string;
  80022. };
  80023. "xr-standard-thumbstick": {
  80024. rootNodeName: string;
  80025. componentProperty: string;
  80026. states: string[];
  80027. };
  80028. };
  80029. axes: {
  80030. "xr-standard-touchpad": {
  80031. "x-axis": {
  80032. rootNodeName: string;
  80033. };
  80034. "y-axis": {
  80035. rootNodeName: string;
  80036. };
  80037. };
  80038. "xr-standard-thumbstick": {
  80039. "x-axis": {
  80040. rootNodeName: string;
  80041. };
  80042. "y-axis": {
  80043. rootNodeName: string;
  80044. };
  80045. };
  80046. };
  80047. };
  80048. /**
  80049. * The base url used to load the left and right controller models
  80050. */
  80051. static MODEL_BASE_URL: string;
  80052. /**
  80053. * The name of the left controller model file
  80054. */
  80055. static MODEL_LEFT_FILENAME: string;
  80056. /**
  80057. * The name of the right controller model file
  80058. */
  80059. static MODEL_RIGHT_FILENAME: string;
  80060. profileId: string;
  80061. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80062. protected _getFilenameAndPath(): {
  80063. filename: string;
  80064. path: string;
  80065. };
  80066. protected _getModelLoadingConstraints(): boolean;
  80067. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80068. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80069. protected _updateModel(): void;
  80070. }
  80071. }
  80072. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80073. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80075. import { Scene } from "babylonjs/scene";
  80076. /**
  80077. * The motion controller class for oculus touch (quest, rift).
  80078. * This class supports legacy mapping as well the standard xr mapping
  80079. */
  80080. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80081. private _forceLegacyControllers;
  80082. private _modelRootNode;
  80083. /**
  80084. * The base url used to load the left and right controller models
  80085. */
  80086. static MODEL_BASE_URL: string;
  80087. /**
  80088. * The name of the left controller model file
  80089. */
  80090. static MODEL_LEFT_FILENAME: string;
  80091. /**
  80092. * The name of the right controller model file
  80093. */
  80094. static MODEL_RIGHT_FILENAME: string;
  80095. /**
  80096. * Base Url for the Quest controller model.
  80097. */
  80098. static QUEST_MODEL_BASE_URL: string;
  80099. profileId: string;
  80100. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80101. protected _getFilenameAndPath(): {
  80102. filename: string;
  80103. path: string;
  80104. };
  80105. protected _getModelLoadingConstraints(): boolean;
  80106. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80107. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80108. protected _updateModel(): void;
  80109. /**
  80110. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80111. * between the touch and touch 2.
  80112. */
  80113. private _isQuest;
  80114. }
  80115. }
  80116. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80117. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80118. import { Scene } from "babylonjs/scene";
  80119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80120. /**
  80121. * The motion controller class for the standard HTC-Vive controllers
  80122. */
  80123. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80124. private _modelRootNode;
  80125. /**
  80126. * The base url used to load the left and right controller models
  80127. */
  80128. static MODEL_BASE_URL: string;
  80129. /**
  80130. * File name for the controller model.
  80131. */
  80132. static MODEL_FILENAME: string;
  80133. profileId: string;
  80134. /**
  80135. * Create a new Vive motion controller object
  80136. * @param scene the scene to use to create this controller
  80137. * @param gamepadObject the corresponding gamepad object
  80138. * @param handedness the handedness of the controller
  80139. */
  80140. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80141. protected _getFilenameAndPath(): {
  80142. filename: string;
  80143. path: string;
  80144. };
  80145. protected _getModelLoadingConstraints(): boolean;
  80146. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80147. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80148. protected _updateModel(): void;
  80149. }
  80150. }
  80151. declare module "babylonjs/XR/motionController/index" {
  80152. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80153. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80154. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80155. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80156. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80157. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80158. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80159. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80160. }
  80161. declare module "babylonjs/XR/index" {
  80162. export * from "babylonjs/XR/webXRCamera";
  80163. export * from "babylonjs/XR/webXREnterExitUI";
  80164. export * from "babylonjs/XR/webXRExperienceHelper";
  80165. export * from "babylonjs/XR/webXRInput";
  80166. export * from "babylonjs/XR/webXRInputSource";
  80167. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80168. export * from "babylonjs/XR/webXRTypes";
  80169. export * from "babylonjs/XR/webXRSessionManager";
  80170. export * from "babylonjs/XR/webXRDefaultExperience";
  80171. export * from "babylonjs/XR/webXRFeaturesManager";
  80172. export * from "babylonjs/XR/features/index";
  80173. export * from "babylonjs/XR/motionController/index";
  80174. }
  80175. declare module "babylonjs/index" {
  80176. export * from "babylonjs/abstractScene";
  80177. export * from "babylonjs/Actions/index";
  80178. export * from "babylonjs/Animations/index";
  80179. export * from "babylonjs/assetContainer";
  80180. export * from "babylonjs/Audio/index";
  80181. export * from "babylonjs/Behaviors/index";
  80182. export * from "babylonjs/Bones/index";
  80183. export * from "babylonjs/Cameras/index";
  80184. export * from "babylonjs/Collisions/index";
  80185. export * from "babylonjs/Culling/index";
  80186. export * from "babylonjs/Debug/index";
  80187. export * from "babylonjs/DeviceInput/index";
  80188. export * from "babylonjs/Engines/index";
  80189. export * from "babylonjs/Events/index";
  80190. export * from "babylonjs/Gamepads/index";
  80191. export * from "babylonjs/Gizmos/index";
  80192. export * from "babylonjs/Helpers/index";
  80193. export * from "babylonjs/Instrumentation/index";
  80194. export * from "babylonjs/Layers/index";
  80195. export * from "babylonjs/LensFlares/index";
  80196. export * from "babylonjs/Lights/index";
  80197. export * from "babylonjs/Loading/index";
  80198. export * from "babylonjs/Materials/index";
  80199. export * from "babylonjs/Maths/index";
  80200. export * from "babylonjs/Meshes/index";
  80201. export * from "babylonjs/Morph/index";
  80202. export * from "babylonjs/Navigation/index";
  80203. export * from "babylonjs/node";
  80204. export * from "babylonjs/Offline/index";
  80205. export * from "babylonjs/Particles/index";
  80206. export * from "babylonjs/Physics/index";
  80207. export * from "babylonjs/PostProcesses/index";
  80208. export * from "babylonjs/Probes/index";
  80209. export * from "babylonjs/Rendering/index";
  80210. export * from "babylonjs/scene";
  80211. export * from "babylonjs/sceneComponent";
  80212. export * from "babylonjs/Sprites/index";
  80213. export * from "babylonjs/States/index";
  80214. export * from "babylonjs/Misc/index";
  80215. export * from "babylonjs/XR/index";
  80216. export * from "babylonjs/types";
  80217. }
  80218. declare module "babylonjs/Animations/pathCursor" {
  80219. import { Vector3 } from "babylonjs/Maths/math.vector";
  80220. import { Path2 } from "babylonjs/Maths/math.path";
  80221. /**
  80222. * A cursor which tracks a point on a path
  80223. */
  80224. export class PathCursor {
  80225. private path;
  80226. /**
  80227. * Stores path cursor callbacks for when an onchange event is triggered
  80228. */
  80229. private _onchange;
  80230. /**
  80231. * The value of the path cursor
  80232. */
  80233. value: number;
  80234. /**
  80235. * The animation array of the path cursor
  80236. */
  80237. animations: Animation[];
  80238. /**
  80239. * Initializes the path cursor
  80240. * @param path The path to track
  80241. */
  80242. constructor(path: Path2);
  80243. /**
  80244. * Gets the cursor point on the path
  80245. * @returns A point on the path cursor at the cursor location
  80246. */
  80247. getPoint(): Vector3;
  80248. /**
  80249. * Moves the cursor ahead by the step amount
  80250. * @param step The amount to move the cursor forward
  80251. * @returns This path cursor
  80252. */
  80253. moveAhead(step?: number): PathCursor;
  80254. /**
  80255. * Moves the cursor behind by the step amount
  80256. * @param step The amount to move the cursor back
  80257. * @returns This path cursor
  80258. */
  80259. moveBack(step?: number): PathCursor;
  80260. /**
  80261. * Moves the cursor by the step amount
  80262. * If the step amount is greater than one, an exception is thrown
  80263. * @param step The amount to move the cursor
  80264. * @returns This path cursor
  80265. */
  80266. move(step: number): PathCursor;
  80267. /**
  80268. * Ensures that the value is limited between zero and one
  80269. * @returns This path cursor
  80270. */
  80271. private ensureLimits;
  80272. /**
  80273. * Runs onchange callbacks on change (used by the animation engine)
  80274. * @returns This path cursor
  80275. */
  80276. private raiseOnChange;
  80277. /**
  80278. * Executes a function on change
  80279. * @param f A path cursor onchange callback
  80280. * @returns This path cursor
  80281. */
  80282. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80283. }
  80284. }
  80285. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  80286. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  80287. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  80288. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  80289. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  80290. }
  80291. declare module "babylonjs/Engines/Processors/Expressions/index" {
  80292. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  80293. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  80294. }
  80295. declare module "babylonjs/Engines/Processors/index" {
  80296. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  80297. export * from "babylonjs/Engines/Processors/Expressions/index";
  80298. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  80299. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  80300. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  80301. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  80302. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  80303. export * from "babylonjs/Engines/Processors/shaderProcessor";
  80304. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  80305. }
  80306. declare module "babylonjs/Legacy/legacy" {
  80307. import * as Babylon from "babylonjs/index";
  80308. export * from "babylonjs/index";
  80309. }
  80310. declare module "babylonjs/Shaders/blur.fragment" {
  80311. /** @hidden */
  80312. export var blurPixelShader: {
  80313. name: string;
  80314. shader: string;
  80315. };
  80316. }
  80317. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  80318. /** @hidden */
  80319. export var pointCloudVertexDeclaration: {
  80320. name: string;
  80321. shader: string;
  80322. };
  80323. }
  80324. declare module "babylonjs" {
  80325. export * from "babylonjs/Legacy/legacy";
  80326. }
  80327. declare module BABYLON {
  80328. /** Alias type for value that can be null */
  80329. export type Nullable<T> = T | null;
  80330. /**
  80331. * Alias type for number that are floats
  80332. * @ignorenaming
  80333. */
  80334. export type float = number;
  80335. /**
  80336. * Alias type for number that are doubles.
  80337. * @ignorenaming
  80338. */
  80339. export type double = number;
  80340. /**
  80341. * Alias type for number that are integer
  80342. * @ignorenaming
  80343. */
  80344. export type int = number;
  80345. /** Alias type for number array or Float32Array */
  80346. export type FloatArray = number[] | Float32Array;
  80347. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  80348. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  80349. /**
  80350. * Alias for types that can be used by a Buffer or VertexBuffer.
  80351. */
  80352. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  80353. /**
  80354. * Alias type for primitive types
  80355. * @ignorenaming
  80356. */
  80357. type Primitive = undefined | null | boolean | string | number | Function;
  80358. /**
  80359. * Type modifier to make all the properties of an object Readonly
  80360. */
  80361. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  80362. /**
  80363. * Type modifier to make all the properties of an object Readonly recursively
  80364. */
  80365. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  80366. /**
  80367. * Type modifier to make object properties readonly.
  80368. */
  80369. export type DeepImmutableObject<T> = {
  80370. readonly [K in keyof T]: DeepImmutable<T[K]>;
  80371. };
  80372. /** @hidden */
  80373. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  80374. }
  80375. }
  80376. declare module BABYLON {
  80377. /**
  80378. * A class serves as a medium between the observable and its observers
  80379. */
  80380. export class EventState {
  80381. /**
  80382. * Create a new EventState
  80383. * @param mask defines the mask associated with this state
  80384. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80385. * @param target defines the original target of the state
  80386. * @param currentTarget defines the current target of the state
  80387. */
  80388. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  80389. /**
  80390. * Initialize the current event state
  80391. * @param mask defines the mask associated with this state
  80392. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80393. * @param target defines the original target of the state
  80394. * @param currentTarget defines the current target of the state
  80395. * @returns the current event state
  80396. */
  80397. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  80398. /**
  80399. * An Observer can set this property to true to prevent subsequent observers of being notified
  80400. */
  80401. skipNextObservers: boolean;
  80402. /**
  80403. * Get the mask value that were used to trigger the event corresponding to this EventState object
  80404. */
  80405. mask: number;
  80406. /**
  80407. * The object that originally notified the event
  80408. */
  80409. target?: any;
  80410. /**
  80411. * The current object in the bubbling phase
  80412. */
  80413. currentTarget?: any;
  80414. /**
  80415. * This will be populated with the return value of the last function that was executed.
  80416. * If it is the first function in the callback chain it will be the event data.
  80417. */
  80418. lastReturnValue?: any;
  80419. }
  80420. /**
  80421. * Represent an Observer registered to a given Observable object.
  80422. */
  80423. export class Observer<T> {
  80424. /**
  80425. * Defines the callback to call when the observer is notified
  80426. */
  80427. callback: (eventData: T, eventState: EventState) => void;
  80428. /**
  80429. * Defines the mask of the observer (used to filter notifications)
  80430. */
  80431. mask: number;
  80432. /**
  80433. * Defines the current scope used to restore the JS context
  80434. */
  80435. scope: any;
  80436. /** @hidden */
  80437. _willBeUnregistered: boolean;
  80438. /**
  80439. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80440. */
  80441. unregisterOnNextCall: boolean;
  80442. /**
  80443. * Creates a new observer
  80444. * @param callback defines the callback to call when the observer is notified
  80445. * @param mask defines the mask of the observer (used to filter notifications)
  80446. * @param scope defines the current scope used to restore the JS context
  80447. */
  80448. constructor(
  80449. /**
  80450. * Defines the callback to call when the observer is notified
  80451. */
  80452. callback: (eventData: T, eventState: EventState) => void,
  80453. /**
  80454. * Defines the mask of the observer (used to filter notifications)
  80455. */
  80456. mask: number,
  80457. /**
  80458. * Defines the current scope used to restore the JS context
  80459. */
  80460. scope?: any);
  80461. }
  80462. /**
  80463. * Represent a list of observers registered to multiple Observables object.
  80464. */
  80465. export class MultiObserver<T> {
  80466. private _observers;
  80467. private _observables;
  80468. /**
  80469. * Release associated resources
  80470. */
  80471. dispose(): void;
  80472. /**
  80473. * Raise a callback when one of the observable will notify
  80474. * @param observables defines a list of observables to watch
  80475. * @param callback defines the callback to call on notification
  80476. * @param mask defines the mask used to filter notifications
  80477. * @param scope defines the current scope used to restore the JS context
  80478. * @returns the new MultiObserver
  80479. */
  80480. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80481. }
  80482. /**
  80483. * The Observable class is a simple implementation of the Observable pattern.
  80484. *
  80485. * 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.
  80486. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80487. * 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).
  80488. * 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.
  80489. */
  80490. export class Observable<T> {
  80491. private _observers;
  80492. private _eventState;
  80493. private _onObserverAdded;
  80494. /**
  80495. * Gets the list of observers
  80496. */
  80497. get observers(): Array<Observer<T>>;
  80498. /**
  80499. * Creates a new observable
  80500. * @param onObserverAdded defines a callback to call when a new observer is added
  80501. */
  80502. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80503. /**
  80504. * Create a new Observer with the specified callback
  80505. * @param callback the callback that will be executed for that Observer
  80506. * @param mask the mask used to filter observers
  80507. * @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.
  80508. * @param scope optional scope for the callback to be called from
  80509. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80510. * @returns the new observer created for the callback
  80511. */
  80512. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  80513. /**
  80514. * Create a new Observer with the specified callback and unregisters after the next notification
  80515. * @param callback the callback that will be executed for that Observer
  80516. * @returns the new observer created for the callback
  80517. */
  80518. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  80519. /**
  80520. * Remove an Observer from the Observable object
  80521. * @param observer the instance of the Observer to remove
  80522. * @returns false if it doesn't belong to this Observable
  80523. */
  80524. remove(observer: Nullable<Observer<T>>): boolean;
  80525. /**
  80526. * Remove a callback from the Observable object
  80527. * @param callback the callback to remove
  80528. * @param scope optional scope. If used only the callbacks with this scope will be removed
  80529. * @returns false if it doesn't belong to this Observable
  80530. */
  80531. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  80532. private _deferUnregister;
  80533. private _remove;
  80534. /**
  80535. * Moves the observable to the top of the observer list making it get called first when notified
  80536. * @param observer the observer to move
  80537. */
  80538. makeObserverTopPriority(observer: Observer<T>): void;
  80539. /**
  80540. * Moves the observable to the bottom of the observer list making it get called last when notified
  80541. * @param observer the observer to move
  80542. */
  80543. makeObserverBottomPriority(observer: Observer<T>): void;
  80544. /**
  80545. * Notify all Observers by calling their respective callback with the given data
  80546. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80547. * @param eventData defines the data to send to all observers
  80548. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80549. * @param target defines the original target of the state
  80550. * @param currentTarget defines the current target of the state
  80551. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  80552. */
  80553. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  80554. /**
  80555. * Calling this will execute each callback, expecting it to be a promise or return a value.
  80556. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  80557. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  80558. * and it is crucial that all callbacks will be executed.
  80559. * The order of the callbacks is kept, callbacks are not executed parallel.
  80560. *
  80561. * @param eventData The data to be sent to each callback
  80562. * @param mask is used to filter observers defaults to -1
  80563. * @param target defines the callback target (see EventState)
  80564. * @param currentTarget defines he current object in the bubbling phase
  80565. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  80566. */
  80567. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  80568. /**
  80569. * Notify a specific observer
  80570. * @param observer defines the observer to notify
  80571. * @param eventData defines the data to be sent to each callback
  80572. * @param mask is used to filter observers defaults to -1
  80573. */
  80574. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  80575. /**
  80576. * Gets a boolean indicating if the observable has at least one observer
  80577. * @returns true is the Observable has at least one Observer registered
  80578. */
  80579. hasObservers(): boolean;
  80580. /**
  80581. * Clear the list of observers
  80582. */
  80583. clear(): void;
  80584. /**
  80585. * Clone the current observable
  80586. * @returns a new observable
  80587. */
  80588. clone(): Observable<T>;
  80589. /**
  80590. * Does this observable handles observer registered with a given mask
  80591. * @param mask defines the mask to be tested
  80592. * @return whether or not one observer registered with the given mask is handeled
  80593. **/
  80594. hasSpecificMask(mask?: number): boolean;
  80595. }
  80596. }
  80597. declare module BABYLON {
  80598. /**
  80599. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  80600. * Babylon.js
  80601. */
  80602. export class DomManagement {
  80603. /**
  80604. * Checks if the window object exists
  80605. * @returns true if the window object exists
  80606. */
  80607. static IsWindowObjectExist(): boolean;
  80608. /**
  80609. * Checks if the navigator object exists
  80610. * @returns true if the navigator object exists
  80611. */
  80612. static IsNavigatorAvailable(): boolean;
  80613. /**
  80614. * Check if the document object exists
  80615. * @returns true if the document object exists
  80616. */
  80617. static IsDocumentAvailable(): boolean;
  80618. /**
  80619. * Extracts text content from a DOM element hierarchy
  80620. * @param element defines the root element
  80621. * @returns a string
  80622. */
  80623. static GetDOMTextContent(element: HTMLElement): string;
  80624. }
  80625. }
  80626. declare module BABYLON {
  80627. /**
  80628. * Logger used througouht the application to allow configuration of
  80629. * the log level required for the messages.
  80630. */
  80631. export class Logger {
  80632. /**
  80633. * No log
  80634. */
  80635. static readonly NoneLogLevel: number;
  80636. /**
  80637. * Only message logs
  80638. */
  80639. static readonly MessageLogLevel: number;
  80640. /**
  80641. * Only warning logs
  80642. */
  80643. static readonly WarningLogLevel: number;
  80644. /**
  80645. * Only error logs
  80646. */
  80647. static readonly ErrorLogLevel: number;
  80648. /**
  80649. * All logs
  80650. */
  80651. static readonly AllLogLevel: number;
  80652. private static _LogCache;
  80653. /**
  80654. * Gets a value indicating the number of loading errors
  80655. * @ignorenaming
  80656. */
  80657. static errorsCount: number;
  80658. /**
  80659. * Callback called when a new log is added
  80660. */
  80661. static OnNewCacheEntry: (entry: string) => void;
  80662. private static _AddLogEntry;
  80663. private static _FormatMessage;
  80664. private static _LogDisabled;
  80665. private static _LogEnabled;
  80666. private static _WarnDisabled;
  80667. private static _WarnEnabled;
  80668. private static _ErrorDisabled;
  80669. private static _ErrorEnabled;
  80670. /**
  80671. * Log a message to the console
  80672. */
  80673. static Log: (message: string) => void;
  80674. /**
  80675. * Write a warning message to the console
  80676. */
  80677. static Warn: (message: string) => void;
  80678. /**
  80679. * Write an error message to the console
  80680. */
  80681. static Error: (message: string) => void;
  80682. /**
  80683. * Gets current log cache (list of logs)
  80684. */
  80685. static get LogCache(): string;
  80686. /**
  80687. * Clears the log cache
  80688. */
  80689. static ClearLogCache(): void;
  80690. /**
  80691. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  80692. */
  80693. static set LogLevels(level: number);
  80694. }
  80695. }
  80696. declare module BABYLON {
  80697. /** @hidden */
  80698. export class _TypeStore {
  80699. /** @hidden */
  80700. static RegisteredTypes: {
  80701. [key: string]: Object;
  80702. };
  80703. /** @hidden */
  80704. static GetClass(fqdn: string): any;
  80705. }
  80706. }
  80707. declare module BABYLON {
  80708. /**
  80709. * Helper to manipulate strings
  80710. */
  80711. export class StringTools {
  80712. /**
  80713. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  80714. * @param str Source string
  80715. * @param suffix Suffix to search for in the source string
  80716. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80717. */
  80718. static EndsWith(str: string, suffix: string): boolean;
  80719. /**
  80720. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  80721. * @param str Source string
  80722. * @param suffix Suffix to search for in the source string
  80723. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80724. */
  80725. static StartsWith(str: string, suffix: string): boolean;
  80726. /**
  80727. * Decodes a buffer into a string
  80728. * @param buffer The buffer to decode
  80729. * @returns The decoded string
  80730. */
  80731. static Decode(buffer: Uint8Array | Uint16Array): string;
  80732. /**
  80733. * Encode a buffer to a base64 string
  80734. * @param buffer defines the buffer to encode
  80735. * @returns the encoded string
  80736. */
  80737. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  80738. /**
  80739. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  80740. * @param num the number to convert and pad
  80741. * @param length the expected length of the string
  80742. * @returns the padded string
  80743. */
  80744. static PadNumber(num: number, length: number): string;
  80745. }
  80746. }
  80747. declare module BABYLON {
  80748. /**
  80749. * Class containing a set of static utilities functions for deep copy.
  80750. */
  80751. export class DeepCopier {
  80752. /**
  80753. * Tries to copy an object by duplicating every property
  80754. * @param source defines the source object
  80755. * @param destination defines the target object
  80756. * @param doNotCopyList defines a list of properties to avoid
  80757. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  80758. */
  80759. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  80760. }
  80761. }
  80762. declare module BABYLON {
  80763. /**
  80764. * Class containing a set of static utilities functions for precision date
  80765. */
  80766. export class PrecisionDate {
  80767. /**
  80768. * Gets either window.performance.now() if supported or Date.now() else
  80769. */
  80770. static get Now(): number;
  80771. }
  80772. }
  80773. declare module BABYLON {
  80774. /** @hidden */
  80775. export class _DevTools {
  80776. static WarnImport(name: string): string;
  80777. }
  80778. }
  80779. declare module BABYLON {
  80780. /**
  80781. * Interface used to define the mechanism to get data from the network
  80782. */
  80783. export interface IWebRequest {
  80784. /**
  80785. * Returns client's response url
  80786. */
  80787. responseURL: string;
  80788. /**
  80789. * Returns client's status
  80790. */
  80791. status: number;
  80792. /**
  80793. * Returns client's status as a text
  80794. */
  80795. statusText: string;
  80796. }
  80797. }
  80798. declare module BABYLON {
  80799. /**
  80800. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  80801. */
  80802. export class WebRequest implements IWebRequest {
  80803. private _xhr;
  80804. /**
  80805. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  80806. * i.e. when loading files, where the server/service expects an Authorization header
  80807. */
  80808. static CustomRequestHeaders: {
  80809. [key: string]: string;
  80810. };
  80811. /**
  80812. * Add callback functions in this array to update all the requests before they get sent to the network
  80813. */
  80814. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  80815. private _injectCustomRequestHeaders;
  80816. /**
  80817. * Gets or sets a function to be called when loading progress changes
  80818. */
  80819. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  80820. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  80821. /**
  80822. * Returns client's state
  80823. */
  80824. get readyState(): number;
  80825. /**
  80826. * Returns client's status
  80827. */
  80828. get status(): number;
  80829. /**
  80830. * Returns client's status as a text
  80831. */
  80832. get statusText(): string;
  80833. /**
  80834. * Returns client's response
  80835. */
  80836. get response(): any;
  80837. /**
  80838. * Returns client's response url
  80839. */
  80840. get responseURL(): string;
  80841. /**
  80842. * Returns client's response as text
  80843. */
  80844. get responseText(): string;
  80845. /**
  80846. * Gets or sets the expected response type
  80847. */
  80848. get responseType(): XMLHttpRequestResponseType;
  80849. set responseType(value: XMLHttpRequestResponseType);
  80850. /** @hidden */
  80851. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  80852. /** @hidden */
  80853. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  80854. /**
  80855. * Cancels any network activity
  80856. */
  80857. abort(): void;
  80858. /**
  80859. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  80860. * @param body defines an optional request body
  80861. */
  80862. send(body?: Document | BodyInit | null): void;
  80863. /**
  80864. * Sets the request method, request URL
  80865. * @param method defines the method to use (GET, POST, etc..)
  80866. * @param url defines the url to connect with
  80867. */
  80868. open(method: string, url: string): void;
  80869. /**
  80870. * Sets the value of a request header.
  80871. * @param name The name of the header whose value is to be set
  80872. * @param value The value to set as the body of the header
  80873. */
  80874. setRequestHeader(name: string, value: string): void;
  80875. /**
  80876. * Get the string containing the text of a particular header's value.
  80877. * @param name The name of the header
  80878. * @returns The string containing the text of the given header name
  80879. */
  80880. getResponseHeader(name: string): Nullable<string>;
  80881. }
  80882. }
  80883. declare module BABYLON {
  80884. /**
  80885. * File request interface
  80886. */
  80887. export interface IFileRequest {
  80888. /**
  80889. * Raised when the request is complete (success or error).
  80890. */
  80891. onCompleteObservable: Observable<IFileRequest>;
  80892. /**
  80893. * Aborts the request for a file.
  80894. */
  80895. abort: () => void;
  80896. }
  80897. }
  80898. declare module BABYLON {
  80899. /**
  80900. * Define options used to create a render target texture
  80901. */
  80902. export class RenderTargetCreationOptions {
  80903. /**
  80904. * Specifies is mipmaps must be generated
  80905. */
  80906. generateMipMaps?: boolean;
  80907. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  80908. generateDepthBuffer?: boolean;
  80909. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  80910. generateStencilBuffer?: boolean;
  80911. /** Defines texture type (int by default) */
  80912. type?: number;
  80913. /** Defines sampling mode (trilinear by default) */
  80914. samplingMode?: number;
  80915. /** Defines format (RGBA by default) */
  80916. format?: number;
  80917. }
  80918. }
  80919. declare module BABYLON {
  80920. /** Defines the cross module used constants to avoid circular dependncies */
  80921. export class Constants {
  80922. /** Defines that alpha blending is disabled */
  80923. static readonly ALPHA_DISABLE: number;
  80924. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  80925. static readonly ALPHA_ADD: number;
  80926. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  80927. static readonly ALPHA_COMBINE: number;
  80928. /** Defines that alpha blending is DEST - SRC * DEST */
  80929. static readonly ALPHA_SUBTRACT: number;
  80930. /** Defines that alpha blending is SRC * DEST */
  80931. static readonly ALPHA_MULTIPLY: number;
  80932. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  80933. static readonly ALPHA_MAXIMIZED: number;
  80934. /** Defines that alpha blending is SRC + DEST */
  80935. static readonly ALPHA_ONEONE: number;
  80936. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  80937. static readonly ALPHA_PREMULTIPLIED: number;
  80938. /**
  80939. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  80940. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  80941. */
  80942. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  80943. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  80944. static readonly ALPHA_INTERPOLATE: number;
  80945. /**
  80946. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  80947. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  80948. */
  80949. static readonly ALPHA_SCREENMODE: number;
  80950. /**
  80951. * Defines that alpha blending is SRC + DST
  80952. * Alpha will be set to SRC ALPHA + DST ALPHA
  80953. */
  80954. static readonly ALPHA_ONEONE_ONEONE: number;
  80955. /**
  80956. * Defines that alpha blending is SRC * DST ALPHA + DST
  80957. * Alpha will be set to 0
  80958. */
  80959. static readonly ALPHA_ALPHATOCOLOR: number;
  80960. /**
  80961. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80962. */
  80963. static readonly ALPHA_REVERSEONEMINUS: number;
  80964. /**
  80965. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  80966. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  80967. */
  80968. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  80969. /**
  80970. * Defines that alpha blending is SRC + DST
  80971. * Alpha will be set to SRC ALPHA
  80972. */
  80973. static readonly ALPHA_ONEONE_ONEZERO: number;
  80974. /**
  80975. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80976. * Alpha will be set to DST ALPHA
  80977. */
  80978. static readonly ALPHA_EXCLUSION: number;
  80979. /** Defines that alpha blending equation a SUM */
  80980. static readonly ALPHA_EQUATION_ADD: number;
  80981. /** Defines that alpha blending equation a SUBSTRACTION */
  80982. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  80983. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  80984. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  80985. /** Defines that alpha blending equation a MAX operation */
  80986. static readonly ALPHA_EQUATION_MAX: number;
  80987. /** Defines that alpha blending equation a MIN operation */
  80988. static readonly ALPHA_EQUATION_MIN: number;
  80989. /**
  80990. * Defines that alpha blending equation a DARKEN operation:
  80991. * It takes the min of the src and sums the alpha channels.
  80992. */
  80993. static readonly ALPHA_EQUATION_DARKEN: number;
  80994. /** Defines that the ressource is not delayed*/
  80995. static readonly DELAYLOADSTATE_NONE: number;
  80996. /** Defines that the ressource was successfully delay loaded */
  80997. static readonly DELAYLOADSTATE_LOADED: number;
  80998. /** Defines that the ressource is currently delay loading */
  80999. static readonly DELAYLOADSTATE_LOADING: number;
  81000. /** Defines that the ressource is delayed and has not started loading */
  81001. static readonly DELAYLOADSTATE_NOTLOADED: number;
  81002. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  81003. static readonly NEVER: number;
  81004. /** 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 */
  81005. static readonly ALWAYS: number;
  81006. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  81007. static readonly LESS: number;
  81008. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  81009. static readonly EQUAL: number;
  81010. /** 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 */
  81011. static readonly LEQUAL: number;
  81012. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  81013. static readonly GREATER: number;
  81014. /** 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 */
  81015. static readonly GEQUAL: number;
  81016. /** 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 */
  81017. static readonly NOTEQUAL: number;
  81018. /** Passed to stencilOperation to specify that stencil value must be kept */
  81019. static readonly KEEP: number;
  81020. /** Passed to stencilOperation to specify that stencil value must be replaced */
  81021. static readonly REPLACE: number;
  81022. /** Passed to stencilOperation to specify that stencil value must be incremented */
  81023. static readonly INCR: number;
  81024. /** Passed to stencilOperation to specify that stencil value must be decremented */
  81025. static readonly DECR: number;
  81026. /** Passed to stencilOperation to specify that stencil value must be inverted */
  81027. static readonly INVERT: number;
  81028. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  81029. static readonly INCR_WRAP: number;
  81030. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  81031. static readonly DECR_WRAP: number;
  81032. /** Texture is not repeating outside of 0..1 UVs */
  81033. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  81034. /** Texture is repeating outside of 0..1 UVs */
  81035. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  81036. /** Texture is repeating and mirrored */
  81037. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  81038. /** ALPHA */
  81039. static readonly TEXTUREFORMAT_ALPHA: number;
  81040. /** LUMINANCE */
  81041. static readonly TEXTUREFORMAT_LUMINANCE: number;
  81042. /** LUMINANCE_ALPHA */
  81043. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  81044. /** RGB */
  81045. static readonly TEXTUREFORMAT_RGB: number;
  81046. /** RGBA */
  81047. static readonly TEXTUREFORMAT_RGBA: number;
  81048. /** RED */
  81049. static readonly TEXTUREFORMAT_RED: number;
  81050. /** RED (2nd reference) */
  81051. static readonly TEXTUREFORMAT_R: number;
  81052. /** RG */
  81053. static readonly TEXTUREFORMAT_RG: number;
  81054. /** RED_INTEGER */
  81055. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81056. /** RED_INTEGER (2nd reference) */
  81057. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81058. /** RG_INTEGER */
  81059. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81060. /** RGB_INTEGER */
  81061. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81062. /** RGBA_INTEGER */
  81063. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81064. /** UNSIGNED_BYTE */
  81065. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81066. /** UNSIGNED_BYTE (2nd reference) */
  81067. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81068. /** FLOAT */
  81069. static readonly TEXTURETYPE_FLOAT: number;
  81070. /** HALF_FLOAT */
  81071. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81072. /** BYTE */
  81073. static readonly TEXTURETYPE_BYTE: number;
  81074. /** SHORT */
  81075. static readonly TEXTURETYPE_SHORT: number;
  81076. /** UNSIGNED_SHORT */
  81077. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81078. /** INT */
  81079. static readonly TEXTURETYPE_INT: number;
  81080. /** UNSIGNED_INT */
  81081. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81082. /** UNSIGNED_SHORT_4_4_4_4 */
  81083. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81084. /** UNSIGNED_SHORT_5_5_5_1 */
  81085. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81086. /** UNSIGNED_SHORT_5_6_5 */
  81087. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81088. /** UNSIGNED_INT_2_10_10_10_REV */
  81089. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81090. /** UNSIGNED_INT_24_8 */
  81091. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81092. /** UNSIGNED_INT_10F_11F_11F_REV */
  81093. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81094. /** UNSIGNED_INT_5_9_9_9_REV */
  81095. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81096. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81097. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81098. /** nearest is mag = nearest and min = nearest and no mip */
  81099. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81100. /** mag = nearest and min = nearest and mip = none */
  81101. static readonly TEXTURE_NEAREST_NEAREST: number;
  81102. /** Bilinear is mag = linear and min = linear and no mip */
  81103. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81104. /** mag = linear and min = linear and mip = none */
  81105. static readonly TEXTURE_LINEAR_LINEAR: number;
  81106. /** Trilinear is mag = linear and min = linear and mip = linear */
  81107. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81108. /** Trilinear is mag = linear and min = linear and mip = linear */
  81109. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81110. /** mag = nearest and min = nearest and mip = nearest */
  81111. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81112. /** mag = nearest and min = linear and mip = nearest */
  81113. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81114. /** mag = nearest and min = linear and mip = linear */
  81115. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81116. /** mag = nearest and min = linear and mip = none */
  81117. static readonly TEXTURE_NEAREST_LINEAR: number;
  81118. /** nearest is mag = nearest and min = nearest and mip = linear */
  81119. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81120. /** mag = linear and min = nearest and mip = nearest */
  81121. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81122. /** mag = linear and min = nearest and mip = linear */
  81123. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81124. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81125. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81126. /** mag = linear and min = nearest and mip = none */
  81127. static readonly TEXTURE_LINEAR_NEAREST: number;
  81128. /** Explicit coordinates mode */
  81129. static readonly TEXTURE_EXPLICIT_MODE: number;
  81130. /** Spherical coordinates mode */
  81131. static readonly TEXTURE_SPHERICAL_MODE: number;
  81132. /** Planar coordinates mode */
  81133. static readonly TEXTURE_PLANAR_MODE: number;
  81134. /** Cubic coordinates mode */
  81135. static readonly TEXTURE_CUBIC_MODE: number;
  81136. /** Projection coordinates mode */
  81137. static readonly TEXTURE_PROJECTION_MODE: number;
  81138. /** Skybox coordinates mode */
  81139. static readonly TEXTURE_SKYBOX_MODE: number;
  81140. /** Inverse Cubic coordinates mode */
  81141. static readonly TEXTURE_INVCUBIC_MODE: number;
  81142. /** Equirectangular coordinates mode */
  81143. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81144. /** Equirectangular Fixed coordinates mode */
  81145. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81146. /** Equirectangular Fixed Mirrored coordinates mode */
  81147. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81148. /** Offline (baking) quality for texture filtering */
  81149. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81150. /** High quality for texture filtering */
  81151. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81152. /** Medium quality for texture filtering */
  81153. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81154. /** Low quality for texture filtering */
  81155. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81156. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81157. static readonly SCALEMODE_FLOOR: number;
  81158. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81159. static readonly SCALEMODE_NEAREST: number;
  81160. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81161. static readonly SCALEMODE_CEILING: number;
  81162. /**
  81163. * The dirty texture flag value
  81164. */
  81165. static readonly MATERIAL_TextureDirtyFlag: number;
  81166. /**
  81167. * The dirty light flag value
  81168. */
  81169. static readonly MATERIAL_LightDirtyFlag: number;
  81170. /**
  81171. * The dirty fresnel flag value
  81172. */
  81173. static readonly MATERIAL_FresnelDirtyFlag: number;
  81174. /**
  81175. * The dirty attribute flag value
  81176. */
  81177. static readonly MATERIAL_AttributesDirtyFlag: number;
  81178. /**
  81179. * The dirty misc flag value
  81180. */
  81181. static readonly MATERIAL_MiscDirtyFlag: number;
  81182. /**
  81183. * The all dirty flag value
  81184. */
  81185. static readonly MATERIAL_AllDirtyFlag: number;
  81186. /**
  81187. * Returns the triangle fill mode
  81188. */
  81189. static readonly MATERIAL_TriangleFillMode: number;
  81190. /**
  81191. * Returns the wireframe mode
  81192. */
  81193. static readonly MATERIAL_WireFrameFillMode: number;
  81194. /**
  81195. * Returns the point fill mode
  81196. */
  81197. static readonly MATERIAL_PointFillMode: number;
  81198. /**
  81199. * Returns the point list draw mode
  81200. */
  81201. static readonly MATERIAL_PointListDrawMode: number;
  81202. /**
  81203. * Returns the line list draw mode
  81204. */
  81205. static readonly MATERIAL_LineListDrawMode: number;
  81206. /**
  81207. * Returns the line loop draw mode
  81208. */
  81209. static readonly MATERIAL_LineLoopDrawMode: number;
  81210. /**
  81211. * Returns the line strip draw mode
  81212. */
  81213. static readonly MATERIAL_LineStripDrawMode: number;
  81214. /**
  81215. * Returns the triangle strip draw mode
  81216. */
  81217. static readonly MATERIAL_TriangleStripDrawMode: number;
  81218. /**
  81219. * Returns the triangle fan draw mode
  81220. */
  81221. static readonly MATERIAL_TriangleFanDrawMode: number;
  81222. /**
  81223. * Stores the clock-wise side orientation
  81224. */
  81225. static readonly MATERIAL_ClockWiseSideOrientation: number;
  81226. /**
  81227. * Stores the counter clock-wise side orientation
  81228. */
  81229. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  81230. /**
  81231. * Nothing
  81232. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81233. */
  81234. static readonly ACTION_NothingTrigger: number;
  81235. /**
  81236. * On pick
  81237. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81238. */
  81239. static readonly ACTION_OnPickTrigger: number;
  81240. /**
  81241. * On left pick
  81242. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81243. */
  81244. static readonly ACTION_OnLeftPickTrigger: number;
  81245. /**
  81246. * On right pick
  81247. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81248. */
  81249. static readonly ACTION_OnRightPickTrigger: number;
  81250. /**
  81251. * On center pick
  81252. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81253. */
  81254. static readonly ACTION_OnCenterPickTrigger: number;
  81255. /**
  81256. * On pick down
  81257. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81258. */
  81259. static readonly ACTION_OnPickDownTrigger: number;
  81260. /**
  81261. * On double pick
  81262. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81263. */
  81264. static readonly ACTION_OnDoublePickTrigger: number;
  81265. /**
  81266. * On pick up
  81267. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81268. */
  81269. static readonly ACTION_OnPickUpTrigger: number;
  81270. /**
  81271. * On pick out.
  81272. * This trigger will only be raised if you also declared a OnPickDown
  81273. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81274. */
  81275. static readonly ACTION_OnPickOutTrigger: number;
  81276. /**
  81277. * On long press
  81278. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81279. */
  81280. static readonly ACTION_OnLongPressTrigger: number;
  81281. /**
  81282. * On pointer over
  81283. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81284. */
  81285. static readonly ACTION_OnPointerOverTrigger: number;
  81286. /**
  81287. * On pointer out
  81288. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81289. */
  81290. static readonly ACTION_OnPointerOutTrigger: number;
  81291. /**
  81292. * On every frame
  81293. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81294. */
  81295. static readonly ACTION_OnEveryFrameTrigger: number;
  81296. /**
  81297. * On intersection enter
  81298. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81299. */
  81300. static readonly ACTION_OnIntersectionEnterTrigger: number;
  81301. /**
  81302. * On intersection exit
  81303. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81304. */
  81305. static readonly ACTION_OnIntersectionExitTrigger: number;
  81306. /**
  81307. * On key down
  81308. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81309. */
  81310. static readonly ACTION_OnKeyDownTrigger: number;
  81311. /**
  81312. * On key up
  81313. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81314. */
  81315. static readonly ACTION_OnKeyUpTrigger: number;
  81316. /**
  81317. * Billboard mode will only apply to Y axis
  81318. */
  81319. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  81320. /**
  81321. * Billboard mode will apply to all axes
  81322. */
  81323. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  81324. /**
  81325. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81326. */
  81327. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  81328. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81329. * Test order :
  81330. * Is the bounding sphere outside the frustum ?
  81331. * If not, are the bounding box vertices outside the frustum ?
  81332. * It not, then the cullable object is in the frustum.
  81333. */
  81334. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  81335. /** Culling strategy : Bounding Sphere Only.
  81336. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81337. * It's also less accurate than the standard because some not visible objects can still be selected.
  81338. * Test : is the bounding sphere outside the frustum ?
  81339. * If not, then the cullable object is in the frustum.
  81340. */
  81341. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81342. /** Culling strategy : Optimistic Inclusion.
  81343. * This in an inclusion test first, then the standard exclusion test.
  81344. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81345. * 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.
  81346. * Anyway, it's as accurate as the standard strategy.
  81347. * Test :
  81348. * Is the cullable object bounding sphere center in the frustum ?
  81349. * If not, apply the default culling strategy.
  81350. */
  81351. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81352. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81353. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81354. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81355. * 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.
  81356. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81357. * Test :
  81358. * Is the cullable object bounding sphere center in the frustum ?
  81359. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81360. */
  81361. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81362. /**
  81363. * No logging while loading
  81364. */
  81365. static readonly SCENELOADER_NO_LOGGING: number;
  81366. /**
  81367. * Minimal logging while loading
  81368. */
  81369. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  81370. /**
  81371. * Summary logging while loading
  81372. */
  81373. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  81374. /**
  81375. * Detailled logging while loading
  81376. */
  81377. static readonly SCENELOADER_DETAILED_LOGGING: number;
  81378. /**
  81379. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  81380. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  81381. */
  81382. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  81383. /**
  81384. * Constant used to retrieve the position texture index in the textures array in the prepass
  81385. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  81386. */
  81387. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  81388. /**
  81389. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  81390. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  81391. */
  81392. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  81393. /**
  81394. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  81395. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  81396. */
  81397. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  81398. /**
  81399. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  81400. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  81401. */
  81402. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  81403. /**
  81404. * Constant used to retrieve depth + normal index in the textures array in the prepass
  81405. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  81406. */
  81407. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  81408. /**
  81409. * Constant used to retrieve albedo index in the textures array in the prepass
  81410. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  81411. */
  81412. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  81413. }
  81414. }
  81415. declare module BABYLON {
  81416. /**
  81417. * This represents the required contract to create a new type of texture loader.
  81418. */
  81419. export interface IInternalTextureLoader {
  81420. /**
  81421. * Defines wether the loader supports cascade loading the different faces.
  81422. */
  81423. supportCascades: boolean;
  81424. /**
  81425. * This returns if the loader support the current file information.
  81426. * @param extension defines the file extension of the file being loaded
  81427. * @param mimeType defines the optional mime type of the file being loaded
  81428. * @returns true if the loader can load the specified file
  81429. */
  81430. canLoad(extension: string, mimeType?: string): boolean;
  81431. /**
  81432. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  81433. * @param data contains the texture data
  81434. * @param texture defines the BabylonJS internal texture
  81435. * @param createPolynomials will be true if polynomials have been requested
  81436. * @param onLoad defines the callback to trigger once the texture is ready
  81437. * @param onError defines the callback to trigger in case of error
  81438. */
  81439. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81440. /**
  81441. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  81442. * @param data contains the texture data
  81443. * @param texture defines the BabylonJS internal texture
  81444. * @param callback defines the method to call once ready to upload
  81445. */
  81446. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81447. }
  81448. }
  81449. declare module BABYLON {
  81450. /**
  81451. * Class used to store and describe the pipeline context associated with an effect
  81452. */
  81453. export interface IPipelineContext {
  81454. /**
  81455. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  81456. */
  81457. isAsync: boolean;
  81458. /**
  81459. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81460. */
  81461. isReady: boolean;
  81462. /** @hidden */
  81463. _getVertexShaderCode(): string | null;
  81464. /** @hidden */
  81465. _getFragmentShaderCode(): string | null;
  81466. /** @hidden */
  81467. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81468. }
  81469. }
  81470. declare module BABYLON {
  81471. /**
  81472. * Class used to store gfx data (like WebGLBuffer)
  81473. */
  81474. export class DataBuffer {
  81475. /**
  81476. * Gets or sets the number of objects referencing this buffer
  81477. */
  81478. references: number;
  81479. /** Gets or sets the size of the underlying buffer */
  81480. capacity: number;
  81481. /**
  81482. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  81483. */
  81484. is32Bits: boolean;
  81485. /**
  81486. * Gets the underlying buffer
  81487. */
  81488. get underlyingResource(): any;
  81489. }
  81490. }
  81491. declare module BABYLON {
  81492. /** @hidden */
  81493. export interface IShaderProcessor {
  81494. attributeProcessor?: (attribute: string) => string;
  81495. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81496. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81497. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81498. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81499. lineProcessor?: (line: string, isFragment: boolean) => string;
  81500. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81501. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81502. }
  81503. }
  81504. declare module BABYLON {
  81505. /** @hidden */
  81506. export interface ProcessingOptions {
  81507. defines: string[];
  81508. indexParameters: any;
  81509. isFragment: boolean;
  81510. shouldUseHighPrecisionShader: boolean;
  81511. supportsUniformBuffers: boolean;
  81512. shadersRepository: string;
  81513. includesShadersStore: {
  81514. [key: string]: string;
  81515. };
  81516. processor?: IShaderProcessor;
  81517. version: string;
  81518. platformName: string;
  81519. lookForClosingBracketForUniformBuffer?: boolean;
  81520. }
  81521. }
  81522. declare module BABYLON {
  81523. /** @hidden */
  81524. export class ShaderCodeNode {
  81525. line: string;
  81526. children: ShaderCodeNode[];
  81527. additionalDefineKey?: string;
  81528. additionalDefineValue?: string;
  81529. isValid(preprocessors: {
  81530. [key: string]: string;
  81531. }): boolean;
  81532. process(preprocessors: {
  81533. [key: string]: string;
  81534. }, options: ProcessingOptions): string;
  81535. }
  81536. }
  81537. declare module BABYLON {
  81538. /** @hidden */
  81539. export class ShaderCodeCursor {
  81540. private _lines;
  81541. lineIndex: number;
  81542. get currentLine(): string;
  81543. get canRead(): boolean;
  81544. set lines(value: string[]);
  81545. }
  81546. }
  81547. declare module BABYLON {
  81548. /** @hidden */
  81549. export class ShaderCodeConditionNode extends ShaderCodeNode {
  81550. process(preprocessors: {
  81551. [key: string]: string;
  81552. }, options: ProcessingOptions): string;
  81553. }
  81554. }
  81555. declare module BABYLON {
  81556. /** @hidden */
  81557. export class ShaderDefineExpression {
  81558. isTrue(preprocessors: {
  81559. [key: string]: string;
  81560. }): boolean;
  81561. private static _OperatorPriority;
  81562. private static _Stack;
  81563. static postfixToInfix(postfix: string[]): string;
  81564. static infixToPostfix(infix: string): string[];
  81565. }
  81566. }
  81567. declare module BABYLON {
  81568. /** @hidden */
  81569. export class ShaderCodeTestNode extends ShaderCodeNode {
  81570. testExpression: ShaderDefineExpression;
  81571. isValid(preprocessors: {
  81572. [key: string]: string;
  81573. }): boolean;
  81574. }
  81575. }
  81576. declare module BABYLON {
  81577. /** @hidden */
  81578. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  81579. define: string;
  81580. not: boolean;
  81581. constructor(define: string, not?: boolean);
  81582. isTrue(preprocessors: {
  81583. [key: string]: string;
  81584. }): boolean;
  81585. }
  81586. }
  81587. declare module BABYLON {
  81588. /** @hidden */
  81589. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  81590. leftOperand: ShaderDefineExpression;
  81591. rightOperand: ShaderDefineExpression;
  81592. isTrue(preprocessors: {
  81593. [key: string]: string;
  81594. }): boolean;
  81595. }
  81596. }
  81597. declare module BABYLON {
  81598. /** @hidden */
  81599. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  81600. leftOperand: ShaderDefineExpression;
  81601. rightOperand: ShaderDefineExpression;
  81602. isTrue(preprocessors: {
  81603. [key: string]: string;
  81604. }): boolean;
  81605. }
  81606. }
  81607. declare module BABYLON {
  81608. /** @hidden */
  81609. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  81610. define: string;
  81611. operand: string;
  81612. testValue: string;
  81613. constructor(define: string, operand: string, testValue: string);
  81614. isTrue(preprocessors: {
  81615. [key: string]: string;
  81616. }): boolean;
  81617. }
  81618. }
  81619. declare module BABYLON {
  81620. /**
  81621. * Class used to enable access to offline support
  81622. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  81623. */
  81624. export interface IOfflineProvider {
  81625. /**
  81626. * Gets a boolean indicating if scene must be saved in the database
  81627. */
  81628. enableSceneOffline: boolean;
  81629. /**
  81630. * Gets a boolean indicating if textures must be saved in the database
  81631. */
  81632. enableTexturesOffline: boolean;
  81633. /**
  81634. * Open the offline support and make it available
  81635. * @param successCallback defines the callback to call on success
  81636. * @param errorCallback defines the callback to call on error
  81637. */
  81638. open(successCallback: () => void, errorCallback: () => void): void;
  81639. /**
  81640. * Loads an image from the offline support
  81641. * @param url defines the url to load from
  81642. * @param image defines the target DOM image
  81643. */
  81644. loadImage(url: string, image: HTMLImageElement): void;
  81645. /**
  81646. * Loads a file from offline support
  81647. * @param url defines the URL to load from
  81648. * @param sceneLoaded defines a callback to call on success
  81649. * @param progressCallBack defines a callback to call when progress changed
  81650. * @param errorCallback defines a callback to call on error
  81651. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  81652. */
  81653. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  81654. }
  81655. }
  81656. declare module BABYLON {
  81657. /**
  81658. * Class used to help managing file picking and drag'n'drop
  81659. * File Storage
  81660. */
  81661. export class FilesInputStore {
  81662. /**
  81663. * List of files ready to be loaded
  81664. */
  81665. static FilesToLoad: {
  81666. [key: string]: File;
  81667. };
  81668. }
  81669. }
  81670. declare module BABYLON {
  81671. /**
  81672. * Class used to define a retry strategy when error happens while loading assets
  81673. */
  81674. export class RetryStrategy {
  81675. /**
  81676. * Function used to defines an exponential back off strategy
  81677. * @param maxRetries defines the maximum number of retries (3 by default)
  81678. * @param baseInterval defines the interval between retries
  81679. * @returns the strategy function to use
  81680. */
  81681. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  81682. }
  81683. }
  81684. declare module BABYLON {
  81685. /**
  81686. * @ignore
  81687. * Application error to support additional information when loading a file
  81688. */
  81689. export abstract class BaseError extends Error {
  81690. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  81691. }
  81692. }
  81693. declare module BABYLON {
  81694. /** @ignore */
  81695. export class LoadFileError extends BaseError {
  81696. request?: WebRequest;
  81697. file?: File;
  81698. /**
  81699. * Creates a new LoadFileError
  81700. * @param message defines the message of the error
  81701. * @param request defines the optional web request
  81702. * @param file defines the optional file
  81703. */
  81704. constructor(message: string, object?: WebRequest | File);
  81705. }
  81706. /** @ignore */
  81707. export class RequestFileError extends BaseError {
  81708. request: WebRequest;
  81709. /**
  81710. * Creates a new LoadFileError
  81711. * @param message defines the message of the error
  81712. * @param request defines the optional web request
  81713. */
  81714. constructor(message: string, request: WebRequest);
  81715. }
  81716. /** @ignore */
  81717. export class ReadFileError extends BaseError {
  81718. file: File;
  81719. /**
  81720. * Creates a new ReadFileError
  81721. * @param message defines the message of the error
  81722. * @param file defines the optional file
  81723. */
  81724. constructor(message: string, file: File);
  81725. }
  81726. /**
  81727. * @hidden
  81728. */
  81729. export class FileTools {
  81730. /**
  81731. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  81732. */
  81733. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  81734. /**
  81735. * Gets or sets the base URL to use to load assets
  81736. */
  81737. static BaseUrl: string;
  81738. /**
  81739. * Default behaviour for cors in the application.
  81740. * It can be a string if the expected behavior is identical in the entire app.
  81741. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  81742. */
  81743. static CorsBehavior: string | ((url: string | string[]) => string);
  81744. /**
  81745. * Gets or sets a function used to pre-process url before using them to load assets
  81746. */
  81747. static PreprocessUrl: (url: string) => string;
  81748. /**
  81749. * Removes unwanted characters from an url
  81750. * @param url defines the url to clean
  81751. * @returns the cleaned url
  81752. */
  81753. private static _CleanUrl;
  81754. /**
  81755. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  81756. * @param url define the url we are trying
  81757. * @param element define the dom element where to configure the cors policy
  81758. */
  81759. static SetCorsBehavior(url: string | string[], element: {
  81760. crossOrigin: string | null;
  81761. }): void;
  81762. /**
  81763. * Loads an image as an HTMLImageElement.
  81764. * @param input url string, ArrayBuffer, or Blob to load
  81765. * @param onLoad callback called when the image successfully loads
  81766. * @param onError callback called when the image fails to load
  81767. * @param offlineProvider offline provider for caching
  81768. * @param mimeType optional mime type
  81769. * @returns the HTMLImageElement of the loaded image
  81770. */
  81771. 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>;
  81772. /**
  81773. * Reads a file from a File object
  81774. * @param file defines the file to load
  81775. * @param onSuccess defines the callback to call when data is loaded
  81776. * @param onProgress defines the callback to call during loading process
  81777. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  81778. * @param onError defines the callback to call when an error occurs
  81779. * @returns a file request object
  81780. */
  81781. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  81782. /**
  81783. * Loads a file from a url
  81784. * @param url url to load
  81785. * @param onSuccess callback called when the file successfully loads
  81786. * @param onProgress callback called while file is loading (if the server supports this mode)
  81787. * @param offlineProvider defines the offline provider for caching
  81788. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81789. * @param onError callback called when the file fails to load
  81790. * @returns a file request object
  81791. */
  81792. 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;
  81793. /**
  81794. * Loads a file
  81795. * @param url url to load
  81796. * @param onSuccess callback called when the file successfully loads
  81797. * @param onProgress callback called while file is loading (if the server supports this mode)
  81798. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81799. * @param onError callback called when the file fails to load
  81800. * @param onOpened callback called when the web request is opened
  81801. * @returns a file request object
  81802. */
  81803. 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;
  81804. /**
  81805. * Checks if the loaded document was accessed via `file:`-Protocol.
  81806. * @returns boolean
  81807. */
  81808. static IsFileURL(): boolean;
  81809. }
  81810. }
  81811. declare module BABYLON {
  81812. /** @hidden */
  81813. export class ShaderProcessor {
  81814. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  81815. private static _ProcessPrecision;
  81816. private static _ExtractOperation;
  81817. private static _BuildSubExpression;
  81818. private static _BuildExpression;
  81819. private static _MoveCursorWithinIf;
  81820. private static _MoveCursor;
  81821. private static _EvaluatePreProcessors;
  81822. private static _PreparePreProcessors;
  81823. private static _ProcessShaderConversion;
  81824. private static _ProcessIncludes;
  81825. /**
  81826. * Loads a file from a url
  81827. * @param url url to load
  81828. * @param onSuccess callback called when the file successfully loads
  81829. * @param onProgress callback called while file is loading (if the server supports this mode)
  81830. * @param offlineProvider defines the offline provider for caching
  81831. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81832. * @param onError callback called when the file fails to load
  81833. * @returns a file request object
  81834. * @hidden
  81835. */
  81836. 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;
  81837. }
  81838. }
  81839. declare module BABYLON {
  81840. /**
  81841. * @hidden
  81842. */
  81843. export interface IColor4Like {
  81844. r: float;
  81845. g: float;
  81846. b: float;
  81847. a: float;
  81848. }
  81849. /**
  81850. * @hidden
  81851. */
  81852. export interface IColor3Like {
  81853. r: float;
  81854. g: float;
  81855. b: float;
  81856. }
  81857. /**
  81858. * @hidden
  81859. */
  81860. export interface IVector4Like {
  81861. x: float;
  81862. y: float;
  81863. z: float;
  81864. w: float;
  81865. }
  81866. /**
  81867. * @hidden
  81868. */
  81869. export interface IVector3Like {
  81870. x: float;
  81871. y: float;
  81872. z: float;
  81873. }
  81874. /**
  81875. * @hidden
  81876. */
  81877. export interface IVector2Like {
  81878. x: float;
  81879. y: float;
  81880. }
  81881. /**
  81882. * @hidden
  81883. */
  81884. export interface IMatrixLike {
  81885. toArray(): DeepImmutable<Float32Array | Array<number>>;
  81886. updateFlag: int;
  81887. }
  81888. /**
  81889. * @hidden
  81890. */
  81891. export interface IViewportLike {
  81892. x: float;
  81893. y: float;
  81894. width: float;
  81895. height: float;
  81896. }
  81897. /**
  81898. * @hidden
  81899. */
  81900. export interface IPlaneLike {
  81901. normal: IVector3Like;
  81902. d: float;
  81903. normalize(): void;
  81904. }
  81905. }
  81906. declare module BABYLON {
  81907. /**
  81908. * Interface used to define common properties for effect fallbacks
  81909. */
  81910. export interface IEffectFallbacks {
  81911. /**
  81912. * Removes the defines that should be removed when falling back.
  81913. * @param currentDefines defines the current define statements for the shader.
  81914. * @param effect defines the current effect we try to compile
  81915. * @returns The resulting defines with defines of the current rank removed.
  81916. */
  81917. reduce(currentDefines: string, effect: Effect): string;
  81918. /**
  81919. * Removes the fallback from the bound mesh.
  81920. */
  81921. unBindMesh(): void;
  81922. /**
  81923. * Checks to see if more fallbacks are still availible.
  81924. */
  81925. hasMoreFallbacks: boolean;
  81926. }
  81927. }
  81928. declare module BABYLON {
  81929. /**
  81930. * Class used to evalaute queries containing `and` and `or` operators
  81931. */
  81932. export class AndOrNotEvaluator {
  81933. /**
  81934. * Evaluate a query
  81935. * @param query defines the query to evaluate
  81936. * @param evaluateCallback defines the callback used to filter result
  81937. * @returns true if the query matches
  81938. */
  81939. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  81940. private static _HandleParenthesisContent;
  81941. private static _SimplifyNegation;
  81942. }
  81943. }
  81944. declare module BABYLON {
  81945. /**
  81946. * Class used to store custom tags
  81947. */
  81948. export class Tags {
  81949. /**
  81950. * Adds support for tags on the given object
  81951. * @param obj defines the object to use
  81952. */
  81953. static EnableFor(obj: any): void;
  81954. /**
  81955. * Removes tags support
  81956. * @param obj defines the object to use
  81957. */
  81958. static DisableFor(obj: any): void;
  81959. /**
  81960. * Gets a boolean indicating if the given object has tags
  81961. * @param obj defines the object to use
  81962. * @returns a boolean
  81963. */
  81964. static HasTags(obj: any): boolean;
  81965. /**
  81966. * Gets the tags available on a given object
  81967. * @param obj defines the object to use
  81968. * @param asString defines if the tags must be returned as a string instead of an array of strings
  81969. * @returns the tags
  81970. */
  81971. static GetTags(obj: any, asString?: boolean): any;
  81972. /**
  81973. * Adds tags to an object
  81974. * @param obj defines the object to use
  81975. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  81976. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  81977. */
  81978. static AddTagsTo(obj: any, tagsString: string): void;
  81979. /**
  81980. * @hidden
  81981. */
  81982. static _AddTagTo(obj: any, tag: string): void;
  81983. /**
  81984. * Removes specific tags from a specific object
  81985. * @param obj defines the object to use
  81986. * @param tagsString defines the tags to remove
  81987. */
  81988. static RemoveTagsFrom(obj: any, tagsString: string): void;
  81989. /**
  81990. * @hidden
  81991. */
  81992. static _RemoveTagFrom(obj: any, tag: string): void;
  81993. /**
  81994. * Defines if tags hosted on an object match a given query
  81995. * @param obj defines the object to use
  81996. * @param tagsQuery defines the tag query
  81997. * @returns a boolean
  81998. */
  81999. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  82000. }
  82001. }
  82002. declare module BABYLON {
  82003. /**
  82004. * Scalar computation library
  82005. */
  82006. export class Scalar {
  82007. /**
  82008. * Two pi constants convenient for computation.
  82009. */
  82010. static TwoPi: number;
  82011. /**
  82012. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82013. * @param a number
  82014. * @param b number
  82015. * @param epsilon (default = 1.401298E-45)
  82016. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82017. */
  82018. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  82019. /**
  82020. * Returns a string : the upper case translation of the number i to hexadecimal.
  82021. * @param i number
  82022. * @returns the upper case translation of the number i to hexadecimal.
  82023. */
  82024. static ToHex(i: number): string;
  82025. /**
  82026. * Returns -1 if value is negative and +1 is value is positive.
  82027. * @param value the value
  82028. * @returns the value itself if it's equal to zero.
  82029. */
  82030. static Sign(value: number): number;
  82031. /**
  82032. * Returns the value itself if it's between min and max.
  82033. * Returns min if the value is lower than min.
  82034. * Returns max if the value is greater than max.
  82035. * @param value the value to clmap
  82036. * @param min the min value to clamp to (default: 0)
  82037. * @param max the max value to clamp to (default: 1)
  82038. * @returns the clamped value
  82039. */
  82040. static Clamp(value: number, min?: number, max?: number): number;
  82041. /**
  82042. * the log2 of value.
  82043. * @param value the value to compute log2 of
  82044. * @returns the log2 of value.
  82045. */
  82046. static Log2(value: number): number;
  82047. /**
  82048. * Loops the value, so that it is never larger than length and never smaller than 0.
  82049. *
  82050. * This is similar to the modulo operator but it works with floating point numbers.
  82051. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82052. * With t = 5 and length = 2.5, the result would be 0.0.
  82053. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82054. * @param value the value
  82055. * @param length the length
  82056. * @returns the looped value
  82057. */
  82058. static Repeat(value: number, length: number): number;
  82059. /**
  82060. * Normalize the value between 0.0 and 1.0 using min and max values
  82061. * @param value value to normalize
  82062. * @param min max to normalize between
  82063. * @param max min to normalize between
  82064. * @returns the normalized value
  82065. */
  82066. static Normalize(value: number, min: number, max: number): number;
  82067. /**
  82068. * Denormalize the value from 0.0 and 1.0 using min and max values
  82069. * @param normalized value to denormalize
  82070. * @param min max to denormalize between
  82071. * @param max min to denormalize between
  82072. * @returns the denormalized value
  82073. */
  82074. static Denormalize(normalized: number, min: number, max: number): number;
  82075. /**
  82076. * Calculates the shortest difference between two given angles given in degrees.
  82077. * @param current current angle in degrees
  82078. * @param target target angle in degrees
  82079. * @returns the delta
  82080. */
  82081. static DeltaAngle(current: number, target: number): number;
  82082. /**
  82083. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82084. * @param tx value
  82085. * @param length length
  82086. * @returns The returned value will move back and forth between 0 and length
  82087. */
  82088. static PingPong(tx: number, length: number): number;
  82089. /**
  82090. * Interpolates between min and max with smoothing at the limits.
  82091. *
  82092. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82093. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82094. * @param from from
  82095. * @param to to
  82096. * @param tx value
  82097. * @returns the smooth stepped value
  82098. */
  82099. static SmoothStep(from: number, to: number, tx: number): number;
  82100. /**
  82101. * Moves a value current towards target.
  82102. *
  82103. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82104. * Negative values of maxDelta pushes the value away from target.
  82105. * @param current current value
  82106. * @param target target value
  82107. * @param maxDelta max distance to move
  82108. * @returns resulting value
  82109. */
  82110. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82111. /**
  82112. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82113. *
  82114. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82115. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82116. * @param current current value
  82117. * @param target target value
  82118. * @param maxDelta max distance to move
  82119. * @returns resulting angle
  82120. */
  82121. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82122. /**
  82123. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82124. * @param start start value
  82125. * @param end target value
  82126. * @param amount amount to lerp between
  82127. * @returns the lerped value
  82128. */
  82129. static Lerp(start: number, end: number, amount: number): number;
  82130. /**
  82131. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82132. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82133. * @param start start value
  82134. * @param end target value
  82135. * @param amount amount to lerp between
  82136. * @returns the lerped value
  82137. */
  82138. static LerpAngle(start: number, end: number, amount: number): number;
  82139. /**
  82140. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82141. * @param a start value
  82142. * @param b target value
  82143. * @param value value between a and b
  82144. * @returns the inverseLerp value
  82145. */
  82146. static InverseLerp(a: number, b: number, value: number): number;
  82147. /**
  82148. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82149. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82150. * @param value1 spline value
  82151. * @param tangent1 spline value
  82152. * @param value2 spline value
  82153. * @param tangent2 spline value
  82154. * @param amount input value
  82155. * @returns hermite result
  82156. */
  82157. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  82158. /**
  82159. * Returns a random float number between and min and max values
  82160. * @param min min value of random
  82161. * @param max max value of random
  82162. * @returns random value
  82163. */
  82164. static RandomRange(min: number, max: number): number;
  82165. /**
  82166. * This function returns percentage of a number in a given range.
  82167. *
  82168. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82169. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82170. * @param number to convert to percentage
  82171. * @param min min range
  82172. * @param max max range
  82173. * @returns the percentage
  82174. */
  82175. static RangeToPercent(number: number, min: number, max: number): number;
  82176. /**
  82177. * This function returns number that corresponds to the percentage in a given range.
  82178. *
  82179. * PercentToRange(0.34,0,100) will return 34.
  82180. * @param percent to convert to number
  82181. * @param min min range
  82182. * @param max max range
  82183. * @returns the number
  82184. */
  82185. static PercentToRange(percent: number, min: number, max: number): number;
  82186. /**
  82187. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  82188. * @param angle The angle to normalize in radian.
  82189. * @return The converted angle.
  82190. */
  82191. static NormalizeRadians(angle: number): number;
  82192. }
  82193. }
  82194. declare module BABYLON {
  82195. /**
  82196. * Constant used to convert a value to gamma space
  82197. * @ignorenaming
  82198. */
  82199. export const ToGammaSpace: number;
  82200. /**
  82201. * Constant used to convert a value to linear space
  82202. * @ignorenaming
  82203. */
  82204. export const ToLinearSpace = 2.2;
  82205. /**
  82206. * Constant used to define the minimal number value in Babylon.js
  82207. * @ignorenaming
  82208. */
  82209. let Epsilon: number;
  82210. }
  82211. declare module BABYLON {
  82212. /**
  82213. * Class used to represent a viewport on screen
  82214. */
  82215. export class Viewport {
  82216. /** viewport left coordinate */
  82217. x: number;
  82218. /** viewport top coordinate */
  82219. y: number;
  82220. /**viewport width */
  82221. width: number;
  82222. /** viewport height */
  82223. height: number;
  82224. /**
  82225. * Creates a Viewport object located at (x, y) and sized (width, height)
  82226. * @param x defines viewport left coordinate
  82227. * @param y defines viewport top coordinate
  82228. * @param width defines the viewport width
  82229. * @param height defines the viewport height
  82230. */
  82231. constructor(
  82232. /** viewport left coordinate */
  82233. x: number,
  82234. /** viewport top coordinate */
  82235. y: number,
  82236. /**viewport width */
  82237. width: number,
  82238. /** viewport height */
  82239. height: number);
  82240. /**
  82241. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  82242. * @param renderWidth defines the rendering width
  82243. * @param renderHeight defines the rendering height
  82244. * @returns a new Viewport
  82245. */
  82246. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  82247. /**
  82248. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  82249. * @param renderWidth defines the rendering width
  82250. * @param renderHeight defines the rendering height
  82251. * @param ref defines the target viewport
  82252. * @returns the current viewport
  82253. */
  82254. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  82255. /**
  82256. * Returns a new Viewport copied from the current one
  82257. * @returns a new Viewport
  82258. */
  82259. clone(): Viewport;
  82260. }
  82261. }
  82262. declare module BABYLON {
  82263. /**
  82264. * Class containing a set of static utilities functions for arrays.
  82265. */
  82266. export class ArrayTools {
  82267. /**
  82268. * Returns an array of the given size filled with element built from the given constructor and the paramters
  82269. * @param size the number of element to construct and put in the array
  82270. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  82271. * @returns a new array filled with new objects
  82272. */
  82273. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  82274. }
  82275. }
  82276. declare module BABYLON {
  82277. /**
  82278. * Represents a plane by the equation ax + by + cz + d = 0
  82279. */
  82280. export class Plane {
  82281. private static _TmpMatrix;
  82282. /**
  82283. * Normal of the plane (a,b,c)
  82284. */
  82285. normal: Vector3;
  82286. /**
  82287. * d component of the plane
  82288. */
  82289. d: number;
  82290. /**
  82291. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  82292. * @param a a component of the plane
  82293. * @param b b component of the plane
  82294. * @param c c component of the plane
  82295. * @param d d component of the plane
  82296. */
  82297. constructor(a: number, b: number, c: number, d: number);
  82298. /**
  82299. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  82300. */
  82301. asArray(): number[];
  82302. /**
  82303. * @returns a new plane copied from the current Plane.
  82304. */
  82305. clone(): Plane;
  82306. /**
  82307. * @returns the string "Plane".
  82308. */
  82309. getClassName(): string;
  82310. /**
  82311. * @returns the Plane hash code.
  82312. */
  82313. getHashCode(): number;
  82314. /**
  82315. * Normalize the current Plane in place.
  82316. * @returns the updated Plane.
  82317. */
  82318. normalize(): Plane;
  82319. /**
  82320. * Applies a transformation the plane and returns the result
  82321. * @param transformation the transformation matrix to be applied to the plane
  82322. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  82323. */
  82324. transform(transformation: DeepImmutable<Matrix>): Plane;
  82325. /**
  82326. * Compute the dot product between the point and the plane normal
  82327. * @param point point to calculate the dot product with
  82328. * @returns the dot product (float) of the point coordinates and the plane normal.
  82329. */
  82330. dotCoordinate(point: DeepImmutable<Vector3>): number;
  82331. /**
  82332. * Updates the current Plane from the plane defined by the three given points.
  82333. * @param point1 one of the points used to contruct the plane
  82334. * @param point2 one of the points used to contruct the plane
  82335. * @param point3 one of the points used to contruct the plane
  82336. * @returns the updated Plane.
  82337. */
  82338. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82339. /**
  82340. * Checks if the plane is facing a given direction
  82341. * @param direction the direction to check if the plane is facing
  82342. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  82343. * @returns True is the vector "direction" is the same side than the plane normal.
  82344. */
  82345. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  82346. /**
  82347. * Calculates the distance to a point
  82348. * @param point point to calculate distance to
  82349. * @returns the signed distance (float) from the given point to the Plane.
  82350. */
  82351. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  82352. /**
  82353. * Creates a plane from an array
  82354. * @param array the array to create a plane from
  82355. * @returns a new Plane from the given array.
  82356. */
  82357. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  82358. /**
  82359. * Creates a plane from three points
  82360. * @param point1 point used to create the plane
  82361. * @param point2 point used to create the plane
  82362. * @param point3 point used to create the plane
  82363. * @returns a new Plane defined by the three given points.
  82364. */
  82365. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82366. /**
  82367. * Creates a plane from an origin point and a normal
  82368. * @param origin origin of the plane to be constructed
  82369. * @param normal normal of the plane to be constructed
  82370. * @returns a new Plane the normal vector to this plane at the given origin point.
  82371. * Note : the vector "normal" is updated because normalized.
  82372. */
  82373. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  82374. /**
  82375. * Calculates the distance from a plane and a point
  82376. * @param origin origin of the plane to be constructed
  82377. * @param normal normal of the plane to be constructed
  82378. * @param point point to calculate distance to
  82379. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  82380. */
  82381. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  82382. }
  82383. }
  82384. declare module BABYLON {
  82385. /** @hidden */
  82386. export class PerformanceConfigurator {
  82387. /** @hidden */
  82388. static MatrixUse64Bits: boolean;
  82389. /** @hidden */
  82390. static MatrixTrackPrecisionChange: boolean;
  82391. /** @hidden */
  82392. static MatrixCurrentType: any;
  82393. /** @hidden */
  82394. static MatrixTrackedMatrices: Array<any> | null;
  82395. /** @hidden */
  82396. static SetMatrixPrecision(use64bits: boolean): void;
  82397. }
  82398. }
  82399. declare module BABYLON {
  82400. /**
  82401. * Class representing a vector containing 2 coordinates
  82402. */
  82403. export class Vector2 {
  82404. /** defines the first coordinate */
  82405. x: number;
  82406. /** defines the second coordinate */
  82407. y: number;
  82408. /**
  82409. * Creates a new Vector2 from the given x and y coordinates
  82410. * @param x defines the first coordinate
  82411. * @param y defines the second coordinate
  82412. */
  82413. constructor(
  82414. /** defines the first coordinate */
  82415. x?: number,
  82416. /** defines the second coordinate */
  82417. y?: number);
  82418. /**
  82419. * Gets a string with the Vector2 coordinates
  82420. * @returns a string with the Vector2 coordinates
  82421. */
  82422. toString(): string;
  82423. /**
  82424. * Gets class name
  82425. * @returns the string "Vector2"
  82426. */
  82427. getClassName(): string;
  82428. /**
  82429. * Gets current vector hash code
  82430. * @returns the Vector2 hash code as a number
  82431. */
  82432. getHashCode(): number;
  82433. /**
  82434. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  82435. * @param array defines the source array
  82436. * @param index defines the offset in source array
  82437. * @returns the current Vector2
  82438. */
  82439. toArray(array: FloatArray, index?: number): Vector2;
  82440. /**
  82441. * Update the current vector from an array
  82442. * @param array defines the destination array
  82443. * @param index defines the offset in the destination array
  82444. * @returns the current Vector3
  82445. */
  82446. fromArray(array: FloatArray, index?: number): Vector2;
  82447. /**
  82448. * Copy the current vector to an array
  82449. * @returns a new array with 2 elements: the Vector2 coordinates.
  82450. */
  82451. asArray(): number[];
  82452. /**
  82453. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82454. * @param source defines the source Vector2
  82455. * @returns the current updated Vector2
  82456. */
  82457. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82458. /**
  82459. * Sets the Vector2 coordinates with the given floats
  82460. * @param x defines the first coordinate
  82461. * @param y defines the second coordinate
  82462. * @returns the current updated Vector2
  82463. */
  82464. copyFromFloats(x: number, y: number): Vector2;
  82465. /**
  82466. * Sets the Vector2 coordinates with the given floats
  82467. * @param x defines the first coordinate
  82468. * @param y defines the second coordinate
  82469. * @returns the current updated Vector2
  82470. */
  82471. set(x: number, y: number): Vector2;
  82472. /**
  82473. * Add another vector with the current one
  82474. * @param otherVector defines the other vector
  82475. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82476. */
  82477. add(otherVector: DeepImmutable<Vector2>): Vector2;
  82478. /**
  82479. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82480. * @param otherVector defines the other vector
  82481. * @param result defines the target vector
  82482. * @returns the unmodified current Vector2
  82483. */
  82484. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82485. /**
  82486. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82487. * @param otherVector defines the other vector
  82488. * @returns the current updated Vector2
  82489. */
  82490. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82491. /**
  82492. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82493. * @param otherVector defines the other vector
  82494. * @returns a new Vector2
  82495. */
  82496. addVector3(otherVector: Vector3): Vector2;
  82497. /**
  82498. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82499. * @param otherVector defines the other vector
  82500. * @returns a new Vector2
  82501. */
  82502. subtract(otherVector: Vector2): Vector2;
  82503. /**
  82504. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82505. * @param otherVector defines the other vector
  82506. * @param result defines the target vector
  82507. * @returns the unmodified current Vector2
  82508. */
  82509. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82510. /**
  82511. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82512. * @param otherVector defines the other vector
  82513. * @returns the current updated Vector2
  82514. */
  82515. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82516. /**
  82517. * Multiplies in place the current Vector2 coordinates by the given ones
  82518. * @param otherVector defines the other vector
  82519. * @returns the current updated Vector2
  82520. */
  82521. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82522. /**
  82523. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82524. * @param otherVector defines the other vector
  82525. * @returns a new Vector2
  82526. */
  82527. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  82528. /**
  82529. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  82530. * @param otherVector defines the other vector
  82531. * @param result defines the target vector
  82532. * @returns the unmodified current Vector2
  82533. */
  82534. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82535. /**
  82536. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  82537. * @param x defines the first coordinate
  82538. * @param y defines the second coordinate
  82539. * @returns a new Vector2
  82540. */
  82541. multiplyByFloats(x: number, y: number): Vector2;
  82542. /**
  82543. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  82544. * @param otherVector defines the other vector
  82545. * @returns a new Vector2
  82546. */
  82547. divide(otherVector: Vector2): Vector2;
  82548. /**
  82549. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  82550. * @param otherVector defines the other vector
  82551. * @param result defines the target vector
  82552. * @returns the unmodified current Vector2
  82553. */
  82554. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82555. /**
  82556. * Divides the current Vector2 coordinates by the given ones
  82557. * @param otherVector defines the other vector
  82558. * @returns the current updated Vector2
  82559. */
  82560. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82561. /**
  82562. * Gets a new Vector2 with current Vector2 negated coordinates
  82563. * @returns a new Vector2
  82564. */
  82565. negate(): Vector2;
  82566. /**
  82567. * Negate this vector in place
  82568. * @returns this
  82569. */
  82570. negateInPlace(): Vector2;
  82571. /**
  82572. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  82573. * @param result defines the Vector3 object where to store the result
  82574. * @returns the current Vector2
  82575. */
  82576. negateToRef(result: Vector2): Vector2;
  82577. /**
  82578. * Multiply the Vector2 coordinates by scale
  82579. * @param scale defines the scaling factor
  82580. * @returns the current updated Vector2
  82581. */
  82582. scaleInPlace(scale: number): Vector2;
  82583. /**
  82584. * Returns a new Vector2 scaled by "scale" from the current Vector2
  82585. * @param scale defines the scaling factor
  82586. * @returns a new Vector2
  82587. */
  82588. scale(scale: number): Vector2;
  82589. /**
  82590. * Scale the current Vector2 values by a factor to a given Vector2
  82591. * @param scale defines the scale factor
  82592. * @param result defines the Vector2 object where to store the result
  82593. * @returns the unmodified current Vector2
  82594. */
  82595. scaleToRef(scale: number, result: Vector2): Vector2;
  82596. /**
  82597. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  82598. * @param scale defines the scale factor
  82599. * @param result defines the Vector2 object where to store the result
  82600. * @returns the unmodified current Vector2
  82601. */
  82602. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  82603. /**
  82604. * Gets a boolean if two vectors are equals
  82605. * @param otherVector defines the other vector
  82606. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  82607. */
  82608. equals(otherVector: DeepImmutable<Vector2>): boolean;
  82609. /**
  82610. * Gets a boolean if two vectors are equals (using an epsilon value)
  82611. * @param otherVector defines the other vector
  82612. * @param epsilon defines the minimal distance to consider equality
  82613. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  82614. */
  82615. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  82616. /**
  82617. * Gets a new Vector2 from current Vector2 floored values
  82618. * @returns a new Vector2
  82619. */
  82620. floor(): Vector2;
  82621. /**
  82622. * Gets a new Vector2 from current Vector2 floored values
  82623. * @returns a new Vector2
  82624. */
  82625. fract(): Vector2;
  82626. /**
  82627. * Gets the length of the vector
  82628. * @returns the vector length (float)
  82629. */
  82630. length(): number;
  82631. /**
  82632. * Gets the vector squared length
  82633. * @returns the vector squared length (float)
  82634. */
  82635. lengthSquared(): number;
  82636. /**
  82637. * Normalize the vector
  82638. * @returns the current updated Vector2
  82639. */
  82640. normalize(): Vector2;
  82641. /**
  82642. * Gets a new Vector2 copied from the Vector2
  82643. * @returns a new Vector2
  82644. */
  82645. clone(): Vector2;
  82646. /**
  82647. * Gets a new Vector2(0, 0)
  82648. * @returns a new Vector2
  82649. */
  82650. static Zero(): Vector2;
  82651. /**
  82652. * Gets a new Vector2(1, 1)
  82653. * @returns a new Vector2
  82654. */
  82655. static One(): Vector2;
  82656. /**
  82657. * Gets a new Vector2 set from the given index element of the given array
  82658. * @param array defines the data source
  82659. * @param offset defines the offset in the data source
  82660. * @returns a new Vector2
  82661. */
  82662. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  82663. /**
  82664. * Sets "result" from the given index element of the given array
  82665. * @param array defines the data source
  82666. * @param offset defines the offset in the data source
  82667. * @param result defines the target vector
  82668. */
  82669. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  82670. /**
  82671. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  82672. * @param value1 defines 1st point of control
  82673. * @param value2 defines 2nd point of control
  82674. * @param value3 defines 3rd point of control
  82675. * @param value4 defines 4th point of control
  82676. * @param amount defines the interpolation factor
  82677. * @returns a new Vector2
  82678. */
  82679. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  82680. /**
  82681. * 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".
  82682. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  82683. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  82684. * @param value defines the value to clamp
  82685. * @param min defines the lower limit
  82686. * @param max defines the upper limit
  82687. * @returns a new Vector2
  82688. */
  82689. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  82690. /**
  82691. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  82692. * @param value1 defines the 1st control point
  82693. * @param tangent1 defines the outgoing tangent
  82694. * @param value2 defines the 2nd control point
  82695. * @param tangent2 defines the incoming tangent
  82696. * @param amount defines the interpolation factor
  82697. * @returns a new Vector2
  82698. */
  82699. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  82700. /**
  82701. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  82702. * @param start defines the start vector
  82703. * @param end defines the end vector
  82704. * @param amount defines the interpolation factor
  82705. * @returns a new Vector2
  82706. */
  82707. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  82708. /**
  82709. * Gets the dot product of the vector "left" and the vector "right"
  82710. * @param left defines first vector
  82711. * @param right defines second vector
  82712. * @returns the dot product (float)
  82713. */
  82714. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  82715. /**
  82716. * Returns a new Vector2 equal to the normalized given vector
  82717. * @param vector defines the vector to normalize
  82718. * @returns a new Vector2
  82719. */
  82720. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  82721. /**
  82722. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  82723. * @param left defines 1st vector
  82724. * @param right defines 2nd vector
  82725. * @returns a new Vector2
  82726. */
  82727. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82728. /**
  82729. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  82730. * @param left defines 1st vector
  82731. * @param right defines 2nd vector
  82732. * @returns a new Vector2
  82733. */
  82734. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82735. /**
  82736. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  82737. * @param vector defines the vector to transform
  82738. * @param transformation defines the matrix to apply
  82739. * @returns a new Vector2
  82740. */
  82741. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  82742. /**
  82743. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  82744. * @param vector defines the vector to transform
  82745. * @param transformation defines the matrix to apply
  82746. * @param result defines the target vector
  82747. */
  82748. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  82749. /**
  82750. * Determines if a given vector is included in a triangle
  82751. * @param p defines the vector to test
  82752. * @param p0 defines 1st triangle point
  82753. * @param p1 defines 2nd triangle point
  82754. * @param p2 defines 3rd triangle point
  82755. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  82756. */
  82757. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  82758. /**
  82759. * Gets the distance between the vectors "value1" and "value2"
  82760. * @param value1 defines first vector
  82761. * @param value2 defines second vector
  82762. * @returns the distance between vectors
  82763. */
  82764. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82765. /**
  82766. * Returns the squared distance between the vectors "value1" and "value2"
  82767. * @param value1 defines first vector
  82768. * @param value2 defines second vector
  82769. * @returns the squared distance between vectors
  82770. */
  82771. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82772. /**
  82773. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  82774. * @param value1 defines first vector
  82775. * @param value2 defines second vector
  82776. * @returns a new Vector2
  82777. */
  82778. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  82779. /**
  82780. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  82781. * @param p defines the middle point
  82782. * @param segA defines one point of the segment
  82783. * @param segB defines the other point of the segment
  82784. * @returns the shortest distance
  82785. */
  82786. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  82787. }
  82788. /**
  82789. * Class used to store (x,y,z) vector representation
  82790. * A Vector3 is the main object used in 3D geometry
  82791. * It can represent etiher the coordinates of a point the space, either a direction
  82792. * Reminder: js uses a left handed forward facing system
  82793. */
  82794. export class Vector3 {
  82795. private static _UpReadOnly;
  82796. private static _ZeroReadOnly;
  82797. /** @hidden */
  82798. _x: number;
  82799. /** @hidden */
  82800. _y: number;
  82801. /** @hidden */
  82802. _z: number;
  82803. /** @hidden */
  82804. _isDirty: boolean;
  82805. /** Gets or sets the x coordinate */
  82806. get x(): number;
  82807. set x(value: number);
  82808. /** Gets or sets the y coordinate */
  82809. get y(): number;
  82810. set y(value: number);
  82811. /** Gets or sets the z coordinate */
  82812. get z(): number;
  82813. set z(value: number);
  82814. /**
  82815. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  82816. * @param x defines the first coordinates (on X axis)
  82817. * @param y defines the second coordinates (on Y axis)
  82818. * @param z defines the third coordinates (on Z axis)
  82819. */
  82820. constructor(x?: number, y?: number, z?: number);
  82821. /**
  82822. * Creates a string representation of the Vector3
  82823. * @returns a string with the Vector3 coordinates.
  82824. */
  82825. toString(): string;
  82826. /**
  82827. * Gets the class name
  82828. * @returns the string "Vector3"
  82829. */
  82830. getClassName(): string;
  82831. /**
  82832. * Creates the Vector3 hash code
  82833. * @returns a number which tends to be unique between Vector3 instances
  82834. */
  82835. getHashCode(): number;
  82836. /**
  82837. * Creates an array containing three elements : the coordinates of the Vector3
  82838. * @returns a new array of numbers
  82839. */
  82840. asArray(): number[];
  82841. /**
  82842. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  82843. * @param array defines the destination array
  82844. * @param index defines the offset in the destination array
  82845. * @returns the current Vector3
  82846. */
  82847. toArray(array: FloatArray, index?: number): Vector3;
  82848. /**
  82849. * Update the current vector from an array
  82850. * @param array defines the destination array
  82851. * @param index defines the offset in the destination array
  82852. * @returns the current Vector3
  82853. */
  82854. fromArray(array: FloatArray, index?: number): Vector3;
  82855. /**
  82856. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  82857. * @returns a new Quaternion object, computed from the Vector3 coordinates
  82858. */
  82859. toQuaternion(): Quaternion;
  82860. /**
  82861. * Adds the given vector to the current Vector3
  82862. * @param otherVector defines the second operand
  82863. * @returns the current updated Vector3
  82864. */
  82865. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82866. /**
  82867. * Adds the given coordinates to the current Vector3
  82868. * @param x defines the x coordinate of the operand
  82869. * @param y defines the y coordinate of the operand
  82870. * @param z defines the z coordinate of the operand
  82871. * @returns the current updated Vector3
  82872. */
  82873. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82874. /**
  82875. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  82876. * @param otherVector defines the second operand
  82877. * @returns the resulting Vector3
  82878. */
  82879. add(otherVector: DeepImmutable<Vector3>): Vector3;
  82880. /**
  82881. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  82882. * @param otherVector defines the second operand
  82883. * @param result defines the Vector3 object where to store the result
  82884. * @returns the current Vector3
  82885. */
  82886. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82887. /**
  82888. * Subtract the given vector from the current Vector3
  82889. * @param otherVector defines the second operand
  82890. * @returns the current updated Vector3
  82891. */
  82892. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82893. /**
  82894. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  82895. * @param otherVector defines the second operand
  82896. * @returns the resulting Vector3
  82897. */
  82898. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  82899. /**
  82900. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  82901. * @param otherVector defines the second operand
  82902. * @param result defines the Vector3 object where to store the result
  82903. * @returns the current Vector3
  82904. */
  82905. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82906. /**
  82907. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  82908. * @param x defines the x coordinate of the operand
  82909. * @param y defines the y coordinate of the operand
  82910. * @param z defines the z coordinate of the operand
  82911. * @returns the resulting Vector3
  82912. */
  82913. subtractFromFloats(x: number, y: number, z: number): Vector3;
  82914. /**
  82915. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  82916. * @param x defines the x coordinate of the operand
  82917. * @param y defines the y coordinate of the operand
  82918. * @param z defines the z coordinate of the operand
  82919. * @param result defines the Vector3 object where to store the result
  82920. * @returns the current Vector3
  82921. */
  82922. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  82923. /**
  82924. * Gets a new Vector3 set with the current Vector3 negated coordinates
  82925. * @returns a new Vector3
  82926. */
  82927. negate(): Vector3;
  82928. /**
  82929. * Negate this vector in place
  82930. * @returns this
  82931. */
  82932. negateInPlace(): Vector3;
  82933. /**
  82934. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  82935. * @param result defines the Vector3 object where to store the result
  82936. * @returns the current Vector3
  82937. */
  82938. negateToRef(result: Vector3): Vector3;
  82939. /**
  82940. * Multiplies the Vector3 coordinates by the float "scale"
  82941. * @param scale defines the multiplier factor
  82942. * @returns the current updated Vector3
  82943. */
  82944. scaleInPlace(scale: number): Vector3;
  82945. /**
  82946. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  82947. * @param scale defines the multiplier factor
  82948. * @returns a new Vector3
  82949. */
  82950. scale(scale: number): Vector3;
  82951. /**
  82952. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  82953. * @param scale defines the multiplier factor
  82954. * @param result defines the Vector3 object where to store the result
  82955. * @returns the current Vector3
  82956. */
  82957. scaleToRef(scale: number, result: Vector3): Vector3;
  82958. /**
  82959. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  82960. * @param scale defines the scale factor
  82961. * @param result defines the Vector3 object where to store the result
  82962. * @returns the unmodified current Vector3
  82963. */
  82964. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  82965. /**
  82966. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82967. * @param origin defines the origin of the projection ray
  82968. * @param plane defines the plane to project to
  82969. * @returns the projected vector3
  82970. */
  82971. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  82972. /**
  82973. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82974. * @param origin defines the origin of the projection ray
  82975. * @param plane defines the plane to project to
  82976. * @param result defines the Vector3 where to store the result
  82977. */
  82978. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  82979. /**
  82980. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  82981. * @param otherVector defines the second operand
  82982. * @returns true if both vectors are equals
  82983. */
  82984. equals(otherVector: DeepImmutable<Vector3>): boolean;
  82985. /**
  82986. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  82987. * @param otherVector defines the second operand
  82988. * @param epsilon defines the minimal distance to define values as equals
  82989. * @returns true if both vectors are distant less than epsilon
  82990. */
  82991. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  82992. /**
  82993. * Returns true if the current Vector3 coordinates equals the given floats
  82994. * @param x defines the x coordinate of the operand
  82995. * @param y defines the y coordinate of the operand
  82996. * @param z defines the z coordinate of the operand
  82997. * @returns true if both vectors are equals
  82998. */
  82999. equalsToFloats(x: number, y: number, z: number): boolean;
  83000. /**
  83001. * Multiplies the current Vector3 coordinates by the given ones
  83002. * @param otherVector defines the second operand
  83003. * @returns the current updated Vector3
  83004. */
  83005. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83006. /**
  83007. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  83008. * @param otherVector defines the second operand
  83009. * @returns the new Vector3
  83010. */
  83011. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  83012. /**
  83013. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  83014. * @param otherVector defines the second operand
  83015. * @param result defines the Vector3 object where to store the result
  83016. * @returns the current Vector3
  83017. */
  83018. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83019. /**
  83020. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  83021. * @param x defines the x coordinate of the operand
  83022. * @param y defines the y coordinate of the operand
  83023. * @param z defines the z coordinate of the operand
  83024. * @returns the new Vector3
  83025. */
  83026. multiplyByFloats(x: number, y: number, z: number): Vector3;
  83027. /**
  83028. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  83029. * @param otherVector defines the second operand
  83030. * @returns the new Vector3
  83031. */
  83032. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  83033. /**
  83034. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  83035. * @param otherVector defines the second operand
  83036. * @param result defines the Vector3 object where to store the result
  83037. * @returns the current Vector3
  83038. */
  83039. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83040. /**
  83041. * Divides the current Vector3 coordinates by the given ones.
  83042. * @param otherVector defines the second operand
  83043. * @returns the current updated Vector3
  83044. */
  83045. divideInPlace(otherVector: Vector3): Vector3;
  83046. /**
  83047. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83048. * @param other defines the second operand
  83049. * @returns the current updated Vector3
  83050. */
  83051. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83052. /**
  83053. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83054. * @param other defines the second operand
  83055. * @returns the current updated Vector3
  83056. */
  83057. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83058. /**
  83059. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83060. * @param x defines the x coordinate of the operand
  83061. * @param y defines the y coordinate of the operand
  83062. * @param z defines the z coordinate of the operand
  83063. * @returns the current updated Vector3
  83064. */
  83065. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83066. /**
  83067. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83068. * @param x defines the x coordinate of the operand
  83069. * @param y defines the y coordinate of the operand
  83070. * @param z defines the z coordinate of the operand
  83071. * @returns the current updated Vector3
  83072. */
  83073. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83074. /**
  83075. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83076. * Check if is non uniform within a certain amount of decimal places to account for this
  83077. * @param epsilon the amount the values can differ
  83078. * @returns if the the vector is non uniform to a certain number of decimal places
  83079. */
  83080. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83081. /**
  83082. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83083. */
  83084. get isNonUniform(): boolean;
  83085. /**
  83086. * Gets a new Vector3 from current Vector3 floored values
  83087. * @returns a new Vector3
  83088. */
  83089. floor(): Vector3;
  83090. /**
  83091. * Gets a new Vector3 from current Vector3 floored values
  83092. * @returns a new Vector3
  83093. */
  83094. fract(): Vector3;
  83095. /**
  83096. * Gets the length of the Vector3
  83097. * @returns the length of the Vector3
  83098. */
  83099. length(): number;
  83100. /**
  83101. * Gets the squared length of the Vector3
  83102. * @returns squared length of the Vector3
  83103. */
  83104. lengthSquared(): number;
  83105. /**
  83106. * Normalize the current Vector3.
  83107. * Please note that this is an in place operation.
  83108. * @returns the current updated Vector3
  83109. */
  83110. normalize(): Vector3;
  83111. /**
  83112. * Reorders the x y z properties of the vector in place
  83113. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83114. * @returns the current updated vector
  83115. */
  83116. reorderInPlace(order: string): this;
  83117. /**
  83118. * Rotates the vector around 0,0,0 by a quaternion
  83119. * @param quaternion the rotation quaternion
  83120. * @param result vector to store the result
  83121. * @returns the resulting vector
  83122. */
  83123. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83124. /**
  83125. * Rotates a vector around a given point
  83126. * @param quaternion the rotation quaternion
  83127. * @param point the point to rotate around
  83128. * @param result vector to store the result
  83129. * @returns the resulting vector
  83130. */
  83131. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83132. /**
  83133. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83134. * The cross product is then orthogonal to both current and "other"
  83135. * @param other defines the right operand
  83136. * @returns the cross product
  83137. */
  83138. cross(other: Vector3): Vector3;
  83139. /**
  83140. * Normalize the current Vector3 with the given input length.
  83141. * Please note that this is an in place operation.
  83142. * @param len the length of the vector
  83143. * @returns the current updated Vector3
  83144. */
  83145. normalizeFromLength(len: number): Vector3;
  83146. /**
  83147. * Normalize the current Vector3 to a new vector
  83148. * @returns the new Vector3
  83149. */
  83150. normalizeToNew(): Vector3;
  83151. /**
  83152. * Normalize the current Vector3 to the reference
  83153. * @param reference define the Vector3 to update
  83154. * @returns the updated Vector3
  83155. */
  83156. normalizeToRef(reference: Vector3): Vector3;
  83157. /**
  83158. * Creates a new Vector3 copied from the current Vector3
  83159. * @returns the new Vector3
  83160. */
  83161. clone(): Vector3;
  83162. /**
  83163. * Copies the given vector coordinates to the current Vector3 ones
  83164. * @param source defines the source Vector3
  83165. * @returns the current updated Vector3
  83166. */
  83167. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  83168. /**
  83169. * Copies the given floats to the current Vector3 coordinates
  83170. * @param x defines the x coordinate of the operand
  83171. * @param y defines the y coordinate of the operand
  83172. * @param z defines the z coordinate of the operand
  83173. * @returns the current updated Vector3
  83174. */
  83175. copyFromFloats(x: number, y: number, z: number): Vector3;
  83176. /**
  83177. * Copies the given floats to the current Vector3 coordinates
  83178. * @param x defines the x coordinate of the operand
  83179. * @param y defines the y coordinate of the operand
  83180. * @param z defines the z coordinate of the operand
  83181. * @returns the current updated Vector3
  83182. */
  83183. set(x: number, y: number, z: number): Vector3;
  83184. /**
  83185. * Copies the given float to the current Vector3 coordinates
  83186. * @param v defines the x, y and z coordinates of the operand
  83187. * @returns the current updated Vector3
  83188. */
  83189. setAll(v: number): Vector3;
  83190. /**
  83191. * Get the clip factor between two vectors
  83192. * @param vector0 defines the first operand
  83193. * @param vector1 defines the second operand
  83194. * @param axis defines the axis to use
  83195. * @param size defines the size along the axis
  83196. * @returns the clip factor
  83197. */
  83198. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  83199. /**
  83200. * Get angle between two vectors
  83201. * @param vector0 angle between vector0 and vector1
  83202. * @param vector1 angle between vector0 and vector1
  83203. * @param normal direction of the normal
  83204. * @return the angle between vector0 and vector1
  83205. */
  83206. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  83207. /**
  83208. * Returns a new Vector3 set from the index "offset" of the given array
  83209. * @param array defines the source array
  83210. * @param offset defines the offset in the source array
  83211. * @returns the new Vector3
  83212. */
  83213. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  83214. /**
  83215. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  83216. * @param array defines the source array
  83217. * @param offset defines the offset in the source array
  83218. * @returns the new Vector3
  83219. * @deprecated Please use FromArray instead.
  83220. */
  83221. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  83222. /**
  83223. * Sets the given vector "result" with the element values from the index "offset" of the given array
  83224. * @param array defines the source array
  83225. * @param offset defines the offset in the source array
  83226. * @param result defines the Vector3 where to store the result
  83227. */
  83228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  83229. /**
  83230. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  83231. * @param array defines the source array
  83232. * @param offset defines the offset in the source array
  83233. * @param result defines the Vector3 where to store the result
  83234. * @deprecated Please use FromArrayToRef instead.
  83235. */
  83236. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  83237. /**
  83238. * Sets the given vector "result" with the given floats.
  83239. * @param x defines the x coordinate of the source
  83240. * @param y defines the y coordinate of the source
  83241. * @param z defines the z coordinate of the source
  83242. * @param result defines the Vector3 where to store the result
  83243. */
  83244. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  83245. /**
  83246. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  83247. * @returns a new empty Vector3
  83248. */
  83249. static Zero(): Vector3;
  83250. /**
  83251. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  83252. * @returns a new unit Vector3
  83253. */
  83254. static One(): Vector3;
  83255. /**
  83256. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  83257. * @returns a new up Vector3
  83258. */
  83259. static Up(): Vector3;
  83260. /**
  83261. * Gets a up Vector3 that must not be updated
  83262. */
  83263. static get UpReadOnly(): DeepImmutable<Vector3>;
  83264. /**
  83265. * Gets a zero Vector3 that must not be updated
  83266. */
  83267. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  83268. /**
  83269. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  83270. * @returns a new down Vector3
  83271. */
  83272. static Down(): Vector3;
  83273. /**
  83274. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  83275. * @param rightHandedSystem is the scene right-handed (negative z)
  83276. * @returns a new forward Vector3
  83277. */
  83278. static Forward(rightHandedSystem?: boolean): Vector3;
  83279. /**
  83280. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  83281. * @param rightHandedSystem is the scene right-handed (negative-z)
  83282. * @returns a new forward Vector3
  83283. */
  83284. static Backward(rightHandedSystem?: boolean): Vector3;
  83285. /**
  83286. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  83287. * @returns a new right Vector3
  83288. */
  83289. static Right(): Vector3;
  83290. /**
  83291. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  83292. * @returns a new left Vector3
  83293. */
  83294. static Left(): Vector3;
  83295. /**
  83296. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  83297. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83298. * @param vector defines the Vector3 to transform
  83299. * @param transformation defines the transformation matrix
  83300. * @returns the transformed Vector3
  83301. */
  83302. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83303. /**
  83304. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  83305. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83306. * @param vector defines the Vector3 to transform
  83307. * @param transformation defines the transformation matrix
  83308. * @param result defines the Vector3 where to store the result
  83309. */
  83310. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83311. /**
  83312. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  83313. * This method computes tranformed coordinates only, not transformed direction vectors
  83314. * @param x define the x coordinate of the source vector
  83315. * @param y define the y coordinate of the source vector
  83316. * @param z define the z coordinate of the source vector
  83317. * @param transformation defines the transformation matrix
  83318. * @param result defines the Vector3 where to store the result
  83319. */
  83320. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83321. /**
  83322. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  83323. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83324. * @param vector defines the Vector3 to transform
  83325. * @param transformation defines the transformation matrix
  83326. * @returns the new Vector3
  83327. */
  83328. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83329. /**
  83330. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  83331. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83332. * @param vector defines the Vector3 to transform
  83333. * @param transformation defines the transformation matrix
  83334. * @param result defines the Vector3 where to store the result
  83335. */
  83336. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83337. /**
  83338. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  83339. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83340. * @param x define the x coordinate of the source vector
  83341. * @param y define the y coordinate of the source vector
  83342. * @param z define the z coordinate of the source vector
  83343. * @param transformation defines the transformation matrix
  83344. * @param result defines the Vector3 where to store the result
  83345. */
  83346. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83347. /**
  83348. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  83349. * @param value1 defines the first control point
  83350. * @param value2 defines the second control point
  83351. * @param value3 defines the third control point
  83352. * @param value4 defines the fourth control point
  83353. * @param amount defines the amount on the spline to use
  83354. * @returns the new Vector3
  83355. */
  83356. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  83357. /**
  83358. * 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"
  83359. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83360. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83361. * @param value defines the current value
  83362. * @param min defines the lower range value
  83363. * @param max defines the upper range value
  83364. * @returns the new Vector3
  83365. */
  83366. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  83367. /**
  83368. * 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"
  83369. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83370. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83371. * @param value defines the current value
  83372. * @param min defines the lower range value
  83373. * @param max defines the upper range value
  83374. * @param result defines the Vector3 where to store the result
  83375. */
  83376. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  83377. /**
  83378. * Checks if a given vector is inside a specific range
  83379. * @param v defines the vector to test
  83380. * @param min defines the minimum range
  83381. * @param max defines the maximum range
  83382. */
  83383. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  83384. /**
  83385. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  83386. * @param value1 defines the first control point
  83387. * @param tangent1 defines the first tangent vector
  83388. * @param value2 defines the second control point
  83389. * @param tangent2 defines the second tangent vector
  83390. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  83391. * @returns the new Vector3
  83392. */
  83393. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  83394. /**
  83395. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  83396. * @param start defines the start value
  83397. * @param end defines the end value
  83398. * @param amount max defines amount between both (between 0 and 1)
  83399. * @returns the new Vector3
  83400. */
  83401. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  83402. /**
  83403. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  83404. * @param start defines the start value
  83405. * @param end defines the end value
  83406. * @param amount max defines amount between both (between 0 and 1)
  83407. * @param result defines the Vector3 where to store the result
  83408. */
  83409. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  83410. /**
  83411. * Returns the dot product (float) between the vectors "left" and "right"
  83412. * @param left defines the left operand
  83413. * @param right defines the right operand
  83414. * @returns the dot product
  83415. */
  83416. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  83417. /**
  83418. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  83419. * The cross product is then orthogonal to both "left" and "right"
  83420. * @param left defines the left operand
  83421. * @param right defines the right operand
  83422. * @returns the cross product
  83423. */
  83424. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83425. /**
  83426. * Sets the given vector "result" with the cross product of "left" and "right"
  83427. * The cross product is then orthogonal to both "left" and "right"
  83428. * @param left defines the left operand
  83429. * @param right defines the right operand
  83430. * @param result defines the Vector3 where to store the result
  83431. */
  83432. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  83433. /**
  83434. * Returns a new Vector3 as the normalization of the given vector
  83435. * @param vector defines the Vector3 to normalize
  83436. * @returns the new Vector3
  83437. */
  83438. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  83439. /**
  83440. * Sets the given vector "result" with the normalization of the given first vector
  83441. * @param vector defines the Vector3 to normalize
  83442. * @param result defines the Vector3 where to store the result
  83443. */
  83444. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  83445. /**
  83446. * Project a Vector3 onto screen space
  83447. * @param vector defines the Vector3 to project
  83448. * @param world defines the world matrix to use
  83449. * @param transform defines the transform (view x projection) matrix to use
  83450. * @param viewport defines the screen viewport to use
  83451. * @returns the new Vector3
  83452. */
  83453. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  83454. /** @hidden */
  83455. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  83456. /**
  83457. * Unproject from screen space to object space
  83458. * @param source defines the screen space Vector3 to use
  83459. * @param viewportWidth defines the current width of the viewport
  83460. * @param viewportHeight defines the current height of the viewport
  83461. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83462. * @param transform defines the transform (view x projection) matrix to use
  83463. * @returns the new Vector3
  83464. */
  83465. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  83466. /**
  83467. * Unproject from screen space to object space
  83468. * @param source defines the screen space Vector3 to use
  83469. * @param viewportWidth defines the current width of the viewport
  83470. * @param viewportHeight defines the current height of the viewport
  83471. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83472. * @param view defines the view matrix to use
  83473. * @param projection defines the projection matrix to use
  83474. * @returns the new Vector3
  83475. */
  83476. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  83477. /**
  83478. * Unproject from screen space to object space
  83479. * @param source defines the screen space Vector3 to use
  83480. * @param viewportWidth defines the current width of the viewport
  83481. * @param viewportHeight defines the current height of the viewport
  83482. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83483. * @param view defines the view matrix to use
  83484. * @param projection defines the projection matrix to use
  83485. * @param result defines the Vector3 where to store the result
  83486. */
  83487. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83488. /**
  83489. * Unproject from screen space to object space
  83490. * @param sourceX defines the screen space x coordinate to use
  83491. * @param sourceY defines the screen space y coordinate to use
  83492. * @param sourceZ defines the screen space z coordinate to use
  83493. * @param viewportWidth defines the current width of the viewport
  83494. * @param viewportHeight defines the current height of the viewport
  83495. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83496. * @param view defines the view matrix to use
  83497. * @param projection defines the projection matrix to use
  83498. * @param result defines the Vector3 where to store the result
  83499. */
  83500. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83501. /**
  83502. * Gets the minimal coordinate values between two Vector3
  83503. * @param left defines the first operand
  83504. * @param right defines the second operand
  83505. * @returns the new Vector3
  83506. */
  83507. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83508. /**
  83509. * Gets the maximal coordinate values between two Vector3
  83510. * @param left defines the first operand
  83511. * @param right defines the second operand
  83512. * @returns the new Vector3
  83513. */
  83514. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83515. /**
  83516. * Returns the distance between the vectors "value1" and "value2"
  83517. * @param value1 defines the first operand
  83518. * @param value2 defines the second operand
  83519. * @returns the distance
  83520. */
  83521. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83522. /**
  83523. * Returns the squared distance between the vectors "value1" and "value2"
  83524. * @param value1 defines the first operand
  83525. * @param value2 defines the second operand
  83526. * @returns the squared distance
  83527. */
  83528. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83529. /**
  83530. * Returns a new Vector3 located at the center between "value1" and "value2"
  83531. * @param value1 defines the first operand
  83532. * @param value2 defines the second operand
  83533. * @returns the new Vector3
  83534. */
  83535. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  83536. /**
  83537. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  83538. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  83539. * to something in order to rotate it from its local system to the given target system
  83540. * Note: axis1, axis2 and axis3 are normalized during this operation
  83541. * @param axis1 defines the first axis
  83542. * @param axis2 defines the second axis
  83543. * @param axis3 defines the third axis
  83544. * @returns a new Vector3
  83545. */
  83546. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  83547. /**
  83548. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  83549. * @param axis1 defines the first axis
  83550. * @param axis2 defines the second axis
  83551. * @param axis3 defines the third axis
  83552. * @param ref defines the Vector3 where to store the result
  83553. */
  83554. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  83555. }
  83556. /**
  83557. * Vector4 class created for EulerAngle class conversion to Quaternion
  83558. */
  83559. export class Vector4 {
  83560. /** x value of the vector */
  83561. x: number;
  83562. /** y value of the vector */
  83563. y: number;
  83564. /** z value of the vector */
  83565. z: number;
  83566. /** w value of the vector */
  83567. w: number;
  83568. /**
  83569. * Creates a Vector4 object from the given floats.
  83570. * @param x x value of the vector
  83571. * @param y y value of the vector
  83572. * @param z z value of the vector
  83573. * @param w w value of the vector
  83574. */
  83575. constructor(
  83576. /** x value of the vector */
  83577. x: number,
  83578. /** y value of the vector */
  83579. y: number,
  83580. /** z value of the vector */
  83581. z: number,
  83582. /** w value of the vector */
  83583. w: number);
  83584. /**
  83585. * Returns the string with the Vector4 coordinates.
  83586. * @returns a string containing all the vector values
  83587. */
  83588. toString(): string;
  83589. /**
  83590. * Returns the string "Vector4".
  83591. * @returns "Vector4"
  83592. */
  83593. getClassName(): string;
  83594. /**
  83595. * Returns the Vector4 hash code.
  83596. * @returns a unique hash code
  83597. */
  83598. getHashCode(): number;
  83599. /**
  83600. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  83601. * @returns the resulting array
  83602. */
  83603. asArray(): number[];
  83604. /**
  83605. * Populates the given array from the given index with the Vector4 coordinates.
  83606. * @param array array to populate
  83607. * @param index index of the array to start at (default: 0)
  83608. * @returns the Vector4.
  83609. */
  83610. toArray(array: FloatArray, index?: number): Vector4;
  83611. /**
  83612. * Update the current vector from an array
  83613. * @param array defines the destination array
  83614. * @param index defines the offset in the destination array
  83615. * @returns the current Vector3
  83616. */
  83617. fromArray(array: FloatArray, index?: number): Vector4;
  83618. /**
  83619. * Adds the given vector to the current Vector4.
  83620. * @param otherVector the vector to add
  83621. * @returns the updated Vector4.
  83622. */
  83623. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83624. /**
  83625. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  83626. * @param otherVector the vector to add
  83627. * @returns the resulting vector
  83628. */
  83629. add(otherVector: DeepImmutable<Vector4>): Vector4;
  83630. /**
  83631. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  83632. * @param otherVector the vector to add
  83633. * @param result the vector to store the result
  83634. * @returns the current Vector4.
  83635. */
  83636. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83637. /**
  83638. * Subtract in place the given vector from the current Vector4.
  83639. * @param otherVector the vector to subtract
  83640. * @returns the updated Vector4.
  83641. */
  83642. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83643. /**
  83644. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  83645. * @param otherVector the vector to add
  83646. * @returns the new vector with the result
  83647. */
  83648. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  83649. /**
  83650. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  83651. * @param otherVector the vector to subtract
  83652. * @param result the vector to store the result
  83653. * @returns the current Vector4.
  83654. */
  83655. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83656. /**
  83657. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83658. */
  83659. /**
  83660. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83661. * @param x value to subtract
  83662. * @param y value to subtract
  83663. * @param z value to subtract
  83664. * @param w value to subtract
  83665. * @returns new vector containing the result
  83666. */
  83667. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83668. /**
  83669. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83670. * @param x value to subtract
  83671. * @param y value to subtract
  83672. * @param z value to subtract
  83673. * @param w value to subtract
  83674. * @param result the vector to store the result in
  83675. * @returns the current Vector4.
  83676. */
  83677. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  83678. /**
  83679. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  83680. * @returns a new vector with the negated values
  83681. */
  83682. negate(): Vector4;
  83683. /**
  83684. * Negate this vector in place
  83685. * @returns this
  83686. */
  83687. negateInPlace(): Vector4;
  83688. /**
  83689. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  83690. * @param result defines the Vector3 object where to store the result
  83691. * @returns the current Vector4
  83692. */
  83693. negateToRef(result: Vector4): Vector4;
  83694. /**
  83695. * Multiplies the current Vector4 coordinates by scale (float).
  83696. * @param scale the number to scale with
  83697. * @returns the updated Vector4.
  83698. */
  83699. scaleInPlace(scale: number): Vector4;
  83700. /**
  83701. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  83702. * @param scale the number to scale with
  83703. * @returns a new vector with the result
  83704. */
  83705. scale(scale: number): Vector4;
  83706. /**
  83707. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  83708. * @param scale the number to scale with
  83709. * @param result a vector to store the result in
  83710. * @returns the current Vector4.
  83711. */
  83712. scaleToRef(scale: number, result: Vector4): Vector4;
  83713. /**
  83714. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  83715. * @param scale defines the scale factor
  83716. * @param result defines the Vector4 object where to store the result
  83717. * @returns the unmodified current Vector4
  83718. */
  83719. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  83720. /**
  83721. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  83722. * @param otherVector the vector to compare against
  83723. * @returns true if they are equal
  83724. */
  83725. equals(otherVector: DeepImmutable<Vector4>): boolean;
  83726. /**
  83727. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  83728. * @param otherVector vector to compare against
  83729. * @param epsilon (Default: very small number)
  83730. * @returns true if they are equal
  83731. */
  83732. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  83733. /**
  83734. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  83735. * @param x x value to compare against
  83736. * @param y y value to compare against
  83737. * @param z z value to compare against
  83738. * @param w w value to compare against
  83739. * @returns true if equal
  83740. */
  83741. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  83742. /**
  83743. * Multiplies in place the current Vector4 by the given one.
  83744. * @param otherVector vector to multiple with
  83745. * @returns the updated Vector4.
  83746. */
  83747. multiplyInPlace(otherVector: Vector4): Vector4;
  83748. /**
  83749. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  83750. * @param otherVector vector to multiple with
  83751. * @returns resulting new vector
  83752. */
  83753. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  83754. /**
  83755. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  83756. * @param otherVector vector to multiple with
  83757. * @param result vector to store the result
  83758. * @returns the current Vector4.
  83759. */
  83760. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83761. /**
  83762. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  83763. * @param x x value multiply with
  83764. * @param y y value multiply with
  83765. * @param z z value multiply with
  83766. * @param w w value multiply with
  83767. * @returns resulting new vector
  83768. */
  83769. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  83770. /**
  83771. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  83772. * @param otherVector vector to devide with
  83773. * @returns resulting new vector
  83774. */
  83775. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  83776. /**
  83777. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  83778. * @param otherVector vector to devide with
  83779. * @param result vector to store the result
  83780. * @returns the current Vector4.
  83781. */
  83782. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83783. /**
  83784. * Divides the current Vector3 coordinates by the given ones.
  83785. * @param otherVector vector to devide with
  83786. * @returns the updated Vector3.
  83787. */
  83788. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83789. /**
  83790. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  83791. * @param other defines the second operand
  83792. * @returns the current updated Vector4
  83793. */
  83794. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83795. /**
  83796. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  83797. * @param other defines the second operand
  83798. * @returns the current updated Vector4
  83799. */
  83800. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83801. /**
  83802. * Gets a new Vector4 from current Vector4 floored values
  83803. * @returns a new Vector4
  83804. */
  83805. floor(): Vector4;
  83806. /**
  83807. * Gets a new Vector4 from current Vector3 floored values
  83808. * @returns a new Vector4
  83809. */
  83810. fract(): Vector4;
  83811. /**
  83812. * Returns the Vector4 length (float).
  83813. * @returns the length
  83814. */
  83815. length(): number;
  83816. /**
  83817. * Returns the Vector4 squared length (float).
  83818. * @returns the length squared
  83819. */
  83820. lengthSquared(): number;
  83821. /**
  83822. * Normalizes in place the Vector4.
  83823. * @returns the updated Vector4.
  83824. */
  83825. normalize(): Vector4;
  83826. /**
  83827. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  83828. * @returns this converted to a new vector3
  83829. */
  83830. toVector3(): Vector3;
  83831. /**
  83832. * Returns a new Vector4 copied from the current one.
  83833. * @returns the new cloned vector
  83834. */
  83835. clone(): Vector4;
  83836. /**
  83837. * Updates the current Vector4 with the given one coordinates.
  83838. * @param source the source vector to copy from
  83839. * @returns the updated Vector4.
  83840. */
  83841. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  83842. /**
  83843. * Updates the current Vector4 coordinates with the given floats.
  83844. * @param x float to copy from
  83845. * @param y float to copy from
  83846. * @param z float to copy from
  83847. * @param w float to copy from
  83848. * @returns the updated Vector4.
  83849. */
  83850. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83851. /**
  83852. * Updates the current Vector4 coordinates with the given floats.
  83853. * @param x float to set from
  83854. * @param y float to set from
  83855. * @param z float to set from
  83856. * @param w float to set from
  83857. * @returns the updated Vector4.
  83858. */
  83859. set(x: number, y: number, z: number, w: number): Vector4;
  83860. /**
  83861. * Copies the given float to the current Vector3 coordinates
  83862. * @param v defines the x, y, z and w coordinates of the operand
  83863. * @returns the current updated Vector3
  83864. */
  83865. setAll(v: number): Vector4;
  83866. /**
  83867. * Returns a new Vector4 set from the starting index of the given array.
  83868. * @param array the array to pull values from
  83869. * @param offset the offset into the array to start at
  83870. * @returns the new vector
  83871. */
  83872. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  83873. /**
  83874. * Updates the given vector "result" from the starting index of the given array.
  83875. * @param array the array to pull values from
  83876. * @param offset the offset into the array to start at
  83877. * @param result the vector to store the result in
  83878. */
  83879. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  83880. /**
  83881. * Updates the given vector "result" from the starting index of the given Float32Array.
  83882. * @param array the array to pull values from
  83883. * @param offset the offset into the array to start at
  83884. * @param result the vector to store the result in
  83885. */
  83886. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  83887. /**
  83888. * Updates the given vector "result" coordinates from the given floats.
  83889. * @param x float to set from
  83890. * @param y float to set from
  83891. * @param z float to set from
  83892. * @param w float to set from
  83893. * @param result the vector to the floats in
  83894. */
  83895. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  83896. /**
  83897. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  83898. * @returns the new vector
  83899. */
  83900. static Zero(): Vector4;
  83901. /**
  83902. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  83903. * @returns the new vector
  83904. */
  83905. static One(): Vector4;
  83906. /**
  83907. * Returns a new normalized Vector4 from the given one.
  83908. * @param vector the vector to normalize
  83909. * @returns the vector
  83910. */
  83911. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  83912. /**
  83913. * Updates the given vector "result" from the normalization of the given one.
  83914. * @param vector the vector to normalize
  83915. * @param result the vector to store the result in
  83916. */
  83917. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  83918. /**
  83919. * Returns a vector with the minimum values from the left and right vectors
  83920. * @param left left vector to minimize
  83921. * @param right right vector to minimize
  83922. * @returns a new vector with the minimum of the left and right vector values
  83923. */
  83924. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83925. /**
  83926. * Returns a vector with the maximum values from the left and right vectors
  83927. * @param left left vector to maximize
  83928. * @param right right vector to maximize
  83929. * @returns a new vector with the maximum of the left and right vector values
  83930. */
  83931. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83932. /**
  83933. * Returns the distance (float) between the vectors "value1" and "value2".
  83934. * @param value1 value to calulate the distance between
  83935. * @param value2 value to calulate the distance between
  83936. * @return the distance between the two vectors
  83937. */
  83938. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83939. /**
  83940. * Returns the squared distance (float) between the vectors "value1" and "value2".
  83941. * @param value1 value to calulate the distance between
  83942. * @param value2 value to calulate the distance between
  83943. * @return the distance between the two vectors squared
  83944. */
  83945. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83946. /**
  83947. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  83948. * @param value1 value to calulate the center between
  83949. * @param value2 value to calulate the center between
  83950. * @return the center between the two vectors
  83951. */
  83952. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  83953. /**
  83954. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  83955. * This methods computes transformed normalized direction vectors only.
  83956. * @param vector the vector to transform
  83957. * @param transformation the transformation matrix to apply
  83958. * @returns the new vector
  83959. */
  83960. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  83961. /**
  83962. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  83963. * This methods computes transformed normalized direction vectors only.
  83964. * @param vector the vector to transform
  83965. * @param transformation the transformation matrix to apply
  83966. * @param result the vector to store the result in
  83967. */
  83968. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83969. /**
  83970. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  83971. * This methods computes transformed normalized direction vectors only.
  83972. * @param x value to transform
  83973. * @param y value to transform
  83974. * @param z value to transform
  83975. * @param w value to transform
  83976. * @param transformation the transformation matrix to apply
  83977. * @param result the vector to store the results in
  83978. */
  83979. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83980. /**
  83981. * Creates a new Vector4 from a Vector3
  83982. * @param source defines the source data
  83983. * @param w defines the 4th component (default is 0)
  83984. * @returns a new Vector4
  83985. */
  83986. static FromVector3(source: Vector3, w?: number): Vector4;
  83987. }
  83988. /**
  83989. * Class used to store quaternion data
  83990. * @see https://en.wikipedia.org/wiki/Quaternion
  83991. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  83992. */
  83993. export class Quaternion {
  83994. /** @hidden */
  83995. _x: number;
  83996. /** @hidden */
  83997. _y: number;
  83998. /** @hidden */
  83999. _z: number;
  84000. /** @hidden */
  84001. _w: number;
  84002. /** @hidden */
  84003. _isDirty: boolean;
  84004. /** Gets or sets the x coordinate */
  84005. get x(): number;
  84006. set x(value: number);
  84007. /** Gets or sets the y coordinate */
  84008. get y(): number;
  84009. set y(value: number);
  84010. /** Gets or sets the z coordinate */
  84011. get z(): number;
  84012. set z(value: number);
  84013. /** Gets or sets the w coordinate */
  84014. get w(): number;
  84015. set w(value: number);
  84016. /**
  84017. * Creates a new Quaternion from the given floats
  84018. * @param x defines the first component (0 by default)
  84019. * @param y defines the second component (0 by default)
  84020. * @param z defines the third component (0 by default)
  84021. * @param w defines the fourth component (1.0 by default)
  84022. */
  84023. constructor(x?: number, y?: number, z?: number, w?: number);
  84024. /**
  84025. * Gets a string representation for the current quaternion
  84026. * @returns a string with the Quaternion coordinates
  84027. */
  84028. toString(): string;
  84029. /**
  84030. * Gets the class name of the quaternion
  84031. * @returns the string "Quaternion"
  84032. */
  84033. getClassName(): string;
  84034. /**
  84035. * Gets a hash code for this quaternion
  84036. * @returns the quaternion hash code
  84037. */
  84038. getHashCode(): number;
  84039. /**
  84040. * Copy the quaternion to an array
  84041. * @returns a new array populated with 4 elements from the quaternion coordinates
  84042. */
  84043. asArray(): number[];
  84044. /**
  84045. * Check if two quaternions are equals
  84046. * @param otherQuaternion defines the second operand
  84047. * @return true if the current quaternion and the given one coordinates are strictly equals
  84048. */
  84049. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84050. /**
  84051. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84052. * @param otherQuaternion defines the other quaternion
  84053. * @param epsilon defines the minimal distance to consider equality
  84054. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84055. */
  84056. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84057. /**
  84058. * Clone the current quaternion
  84059. * @returns a new quaternion copied from the current one
  84060. */
  84061. clone(): Quaternion;
  84062. /**
  84063. * Copy a quaternion to the current one
  84064. * @param other defines the other quaternion
  84065. * @returns the updated current quaternion
  84066. */
  84067. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84068. /**
  84069. * Updates the current quaternion with the given float coordinates
  84070. * @param x defines the x coordinate
  84071. * @param y defines the y coordinate
  84072. * @param z defines the z coordinate
  84073. * @param w defines the w coordinate
  84074. * @returns the updated current quaternion
  84075. */
  84076. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84077. /**
  84078. * Updates the current quaternion from the given float coordinates
  84079. * @param x defines the x coordinate
  84080. * @param y defines the y coordinate
  84081. * @param z defines the z coordinate
  84082. * @param w defines the w coordinate
  84083. * @returns the updated current quaternion
  84084. */
  84085. set(x: number, y: number, z: number, w: number): Quaternion;
  84086. /**
  84087. * Adds two quaternions
  84088. * @param other defines the second operand
  84089. * @returns a new quaternion as the addition result of the given one and the current quaternion
  84090. */
  84091. add(other: DeepImmutable<Quaternion>): Quaternion;
  84092. /**
  84093. * Add a quaternion to the current one
  84094. * @param other defines the quaternion to add
  84095. * @returns the current quaternion
  84096. */
  84097. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84098. /**
  84099. * Subtract two quaternions
  84100. * @param other defines the second operand
  84101. * @returns a new quaternion as the subtraction result of the given one from the current one
  84102. */
  84103. subtract(other: Quaternion): Quaternion;
  84104. /**
  84105. * Multiplies the current quaternion by a scale factor
  84106. * @param value defines the scale factor
  84107. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84108. */
  84109. scale(value: number): Quaternion;
  84110. /**
  84111. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84112. * @param scale defines the scale factor
  84113. * @param result defines the Quaternion object where to store the result
  84114. * @returns the unmodified current quaternion
  84115. */
  84116. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84117. /**
  84118. * Multiplies in place the current quaternion by a scale factor
  84119. * @param value defines the scale factor
  84120. * @returns the current modified quaternion
  84121. */
  84122. scaleInPlace(value: number): Quaternion;
  84123. /**
  84124. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84125. * @param scale defines the scale factor
  84126. * @param result defines the Quaternion object where to store the result
  84127. * @returns the unmodified current quaternion
  84128. */
  84129. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84130. /**
  84131. * Multiplies two quaternions
  84132. * @param q1 defines the second operand
  84133. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84134. */
  84135. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84136. /**
  84137. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84138. * @param q1 defines the second operand
  84139. * @param result defines the target quaternion
  84140. * @returns the current quaternion
  84141. */
  84142. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84143. /**
  84144. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84145. * @param q1 defines the second operand
  84146. * @returns the currentupdated quaternion
  84147. */
  84148. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  84149. /**
  84150. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  84151. * @param ref defines the target quaternion
  84152. * @returns the current quaternion
  84153. */
  84154. conjugateToRef(ref: Quaternion): Quaternion;
  84155. /**
  84156. * Conjugates in place (1-q) the current quaternion
  84157. * @returns the current updated quaternion
  84158. */
  84159. conjugateInPlace(): Quaternion;
  84160. /**
  84161. * Conjugates in place (1-q) the current quaternion
  84162. * @returns a new quaternion
  84163. */
  84164. conjugate(): Quaternion;
  84165. /**
  84166. * Gets length of current quaternion
  84167. * @returns the quaternion length (float)
  84168. */
  84169. length(): number;
  84170. /**
  84171. * Normalize in place the current quaternion
  84172. * @returns the current updated quaternion
  84173. */
  84174. normalize(): Quaternion;
  84175. /**
  84176. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  84177. * @param order is a reserved parameter and is ignored for now
  84178. * @returns a new Vector3 containing the Euler angles
  84179. */
  84180. toEulerAngles(order?: string): Vector3;
  84181. /**
  84182. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  84183. * @param result defines the vector which will be filled with the Euler angles
  84184. * @returns the current unchanged quaternion
  84185. */
  84186. toEulerAnglesToRef(result: Vector3): Quaternion;
  84187. /**
  84188. * Updates the given rotation matrix with the current quaternion values
  84189. * @param result defines the target matrix
  84190. * @returns the current unchanged quaternion
  84191. */
  84192. toRotationMatrix(result: Matrix): Quaternion;
  84193. /**
  84194. * Updates the current quaternion from the given rotation matrix values
  84195. * @param matrix defines the source matrix
  84196. * @returns the current updated quaternion
  84197. */
  84198. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84199. /**
  84200. * Creates a new quaternion from a rotation matrix
  84201. * @param matrix defines the source matrix
  84202. * @returns a new quaternion created from the given rotation matrix values
  84203. */
  84204. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84205. /**
  84206. * Updates the given quaternion with the given rotation matrix values
  84207. * @param matrix defines the source matrix
  84208. * @param result defines the target quaternion
  84209. */
  84210. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  84211. /**
  84212. * Returns the dot product (float) between the quaternions "left" and "right"
  84213. * @param left defines the left operand
  84214. * @param right defines the right operand
  84215. * @returns the dot product
  84216. */
  84217. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  84218. /**
  84219. * Checks if the two quaternions are close to each other
  84220. * @param quat0 defines the first quaternion to check
  84221. * @param quat1 defines the second quaternion to check
  84222. * @returns true if the two quaternions are close to each other
  84223. */
  84224. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  84225. /**
  84226. * Creates an empty quaternion
  84227. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  84228. */
  84229. static Zero(): Quaternion;
  84230. /**
  84231. * Inverse a given quaternion
  84232. * @param q defines the source quaternion
  84233. * @returns a new quaternion as the inverted current quaternion
  84234. */
  84235. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  84236. /**
  84237. * Inverse a given quaternion
  84238. * @param q defines the source quaternion
  84239. * @param result the quaternion the result will be stored in
  84240. * @returns the result quaternion
  84241. */
  84242. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  84243. /**
  84244. * Creates an identity quaternion
  84245. * @returns the identity quaternion
  84246. */
  84247. static Identity(): Quaternion;
  84248. /**
  84249. * Gets a boolean indicating if the given quaternion is identity
  84250. * @param quaternion defines the quaternion to check
  84251. * @returns true if the quaternion is identity
  84252. */
  84253. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  84254. /**
  84255. * Creates a quaternion from a rotation around an axis
  84256. * @param axis defines the axis to use
  84257. * @param angle defines the angle to use
  84258. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  84259. */
  84260. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  84261. /**
  84262. * Creates a rotation around an axis and stores it into the given quaternion
  84263. * @param axis defines the axis to use
  84264. * @param angle defines the angle to use
  84265. * @param result defines the target quaternion
  84266. * @returns the target quaternion
  84267. */
  84268. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  84269. /**
  84270. * Creates a new quaternion from data stored into an array
  84271. * @param array defines the data source
  84272. * @param offset defines the offset in the source array where the data starts
  84273. * @returns a new quaternion
  84274. */
  84275. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  84276. /**
  84277. * Updates the given quaternion "result" from the starting index of the given array.
  84278. * @param array the array to pull values from
  84279. * @param offset the offset into the array to start at
  84280. * @param result the quaternion to store the result in
  84281. */
  84282. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  84283. /**
  84284. * Create a quaternion from Euler rotation angles
  84285. * @param x Pitch
  84286. * @param y Yaw
  84287. * @param z Roll
  84288. * @returns the new Quaternion
  84289. */
  84290. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  84291. /**
  84292. * Updates a quaternion from Euler rotation angles
  84293. * @param x Pitch
  84294. * @param y Yaw
  84295. * @param z Roll
  84296. * @param result the quaternion to store the result
  84297. * @returns the updated quaternion
  84298. */
  84299. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  84300. /**
  84301. * Create a quaternion from Euler rotation vector
  84302. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84303. * @returns the new Quaternion
  84304. */
  84305. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  84306. /**
  84307. * Updates a quaternion from Euler rotation vector
  84308. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84309. * @param result the quaternion to store the result
  84310. * @returns the updated quaternion
  84311. */
  84312. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  84313. /**
  84314. * Creates a new quaternion from the given Euler float angles (y, x, z)
  84315. * @param yaw defines the rotation around Y axis
  84316. * @param pitch defines the rotation around X axis
  84317. * @param roll defines the rotation around Z axis
  84318. * @returns the new quaternion
  84319. */
  84320. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  84321. /**
  84322. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  84323. * @param yaw defines the rotation around Y axis
  84324. * @param pitch defines the rotation around X axis
  84325. * @param roll defines the rotation around Z axis
  84326. * @param result defines the target quaternion
  84327. */
  84328. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  84329. /**
  84330. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  84331. * @param alpha defines the rotation around first axis
  84332. * @param beta defines the rotation around second axis
  84333. * @param gamma defines the rotation around third axis
  84334. * @returns the new quaternion
  84335. */
  84336. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  84337. /**
  84338. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  84339. * @param alpha defines the rotation around first axis
  84340. * @param beta defines the rotation around second axis
  84341. * @param gamma defines the rotation around third axis
  84342. * @param result defines the target quaternion
  84343. */
  84344. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  84345. /**
  84346. * 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)
  84347. * @param axis1 defines the first axis
  84348. * @param axis2 defines the second axis
  84349. * @param axis3 defines the third axis
  84350. * @returns the new quaternion
  84351. */
  84352. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  84353. /**
  84354. * 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
  84355. * @param axis1 defines the first axis
  84356. * @param axis2 defines the second axis
  84357. * @param axis3 defines the third axis
  84358. * @param ref defines the target quaternion
  84359. */
  84360. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  84361. /**
  84362. * Interpolates between two quaternions
  84363. * @param left defines first quaternion
  84364. * @param right defines second quaternion
  84365. * @param amount defines the gradient to use
  84366. * @returns the new interpolated quaternion
  84367. */
  84368. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84369. /**
  84370. * Interpolates between two quaternions and stores it into a target quaternion
  84371. * @param left defines first quaternion
  84372. * @param right defines second quaternion
  84373. * @param amount defines the gradient to use
  84374. * @param result defines the target quaternion
  84375. */
  84376. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  84377. /**
  84378. * Interpolate between two quaternions using Hermite interpolation
  84379. * @param value1 defines first quaternion
  84380. * @param tangent1 defines the incoming tangent
  84381. * @param value2 defines second quaternion
  84382. * @param tangent2 defines the outgoing tangent
  84383. * @param amount defines the target quaternion
  84384. * @returns the new interpolated quaternion
  84385. */
  84386. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84387. }
  84388. /**
  84389. * Class used to store matrix data (4x4)
  84390. */
  84391. export class Matrix {
  84392. /**
  84393. * Gets the precision of matrix computations
  84394. */
  84395. static get Use64Bits(): boolean;
  84396. private static _updateFlagSeed;
  84397. private static _identityReadOnly;
  84398. private _isIdentity;
  84399. private _isIdentityDirty;
  84400. private _isIdentity3x2;
  84401. private _isIdentity3x2Dirty;
  84402. /**
  84403. * Gets the update flag of the matrix which is an unique number for the matrix.
  84404. * It will be incremented every time the matrix data change.
  84405. * You can use it to speed the comparison between two versions of the same matrix.
  84406. */
  84407. updateFlag: number;
  84408. private readonly _m;
  84409. /**
  84410. * Gets the internal data of the matrix
  84411. */
  84412. get m(): DeepImmutable<Float32Array | Array<number>>;
  84413. /** @hidden */
  84414. _markAsUpdated(): void;
  84415. /** @hidden */
  84416. private _updateIdentityStatus;
  84417. /**
  84418. * Creates an empty matrix (filled with zeros)
  84419. */
  84420. constructor();
  84421. /**
  84422. * Check if the current matrix is identity
  84423. * @returns true is the matrix is the identity matrix
  84424. */
  84425. isIdentity(): boolean;
  84426. /**
  84427. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  84428. * @returns true is the matrix is the identity matrix
  84429. */
  84430. isIdentityAs3x2(): boolean;
  84431. /**
  84432. * Gets the determinant of the matrix
  84433. * @returns the matrix determinant
  84434. */
  84435. determinant(): number;
  84436. /**
  84437. * Returns the matrix as a Float32Array or Array<number>
  84438. * @returns the matrix underlying array
  84439. */
  84440. toArray(): DeepImmutable<Float32Array | Array<number>>;
  84441. /**
  84442. * Returns the matrix as a Float32Array or Array<number>
  84443. * @returns the matrix underlying array.
  84444. */
  84445. asArray(): DeepImmutable<Float32Array | Array<number>>;
  84446. /**
  84447. * Inverts the current matrix in place
  84448. * @returns the current inverted matrix
  84449. */
  84450. invert(): Matrix;
  84451. /**
  84452. * Sets all the matrix elements to zero
  84453. * @returns the current matrix
  84454. */
  84455. reset(): Matrix;
  84456. /**
  84457. * Adds the current matrix with a second one
  84458. * @param other defines the matrix to add
  84459. * @returns a new matrix as the addition of the current matrix and the given one
  84460. */
  84461. add(other: DeepImmutable<Matrix>): Matrix;
  84462. /**
  84463. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84464. * @param other defines the matrix to add
  84465. * @param result defines the target matrix
  84466. * @returns the current matrix
  84467. */
  84468. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84469. /**
  84470. * Adds in place the given matrix to the current matrix
  84471. * @param other defines the second operand
  84472. * @returns the current updated matrix
  84473. */
  84474. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  84475. /**
  84476. * Sets the given matrix to the current inverted Matrix
  84477. * @param other defines the target matrix
  84478. * @returns the unmodified current matrix
  84479. */
  84480. invertToRef(other: Matrix): Matrix;
  84481. /**
  84482. * add a value at the specified position in the current Matrix
  84483. * @param index the index of the value within the matrix. between 0 and 15.
  84484. * @param value the value to be added
  84485. * @returns the current updated matrix
  84486. */
  84487. addAtIndex(index: number, value: number): Matrix;
  84488. /**
  84489. * mutiply the specified position in the current Matrix by a value
  84490. * @param index the index of the value within the matrix. between 0 and 15.
  84491. * @param value the value to be added
  84492. * @returns the current updated matrix
  84493. */
  84494. multiplyAtIndex(index: number, value: number): Matrix;
  84495. /**
  84496. * Inserts the translation vector (using 3 floats) in the current matrix
  84497. * @param x defines the 1st component of the translation
  84498. * @param y defines the 2nd component of the translation
  84499. * @param z defines the 3rd component of the translation
  84500. * @returns the current updated matrix
  84501. */
  84502. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84503. /**
  84504. * Adds the translation vector (using 3 floats) in the current matrix
  84505. * @param x defines the 1st component of the translation
  84506. * @param y defines the 2nd component of the translation
  84507. * @param z defines the 3rd component of the translation
  84508. * @returns the current updated matrix
  84509. */
  84510. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84511. /**
  84512. * Inserts the translation vector in the current matrix
  84513. * @param vector3 defines the translation to insert
  84514. * @returns the current updated matrix
  84515. */
  84516. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  84517. /**
  84518. * Gets the translation value of the current matrix
  84519. * @returns a new Vector3 as the extracted translation from the matrix
  84520. */
  84521. getTranslation(): Vector3;
  84522. /**
  84523. * Fill a Vector3 with the extracted translation from the matrix
  84524. * @param result defines the Vector3 where to store the translation
  84525. * @returns the current matrix
  84526. */
  84527. getTranslationToRef(result: Vector3): Matrix;
  84528. /**
  84529. * Remove rotation and scaling part from the matrix
  84530. * @returns the updated matrix
  84531. */
  84532. removeRotationAndScaling(): Matrix;
  84533. /**
  84534. * Multiply two matrices
  84535. * @param other defines the second operand
  84536. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  84537. */
  84538. multiply(other: DeepImmutable<Matrix>): Matrix;
  84539. /**
  84540. * Copy the current matrix from the given one
  84541. * @param other defines the source matrix
  84542. * @returns the current updated matrix
  84543. */
  84544. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  84545. /**
  84546. * Populates the given array from the starting index with the current matrix values
  84547. * @param array defines the target array
  84548. * @param offset defines the offset in the target array where to start storing values
  84549. * @returns the current matrix
  84550. */
  84551. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  84552. /**
  84553. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  84554. * @param other defines the second operand
  84555. * @param result defines the matrix where to store the multiplication
  84556. * @returns the current matrix
  84557. */
  84558. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84559. /**
  84560. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  84561. * @param other defines the second operand
  84562. * @param result defines the array where to store the multiplication
  84563. * @param offset defines the offset in the target array where to start storing values
  84564. * @returns the current matrix
  84565. */
  84566. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  84567. /**
  84568. * Check equality between this matrix and a second one
  84569. * @param value defines the second matrix to compare
  84570. * @returns true is the current matrix and the given one values are strictly equal
  84571. */
  84572. equals(value: DeepImmutable<Matrix>): boolean;
  84573. /**
  84574. * Clone the current matrix
  84575. * @returns a new matrix from the current matrix
  84576. */
  84577. clone(): Matrix;
  84578. /**
  84579. * Returns the name of the current matrix class
  84580. * @returns the string "Matrix"
  84581. */
  84582. getClassName(): string;
  84583. /**
  84584. * Gets the hash code of the current matrix
  84585. * @returns the hash code
  84586. */
  84587. getHashCode(): number;
  84588. /**
  84589. * Decomposes the current Matrix into a translation, rotation and scaling components
  84590. * @param scale defines the scale vector3 given as a reference to update
  84591. * @param rotation defines the rotation quaternion given as a reference to update
  84592. * @param translation defines the translation vector3 given as a reference to update
  84593. * @returns true if operation was successful
  84594. */
  84595. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  84596. /**
  84597. * Gets specific row of the matrix
  84598. * @param index defines the number of the row to get
  84599. * @returns the index-th row of the current matrix as a new Vector4
  84600. */
  84601. getRow(index: number): Nullable<Vector4>;
  84602. /**
  84603. * Sets the index-th row of the current matrix to the vector4 values
  84604. * @param index defines the number of the row to set
  84605. * @param row defines the target vector4
  84606. * @returns the updated current matrix
  84607. */
  84608. setRow(index: number, row: Vector4): Matrix;
  84609. /**
  84610. * Compute the transpose of the matrix
  84611. * @returns the new transposed matrix
  84612. */
  84613. transpose(): Matrix;
  84614. /**
  84615. * Compute the transpose of the matrix and store it in a given matrix
  84616. * @param result defines the target matrix
  84617. * @returns the current matrix
  84618. */
  84619. transposeToRef(result: Matrix): Matrix;
  84620. /**
  84621. * Sets the index-th row of the current matrix with the given 4 x float values
  84622. * @param index defines the row index
  84623. * @param x defines the x component to set
  84624. * @param y defines the y component to set
  84625. * @param z defines the z component to set
  84626. * @param w defines the w component to set
  84627. * @returns the updated current matrix
  84628. */
  84629. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  84630. /**
  84631. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  84632. * @param scale defines the scale factor
  84633. * @returns a new matrix
  84634. */
  84635. scale(scale: number): Matrix;
  84636. /**
  84637. * Scale the current matrix values by a factor to a given result matrix
  84638. * @param scale defines the scale factor
  84639. * @param result defines the matrix to store the result
  84640. * @returns the current matrix
  84641. */
  84642. scaleToRef(scale: number, result: Matrix): Matrix;
  84643. /**
  84644. * Scale the current matrix values by a factor and add the result to a given matrix
  84645. * @param scale defines the scale factor
  84646. * @param result defines the Matrix to store the result
  84647. * @returns the current matrix
  84648. */
  84649. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  84650. /**
  84651. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  84652. * @param ref matrix to store the result
  84653. */
  84654. toNormalMatrix(ref: Matrix): void;
  84655. /**
  84656. * Gets only rotation part of the current matrix
  84657. * @returns a new matrix sets to the extracted rotation matrix from the current one
  84658. */
  84659. getRotationMatrix(): Matrix;
  84660. /**
  84661. * Extracts the rotation matrix from the current one and sets it as the given "result"
  84662. * @param result defines the target matrix to store data to
  84663. * @returns the current matrix
  84664. */
  84665. getRotationMatrixToRef(result: Matrix): Matrix;
  84666. /**
  84667. * Toggles model matrix from being right handed to left handed in place and vice versa
  84668. */
  84669. toggleModelMatrixHandInPlace(): void;
  84670. /**
  84671. * Toggles projection matrix from being right handed to left handed in place and vice versa
  84672. */
  84673. toggleProjectionMatrixHandInPlace(): void;
  84674. /**
  84675. * Creates a matrix from an array
  84676. * @param array defines the source array
  84677. * @param offset defines an offset in the source array
  84678. * @returns a new Matrix set from the starting index of the given array
  84679. */
  84680. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  84681. /**
  84682. * Copy the content of an array into a given matrix
  84683. * @param array defines the source array
  84684. * @param offset defines an offset in the source array
  84685. * @param result defines the target matrix
  84686. */
  84687. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  84688. /**
  84689. * Stores an array into a matrix after having multiplied each component by a given factor
  84690. * @param array defines the source array
  84691. * @param offset defines the offset in the source array
  84692. * @param scale defines the scaling factor
  84693. * @param result defines the target matrix
  84694. */
  84695. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  84696. /**
  84697. * Gets an identity matrix that must not be updated
  84698. */
  84699. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  84700. /**
  84701. * Stores a list of values (16) inside a given matrix
  84702. * @param initialM11 defines 1st value of 1st row
  84703. * @param initialM12 defines 2nd value of 1st row
  84704. * @param initialM13 defines 3rd value of 1st row
  84705. * @param initialM14 defines 4th value of 1st row
  84706. * @param initialM21 defines 1st value of 2nd row
  84707. * @param initialM22 defines 2nd value of 2nd row
  84708. * @param initialM23 defines 3rd value of 2nd row
  84709. * @param initialM24 defines 4th value of 2nd row
  84710. * @param initialM31 defines 1st value of 3rd row
  84711. * @param initialM32 defines 2nd value of 3rd row
  84712. * @param initialM33 defines 3rd value of 3rd row
  84713. * @param initialM34 defines 4th value of 3rd row
  84714. * @param initialM41 defines 1st value of 4th row
  84715. * @param initialM42 defines 2nd value of 4th row
  84716. * @param initialM43 defines 3rd value of 4th row
  84717. * @param initialM44 defines 4th value of 4th row
  84718. * @param result defines the target matrix
  84719. */
  84720. 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;
  84721. /**
  84722. * Creates new matrix from a list of values (16)
  84723. * @param initialM11 defines 1st value of 1st row
  84724. * @param initialM12 defines 2nd value of 1st row
  84725. * @param initialM13 defines 3rd value of 1st row
  84726. * @param initialM14 defines 4th value of 1st row
  84727. * @param initialM21 defines 1st value of 2nd row
  84728. * @param initialM22 defines 2nd value of 2nd row
  84729. * @param initialM23 defines 3rd value of 2nd row
  84730. * @param initialM24 defines 4th value of 2nd row
  84731. * @param initialM31 defines 1st value of 3rd row
  84732. * @param initialM32 defines 2nd value of 3rd row
  84733. * @param initialM33 defines 3rd value of 3rd row
  84734. * @param initialM34 defines 4th value of 3rd row
  84735. * @param initialM41 defines 1st value of 4th row
  84736. * @param initialM42 defines 2nd value of 4th row
  84737. * @param initialM43 defines 3rd value of 4th row
  84738. * @param initialM44 defines 4th value of 4th row
  84739. * @returns the new matrix
  84740. */
  84741. 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;
  84742. /**
  84743. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84744. * @param scale defines the scale vector3
  84745. * @param rotation defines the rotation quaternion
  84746. * @param translation defines the translation vector3
  84747. * @returns a new matrix
  84748. */
  84749. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  84750. /**
  84751. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84752. * @param scale defines the scale vector3
  84753. * @param rotation defines the rotation quaternion
  84754. * @param translation defines the translation vector3
  84755. * @param result defines the target matrix
  84756. */
  84757. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  84758. /**
  84759. * Creates a new identity matrix
  84760. * @returns a new identity matrix
  84761. */
  84762. static Identity(): Matrix;
  84763. /**
  84764. * Creates a new identity matrix and stores the result in a given matrix
  84765. * @param result defines the target matrix
  84766. */
  84767. static IdentityToRef(result: Matrix): void;
  84768. /**
  84769. * Creates a new zero matrix
  84770. * @returns a new zero matrix
  84771. */
  84772. static Zero(): Matrix;
  84773. /**
  84774. * Creates a new rotation matrix for "angle" radians around the X axis
  84775. * @param angle defines the angle (in radians) to use
  84776. * @return the new matrix
  84777. */
  84778. static RotationX(angle: number): Matrix;
  84779. /**
  84780. * Creates a new matrix as the invert of a given matrix
  84781. * @param source defines the source matrix
  84782. * @returns the new matrix
  84783. */
  84784. static Invert(source: DeepImmutable<Matrix>): Matrix;
  84785. /**
  84786. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  84787. * @param angle defines the angle (in radians) to use
  84788. * @param result defines the target matrix
  84789. */
  84790. static RotationXToRef(angle: number, result: Matrix): void;
  84791. /**
  84792. * Creates a new rotation matrix for "angle" radians around the Y axis
  84793. * @param angle defines the angle (in radians) to use
  84794. * @return the new matrix
  84795. */
  84796. static RotationY(angle: number): Matrix;
  84797. /**
  84798. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  84799. * @param angle defines the angle (in radians) to use
  84800. * @param result defines the target matrix
  84801. */
  84802. static RotationYToRef(angle: number, result: Matrix): void;
  84803. /**
  84804. * Creates a new rotation matrix for "angle" radians around the Z axis
  84805. * @param angle defines the angle (in radians) to use
  84806. * @return the new matrix
  84807. */
  84808. static RotationZ(angle: number): Matrix;
  84809. /**
  84810. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  84811. * @param angle defines the angle (in radians) to use
  84812. * @param result defines the target matrix
  84813. */
  84814. static RotationZToRef(angle: number, result: Matrix): void;
  84815. /**
  84816. * Creates a new rotation matrix for "angle" radians around the given axis
  84817. * @param axis defines the axis to use
  84818. * @param angle defines the angle (in radians) to use
  84819. * @return the new matrix
  84820. */
  84821. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  84822. /**
  84823. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  84824. * @param axis defines the axis to use
  84825. * @param angle defines the angle (in radians) to use
  84826. * @param result defines the target matrix
  84827. */
  84828. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  84829. /**
  84830. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  84831. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  84832. * @param from defines the vector to align
  84833. * @param to defines the vector to align to
  84834. * @param result defines the target matrix
  84835. */
  84836. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  84837. /**
  84838. * Creates a rotation matrix
  84839. * @param yaw defines the yaw angle in radians (Y axis)
  84840. * @param pitch defines the pitch angle in radians (X axis)
  84841. * @param roll defines the roll angle in radians (Z axis)
  84842. * @returns the new rotation matrix
  84843. */
  84844. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  84845. /**
  84846. * Creates a rotation matrix and stores it in a given matrix
  84847. * @param yaw defines the yaw angle in radians (Y axis)
  84848. * @param pitch defines the pitch angle in radians (X axis)
  84849. * @param roll defines the roll angle in radians (Z axis)
  84850. * @param result defines the target matrix
  84851. */
  84852. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  84853. /**
  84854. * Creates a scaling matrix
  84855. * @param x defines the scale factor on X axis
  84856. * @param y defines the scale factor on Y axis
  84857. * @param z defines the scale factor on Z axis
  84858. * @returns the new matrix
  84859. */
  84860. static Scaling(x: number, y: number, z: number): Matrix;
  84861. /**
  84862. * Creates a scaling matrix and stores it in a given matrix
  84863. * @param x defines the scale factor on X axis
  84864. * @param y defines the scale factor on Y axis
  84865. * @param z defines the scale factor on Z axis
  84866. * @param result defines the target matrix
  84867. */
  84868. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  84869. /**
  84870. * Creates a translation matrix
  84871. * @param x defines the translation on X axis
  84872. * @param y defines the translation on Y axis
  84873. * @param z defines the translationon Z axis
  84874. * @returns the new matrix
  84875. */
  84876. static Translation(x: number, y: number, z: number): Matrix;
  84877. /**
  84878. * Creates a translation matrix and stores it in a given matrix
  84879. * @param x defines the translation on X axis
  84880. * @param y defines the translation on Y axis
  84881. * @param z defines the translationon Z axis
  84882. * @param result defines the target matrix
  84883. */
  84884. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  84885. /**
  84886. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84887. * @param startValue defines the start value
  84888. * @param endValue defines the end value
  84889. * @param gradient defines the gradient factor
  84890. * @returns the new matrix
  84891. */
  84892. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84893. /**
  84894. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84895. * @param startValue defines the start value
  84896. * @param endValue defines the end value
  84897. * @param gradient defines the gradient factor
  84898. * @param result defines the Matrix object where to store data
  84899. */
  84900. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84901. /**
  84902. * Builds a new matrix whose values are computed by:
  84903. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84904. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84905. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84906. * @param startValue defines the first matrix
  84907. * @param endValue defines the second matrix
  84908. * @param gradient defines the gradient between the two matrices
  84909. * @returns the new matrix
  84910. */
  84911. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84912. /**
  84913. * Update a matrix to values which are computed by:
  84914. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84915. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84916. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84917. * @param startValue defines the first matrix
  84918. * @param endValue defines the second matrix
  84919. * @param gradient defines the gradient between the two matrices
  84920. * @param result defines the target matrix
  84921. */
  84922. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84923. /**
  84924. * 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"
  84925. * This function works in left handed mode
  84926. * @param eye defines the final position of the entity
  84927. * @param target defines where the entity should look at
  84928. * @param up defines the up vector for the entity
  84929. * @returns the new matrix
  84930. */
  84931. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84932. /**
  84933. * 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".
  84934. * This function works in left handed mode
  84935. * @param eye defines the final position of the entity
  84936. * @param target defines where the entity should look at
  84937. * @param up defines the up vector for the entity
  84938. * @param result defines the target matrix
  84939. */
  84940. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84941. /**
  84942. * 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"
  84943. * This function works in right handed mode
  84944. * @param eye defines the final position of the entity
  84945. * @param target defines where the entity should look at
  84946. * @param up defines the up vector for the entity
  84947. * @returns the new matrix
  84948. */
  84949. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84950. /**
  84951. * 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".
  84952. * This function works in right handed mode
  84953. * @param eye defines the final position of the entity
  84954. * @param target defines where the entity should look at
  84955. * @param up defines the up vector for the entity
  84956. * @param result defines the target matrix
  84957. */
  84958. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84959. /**
  84960. * Create a left-handed orthographic projection matrix
  84961. * @param width defines the viewport width
  84962. * @param height defines the viewport height
  84963. * @param znear defines the near clip plane
  84964. * @param zfar defines the far clip plane
  84965. * @returns a new matrix as a left-handed orthographic projection matrix
  84966. */
  84967. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84968. /**
  84969. * Store a left-handed orthographic projection to a given matrix
  84970. * @param width defines the viewport width
  84971. * @param height defines the viewport height
  84972. * @param znear defines the near clip plane
  84973. * @param zfar defines the far clip plane
  84974. * @param result defines the target matrix
  84975. */
  84976. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  84977. /**
  84978. * Create a left-handed orthographic projection matrix
  84979. * @param left defines the viewport left coordinate
  84980. * @param right defines the viewport right coordinate
  84981. * @param bottom defines the viewport bottom coordinate
  84982. * @param top defines the viewport top coordinate
  84983. * @param znear defines the near clip plane
  84984. * @param zfar defines the far clip plane
  84985. * @returns a new matrix as a left-handed orthographic projection matrix
  84986. */
  84987. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84988. /**
  84989. * Stores a left-handed orthographic projection into a given matrix
  84990. * @param left defines the viewport left coordinate
  84991. * @param right defines the viewport right coordinate
  84992. * @param bottom defines the viewport bottom coordinate
  84993. * @param top defines the viewport top coordinate
  84994. * @param znear defines the near clip plane
  84995. * @param zfar defines the far clip plane
  84996. * @param result defines the target matrix
  84997. */
  84998. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84999. /**
  85000. * Creates a right-handed orthographic projection matrix
  85001. * @param left defines the viewport left coordinate
  85002. * @param right defines the viewport right coordinate
  85003. * @param bottom defines the viewport bottom coordinate
  85004. * @param top defines the viewport top coordinate
  85005. * @param znear defines the near clip plane
  85006. * @param zfar defines the far clip plane
  85007. * @returns a new matrix as a right-handed orthographic projection matrix
  85008. */
  85009. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85010. /**
  85011. * Stores a right-handed orthographic projection into a given matrix
  85012. * @param left defines the viewport left coordinate
  85013. * @param right defines the viewport right coordinate
  85014. * @param bottom defines the viewport bottom coordinate
  85015. * @param top defines the viewport top coordinate
  85016. * @param znear defines the near clip plane
  85017. * @param zfar defines the far clip plane
  85018. * @param result defines the target matrix
  85019. */
  85020. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85021. /**
  85022. * Creates a left-handed perspective projection matrix
  85023. * @param width defines the viewport width
  85024. * @param height defines the viewport height
  85025. * @param znear defines the near clip plane
  85026. * @param zfar defines the far clip plane
  85027. * @returns a new matrix as a left-handed perspective projection matrix
  85028. */
  85029. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85030. /**
  85031. * Creates a left-handed perspective projection matrix
  85032. * @param fov defines the horizontal field of view
  85033. * @param aspect defines the aspect ratio
  85034. * @param znear defines the near clip plane
  85035. * @param zfar defines the far clip plane
  85036. * @returns a new matrix as a left-handed perspective projection matrix
  85037. */
  85038. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85039. /**
  85040. * Stores a left-handed perspective projection into a given matrix
  85041. * @param fov defines the horizontal field of view
  85042. * @param aspect defines the aspect ratio
  85043. * @param znear defines the near clip plane
  85044. * @param zfar defines the far clip plane
  85045. * @param result defines the target matrix
  85046. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85047. */
  85048. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85049. /**
  85050. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85051. * @param fov defines the horizontal field of view
  85052. * @param aspect defines the aspect ratio
  85053. * @param znear defines the near clip plane
  85054. * @param zfar not used as infinity is used as far clip
  85055. * @param result defines the target matrix
  85056. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85057. */
  85058. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85059. /**
  85060. * Creates a right-handed perspective projection matrix
  85061. * @param fov defines the horizontal field of view
  85062. * @param aspect defines the aspect ratio
  85063. * @param znear defines the near clip plane
  85064. * @param zfar defines the far clip plane
  85065. * @returns a new matrix as a right-handed perspective projection matrix
  85066. */
  85067. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85068. /**
  85069. * Stores a right-handed perspective projection into a given matrix
  85070. * @param fov defines the horizontal field of view
  85071. * @param aspect defines the aspect ratio
  85072. * @param znear defines the near clip plane
  85073. * @param zfar defines the far clip plane
  85074. * @param result defines the target matrix
  85075. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85076. */
  85077. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85078. /**
  85079. * Stores a right-handed perspective projection into a given matrix
  85080. * @param fov defines the horizontal field of view
  85081. * @param aspect defines the aspect ratio
  85082. * @param znear defines the near clip plane
  85083. * @param zfar not used as infinity is used as far clip
  85084. * @param result defines the target matrix
  85085. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85086. */
  85087. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85088. /**
  85089. * Stores a perspective projection for WebVR info a given matrix
  85090. * @param fov defines the field of view
  85091. * @param znear defines the near clip plane
  85092. * @param zfar defines the far clip plane
  85093. * @param result defines the target matrix
  85094. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85095. */
  85096. static PerspectiveFovWebVRToRef(fov: {
  85097. upDegrees: number;
  85098. downDegrees: number;
  85099. leftDegrees: number;
  85100. rightDegrees: number;
  85101. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85102. /**
  85103. * Computes a complete transformation matrix
  85104. * @param viewport defines the viewport to use
  85105. * @param world defines the world matrix
  85106. * @param view defines the view matrix
  85107. * @param projection defines the projection matrix
  85108. * @param zmin defines the near clip plane
  85109. * @param zmax defines the far clip plane
  85110. * @returns the transformation matrix
  85111. */
  85112. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85113. /**
  85114. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85115. * @param matrix defines the matrix to use
  85116. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85117. */
  85118. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85119. /**
  85120. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85121. * @param matrix defines the matrix to use
  85122. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85123. */
  85124. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85125. /**
  85126. * Compute the transpose of a given matrix
  85127. * @param matrix defines the matrix to transpose
  85128. * @returns the new matrix
  85129. */
  85130. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85131. /**
  85132. * Compute the transpose of a matrix and store it in a target matrix
  85133. * @param matrix defines the matrix to transpose
  85134. * @param result defines the target matrix
  85135. */
  85136. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85137. /**
  85138. * Computes a reflection matrix from a plane
  85139. * @param plane defines the reflection plane
  85140. * @returns a new matrix
  85141. */
  85142. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85143. /**
  85144. * Computes a reflection matrix from a plane
  85145. * @param plane defines the reflection plane
  85146. * @param result defines the target matrix
  85147. */
  85148. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  85149. /**
  85150. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  85151. * @param xaxis defines the value of the 1st axis
  85152. * @param yaxis defines the value of the 2nd axis
  85153. * @param zaxis defines the value of the 3rd axis
  85154. * @param result defines the target matrix
  85155. */
  85156. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  85157. /**
  85158. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  85159. * @param quat defines the quaternion to use
  85160. * @param result defines the target matrix
  85161. */
  85162. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  85163. }
  85164. /**
  85165. * @hidden
  85166. */
  85167. export class TmpVectors {
  85168. static Vector2: Vector2[];
  85169. static Vector3: Vector3[];
  85170. static Vector4: Vector4[];
  85171. static Quaternion: Quaternion[];
  85172. static Matrix: Matrix[];
  85173. }
  85174. }
  85175. declare module BABYLON {
  85176. /**
  85177. * Defines potential orientation for back face culling
  85178. */
  85179. export enum Orientation {
  85180. /**
  85181. * Clockwise
  85182. */
  85183. CW = 0,
  85184. /** Counter clockwise */
  85185. CCW = 1
  85186. }
  85187. /** Class used to represent a Bezier curve */
  85188. export class BezierCurve {
  85189. /**
  85190. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  85191. * @param t defines the time
  85192. * @param x1 defines the left coordinate on X axis
  85193. * @param y1 defines the left coordinate on Y axis
  85194. * @param x2 defines the right coordinate on X axis
  85195. * @param y2 defines the right coordinate on Y axis
  85196. * @returns the interpolated value
  85197. */
  85198. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  85199. }
  85200. /**
  85201. * Defines angle representation
  85202. */
  85203. export class Angle {
  85204. private _radians;
  85205. /**
  85206. * Creates an Angle object of "radians" radians (float).
  85207. * @param radians the angle in radians
  85208. */
  85209. constructor(radians: number);
  85210. /**
  85211. * Get value in degrees
  85212. * @returns the Angle value in degrees (float)
  85213. */
  85214. degrees(): number;
  85215. /**
  85216. * Get value in radians
  85217. * @returns the Angle value in radians (float)
  85218. */
  85219. radians(): number;
  85220. /**
  85221. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  85222. * @param a defines first point as the origin
  85223. * @param b defines point
  85224. * @returns a new Angle
  85225. */
  85226. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  85227. /**
  85228. * Gets a new Angle object from the given float in radians
  85229. * @param radians defines the angle value in radians
  85230. * @returns a new Angle
  85231. */
  85232. static FromRadians(radians: number): Angle;
  85233. /**
  85234. * Gets a new Angle object from the given float in degrees
  85235. * @param degrees defines the angle value in degrees
  85236. * @returns a new Angle
  85237. */
  85238. static FromDegrees(degrees: number): Angle;
  85239. }
  85240. /**
  85241. * This represents an arc in a 2d space.
  85242. */
  85243. export class Arc2 {
  85244. /** Defines the start point of the arc */
  85245. startPoint: Vector2;
  85246. /** Defines the mid point of the arc */
  85247. midPoint: Vector2;
  85248. /** Defines the end point of the arc */
  85249. endPoint: Vector2;
  85250. /**
  85251. * Defines the center point of the arc.
  85252. */
  85253. centerPoint: Vector2;
  85254. /**
  85255. * Defines the radius of the arc.
  85256. */
  85257. radius: number;
  85258. /**
  85259. * Defines the angle of the arc (from mid point to end point).
  85260. */
  85261. angle: Angle;
  85262. /**
  85263. * Defines the start angle of the arc (from start point to middle point).
  85264. */
  85265. startAngle: Angle;
  85266. /**
  85267. * Defines the orientation of the arc (clock wise/counter clock wise).
  85268. */
  85269. orientation: Orientation;
  85270. /**
  85271. * Creates an Arc object from the three given points : start, middle and end.
  85272. * @param startPoint Defines the start point of the arc
  85273. * @param midPoint Defines the midlle point of the arc
  85274. * @param endPoint Defines the end point of the arc
  85275. */
  85276. constructor(
  85277. /** Defines the start point of the arc */
  85278. startPoint: Vector2,
  85279. /** Defines the mid point of the arc */
  85280. midPoint: Vector2,
  85281. /** Defines the end point of the arc */
  85282. endPoint: Vector2);
  85283. }
  85284. /**
  85285. * Represents a 2D path made up of multiple 2D points
  85286. */
  85287. export class Path2 {
  85288. private _points;
  85289. private _length;
  85290. /**
  85291. * If the path start and end point are the same
  85292. */
  85293. closed: boolean;
  85294. /**
  85295. * Creates a Path2 object from the starting 2D coordinates x and y.
  85296. * @param x the starting points x value
  85297. * @param y the starting points y value
  85298. */
  85299. constructor(x: number, y: number);
  85300. /**
  85301. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  85302. * @param x the added points x value
  85303. * @param y the added points y value
  85304. * @returns the updated Path2.
  85305. */
  85306. addLineTo(x: number, y: number): Path2;
  85307. /**
  85308. * 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.
  85309. * @param midX middle point x value
  85310. * @param midY middle point y value
  85311. * @param endX end point x value
  85312. * @param endY end point y value
  85313. * @param numberOfSegments (default: 36)
  85314. * @returns the updated Path2.
  85315. */
  85316. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  85317. /**
  85318. * Closes the Path2.
  85319. * @returns the Path2.
  85320. */
  85321. close(): Path2;
  85322. /**
  85323. * Gets the sum of the distance between each sequential point in the path
  85324. * @returns the Path2 total length (float).
  85325. */
  85326. length(): number;
  85327. /**
  85328. * Gets the points which construct the path
  85329. * @returns the Path2 internal array of points.
  85330. */
  85331. getPoints(): Vector2[];
  85332. /**
  85333. * Retreives the point at the distance aways from the starting point
  85334. * @param normalizedLengthPosition the length along the path to retreive the point from
  85335. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  85336. */
  85337. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  85338. /**
  85339. * Creates a new path starting from an x and y position
  85340. * @param x starting x value
  85341. * @param y starting y value
  85342. * @returns a new Path2 starting at the coordinates (x, y).
  85343. */
  85344. static StartingAt(x: number, y: number): Path2;
  85345. }
  85346. /**
  85347. * Represents a 3D path made up of multiple 3D points
  85348. */
  85349. export class Path3D {
  85350. /**
  85351. * an array of Vector3, the curve axis of the Path3D
  85352. */
  85353. path: Vector3[];
  85354. private _curve;
  85355. private _distances;
  85356. private _tangents;
  85357. private _normals;
  85358. private _binormals;
  85359. private _raw;
  85360. private _alignTangentsWithPath;
  85361. private readonly _pointAtData;
  85362. /**
  85363. * new Path3D(path, normal, raw)
  85364. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  85365. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  85366. * @param path an array of Vector3, the curve axis of the Path3D
  85367. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  85368. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  85369. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  85370. */
  85371. constructor(
  85372. /**
  85373. * an array of Vector3, the curve axis of the Path3D
  85374. */
  85375. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  85376. /**
  85377. * Returns the Path3D array of successive Vector3 designing its curve.
  85378. * @returns the Path3D array of successive Vector3 designing its curve.
  85379. */
  85380. getCurve(): Vector3[];
  85381. /**
  85382. * Returns the Path3D array of successive Vector3 designing its curve.
  85383. * @returns the Path3D array of successive Vector3 designing its curve.
  85384. */
  85385. getPoints(): Vector3[];
  85386. /**
  85387. * @returns the computed length (float) of the path.
  85388. */
  85389. length(): number;
  85390. /**
  85391. * Returns an array populated with tangent vectors on each Path3D curve point.
  85392. * @returns an array populated with tangent vectors on each Path3D curve point.
  85393. */
  85394. getTangents(): Vector3[];
  85395. /**
  85396. * Returns an array populated with normal vectors on each Path3D curve point.
  85397. * @returns an array populated with normal vectors on each Path3D curve point.
  85398. */
  85399. getNormals(): Vector3[];
  85400. /**
  85401. * Returns an array populated with binormal vectors on each Path3D curve point.
  85402. * @returns an array populated with binormal vectors on each Path3D curve point.
  85403. */
  85404. getBinormals(): Vector3[];
  85405. /**
  85406. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  85407. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  85408. */
  85409. getDistances(): number[];
  85410. /**
  85411. * Returns an interpolated point along this path
  85412. * @param position the position of the point along this path, from 0.0 to 1.0
  85413. * @returns a new Vector3 as the point
  85414. */
  85415. getPointAt(position: number): Vector3;
  85416. /**
  85417. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85418. * @param position the position of the point along this path, from 0.0 to 1.0
  85419. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  85420. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  85421. */
  85422. getTangentAt(position: number, interpolated?: boolean): Vector3;
  85423. /**
  85424. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85425. * @param position the position of the point along this path, from 0.0 to 1.0
  85426. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  85427. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  85428. */
  85429. getNormalAt(position: number, interpolated?: boolean): Vector3;
  85430. /**
  85431. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  85432. * @param position the position of the point along this path, from 0.0 to 1.0
  85433. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  85434. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  85435. */
  85436. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  85437. /**
  85438. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  85439. * @param position the position of the point along this path, from 0.0 to 1.0
  85440. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  85441. */
  85442. getDistanceAt(position: number): number;
  85443. /**
  85444. * Returns the array index of the previous point of an interpolated point along this path
  85445. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85446. * @returns the array index
  85447. */
  85448. getPreviousPointIndexAt(position: number): number;
  85449. /**
  85450. * 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)
  85451. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85452. * @returns the sub position
  85453. */
  85454. getSubPositionAt(position: number): number;
  85455. /**
  85456. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85457. * @param target the vector of which to get the closest position to
  85458. * @returns the position of the closest virtual point on this path to the target vector
  85459. */
  85460. getClosestPositionTo(target: Vector3): number;
  85461. /**
  85462. * Returns a sub path (slice) of this path
  85463. * @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
  85464. * @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
  85465. * @returns a sub path (slice) of this path
  85466. */
  85467. slice(start?: number, end?: number): Path3D;
  85468. /**
  85469. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  85470. * @param path path which all values are copied into the curves points
  85471. * @param firstNormal which should be projected onto the curve
  85472. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  85473. * @returns the same object updated.
  85474. */
  85475. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  85476. private _compute;
  85477. private _getFirstNonNullVector;
  85478. private _getLastNonNullVector;
  85479. private _normalVector;
  85480. /**
  85481. * Updates the point at data for an interpolated point along this curve
  85482. * @param position the position of the point along this curve, from 0.0 to 1.0
  85483. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85484. * @returns the (updated) point at data
  85485. */
  85486. private _updatePointAtData;
  85487. /**
  85488. * Updates the point at data from the specified parameters
  85489. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85490. * @param point the interpolated point
  85491. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85492. */
  85493. private _setPointAtData;
  85494. /**
  85495. * Updates the point at interpolation matrix for the tangents, normals and binormals
  85496. */
  85497. private _updateInterpolationMatrix;
  85498. }
  85499. /**
  85500. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85501. * A Curve3 is designed from a series of successive Vector3.
  85502. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  85503. */
  85504. export class Curve3 {
  85505. private _points;
  85506. private _length;
  85507. /**
  85508. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  85509. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  85510. * @param v1 (Vector3) the control point
  85511. * @param v2 (Vector3) the end point of the Quadratic Bezier
  85512. * @param nbPoints (integer) the wanted number of points in the curve
  85513. * @returns the created Curve3
  85514. */
  85515. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85516. /**
  85517. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  85518. * @param v0 (Vector3) the origin point of the Cubic Bezier
  85519. * @param v1 (Vector3) the first control point
  85520. * @param v2 (Vector3) the second control point
  85521. * @param v3 (Vector3) the end point of the Cubic Bezier
  85522. * @param nbPoints (integer) the wanted number of points in the curve
  85523. * @returns the created Curve3
  85524. */
  85525. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85526. /**
  85527. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  85528. * @param p1 (Vector3) the origin point of the Hermite Spline
  85529. * @param t1 (Vector3) the tangent vector at the origin point
  85530. * @param p2 (Vector3) the end point of the Hermite Spline
  85531. * @param t2 (Vector3) the tangent vector at the end point
  85532. * @param nbPoints (integer) the wanted number of points in the curve
  85533. * @returns the created Curve3
  85534. */
  85535. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85536. /**
  85537. * Returns a Curve3 object along a CatmullRom Spline curve :
  85538. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  85539. * @param nbPoints (integer) the wanted number of points between each curve control points
  85540. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  85541. * @returns the created Curve3
  85542. */
  85543. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  85544. /**
  85545. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85546. * A Curve3 is designed from a series of successive Vector3.
  85547. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  85548. * @param points points which make up the curve
  85549. */
  85550. constructor(points: Vector3[]);
  85551. /**
  85552. * @returns the Curve3 stored array of successive Vector3
  85553. */
  85554. getPoints(): Vector3[];
  85555. /**
  85556. * @returns the computed length (float) of the curve.
  85557. */
  85558. length(): number;
  85559. /**
  85560. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  85561. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  85562. * curveA and curveB keep unchanged.
  85563. * @param curve the curve to continue from this curve
  85564. * @returns the newly constructed curve
  85565. */
  85566. continue(curve: DeepImmutable<Curve3>): Curve3;
  85567. private _computeLength;
  85568. }
  85569. }
  85570. declare module BABYLON {
  85571. /**
  85572. * This represents the main contract an easing function should follow.
  85573. * Easing functions are used throughout the animation system.
  85574. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85575. */
  85576. export interface IEasingFunction {
  85577. /**
  85578. * Given an input gradient between 0 and 1, this returns the corrseponding value
  85579. * of the easing function.
  85580. * The link below provides some of the most common examples of easing functions.
  85581. * @see https://easings.net/
  85582. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85583. * @returns the corresponding value on the curve defined by the easing function
  85584. */
  85585. ease(gradient: number): number;
  85586. }
  85587. /**
  85588. * Base class used for every default easing function.
  85589. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85590. */
  85591. export class EasingFunction implements IEasingFunction {
  85592. /**
  85593. * Interpolation follows the mathematical formula associated with the easing function.
  85594. */
  85595. static readonly EASINGMODE_EASEIN: number;
  85596. /**
  85597. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  85598. */
  85599. static readonly EASINGMODE_EASEOUT: number;
  85600. /**
  85601. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  85602. */
  85603. static readonly EASINGMODE_EASEINOUT: number;
  85604. private _easingMode;
  85605. /**
  85606. * Sets the easing mode of the current function.
  85607. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  85608. */
  85609. setEasingMode(easingMode: number): void;
  85610. /**
  85611. * Gets the current easing mode.
  85612. * @returns the easing mode
  85613. */
  85614. getEasingMode(): number;
  85615. /**
  85616. * @hidden
  85617. */
  85618. easeInCore(gradient: number): number;
  85619. /**
  85620. * Given an input gradient between 0 and 1, this returns the corresponding value
  85621. * of the easing function.
  85622. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85623. * @returns the corresponding value on the curve defined by the easing function
  85624. */
  85625. ease(gradient: number): number;
  85626. }
  85627. /**
  85628. * Easing function with a circle shape (see link below).
  85629. * @see https://easings.net/#easeInCirc
  85630. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85631. */
  85632. export class CircleEase extends EasingFunction implements IEasingFunction {
  85633. /** @hidden */
  85634. easeInCore(gradient: number): number;
  85635. }
  85636. /**
  85637. * Easing function with a ease back shape (see link below).
  85638. * @see https://easings.net/#easeInBack
  85639. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85640. */
  85641. export class BackEase extends EasingFunction implements IEasingFunction {
  85642. /** Defines the amplitude of the function */
  85643. amplitude: number;
  85644. /**
  85645. * Instantiates a back ease easing
  85646. * @see https://easings.net/#easeInBack
  85647. * @param amplitude Defines the amplitude of the function
  85648. */
  85649. constructor(
  85650. /** Defines the amplitude of the function */
  85651. amplitude?: number);
  85652. /** @hidden */
  85653. easeInCore(gradient: number): number;
  85654. }
  85655. /**
  85656. * Easing function with a bouncing shape (see link below).
  85657. * @see https://easings.net/#easeInBounce
  85658. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85659. */
  85660. export class BounceEase extends EasingFunction implements IEasingFunction {
  85661. /** Defines the number of bounces */
  85662. bounces: number;
  85663. /** Defines the amplitude of the bounce */
  85664. bounciness: number;
  85665. /**
  85666. * Instantiates a bounce easing
  85667. * @see https://easings.net/#easeInBounce
  85668. * @param bounces Defines the number of bounces
  85669. * @param bounciness Defines the amplitude of the bounce
  85670. */
  85671. constructor(
  85672. /** Defines the number of bounces */
  85673. bounces?: number,
  85674. /** Defines the amplitude of the bounce */
  85675. bounciness?: number);
  85676. /** @hidden */
  85677. easeInCore(gradient: number): number;
  85678. }
  85679. /**
  85680. * Easing function with a power of 3 shape (see link below).
  85681. * @see https://easings.net/#easeInCubic
  85682. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85683. */
  85684. export class CubicEase extends EasingFunction implements IEasingFunction {
  85685. /** @hidden */
  85686. easeInCore(gradient: number): number;
  85687. }
  85688. /**
  85689. * Easing function with an elastic shape (see link below).
  85690. * @see https://easings.net/#easeInElastic
  85691. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85692. */
  85693. export class ElasticEase extends EasingFunction implements IEasingFunction {
  85694. /** Defines the number of oscillations*/
  85695. oscillations: number;
  85696. /** Defines the amplitude of the oscillations*/
  85697. springiness: number;
  85698. /**
  85699. * Instantiates an elastic easing function
  85700. * @see https://easings.net/#easeInElastic
  85701. * @param oscillations Defines the number of oscillations
  85702. * @param springiness Defines the amplitude of the oscillations
  85703. */
  85704. constructor(
  85705. /** Defines the number of oscillations*/
  85706. oscillations?: number,
  85707. /** Defines the amplitude of the oscillations*/
  85708. springiness?: number);
  85709. /** @hidden */
  85710. easeInCore(gradient: number): number;
  85711. }
  85712. /**
  85713. * Easing function with an exponential shape (see link below).
  85714. * @see https://easings.net/#easeInExpo
  85715. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85716. */
  85717. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  85718. /** Defines the exponent of the function */
  85719. exponent: number;
  85720. /**
  85721. * Instantiates an exponential easing function
  85722. * @see https://easings.net/#easeInExpo
  85723. * @param exponent Defines the exponent of the function
  85724. */
  85725. constructor(
  85726. /** Defines the exponent of the function */
  85727. exponent?: number);
  85728. /** @hidden */
  85729. easeInCore(gradient: number): number;
  85730. }
  85731. /**
  85732. * Easing function with a power shape (see link below).
  85733. * @see https://easings.net/#easeInQuad
  85734. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85735. */
  85736. export class PowerEase extends EasingFunction implements IEasingFunction {
  85737. /** Defines the power of the function */
  85738. power: number;
  85739. /**
  85740. * Instantiates an power base easing function
  85741. * @see https://easings.net/#easeInQuad
  85742. * @param power Defines the power of the function
  85743. */
  85744. constructor(
  85745. /** Defines the power of the function */
  85746. power?: number);
  85747. /** @hidden */
  85748. easeInCore(gradient: number): number;
  85749. }
  85750. /**
  85751. * Easing function with a power of 2 shape (see link below).
  85752. * @see https://easings.net/#easeInQuad
  85753. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85754. */
  85755. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  85756. /** @hidden */
  85757. easeInCore(gradient: number): number;
  85758. }
  85759. /**
  85760. * Easing function with a power of 4 shape (see link below).
  85761. * @see https://easings.net/#easeInQuart
  85762. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85763. */
  85764. export class QuarticEase extends EasingFunction implements IEasingFunction {
  85765. /** @hidden */
  85766. easeInCore(gradient: number): number;
  85767. }
  85768. /**
  85769. * Easing function with a power of 5 shape (see link below).
  85770. * @see https://easings.net/#easeInQuint
  85771. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85772. */
  85773. export class QuinticEase extends EasingFunction implements IEasingFunction {
  85774. /** @hidden */
  85775. easeInCore(gradient: number): number;
  85776. }
  85777. /**
  85778. * Easing function with a sin shape (see link below).
  85779. * @see https://easings.net/#easeInSine
  85780. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85781. */
  85782. export class SineEase extends EasingFunction implements IEasingFunction {
  85783. /** @hidden */
  85784. easeInCore(gradient: number): number;
  85785. }
  85786. /**
  85787. * Easing function with a bezier shape (see link below).
  85788. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85789. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85790. */
  85791. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  85792. /** Defines the x component of the start tangent in the bezier curve */
  85793. x1: number;
  85794. /** Defines the y component of the start tangent in the bezier curve */
  85795. y1: number;
  85796. /** Defines the x component of the end tangent in the bezier curve */
  85797. x2: number;
  85798. /** Defines the y component of the end tangent in the bezier curve */
  85799. y2: number;
  85800. /**
  85801. * Instantiates a bezier function
  85802. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85803. * @param x1 Defines the x component of the start tangent in the bezier curve
  85804. * @param y1 Defines the y component of the start tangent in the bezier curve
  85805. * @param x2 Defines the x component of the end tangent in the bezier curve
  85806. * @param y2 Defines the y component of the end tangent in the bezier curve
  85807. */
  85808. constructor(
  85809. /** Defines the x component of the start tangent in the bezier curve */
  85810. x1?: number,
  85811. /** Defines the y component of the start tangent in the bezier curve */
  85812. y1?: number,
  85813. /** Defines the x component of the end tangent in the bezier curve */
  85814. x2?: number,
  85815. /** Defines the y component of the end tangent in the bezier curve */
  85816. y2?: number);
  85817. /** @hidden */
  85818. easeInCore(gradient: number): number;
  85819. }
  85820. }
  85821. declare module BABYLON {
  85822. /**
  85823. * Class used to hold a RBG color
  85824. */
  85825. export class Color3 {
  85826. /**
  85827. * Defines the red component (between 0 and 1, default is 0)
  85828. */
  85829. r: number;
  85830. /**
  85831. * Defines the green component (between 0 and 1, default is 0)
  85832. */
  85833. g: number;
  85834. /**
  85835. * Defines the blue component (between 0 and 1, default is 0)
  85836. */
  85837. b: number;
  85838. /**
  85839. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  85840. * @param r defines the red component (between 0 and 1, default is 0)
  85841. * @param g defines the green component (between 0 and 1, default is 0)
  85842. * @param b defines the blue component (between 0 and 1, default is 0)
  85843. */
  85844. constructor(
  85845. /**
  85846. * Defines the red component (between 0 and 1, default is 0)
  85847. */
  85848. r?: number,
  85849. /**
  85850. * Defines the green component (between 0 and 1, default is 0)
  85851. */
  85852. g?: number,
  85853. /**
  85854. * Defines the blue component (between 0 and 1, default is 0)
  85855. */
  85856. b?: number);
  85857. /**
  85858. * Creates a string with the Color3 current values
  85859. * @returns the string representation of the Color3 object
  85860. */
  85861. toString(): string;
  85862. /**
  85863. * Returns the string "Color3"
  85864. * @returns "Color3"
  85865. */
  85866. getClassName(): string;
  85867. /**
  85868. * Compute the Color3 hash code
  85869. * @returns an unique number that can be used to hash Color3 objects
  85870. */
  85871. getHashCode(): number;
  85872. /**
  85873. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  85874. * @param array defines the array where to store the r,g,b components
  85875. * @param index defines an optional index in the target array to define where to start storing values
  85876. * @returns the current Color3 object
  85877. */
  85878. toArray(array: FloatArray, index?: number): Color3;
  85879. /**
  85880. * Update the current color with values stored in an array from the starting index of the given array
  85881. * @param array defines the source array
  85882. * @param offset defines an offset in the source array
  85883. * @returns the current Color3 object
  85884. */
  85885. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85886. /**
  85887. * Returns a new Color4 object from the current Color3 and the given alpha
  85888. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  85889. * @returns a new Color4 object
  85890. */
  85891. toColor4(alpha?: number): Color4;
  85892. /**
  85893. * Returns a new array populated with 3 numeric elements : red, green and blue values
  85894. * @returns the new array
  85895. */
  85896. asArray(): number[];
  85897. /**
  85898. * Returns the luminance value
  85899. * @returns a float value
  85900. */
  85901. toLuminance(): number;
  85902. /**
  85903. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  85904. * @param otherColor defines the second operand
  85905. * @returns the new Color3 object
  85906. */
  85907. multiply(otherColor: DeepImmutable<Color3>): Color3;
  85908. /**
  85909. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  85910. * @param otherColor defines the second operand
  85911. * @param result defines the Color3 object where to store the result
  85912. * @returns the current Color3
  85913. */
  85914. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85915. /**
  85916. * Determines equality between Color3 objects
  85917. * @param otherColor defines the second operand
  85918. * @returns true if the rgb values are equal to the given ones
  85919. */
  85920. equals(otherColor: DeepImmutable<Color3>): boolean;
  85921. /**
  85922. * Determines equality between the current Color3 object and a set of r,b,g values
  85923. * @param r defines the red component to check
  85924. * @param g defines the green component to check
  85925. * @param b defines the blue component to check
  85926. * @returns true if the rgb values are equal to the given ones
  85927. */
  85928. equalsFloats(r: number, g: number, b: number): boolean;
  85929. /**
  85930. * Multiplies in place each rgb value by scale
  85931. * @param scale defines the scaling factor
  85932. * @returns the updated Color3
  85933. */
  85934. scale(scale: number): Color3;
  85935. /**
  85936. * Multiplies the rgb values by scale and stores the result into "result"
  85937. * @param scale defines the scaling factor
  85938. * @param result defines the Color3 object where to store the result
  85939. * @returns the unmodified current Color3
  85940. */
  85941. scaleToRef(scale: number, result: Color3): Color3;
  85942. /**
  85943. * Scale the current Color3 values by a factor and add the result to a given Color3
  85944. * @param scale defines the scale factor
  85945. * @param result defines color to store the result into
  85946. * @returns the unmodified current Color3
  85947. */
  85948. scaleAndAddToRef(scale: number, result: Color3): Color3;
  85949. /**
  85950. * Clamps the rgb values by the min and max values and stores the result into "result"
  85951. * @param min defines minimum clamping value (default is 0)
  85952. * @param max defines maximum clamping value (default is 1)
  85953. * @param result defines color to store the result into
  85954. * @returns the original Color3
  85955. */
  85956. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  85957. /**
  85958. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  85959. * @param otherColor defines the second operand
  85960. * @returns the new Color3
  85961. */
  85962. add(otherColor: DeepImmutable<Color3>): Color3;
  85963. /**
  85964. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  85965. * @param otherColor defines the second operand
  85966. * @param result defines Color3 object to store the result into
  85967. * @returns the unmodified current Color3
  85968. */
  85969. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85970. /**
  85971. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  85972. * @param otherColor defines the second operand
  85973. * @returns the new Color3
  85974. */
  85975. subtract(otherColor: DeepImmutable<Color3>): Color3;
  85976. /**
  85977. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  85978. * @param otherColor defines the second operand
  85979. * @param result defines Color3 object to store the result into
  85980. * @returns the unmodified current Color3
  85981. */
  85982. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85983. /**
  85984. * Copy the current object
  85985. * @returns a new Color3 copied the current one
  85986. */
  85987. clone(): Color3;
  85988. /**
  85989. * Copies the rgb values from the source in the current Color3
  85990. * @param source defines the source Color3 object
  85991. * @returns the updated Color3 object
  85992. */
  85993. copyFrom(source: DeepImmutable<Color3>): Color3;
  85994. /**
  85995. * Updates the Color3 rgb values from the given floats
  85996. * @param r defines the red component to read from
  85997. * @param g defines the green component to read from
  85998. * @param b defines the blue component to read from
  85999. * @returns the current Color3 object
  86000. */
  86001. copyFromFloats(r: number, g: number, b: number): Color3;
  86002. /**
  86003. * Updates the Color3 rgb values from the given floats
  86004. * @param r defines the red component to read from
  86005. * @param g defines the green component to read from
  86006. * @param b defines the blue component to read from
  86007. * @returns the current Color3 object
  86008. */
  86009. set(r: number, g: number, b: number): Color3;
  86010. /**
  86011. * Compute the Color3 hexadecimal code as a string
  86012. * @returns a string containing the hexadecimal representation of the Color3 object
  86013. */
  86014. toHexString(): string;
  86015. /**
  86016. * Computes a new Color3 converted from the current one to linear space
  86017. * @returns a new Color3 object
  86018. */
  86019. toLinearSpace(): Color3;
  86020. /**
  86021. * Converts current color in rgb space to HSV values
  86022. * @returns a new color3 representing the HSV values
  86023. */
  86024. toHSV(): Color3;
  86025. /**
  86026. * Converts current color in rgb space to HSV values
  86027. * @param result defines the Color3 where to store the HSV values
  86028. */
  86029. toHSVToRef(result: Color3): void;
  86030. /**
  86031. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  86032. * @param convertedColor defines the Color3 object where to store the linear space version
  86033. * @returns the unmodified Color3
  86034. */
  86035. toLinearSpaceToRef(convertedColor: Color3): Color3;
  86036. /**
  86037. * Computes a new Color3 converted from the current one to gamma space
  86038. * @returns a new Color3 object
  86039. */
  86040. toGammaSpace(): Color3;
  86041. /**
  86042. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  86043. * @param convertedColor defines the Color3 object where to store the gamma space version
  86044. * @returns the unmodified Color3
  86045. */
  86046. toGammaSpaceToRef(convertedColor: Color3): Color3;
  86047. private static _BlackReadOnly;
  86048. /**
  86049. * Convert Hue, saturation and value to a Color3 (RGB)
  86050. * @param hue defines the hue
  86051. * @param saturation defines the saturation
  86052. * @param value defines the value
  86053. * @param result defines the Color3 where to store the RGB values
  86054. */
  86055. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86056. /**
  86057. * Creates a new Color3 from the string containing valid hexadecimal values
  86058. * @param hex defines a string containing valid hexadecimal values
  86059. * @returns a new Color3 object
  86060. */
  86061. static FromHexString(hex: string): Color3;
  86062. /**
  86063. * Creates a new Color3 from the starting index of the given array
  86064. * @param array defines the source array
  86065. * @param offset defines an offset in the source array
  86066. * @returns a new Color3 object
  86067. */
  86068. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86069. /**
  86070. * Creates a new Color3 from the starting index element of the given array
  86071. * @param array defines the source array to read from
  86072. * @param offset defines the offset in the source array
  86073. * @param result defines the target Color3 object
  86074. */
  86075. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86076. /**
  86077. * Creates a new Color3 from integer values (< 256)
  86078. * @param r defines the red component to read from (value between 0 and 255)
  86079. * @param g defines the green component to read from (value between 0 and 255)
  86080. * @param b defines the blue component to read from (value between 0 and 255)
  86081. * @returns a new Color3 object
  86082. */
  86083. static FromInts(r: number, g: number, b: number): Color3;
  86084. /**
  86085. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86086. * @param start defines the start Color3 value
  86087. * @param end defines the end Color3 value
  86088. * @param amount defines the gradient value between start and end
  86089. * @returns a new Color3 object
  86090. */
  86091. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86092. /**
  86093. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86094. * @param left defines the start value
  86095. * @param right defines the end value
  86096. * @param amount defines the gradient factor
  86097. * @param result defines the Color3 object where to store the result
  86098. */
  86099. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86100. /**
  86101. * Returns a Color3 value containing a red color
  86102. * @returns a new Color3 object
  86103. */
  86104. static Red(): Color3;
  86105. /**
  86106. * Returns a Color3 value containing a green color
  86107. * @returns a new Color3 object
  86108. */
  86109. static Green(): Color3;
  86110. /**
  86111. * Returns a Color3 value containing a blue color
  86112. * @returns a new Color3 object
  86113. */
  86114. static Blue(): Color3;
  86115. /**
  86116. * Returns a Color3 value containing a black color
  86117. * @returns a new Color3 object
  86118. */
  86119. static Black(): Color3;
  86120. /**
  86121. * Gets a Color3 value containing a black color that must not be updated
  86122. */
  86123. static get BlackReadOnly(): DeepImmutable<Color3>;
  86124. /**
  86125. * Returns a Color3 value containing a white color
  86126. * @returns a new Color3 object
  86127. */
  86128. static White(): Color3;
  86129. /**
  86130. * Returns a Color3 value containing a purple color
  86131. * @returns a new Color3 object
  86132. */
  86133. static Purple(): Color3;
  86134. /**
  86135. * Returns a Color3 value containing a magenta color
  86136. * @returns a new Color3 object
  86137. */
  86138. static Magenta(): Color3;
  86139. /**
  86140. * Returns a Color3 value containing a yellow color
  86141. * @returns a new Color3 object
  86142. */
  86143. static Yellow(): Color3;
  86144. /**
  86145. * Returns a Color3 value containing a gray color
  86146. * @returns a new Color3 object
  86147. */
  86148. static Gray(): Color3;
  86149. /**
  86150. * Returns a Color3 value containing a teal color
  86151. * @returns a new Color3 object
  86152. */
  86153. static Teal(): Color3;
  86154. /**
  86155. * Returns a Color3 value containing a random color
  86156. * @returns a new Color3 object
  86157. */
  86158. static Random(): Color3;
  86159. }
  86160. /**
  86161. * Class used to hold a RBGA color
  86162. */
  86163. export class Color4 {
  86164. /**
  86165. * Defines the red component (between 0 and 1, default is 0)
  86166. */
  86167. r: number;
  86168. /**
  86169. * Defines the green component (between 0 and 1, default is 0)
  86170. */
  86171. g: number;
  86172. /**
  86173. * Defines the blue component (between 0 and 1, default is 0)
  86174. */
  86175. b: number;
  86176. /**
  86177. * Defines the alpha component (between 0 and 1, default is 1)
  86178. */
  86179. a: number;
  86180. /**
  86181. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  86182. * @param r defines the red component (between 0 and 1, default is 0)
  86183. * @param g defines the green component (between 0 and 1, default is 0)
  86184. * @param b defines the blue component (between 0 and 1, default is 0)
  86185. * @param a defines the alpha component (between 0 and 1, default is 1)
  86186. */
  86187. constructor(
  86188. /**
  86189. * Defines the red component (between 0 and 1, default is 0)
  86190. */
  86191. r?: number,
  86192. /**
  86193. * Defines the green component (between 0 and 1, default is 0)
  86194. */
  86195. g?: number,
  86196. /**
  86197. * Defines the blue component (between 0 and 1, default is 0)
  86198. */
  86199. b?: number,
  86200. /**
  86201. * Defines the alpha component (between 0 and 1, default is 1)
  86202. */
  86203. a?: number);
  86204. /**
  86205. * Adds in place the given Color4 values to the current Color4 object
  86206. * @param right defines the second operand
  86207. * @returns the current updated Color4 object
  86208. */
  86209. addInPlace(right: DeepImmutable<Color4>): Color4;
  86210. /**
  86211. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  86212. * @returns the new array
  86213. */
  86214. asArray(): number[];
  86215. /**
  86216. * Stores from the starting index in the given array the Color4 successive values
  86217. * @param array defines the array where to store the r,g,b components
  86218. * @param index defines an optional index in the target array to define where to start storing values
  86219. * @returns the current Color4 object
  86220. */
  86221. toArray(array: number[], index?: number): Color4;
  86222. /**
  86223. * Update the current color with values stored in an array from the starting index of the given array
  86224. * @param array defines the source array
  86225. * @param offset defines an offset in the source array
  86226. * @returns the current Color4 object
  86227. */
  86228. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86229. /**
  86230. * Determines equality between Color4 objects
  86231. * @param otherColor defines the second operand
  86232. * @returns true if the rgba values are equal to the given ones
  86233. */
  86234. equals(otherColor: DeepImmutable<Color4>): boolean;
  86235. /**
  86236. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  86237. * @param right defines the second operand
  86238. * @returns a new Color4 object
  86239. */
  86240. add(right: DeepImmutable<Color4>): Color4;
  86241. /**
  86242. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  86243. * @param right defines the second operand
  86244. * @returns a new Color4 object
  86245. */
  86246. subtract(right: DeepImmutable<Color4>): Color4;
  86247. /**
  86248. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  86249. * @param right defines the second operand
  86250. * @param result defines the Color4 object where to store the result
  86251. * @returns the current Color4 object
  86252. */
  86253. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  86254. /**
  86255. * Creates a new Color4 with the current Color4 values multiplied by scale
  86256. * @param scale defines the scaling factor to apply
  86257. * @returns a new Color4 object
  86258. */
  86259. scale(scale: number): Color4;
  86260. /**
  86261. * Multiplies the current Color4 values by scale and stores the result in "result"
  86262. * @param scale defines the scaling factor to apply
  86263. * @param result defines the Color4 object where to store the result
  86264. * @returns the current unmodified Color4
  86265. */
  86266. scaleToRef(scale: number, result: Color4): Color4;
  86267. /**
  86268. * Scale the current Color4 values by a factor and add the result to a given Color4
  86269. * @param scale defines the scale factor
  86270. * @param result defines the Color4 object where to store the result
  86271. * @returns the unmodified current Color4
  86272. */
  86273. scaleAndAddToRef(scale: number, result: Color4): Color4;
  86274. /**
  86275. * Clamps the rgb values by the min and max values and stores the result into "result"
  86276. * @param min defines minimum clamping value (default is 0)
  86277. * @param max defines maximum clamping value (default is 1)
  86278. * @param result defines color to store the result into.
  86279. * @returns the cuurent Color4
  86280. */
  86281. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  86282. /**
  86283. * Multipy an Color4 value by another and return a new Color4 object
  86284. * @param color defines the Color4 value to multiply by
  86285. * @returns a new Color4 object
  86286. */
  86287. multiply(color: Color4): Color4;
  86288. /**
  86289. * Multipy a Color4 value by another and push the result in a reference value
  86290. * @param color defines the Color4 value to multiply by
  86291. * @param result defines the Color4 to fill the result in
  86292. * @returns the result Color4
  86293. */
  86294. multiplyToRef(color: Color4, result: Color4): Color4;
  86295. /**
  86296. * Creates a string with the Color4 current values
  86297. * @returns the string representation of the Color4 object
  86298. */
  86299. toString(): string;
  86300. /**
  86301. * Returns the string "Color4"
  86302. * @returns "Color4"
  86303. */
  86304. getClassName(): string;
  86305. /**
  86306. * Compute the Color4 hash code
  86307. * @returns an unique number that can be used to hash Color4 objects
  86308. */
  86309. getHashCode(): number;
  86310. /**
  86311. * Creates a new Color4 copied from the current one
  86312. * @returns a new Color4 object
  86313. */
  86314. clone(): Color4;
  86315. /**
  86316. * Copies the given Color4 values into the current one
  86317. * @param source defines the source Color4 object
  86318. * @returns the current updated Color4 object
  86319. */
  86320. copyFrom(source: Color4): Color4;
  86321. /**
  86322. * Copies the given float values into the current one
  86323. * @param r defines the red component to read from
  86324. * @param g defines the green component to read from
  86325. * @param b defines the blue component to read from
  86326. * @param a defines the alpha component to read from
  86327. * @returns the current updated Color4 object
  86328. */
  86329. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  86330. /**
  86331. * Copies the given float values into the current one
  86332. * @param r defines the red component to read from
  86333. * @param g defines the green component to read from
  86334. * @param b defines the blue component to read from
  86335. * @param a defines the alpha component to read from
  86336. * @returns the current updated Color4 object
  86337. */
  86338. set(r: number, g: number, b: number, a: number): Color4;
  86339. /**
  86340. * Compute the Color4 hexadecimal code as a string
  86341. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  86342. * @returns a string containing the hexadecimal representation of the Color4 object
  86343. */
  86344. toHexString(returnAsColor3?: boolean): string;
  86345. /**
  86346. * Computes a new Color4 converted from the current one to linear space
  86347. * @returns a new Color4 object
  86348. */
  86349. toLinearSpace(): Color4;
  86350. /**
  86351. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  86352. * @param convertedColor defines the Color4 object where to store the linear space version
  86353. * @returns the unmodified Color4
  86354. */
  86355. toLinearSpaceToRef(convertedColor: Color4): Color4;
  86356. /**
  86357. * Computes a new Color4 converted from the current one to gamma space
  86358. * @returns a new Color4 object
  86359. */
  86360. toGammaSpace(): Color4;
  86361. /**
  86362. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  86363. * @param convertedColor defines the Color4 object where to store the gamma space version
  86364. * @returns the unmodified Color4
  86365. */
  86366. toGammaSpaceToRef(convertedColor: Color4): Color4;
  86367. /**
  86368. * Creates a new Color4 from the string containing valid hexadecimal values
  86369. * @param hex defines a string containing valid hexadecimal values
  86370. * @returns a new Color4 object
  86371. */
  86372. static FromHexString(hex: string): Color4;
  86373. /**
  86374. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86375. * @param left defines the start value
  86376. * @param right defines the end value
  86377. * @param amount defines the gradient factor
  86378. * @returns a new Color4 object
  86379. */
  86380. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  86381. /**
  86382. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86383. * @param left defines the start value
  86384. * @param right defines the end value
  86385. * @param amount defines the gradient factor
  86386. * @param result defines the Color4 object where to store data
  86387. */
  86388. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  86389. /**
  86390. * Creates a new Color4 from a Color3 and an alpha value
  86391. * @param color3 defines the source Color3 to read from
  86392. * @param alpha defines the alpha component (1.0 by default)
  86393. * @returns a new Color4 object
  86394. */
  86395. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  86396. /**
  86397. * Creates a new Color4 from the starting index element of the given array
  86398. * @param array defines the source array to read from
  86399. * @param offset defines the offset in the source array
  86400. * @returns a new Color4 object
  86401. */
  86402. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86403. /**
  86404. * Creates a new Color4 from the starting index element of the given array
  86405. * @param array defines the source array to read from
  86406. * @param offset defines the offset in the source array
  86407. * @param result defines the target Color4 object
  86408. */
  86409. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  86410. /**
  86411. * Creates a new Color3 from integer values (< 256)
  86412. * @param r defines the red component to read from (value between 0 and 255)
  86413. * @param g defines the green component to read from (value between 0 and 255)
  86414. * @param b defines the blue component to read from (value between 0 and 255)
  86415. * @param a defines the alpha component to read from (value between 0 and 255)
  86416. * @returns a new Color3 object
  86417. */
  86418. static FromInts(r: number, g: number, b: number, a: number): Color4;
  86419. /**
  86420. * Check the content of a given array and convert it to an array containing RGBA data
  86421. * If the original array was already containing count * 4 values then it is returned directly
  86422. * @param colors defines the array to check
  86423. * @param count defines the number of RGBA data to expect
  86424. * @returns an array containing count * 4 values (RGBA)
  86425. */
  86426. static CheckColors4(colors: number[], count: number): number[];
  86427. }
  86428. /**
  86429. * @hidden
  86430. */
  86431. export class TmpColors {
  86432. static Color3: Color3[];
  86433. static Color4: Color4[];
  86434. }
  86435. }
  86436. declare module BABYLON {
  86437. /**
  86438. * Defines an interface which represents an animation key frame
  86439. */
  86440. export interface IAnimationKey {
  86441. /**
  86442. * Frame of the key frame
  86443. */
  86444. frame: number;
  86445. /**
  86446. * Value at the specifies key frame
  86447. */
  86448. value: any;
  86449. /**
  86450. * The input tangent for the cubic hermite spline
  86451. */
  86452. inTangent?: any;
  86453. /**
  86454. * The output tangent for the cubic hermite spline
  86455. */
  86456. outTangent?: any;
  86457. /**
  86458. * The animation interpolation type
  86459. */
  86460. interpolation?: AnimationKeyInterpolation;
  86461. }
  86462. /**
  86463. * Enum for the animation key frame interpolation type
  86464. */
  86465. export enum AnimationKeyInterpolation {
  86466. /**
  86467. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  86468. */
  86469. STEP = 1
  86470. }
  86471. }
  86472. declare module BABYLON {
  86473. /**
  86474. * Represents the range of an animation
  86475. */
  86476. export class AnimationRange {
  86477. /**The name of the animation range**/
  86478. name: string;
  86479. /**The starting frame of the animation */
  86480. from: number;
  86481. /**The ending frame of the animation*/
  86482. to: number;
  86483. /**
  86484. * Initializes the range of an animation
  86485. * @param name The name of the animation range
  86486. * @param from The starting frame of the animation
  86487. * @param to The ending frame of the animation
  86488. */
  86489. constructor(
  86490. /**The name of the animation range**/
  86491. name: string,
  86492. /**The starting frame of the animation */
  86493. from: number,
  86494. /**The ending frame of the animation*/
  86495. to: number);
  86496. /**
  86497. * Makes a copy of the animation range
  86498. * @returns A copy of the animation range
  86499. */
  86500. clone(): AnimationRange;
  86501. }
  86502. }
  86503. declare module BABYLON {
  86504. /**
  86505. * Composed of a frame, and an action function
  86506. */
  86507. export class AnimationEvent {
  86508. /** The frame for which the event is triggered **/
  86509. frame: number;
  86510. /** The event to perform when triggered **/
  86511. action: (currentFrame: number) => void;
  86512. /** Specifies if the event should be triggered only once**/
  86513. onlyOnce?: boolean | undefined;
  86514. /**
  86515. * Specifies if the animation event is done
  86516. */
  86517. isDone: boolean;
  86518. /**
  86519. * Initializes the animation event
  86520. * @param frame The frame for which the event is triggered
  86521. * @param action The event to perform when triggered
  86522. * @param onlyOnce Specifies if the event should be triggered only once
  86523. */
  86524. constructor(
  86525. /** The frame for which the event is triggered **/
  86526. frame: number,
  86527. /** The event to perform when triggered **/
  86528. action: (currentFrame: number) => void,
  86529. /** Specifies if the event should be triggered only once**/
  86530. onlyOnce?: boolean | undefined);
  86531. /** @hidden */
  86532. _clone(): AnimationEvent;
  86533. }
  86534. }
  86535. declare module BABYLON {
  86536. /**
  86537. * Interface used to define a behavior
  86538. */
  86539. export interface Behavior<T> {
  86540. /** gets or sets behavior's name */
  86541. name: string;
  86542. /**
  86543. * Function called when the behavior needs to be initialized (after attaching it to a target)
  86544. */
  86545. init(): void;
  86546. /**
  86547. * Called when the behavior is attached to a target
  86548. * @param target defines the target where the behavior is attached to
  86549. */
  86550. attach(target: T): void;
  86551. /**
  86552. * Called when the behavior is detached from its target
  86553. */
  86554. detach(): void;
  86555. }
  86556. /**
  86557. * Interface implemented by classes supporting behaviors
  86558. */
  86559. export interface IBehaviorAware<T> {
  86560. /**
  86561. * Attach a behavior
  86562. * @param behavior defines the behavior to attach
  86563. * @returns the current host
  86564. */
  86565. addBehavior(behavior: Behavior<T>): T;
  86566. /**
  86567. * Remove a behavior from the current object
  86568. * @param behavior defines the behavior to detach
  86569. * @returns the current host
  86570. */
  86571. removeBehavior(behavior: Behavior<T>): T;
  86572. /**
  86573. * Gets a behavior using its name to search
  86574. * @param name defines the name to search
  86575. * @returns the behavior or null if not found
  86576. */
  86577. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  86578. }
  86579. }
  86580. declare module BABYLON {
  86581. /**
  86582. * Defines an array and its length.
  86583. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86584. */
  86585. export interface ISmartArrayLike<T> {
  86586. /**
  86587. * The data of the array.
  86588. */
  86589. data: Array<T>;
  86590. /**
  86591. * The active length of the array.
  86592. */
  86593. length: number;
  86594. }
  86595. /**
  86596. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86597. */
  86598. export class SmartArray<T> implements ISmartArrayLike<T> {
  86599. /**
  86600. * The full set of data from the array.
  86601. */
  86602. data: Array<T>;
  86603. /**
  86604. * The active length of the array.
  86605. */
  86606. length: number;
  86607. protected _id: number;
  86608. /**
  86609. * Instantiates a Smart Array.
  86610. * @param capacity defines the default capacity of the array.
  86611. */
  86612. constructor(capacity: number);
  86613. /**
  86614. * Pushes a value at the end of the active data.
  86615. * @param value defines the object to push in the array.
  86616. */
  86617. push(value: T): void;
  86618. /**
  86619. * Iterates over the active data and apply the lambda to them.
  86620. * @param func defines the action to apply on each value.
  86621. */
  86622. forEach(func: (content: T) => void): void;
  86623. /**
  86624. * Sorts the full sets of data.
  86625. * @param compareFn defines the comparison function to apply.
  86626. */
  86627. sort(compareFn: (a: T, b: T) => number): void;
  86628. /**
  86629. * Resets the active data to an empty array.
  86630. */
  86631. reset(): void;
  86632. /**
  86633. * Releases all the data from the array as well as the array.
  86634. */
  86635. dispose(): void;
  86636. /**
  86637. * Concats the active data with a given array.
  86638. * @param array defines the data to concatenate with.
  86639. */
  86640. concat(array: any): void;
  86641. /**
  86642. * Returns the position of a value in the active data.
  86643. * @param value defines the value to find the index for
  86644. * @returns the index if found in the active data otherwise -1
  86645. */
  86646. indexOf(value: T): number;
  86647. /**
  86648. * Returns whether an element is part of the active data.
  86649. * @param value defines the value to look for
  86650. * @returns true if found in the active data otherwise false
  86651. */
  86652. contains(value: T): boolean;
  86653. private static _GlobalId;
  86654. }
  86655. /**
  86656. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86657. * The data in this array can only be present once
  86658. */
  86659. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  86660. private _duplicateId;
  86661. /**
  86662. * Pushes a value at the end of the active data.
  86663. * THIS DOES NOT PREVENT DUPPLICATE DATA
  86664. * @param value defines the object to push in the array.
  86665. */
  86666. push(value: T): void;
  86667. /**
  86668. * Pushes a value at the end of the active data.
  86669. * If the data is already present, it won t be added again
  86670. * @param value defines the object to push in the array.
  86671. * @returns true if added false if it was already present
  86672. */
  86673. pushNoDuplicate(value: T): boolean;
  86674. /**
  86675. * Resets the active data to an empty array.
  86676. */
  86677. reset(): void;
  86678. /**
  86679. * Concats the active data with a given array.
  86680. * This ensures no dupplicate will be present in the result.
  86681. * @param array defines the data to concatenate with.
  86682. */
  86683. concatWithNoDuplicate(array: any): void;
  86684. }
  86685. }
  86686. declare module BABYLON {
  86687. /**
  86688. * @ignore
  86689. * This is a list of all the different input types that are available in the application.
  86690. * Fo instance: ArcRotateCameraGamepadInput...
  86691. */
  86692. export var CameraInputTypes: {};
  86693. /**
  86694. * This is the contract to implement in order to create a new input class.
  86695. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  86696. */
  86697. export interface ICameraInput<TCamera extends Camera> {
  86698. /**
  86699. * Defines the camera the input is attached to.
  86700. */
  86701. camera: Nullable<TCamera>;
  86702. /**
  86703. * Gets the class name of the current intput.
  86704. * @returns the class name
  86705. */
  86706. getClassName(): string;
  86707. /**
  86708. * Get the friendly name associated with the input class.
  86709. * @returns the input friendly name
  86710. */
  86711. getSimpleName(): string;
  86712. /**
  86713. * Attach the input controls to a specific dom element to get the input from.
  86714. * @param element Defines the element the controls should be listened from
  86715. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86716. */
  86717. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86718. /**
  86719. * Detach the current controls from the specified dom element.
  86720. * @param element Defines the element to stop listening the inputs from
  86721. */
  86722. detachControl(element: Nullable<HTMLElement>): void;
  86723. /**
  86724. * Update the current camera state depending on the inputs that have been used this frame.
  86725. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86726. */
  86727. checkInputs?: () => void;
  86728. }
  86729. /**
  86730. * Represents a map of input types to input instance or input index to input instance.
  86731. */
  86732. export interface CameraInputsMap<TCamera extends Camera> {
  86733. /**
  86734. * Accessor to the input by input type.
  86735. */
  86736. [name: string]: ICameraInput<TCamera>;
  86737. /**
  86738. * Accessor to the input by input index.
  86739. */
  86740. [idx: number]: ICameraInput<TCamera>;
  86741. }
  86742. /**
  86743. * This represents the input manager used within a camera.
  86744. * It helps dealing with all the different kind of input attached to a camera.
  86745. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86746. */
  86747. export class CameraInputsManager<TCamera extends Camera> {
  86748. /**
  86749. * Defines the list of inputs attahed to the camera.
  86750. */
  86751. attached: CameraInputsMap<TCamera>;
  86752. /**
  86753. * Defines the dom element the camera is collecting inputs from.
  86754. * This is null if the controls have not been attached.
  86755. */
  86756. attachedElement: Nullable<HTMLElement>;
  86757. /**
  86758. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86759. */
  86760. noPreventDefault: boolean;
  86761. /**
  86762. * Defined the camera the input manager belongs to.
  86763. */
  86764. camera: TCamera;
  86765. /**
  86766. * Update the current camera state depending on the inputs that have been used this frame.
  86767. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86768. */
  86769. checkInputs: () => void;
  86770. /**
  86771. * Instantiate a new Camera Input Manager.
  86772. * @param camera Defines the camera the input manager blongs to
  86773. */
  86774. constructor(camera: TCamera);
  86775. /**
  86776. * Add an input method to a camera
  86777. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86778. * @param input camera input method
  86779. */
  86780. add(input: ICameraInput<TCamera>): void;
  86781. /**
  86782. * Remove a specific input method from a camera
  86783. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  86784. * @param inputToRemove camera input method
  86785. */
  86786. remove(inputToRemove: ICameraInput<TCamera>): void;
  86787. /**
  86788. * Remove a specific input type from a camera
  86789. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  86790. * @param inputType the type of the input to remove
  86791. */
  86792. removeByType(inputType: string): void;
  86793. private _addCheckInputs;
  86794. /**
  86795. * Attach the input controls to the currently attached dom element to listen the events from.
  86796. * @param input Defines the input to attach
  86797. */
  86798. attachInput(input: ICameraInput<TCamera>): void;
  86799. /**
  86800. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  86801. * @param element Defines the dom element to collect the events from
  86802. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86803. */
  86804. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  86805. /**
  86806. * Detach the current manager inputs controls from a specific dom element.
  86807. * @param element Defines the dom element to collect the events from
  86808. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  86809. */
  86810. detachElement(element: HTMLElement, disconnect?: boolean): void;
  86811. /**
  86812. * Rebuild the dynamic inputCheck function from the current list of
  86813. * defined inputs in the manager.
  86814. */
  86815. rebuildInputCheck(): void;
  86816. /**
  86817. * Remove all attached input methods from a camera
  86818. */
  86819. clear(): void;
  86820. /**
  86821. * Serialize the current input manager attached to a camera.
  86822. * This ensures than once parsed,
  86823. * the input associated to the camera will be identical to the current ones
  86824. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  86825. */
  86826. serialize(serializedCamera: any): void;
  86827. /**
  86828. * Parses an input manager serialized JSON to restore the previous list of inputs
  86829. * and states associated to a camera.
  86830. * @param parsedCamera Defines the JSON to parse
  86831. */
  86832. parse(parsedCamera: any): void;
  86833. }
  86834. }
  86835. declare module BABYLON {
  86836. /**
  86837. * Class used to store data that will be store in GPU memory
  86838. */
  86839. export class Buffer {
  86840. private _engine;
  86841. private _buffer;
  86842. /** @hidden */
  86843. _data: Nullable<DataArray>;
  86844. private _updatable;
  86845. private _instanced;
  86846. private _divisor;
  86847. /**
  86848. * Gets the byte stride.
  86849. */
  86850. readonly byteStride: number;
  86851. /**
  86852. * Constructor
  86853. * @param engine the engine
  86854. * @param data the data to use for this buffer
  86855. * @param updatable whether the data is updatable
  86856. * @param stride the stride (optional)
  86857. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86858. * @param instanced whether the buffer is instanced (optional)
  86859. * @param useBytes set to true if the stride in in bytes (optional)
  86860. * @param divisor sets an optional divisor for instances (1 by default)
  86861. */
  86862. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  86863. /**
  86864. * Create a new VertexBuffer based on the current buffer
  86865. * @param kind defines the vertex buffer kind (position, normal, etc.)
  86866. * @param offset defines offset in the buffer (0 by default)
  86867. * @param size defines the size in floats of attributes (position is 3 for instance)
  86868. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  86869. * @param instanced defines if the vertex buffer contains indexed data
  86870. * @param useBytes defines if the offset and stride are in bytes *
  86871. * @param divisor sets an optional divisor for instances (1 by default)
  86872. * @returns the new vertex buffer
  86873. */
  86874. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  86875. /**
  86876. * Gets a boolean indicating if the Buffer is updatable?
  86877. * @returns true if the buffer is updatable
  86878. */
  86879. isUpdatable(): boolean;
  86880. /**
  86881. * Gets current buffer's data
  86882. * @returns a DataArray or null
  86883. */
  86884. getData(): Nullable<DataArray>;
  86885. /**
  86886. * Gets underlying native buffer
  86887. * @returns underlying native buffer
  86888. */
  86889. getBuffer(): Nullable<DataBuffer>;
  86890. /**
  86891. * Gets the stride in float32 units (i.e. byte stride / 4).
  86892. * May not be an integer if the byte stride is not divisible by 4.
  86893. * @returns the stride in float32 units
  86894. * @deprecated Please use byteStride instead.
  86895. */
  86896. getStrideSize(): number;
  86897. /**
  86898. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86899. * @param data defines the data to store
  86900. */
  86901. create(data?: Nullable<DataArray>): void;
  86902. /** @hidden */
  86903. _rebuild(): void;
  86904. /**
  86905. * Update current buffer data
  86906. * @param data defines the data to store
  86907. */
  86908. update(data: DataArray): void;
  86909. /**
  86910. * Updates the data directly.
  86911. * @param data the new data
  86912. * @param offset the new offset
  86913. * @param vertexCount the vertex count (optional)
  86914. * @param useBytes set to true if the offset is in bytes
  86915. */
  86916. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  86917. /**
  86918. * Release all resources
  86919. */
  86920. dispose(): void;
  86921. }
  86922. /**
  86923. * Specialized buffer used to store vertex data
  86924. */
  86925. export class VertexBuffer {
  86926. /** @hidden */
  86927. _buffer: Buffer;
  86928. private _kind;
  86929. private _size;
  86930. private _ownsBuffer;
  86931. private _instanced;
  86932. private _instanceDivisor;
  86933. /**
  86934. * The byte type.
  86935. */
  86936. static readonly BYTE: number;
  86937. /**
  86938. * The unsigned byte type.
  86939. */
  86940. static readonly UNSIGNED_BYTE: number;
  86941. /**
  86942. * The short type.
  86943. */
  86944. static readonly SHORT: number;
  86945. /**
  86946. * The unsigned short type.
  86947. */
  86948. static readonly UNSIGNED_SHORT: number;
  86949. /**
  86950. * The integer type.
  86951. */
  86952. static readonly INT: number;
  86953. /**
  86954. * The unsigned integer type.
  86955. */
  86956. static readonly UNSIGNED_INT: number;
  86957. /**
  86958. * The float type.
  86959. */
  86960. static readonly FLOAT: number;
  86961. /**
  86962. * Gets or sets the instance divisor when in instanced mode
  86963. */
  86964. get instanceDivisor(): number;
  86965. set instanceDivisor(value: number);
  86966. /**
  86967. * Gets the byte stride.
  86968. */
  86969. readonly byteStride: number;
  86970. /**
  86971. * Gets the byte offset.
  86972. */
  86973. readonly byteOffset: number;
  86974. /**
  86975. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  86976. */
  86977. readonly normalized: boolean;
  86978. /**
  86979. * Gets the data type of each component in the array.
  86980. */
  86981. readonly type: number;
  86982. /**
  86983. * Constructor
  86984. * @param engine the engine
  86985. * @param data the data to use for this vertex buffer
  86986. * @param kind the vertex buffer kind
  86987. * @param updatable whether the data is updatable
  86988. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86989. * @param stride the stride (optional)
  86990. * @param instanced whether the buffer is instanced (optional)
  86991. * @param offset the offset of the data (optional)
  86992. * @param size the number of components (optional)
  86993. * @param type the type of the component (optional)
  86994. * @param normalized whether the data contains normalized data (optional)
  86995. * @param useBytes set to true if stride and offset are in bytes (optional)
  86996. * @param divisor defines the instance divisor to use (1 by default)
  86997. */
  86998. 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);
  86999. /** @hidden */
  87000. _rebuild(): void;
  87001. /**
  87002. * Returns the kind of the VertexBuffer (string)
  87003. * @returns a string
  87004. */
  87005. getKind(): string;
  87006. /**
  87007. * Gets a boolean indicating if the VertexBuffer is updatable?
  87008. * @returns true if the buffer is updatable
  87009. */
  87010. isUpdatable(): boolean;
  87011. /**
  87012. * Gets current buffer's data
  87013. * @returns a DataArray or null
  87014. */
  87015. getData(): Nullable<DataArray>;
  87016. /**
  87017. * Gets underlying native buffer
  87018. * @returns underlying native buffer
  87019. */
  87020. getBuffer(): Nullable<DataBuffer>;
  87021. /**
  87022. * Gets the stride in float32 units (i.e. byte stride / 4).
  87023. * May not be an integer if the byte stride is not divisible by 4.
  87024. * @returns the stride in float32 units
  87025. * @deprecated Please use byteStride instead.
  87026. */
  87027. getStrideSize(): number;
  87028. /**
  87029. * Returns the offset as a multiple of the type byte length.
  87030. * @returns the offset in bytes
  87031. * @deprecated Please use byteOffset instead.
  87032. */
  87033. getOffset(): number;
  87034. /**
  87035. * Returns the number of components per vertex attribute (integer)
  87036. * @returns the size in float
  87037. */
  87038. getSize(): number;
  87039. /**
  87040. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  87041. * @returns true if this buffer is instanced
  87042. */
  87043. getIsInstanced(): boolean;
  87044. /**
  87045. * Returns the instancing divisor, zero for non-instanced (integer).
  87046. * @returns a number
  87047. */
  87048. getInstanceDivisor(): number;
  87049. /**
  87050. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87051. * @param data defines the data to store
  87052. */
  87053. create(data?: DataArray): void;
  87054. /**
  87055. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87056. * This function will create a new buffer if the current one is not updatable
  87057. * @param data defines the data to store
  87058. */
  87059. update(data: DataArray): void;
  87060. /**
  87061. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87062. * Returns the directly updated WebGLBuffer.
  87063. * @param data the new data
  87064. * @param offset the new offset
  87065. * @param useBytes set to true if the offset is in bytes
  87066. */
  87067. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87068. /**
  87069. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87070. */
  87071. dispose(): void;
  87072. /**
  87073. * Enumerates each value of this vertex buffer as numbers.
  87074. * @param count the number of values to enumerate
  87075. * @param callback the callback function called for each value
  87076. */
  87077. forEach(count: number, callback: (value: number, index: number) => void): void;
  87078. /**
  87079. * Positions
  87080. */
  87081. static readonly PositionKind: string;
  87082. /**
  87083. * Normals
  87084. */
  87085. static readonly NormalKind: string;
  87086. /**
  87087. * Tangents
  87088. */
  87089. static readonly TangentKind: string;
  87090. /**
  87091. * Texture coordinates
  87092. */
  87093. static readonly UVKind: string;
  87094. /**
  87095. * Texture coordinates 2
  87096. */
  87097. static readonly UV2Kind: string;
  87098. /**
  87099. * Texture coordinates 3
  87100. */
  87101. static readonly UV3Kind: string;
  87102. /**
  87103. * Texture coordinates 4
  87104. */
  87105. static readonly UV4Kind: string;
  87106. /**
  87107. * Texture coordinates 5
  87108. */
  87109. static readonly UV5Kind: string;
  87110. /**
  87111. * Texture coordinates 6
  87112. */
  87113. static readonly UV6Kind: string;
  87114. /**
  87115. * Colors
  87116. */
  87117. static readonly ColorKind: string;
  87118. /**
  87119. * Matrix indices (for bones)
  87120. */
  87121. static readonly MatricesIndicesKind: string;
  87122. /**
  87123. * Matrix weights (for bones)
  87124. */
  87125. static readonly MatricesWeightsKind: string;
  87126. /**
  87127. * Additional matrix indices (for bones)
  87128. */
  87129. static readonly MatricesIndicesExtraKind: string;
  87130. /**
  87131. * Additional matrix weights (for bones)
  87132. */
  87133. static readonly MatricesWeightsExtraKind: string;
  87134. /**
  87135. * Deduces the stride given a kind.
  87136. * @param kind The kind string to deduce
  87137. * @returns The deduced stride
  87138. */
  87139. static DeduceStride(kind: string): number;
  87140. /**
  87141. * Gets the byte length of the given type.
  87142. * @param type the type
  87143. * @returns the number of bytes
  87144. */
  87145. static GetTypeByteLength(type: number): number;
  87146. /**
  87147. * Enumerates each value of the given parameters as numbers.
  87148. * @param data the data to enumerate
  87149. * @param byteOffset the byte offset of the data
  87150. * @param byteStride the byte stride of the data
  87151. * @param componentCount the number of components per element
  87152. * @param componentType the type of the component
  87153. * @param count the number of values to enumerate
  87154. * @param normalized whether the data is normalized
  87155. * @param callback the callback function called for each value
  87156. */
  87157. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  87158. private static _GetFloatValue;
  87159. }
  87160. }
  87161. declare module BABYLON {
  87162. /**
  87163. * The options Interface for creating a Capsule Mesh
  87164. */
  87165. export interface ICreateCapsuleOptions {
  87166. /** The Orientation of the capsule. Default : Vector3.Up() */
  87167. orientation?: Vector3;
  87168. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  87169. subdivisions: number;
  87170. /** Number of cylindrical segments on the capsule. */
  87171. tessellation: number;
  87172. /** Height or Length of the capsule. */
  87173. height: number;
  87174. /** Radius of the capsule. */
  87175. radius: number;
  87176. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  87177. capSubdivisions: number;
  87178. /** Overwrite for the top radius. */
  87179. radiusTop?: number;
  87180. /** Overwrite for the bottom radius. */
  87181. radiusBottom?: number;
  87182. /** Overwrite for the top capSubdivisions. */
  87183. topCapSubdivisions?: number;
  87184. /** Overwrite for the bottom capSubdivisions. */
  87185. bottomCapSubdivisions?: number;
  87186. }
  87187. /**
  87188. * Class containing static functions to help procedurally build meshes
  87189. */
  87190. export class CapsuleBuilder {
  87191. /**
  87192. * Creates a capsule or a pill mesh
  87193. * @param name defines the name of the mesh
  87194. * @param options The constructors options.
  87195. * @param scene The scene the mesh is scoped to.
  87196. * @returns Capsule Mesh
  87197. */
  87198. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  87199. }
  87200. }
  87201. declare module BABYLON {
  87202. /**
  87203. * @hidden
  87204. */
  87205. export class IntersectionInfo {
  87206. bu: Nullable<number>;
  87207. bv: Nullable<number>;
  87208. distance: number;
  87209. faceId: number;
  87210. subMeshId: number;
  87211. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  87212. }
  87213. }
  87214. declare module BABYLON {
  87215. /**
  87216. * Class used to store bounding sphere information
  87217. */
  87218. export class BoundingSphere {
  87219. /**
  87220. * Gets the center of the bounding sphere in local space
  87221. */
  87222. readonly center: Vector3;
  87223. /**
  87224. * Radius of the bounding sphere in local space
  87225. */
  87226. radius: number;
  87227. /**
  87228. * Gets the center of the bounding sphere in world space
  87229. */
  87230. readonly centerWorld: Vector3;
  87231. /**
  87232. * Radius of the bounding sphere in world space
  87233. */
  87234. radiusWorld: number;
  87235. /**
  87236. * Gets the minimum vector in local space
  87237. */
  87238. readonly minimum: Vector3;
  87239. /**
  87240. * Gets the maximum vector in local space
  87241. */
  87242. readonly maximum: Vector3;
  87243. private _worldMatrix;
  87244. private static readonly TmpVector3;
  87245. /**
  87246. * Creates a new bounding sphere
  87247. * @param min defines the minimum vector (in local space)
  87248. * @param max defines the maximum vector (in local space)
  87249. * @param worldMatrix defines the new world matrix
  87250. */
  87251. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87252. /**
  87253. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  87254. * @param min defines the new minimum vector (in local space)
  87255. * @param max defines the new maximum vector (in local space)
  87256. * @param worldMatrix defines the new world matrix
  87257. */
  87258. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87259. /**
  87260. * Scale the current bounding sphere by applying a scale factor
  87261. * @param factor defines the scale factor to apply
  87262. * @returns the current bounding box
  87263. */
  87264. scale(factor: number): BoundingSphere;
  87265. /**
  87266. * Gets the world matrix of the bounding box
  87267. * @returns a matrix
  87268. */
  87269. getWorldMatrix(): DeepImmutable<Matrix>;
  87270. /** @hidden */
  87271. _update(worldMatrix: DeepImmutable<Matrix>): void;
  87272. /**
  87273. * Tests if the bounding sphere is intersecting the frustum planes
  87274. * @param frustumPlanes defines the frustum planes to test
  87275. * @returns true if there is an intersection
  87276. */
  87277. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87278. /**
  87279. * Tests if the bounding sphere center is in between the frustum planes.
  87280. * Used for optimistic fast inclusion.
  87281. * @param frustumPlanes defines the frustum planes to test
  87282. * @returns true if the sphere center is in between the frustum planes
  87283. */
  87284. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87285. /**
  87286. * Tests if a point is inside the bounding sphere
  87287. * @param point defines the point to test
  87288. * @returns true if the point is inside the bounding sphere
  87289. */
  87290. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87291. /**
  87292. * Checks if two sphere intersct
  87293. * @param sphere0 sphere 0
  87294. * @param sphere1 sphere 1
  87295. * @returns true if the speres intersect
  87296. */
  87297. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  87298. }
  87299. }
  87300. declare module BABYLON {
  87301. /**
  87302. * Class used to store bounding box information
  87303. */
  87304. export class BoundingBox implements ICullable {
  87305. /**
  87306. * Gets the 8 vectors representing the bounding box in local space
  87307. */
  87308. readonly vectors: Vector3[];
  87309. /**
  87310. * Gets the center of the bounding box in local space
  87311. */
  87312. readonly center: Vector3;
  87313. /**
  87314. * Gets the center of the bounding box in world space
  87315. */
  87316. readonly centerWorld: Vector3;
  87317. /**
  87318. * Gets the extend size in local space
  87319. */
  87320. readonly extendSize: Vector3;
  87321. /**
  87322. * Gets the extend size in world space
  87323. */
  87324. readonly extendSizeWorld: Vector3;
  87325. /**
  87326. * Gets the OBB (object bounding box) directions
  87327. */
  87328. readonly directions: Vector3[];
  87329. /**
  87330. * Gets the 8 vectors representing the bounding box in world space
  87331. */
  87332. readonly vectorsWorld: Vector3[];
  87333. /**
  87334. * Gets the minimum vector in world space
  87335. */
  87336. readonly minimumWorld: Vector3;
  87337. /**
  87338. * Gets the maximum vector in world space
  87339. */
  87340. readonly maximumWorld: Vector3;
  87341. /**
  87342. * Gets the minimum vector in local space
  87343. */
  87344. readonly minimum: Vector3;
  87345. /**
  87346. * Gets the maximum vector in local space
  87347. */
  87348. readonly maximum: Vector3;
  87349. private _worldMatrix;
  87350. private static readonly TmpVector3;
  87351. /**
  87352. * @hidden
  87353. */
  87354. _tag: number;
  87355. /**
  87356. * Creates a new bounding box
  87357. * @param min defines the minimum vector (in local space)
  87358. * @param max defines the maximum vector (in local space)
  87359. * @param worldMatrix defines the new world matrix
  87360. */
  87361. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87362. /**
  87363. * Recreates the entire bounding box from scratch as if we call the constructor in place
  87364. * @param min defines the new minimum vector (in local space)
  87365. * @param max defines the new maximum vector (in local space)
  87366. * @param worldMatrix defines the new world matrix
  87367. */
  87368. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87369. /**
  87370. * Scale the current bounding box by applying a scale factor
  87371. * @param factor defines the scale factor to apply
  87372. * @returns the current bounding box
  87373. */
  87374. scale(factor: number): BoundingBox;
  87375. /**
  87376. * Gets the world matrix of the bounding box
  87377. * @returns a matrix
  87378. */
  87379. getWorldMatrix(): DeepImmutable<Matrix>;
  87380. /** @hidden */
  87381. _update(world: DeepImmutable<Matrix>): void;
  87382. /**
  87383. * Tests if the bounding box is intersecting the frustum planes
  87384. * @param frustumPlanes defines the frustum planes to test
  87385. * @returns true if there is an intersection
  87386. */
  87387. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87388. /**
  87389. * Tests if the bounding box is entirely inside the frustum planes
  87390. * @param frustumPlanes defines the frustum planes to test
  87391. * @returns true if there is an inclusion
  87392. */
  87393. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87394. /**
  87395. * Tests if a point is inside the bounding box
  87396. * @param point defines the point to test
  87397. * @returns true if the point is inside the bounding box
  87398. */
  87399. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87400. /**
  87401. * Tests if the bounding box intersects with a bounding sphere
  87402. * @param sphere defines the sphere to test
  87403. * @returns true if there is an intersection
  87404. */
  87405. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  87406. /**
  87407. * Tests if the bounding box intersects with a box defined by a min and max vectors
  87408. * @param min defines the min vector to use
  87409. * @param max defines the max vector to use
  87410. * @returns true if there is an intersection
  87411. */
  87412. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  87413. /**
  87414. * Tests if two bounding boxes are intersections
  87415. * @param box0 defines the first box to test
  87416. * @param box1 defines the second box to test
  87417. * @returns true if there is an intersection
  87418. */
  87419. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  87420. /**
  87421. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  87422. * @param minPoint defines the minimum vector of the bounding box
  87423. * @param maxPoint defines the maximum vector of the bounding box
  87424. * @param sphereCenter defines the sphere center
  87425. * @param sphereRadius defines the sphere radius
  87426. * @returns true if there is an intersection
  87427. */
  87428. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  87429. /**
  87430. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  87431. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87432. * @param frustumPlanes defines the frustum planes to test
  87433. * @return true if there is an inclusion
  87434. */
  87435. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87436. /**
  87437. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  87438. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87439. * @param frustumPlanes defines the frustum planes to test
  87440. * @return true if there is an intersection
  87441. */
  87442. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87443. }
  87444. }
  87445. declare module BABYLON {
  87446. /** @hidden */
  87447. export class Collider {
  87448. /** Define if a collision was found */
  87449. collisionFound: boolean;
  87450. /**
  87451. * Define last intersection point in local space
  87452. */
  87453. intersectionPoint: Vector3;
  87454. /**
  87455. * Define last collided mesh
  87456. */
  87457. collidedMesh: Nullable<AbstractMesh>;
  87458. private _collisionPoint;
  87459. private _planeIntersectionPoint;
  87460. private _tempVector;
  87461. private _tempVector2;
  87462. private _tempVector3;
  87463. private _tempVector4;
  87464. private _edge;
  87465. private _baseToVertex;
  87466. private _destinationPoint;
  87467. private _slidePlaneNormal;
  87468. private _displacementVector;
  87469. /** @hidden */
  87470. _radius: Vector3;
  87471. /** @hidden */
  87472. _retry: number;
  87473. private _velocity;
  87474. private _basePoint;
  87475. private _epsilon;
  87476. /** @hidden */
  87477. _velocityWorldLength: number;
  87478. /** @hidden */
  87479. _basePointWorld: Vector3;
  87480. private _velocityWorld;
  87481. private _normalizedVelocity;
  87482. /** @hidden */
  87483. _initialVelocity: Vector3;
  87484. /** @hidden */
  87485. _initialPosition: Vector3;
  87486. private _nearestDistance;
  87487. private _collisionMask;
  87488. get collisionMask(): number;
  87489. set collisionMask(mask: number);
  87490. /**
  87491. * Gets the plane normal used to compute the sliding response (in local space)
  87492. */
  87493. get slidePlaneNormal(): Vector3;
  87494. /** @hidden */
  87495. _initialize(source: Vector3, dir: Vector3, e: number): void;
  87496. /** @hidden */
  87497. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  87498. /** @hidden */
  87499. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  87500. /** @hidden */
  87501. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87502. /** @hidden */
  87503. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87504. /** @hidden */
  87505. _getResponse(pos: Vector3, vel: Vector3): void;
  87506. }
  87507. }
  87508. declare module BABYLON {
  87509. /**
  87510. * Interface for cullable objects
  87511. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  87512. */
  87513. export interface ICullable {
  87514. /**
  87515. * Checks if the object or part of the object is in the frustum
  87516. * @param frustumPlanes Camera near/planes
  87517. * @returns true if the object is in frustum otherwise false
  87518. */
  87519. isInFrustum(frustumPlanes: Plane[]): boolean;
  87520. /**
  87521. * Checks if a cullable object (mesh...) is in the camera frustum
  87522. * Unlike isInFrustum this cheks the full bounding box
  87523. * @param frustumPlanes Camera near/planes
  87524. * @returns true if the object is in frustum otherwise false
  87525. */
  87526. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87527. }
  87528. /**
  87529. * Info for a bounding data of a mesh
  87530. */
  87531. export class BoundingInfo implements ICullable {
  87532. /**
  87533. * Bounding box for the mesh
  87534. */
  87535. readonly boundingBox: BoundingBox;
  87536. /**
  87537. * Bounding sphere for the mesh
  87538. */
  87539. readonly boundingSphere: BoundingSphere;
  87540. private _isLocked;
  87541. private static readonly TmpVector3;
  87542. /**
  87543. * Constructs bounding info
  87544. * @param minimum min vector of the bounding box/sphere
  87545. * @param maximum max vector of the bounding box/sphere
  87546. * @param worldMatrix defines the new world matrix
  87547. */
  87548. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87549. /**
  87550. * Recreates the entire bounding info from scratch as if we call the constructor in place
  87551. * @param min defines the new minimum vector (in local space)
  87552. * @param max defines the new maximum vector (in local space)
  87553. * @param worldMatrix defines the new world matrix
  87554. */
  87555. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87556. /**
  87557. * min vector of the bounding box/sphere
  87558. */
  87559. get minimum(): Vector3;
  87560. /**
  87561. * max vector of the bounding box/sphere
  87562. */
  87563. get maximum(): Vector3;
  87564. /**
  87565. * If the info is locked and won't be updated to avoid perf overhead
  87566. */
  87567. get isLocked(): boolean;
  87568. set isLocked(value: boolean);
  87569. /**
  87570. * Updates the bounding sphere and box
  87571. * @param world world matrix to be used to update
  87572. */
  87573. update(world: DeepImmutable<Matrix>): void;
  87574. /**
  87575. * Recreate the bounding info to be centered around a specific point given a specific extend.
  87576. * @param center New center of the bounding info
  87577. * @param extend New extend of the bounding info
  87578. * @returns the current bounding info
  87579. */
  87580. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  87581. /**
  87582. * Scale the current bounding info by applying a scale factor
  87583. * @param factor defines the scale factor to apply
  87584. * @returns the current bounding info
  87585. */
  87586. scale(factor: number): BoundingInfo;
  87587. /**
  87588. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  87589. * @param frustumPlanes defines the frustum to test
  87590. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  87591. * @returns true if the bounding info is in the frustum planes
  87592. */
  87593. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  87594. /**
  87595. * Gets the world distance between the min and max points of the bounding box
  87596. */
  87597. get diagonalLength(): number;
  87598. /**
  87599. * Checks if a cullable object (mesh...) is in the camera frustum
  87600. * Unlike isInFrustum this cheks the full bounding box
  87601. * @param frustumPlanes Camera near/planes
  87602. * @returns true if the object is in frustum otherwise false
  87603. */
  87604. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87605. /** @hidden */
  87606. _checkCollision(collider: Collider): boolean;
  87607. /**
  87608. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  87609. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87610. * @param point the point to check intersection with
  87611. * @returns if the point intersects
  87612. */
  87613. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87614. /**
  87615. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  87616. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87617. * @param boundingInfo the bounding info to check intersection with
  87618. * @param precise if the intersection should be done using OBB
  87619. * @returns if the bounding info intersects
  87620. */
  87621. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  87622. }
  87623. }
  87624. declare module BABYLON {
  87625. /**
  87626. * Extracts minimum and maximum values from a list of indexed positions
  87627. * @param positions defines the positions to use
  87628. * @param indices defines the indices to the positions
  87629. * @param indexStart defines the start index
  87630. * @param indexCount defines the end index
  87631. * @param bias defines bias value to add to the result
  87632. * @return minimum and maximum values
  87633. */
  87634. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87635. minimum: Vector3;
  87636. maximum: Vector3;
  87637. };
  87638. /**
  87639. * Extracts minimum and maximum values from a list of positions
  87640. * @param positions defines the positions to use
  87641. * @param start defines the start index in the positions array
  87642. * @param count defines the number of positions to handle
  87643. * @param bias defines bias value to add to the result
  87644. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87645. * @return minimum and maximum values
  87646. */
  87647. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87648. minimum: Vector3;
  87649. maximum: Vector3;
  87650. };
  87651. }
  87652. declare module BABYLON {
  87653. /** @hidden */
  87654. export class WebGLDataBuffer extends DataBuffer {
  87655. private _buffer;
  87656. constructor(resource: WebGLBuffer);
  87657. get underlyingResource(): any;
  87658. }
  87659. }
  87660. declare module BABYLON {
  87661. /** @hidden */
  87662. export class WebGLPipelineContext implements IPipelineContext {
  87663. engine: ThinEngine;
  87664. program: Nullable<WebGLProgram>;
  87665. context?: WebGLRenderingContext;
  87666. vertexShader?: WebGLShader;
  87667. fragmentShader?: WebGLShader;
  87668. isParallelCompiled: boolean;
  87669. onCompiled?: () => void;
  87670. transformFeedback?: WebGLTransformFeedback | null;
  87671. vertexCompilationError: Nullable<string>;
  87672. fragmentCompilationError: Nullable<string>;
  87673. programLinkError: Nullable<string>;
  87674. programValidationError: Nullable<string>;
  87675. get isAsync(): boolean;
  87676. get isReady(): boolean;
  87677. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  87678. _getVertexShaderCode(): string | null;
  87679. _getFragmentShaderCode(): string | null;
  87680. }
  87681. }
  87682. declare module BABYLON {
  87683. interface ThinEngine {
  87684. /**
  87685. * Create an uniform buffer
  87686. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87687. * @param elements defines the content of the uniform buffer
  87688. * @returns the webGL uniform buffer
  87689. */
  87690. createUniformBuffer(elements: FloatArray): DataBuffer;
  87691. /**
  87692. * Create a dynamic uniform buffer
  87693. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87694. * @param elements defines the content of the uniform buffer
  87695. * @returns the webGL uniform buffer
  87696. */
  87697. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  87698. /**
  87699. * Update an existing uniform buffer
  87700. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87701. * @param uniformBuffer defines the target uniform buffer
  87702. * @param elements defines the content to update
  87703. * @param offset defines the offset in the uniform buffer where update should start
  87704. * @param count defines the size of the data to update
  87705. */
  87706. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87707. /**
  87708. * Bind an uniform buffer to the current webGL context
  87709. * @param buffer defines the buffer to bind
  87710. */
  87711. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  87712. /**
  87713. * Bind a buffer to the current webGL context at a given location
  87714. * @param buffer defines the buffer to bind
  87715. * @param location defines the index where to bind the buffer
  87716. */
  87717. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  87718. /**
  87719. * Bind a specific block at a given index in a specific shader program
  87720. * @param pipelineContext defines the pipeline context to use
  87721. * @param blockName defines the block name
  87722. * @param index defines the index where to bind the block
  87723. */
  87724. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  87725. }
  87726. }
  87727. declare module BABYLON {
  87728. /**
  87729. * Uniform buffer objects.
  87730. *
  87731. * Handles blocks of uniform on the GPU.
  87732. *
  87733. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87734. *
  87735. * For more information, please refer to :
  87736. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87737. */
  87738. export class UniformBuffer {
  87739. private _engine;
  87740. private _buffer;
  87741. private _data;
  87742. private _bufferData;
  87743. private _dynamic?;
  87744. private _uniformLocations;
  87745. private _uniformSizes;
  87746. private _uniformLocationPointer;
  87747. private _needSync;
  87748. private _noUBO;
  87749. private _currentEffect;
  87750. /** @hidden */
  87751. _alreadyBound: boolean;
  87752. private static _MAX_UNIFORM_SIZE;
  87753. private static _tempBuffer;
  87754. /**
  87755. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  87756. * This is dynamic to allow compat with webgl 1 and 2.
  87757. * You will need to pass the name of the uniform as well as the value.
  87758. */
  87759. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  87760. /**
  87761. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  87762. * This is dynamic to allow compat with webgl 1 and 2.
  87763. * You will need to pass the name of the uniform as well as the value.
  87764. */
  87765. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  87766. /**
  87767. * Lambda to Update a single float in a uniform buffer.
  87768. * This is dynamic to allow compat with webgl 1 and 2.
  87769. * You will need to pass the name of the uniform as well as the value.
  87770. */
  87771. updateFloat: (name: string, x: number) => void;
  87772. /**
  87773. * Lambda to Update a vec2 of float in a uniform buffer.
  87774. * This is dynamic to allow compat with webgl 1 and 2.
  87775. * You will need to pass the name of the uniform as well as the value.
  87776. */
  87777. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  87778. /**
  87779. * Lambda to Update a vec3 of float in a uniform buffer.
  87780. * This is dynamic to allow compat with webgl 1 and 2.
  87781. * You will need to pass the name of the uniform as well as the value.
  87782. */
  87783. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  87784. /**
  87785. * Lambda to Update a vec4 of float in a uniform buffer.
  87786. * This is dynamic to allow compat with webgl 1 and 2.
  87787. * You will need to pass the name of the uniform as well as the value.
  87788. */
  87789. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  87790. /**
  87791. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  87792. * This is dynamic to allow compat with webgl 1 and 2.
  87793. * You will need to pass the name of the uniform as well as the value.
  87794. */
  87795. updateMatrix: (name: string, mat: Matrix) => void;
  87796. /**
  87797. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  87798. * This is dynamic to allow compat with webgl 1 and 2.
  87799. * You will need to pass the name of the uniform as well as the value.
  87800. */
  87801. updateVector3: (name: string, vector: Vector3) => void;
  87802. /**
  87803. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  87804. * This is dynamic to allow compat with webgl 1 and 2.
  87805. * You will need to pass the name of the uniform as well as the value.
  87806. */
  87807. updateVector4: (name: string, vector: Vector4) => void;
  87808. /**
  87809. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  87810. * This is dynamic to allow compat with webgl 1 and 2.
  87811. * You will need to pass the name of the uniform as well as the value.
  87812. */
  87813. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  87814. /**
  87815. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  87816. * This is dynamic to allow compat with webgl 1 and 2.
  87817. * You will need to pass the name of the uniform as well as the value.
  87818. */
  87819. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  87820. /**
  87821. * Instantiates a new Uniform buffer objects.
  87822. *
  87823. * Handles blocks of uniform on the GPU.
  87824. *
  87825. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87826. *
  87827. * For more information, please refer to :
  87828. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87829. * @param engine Define the engine the buffer is associated with
  87830. * @param data Define the data contained in the buffer
  87831. * @param dynamic Define if the buffer is updatable
  87832. */
  87833. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  87834. /**
  87835. * Indicates if the buffer is using the WebGL2 UBO implementation,
  87836. * or just falling back on setUniformXXX calls.
  87837. */
  87838. get useUbo(): boolean;
  87839. /**
  87840. * Indicates if the WebGL underlying uniform buffer is in sync
  87841. * with the javascript cache data.
  87842. */
  87843. get isSync(): boolean;
  87844. /**
  87845. * Indicates if the WebGL underlying uniform buffer is dynamic.
  87846. * Also, a dynamic UniformBuffer will disable cache verification and always
  87847. * update the underlying WebGL uniform buffer to the GPU.
  87848. * @returns if Dynamic, otherwise false
  87849. */
  87850. isDynamic(): boolean;
  87851. /**
  87852. * The data cache on JS side.
  87853. * @returns the underlying data as a float array
  87854. */
  87855. getData(): Float32Array;
  87856. /**
  87857. * The underlying WebGL Uniform buffer.
  87858. * @returns the webgl buffer
  87859. */
  87860. getBuffer(): Nullable<DataBuffer>;
  87861. /**
  87862. * std140 layout specifies how to align data within an UBO structure.
  87863. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  87864. * for specs.
  87865. */
  87866. private _fillAlignment;
  87867. /**
  87868. * Adds an uniform in the buffer.
  87869. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  87870. * for the layout to be correct !
  87871. * @param name Name of the uniform, as used in the uniform block in the shader.
  87872. * @param size Data size, or data directly.
  87873. */
  87874. addUniform(name: string, size: number | number[]): void;
  87875. /**
  87876. * Adds a Matrix 4x4 to the uniform buffer.
  87877. * @param name Name of the uniform, as used in the uniform block in the shader.
  87878. * @param mat A 4x4 matrix.
  87879. */
  87880. addMatrix(name: string, mat: Matrix): void;
  87881. /**
  87882. * Adds a vec2 to the uniform buffer.
  87883. * @param name Name of the uniform, as used in the uniform block in the shader.
  87884. * @param x Define the x component value of the vec2
  87885. * @param y Define the y component value of the vec2
  87886. */
  87887. addFloat2(name: string, x: number, y: number): void;
  87888. /**
  87889. * Adds a vec3 to the uniform buffer.
  87890. * @param name Name of the uniform, as used in the uniform block in the shader.
  87891. * @param x Define the x component value of the vec3
  87892. * @param y Define the y component value of the vec3
  87893. * @param z Define the z component value of the vec3
  87894. */
  87895. addFloat3(name: string, x: number, y: number, z: number): void;
  87896. /**
  87897. * Adds a vec3 to the uniform buffer.
  87898. * @param name Name of the uniform, as used in the uniform block in the shader.
  87899. * @param color Define the vec3 from a Color
  87900. */
  87901. addColor3(name: string, color: Color3): void;
  87902. /**
  87903. * Adds a vec4 to the uniform buffer.
  87904. * @param name Name of the uniform, as used in the uniform block in the shader.
  87905. * @param color Define the rgb components from a Color
  87906. * @param alpha Define the a component of the vec4
  87907. */
  87908. addColor4(name: string, color: Color3, alpha: number): void;
  87909. /**
  87910. * Adds a vec3 to the uniform buffer.
  87911. * @param name Name of the uniform, as used in the uniform block in the shader.
  87912. * @param vector Define the vec3 components from a Vector
  87913. */
  87914. addVector3(name: string, vector: Vector3): void;
  87915. /**
  87916. * Adds a Matrix 3x3 to the uniform buffer.
  87917. * @param name Name of the uniform, as used in the uniform block in the shader.
  87918. */
  87919. addMatrix3x3(name: string): void;
  87920. /**
  87921. * Adds a Matrix 2x2 to the uniform buffer.
  87922. * @param name Name of the uniform, as used in the uniform block in the shader.
  87923. */
  87924. addMatrix2x2(name: string): void;
  87925. /**
  87926. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  87927. */
  87928. create(): void;
  87929. /** @hidden */
  87930. _rebuild(): void;
  87931. /**
  87932. * Updates the WebGL Uniform Buffer on the GPU.
  87933. * If the `dynamic` flag is set to true, no cache comparison is done.
  87934. * Otherwise, the buffer will be updated only if the cache differs.
  87935. */
  87936. update(): void;
  87937. /**
  87938. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  87939. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87940. * @param data Define the flattened data
  87941. * @param size Define the size of the data.
  87942. */
  87943. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  87944. private _valueCache;
  87945. private _cacheMatrix;
  87946. private _updateMatrix3x3ForUniform;
  87947. private _updateMatrix3x3ForEffect;
  87948. private _updateMatrix2x2ForEffect;
  87949. private _updateMatrix2x2ForUniform;
  87950. private _updateFloatForEffect;
  87951. private _updateFloatForUniform;
  87952. private _updateFloat2ForEffect;
  87953. private _updateFloat2ForUniform;
  87954. private _updateFloat3ForEffect;
  87955. private _updateFloat3ForUniform;
  87956. private _updateFloat4ForEffect;
  87957. private _updateFloat4ForUniform;
  87958. private _updateMatrixForEffect;
  87959. private _updateMatrixForUniform;
  87960. private _updateVector3ForEffect;
  87961. private _updateVector3ForUniform;
  87962. private _updateVector4ForEffect;
  87963. private _updateVector4ForUniform;
  87964. private _updateColor3ForEffect;
  87965. private _updateColor3ForUniform;
  87966. private _updateColor4ForEffect;
  87967. private _updateColor4ForUniform;
  87968. /**
  87969. * Sets a sampler uniform on the effect.
  87970. * @param name Define the name of the sampler.
  87971. * @param texture Define the texture to set in the sampler
  87972. */
  87973. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  87974. /**
  87975. * Directly updates the value of the uniform in the cache AND on the GPU.
  87976. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87977. * @param data Define the flattened data
  87978. */
  87979. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  87980. /**
  87981. * Binds this uniform buffer to an effect.
  87982. * @param effect Define the effect to bind the buffer to
  87983. * @param name Name of the uniform block in the shader.
  87984. */
  87985. bindToEffect(effect: Effect, name: string): void;
  87986. /**
  87987. * Disposes the uniform buffer.
  87988. */
  87989. dispose(): void;
  87990. }
  87991. }
  87992. declare module BABYLON {
  87993. /**
  87994. * Enum that determines the text-wrapping mode to use.
  87995. */
  87996. export enum InspectableType {
  87997. /**
  87998. * Checkbox for booleans
  87999. */
  88000. Checkbox = 0,
  88001. /**
  88002. * Sliders for numbers
  88003. */
  88004. Slider = 1,
  88005. /**
  88006. * Vector3
  88007. */
  88008. Vector3 = 2,
  88009. /**
  88010. * Quaternions
  88011. */
  88012. Quaternion = 3,
  88013. /**
  88014. * Color3
  88015. */
  88016. Color3 = 4,
  88017. /**
  88018. * String
  88019. */
  88020. String = 5
  88021. }
  88022. /**
  88023. * Interface used to define custom inspectable properties.
  88024. * This interface is used by the inspector to display custom property grids
  88025. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88026. */
  88027. export interface IInspectable {
  88028. /**
  88029. * Gets the label to display
  88030. */
  88031. label: string;
  88032. /**
  88033. * Gets the name of the property to edit
  88034. */
  88035. propertyName: string;
  88036. /**
  88037. * Gets the type of the editor to use
  88038. */
  88039. type: InspectableType;
  88040. /**
  88041. * Gets the minimum value of the property when using in "slider" mode
  88042. */
  88043. min?: number;
  88044. /**
  88045. * Gets the maximum value of the property when using in "slider" mode
  88046. */
  88047. max?: number;
  88048. /**
  88049. * Gets the setp to use when using in "slider" mode
  88050. */
  88051. step?: number;
  88052. }
  88053. }
  88054. declare module BABYLON {
  88055. /**
  88056. * Class used to provide helper for timing
  88057. */
  88058. export class TimingTools {
  88059. /**
  88060. * Polyfill for setImmediate
  88061. * @param action defines the action to execute after the current execution block
  88062. */
  88063. static SetImmediate(action: () => void): void;
  88064. }
  88065. }
  88066. declare module BABYLON {
  88067. /**
  88068. * Class used to enable instatition of objects by class name
  88069. */
  88070. export class InstantiationTools {
  88071. /**
  88072. * Use this object to register external classes like custom textures or material
  88073. * to allow the laoders to instantiate them
  88074. */
  88075. static RegisteredExternalClasses: {
  88076. [key: string]: Object;
  88077. };
  88078. /**
  88079. * Tries to instantiate a new object from a given class name
  88080. * @param className defines the class name to instantiate
  88081. * @returns the new object or null if the system was not able to do the instantiation
  88082. */
  88083. static Instantiate(className: string): any;
  88084. }
  88085. }
  88086. declare module BABYLON {
  88087. /**
  88088. * Define options used to create a depth texture
  88089. */
  88090. export class DepthTextureCreationOptions {
  88091. /** Specifies whether or not a stencil should be allocated in the texture */
  88092. generateStencil?: boolean;
  88093. /** Specifies whether or not bilinear filtering is enable on the texture */
  88094. bilinearFiltering?: boolean;
  88095. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88096. comparisonFunction?: number;
  88097. /** Specifies if the created texture is a cube texture */
  88098. isCube?: boolean;
  88099. }
  88100. }
  88101. declare module BABYLON {
  88102. interface ThinEngine {
  88103. /**
  88104. * Creates a depth stencil cube texture.
  88105. * This is only available in WebGL 2.
  88106. * @param size The size of face edge in the cube texture.
  88107. * @param options The options defining the cube texture.
  88108. * @returns The cube texture
  88109. */
  88110. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88111. /**
  88112. * Creates a cube texture
  88113. * @param rootUrl defines the url where the files to load is located
  88114. * @param scene defines the current scene
  88115. * @param files defines the list of files to load (1 per face)
  88116. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88117. * @param onLoad defines an optional callback raised when the texture is loaded
  88118. * @param onError defines an optional callback raised if there is an issue to load the texture
  88119. * @param format defines the format of the data
  88120. * @param forcedExtension defines the extension to use to pick the right loader
  88121. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88122. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88123. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88124. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88125. * @returns the cube texture as an InternalTexture
  88126. */
  88127. 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;
  88128. /**
  88129. * Creates a cube texture
  88130. * @param rootUrl defines the url where the files to load is located
  88131. * @param scene defines the current scene
  88132. * @param files defines the list of files to load (1 per face)
  88133. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88134. * @param onLoad defines an optional callback raised when the texture is loaded
  88135. * @param onError defines an optional callback raised if there is an issue to load the texture
  88136. * @param format defines the format of the data
  88137. * @param forcedExtension defines the extension to use to pick the right loader
  88138. * @returns the cube texture as an InternalTexture
  88139. */
  88140. 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;
  88141. /**
  88142. * Creates a cube texture
  88143. * @param rootUrl defines the url where the files to load is located
  88144. * @param scene defines the current scene
  88145. * @param files defines the list of files to load (1 per face)
  88146. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88147. * @param onLoad defines an optional callback raised when the texture is loaded
  88148. * @param onError defines an optional callback raised if there is an issue to load the texture
  88149. * @param format defines the format of the data
  88150. * @param forcedExtension defines the extension to use to pick the right loader
  88151. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88152. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88153. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88154. * @returns the cube texture as an InternalTexture
  88155. */
  88156. 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;
  88157. /** @hidden */
  88158. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  88159. /** @hidden */
  88160. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  88161. /** @hidden */
  88162. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88163. /** @hidden */
  88164. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88165. /**
  88166. * @hidden
  88167. */
  88168. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88169. }
  88170. }
  88171. declare module BABYLON {
  88172. /**
  88173. * Class for creating a cube texture
  88174. */
  88175. export class CubeTexture extends BaseTexture {
  88176. private _delayedOnLoad;
  88177. /**
  88178. * Observable triggered once the texture has been loaded.
  88179. */
  88180. onLoadObservable: Observable<CubeTexture>;
  88181. /**
  88182. * The url of the texture
  88183. */
  88184. url: string;
  88185. /**
  88186. * Gets or sets the center of the bounding box associated with the cube texture.
  88187. * It must define where the camera used to render the texture was set
  88188. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88189. */
  88190. boundingBoxPosition: Vector3;
  88191. private _boundingBoxSize;
  88192. /**
  88193. * Gets or sets the size of the bounding box associated with the cube texture
  88194. * When defined, the cubemap will switch to local mode
  88195. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88196. * @example https://www.babylonjs-playground.com/#RNASML
  88197. */
  88198. set boundingBoxSize(value: Vector3);
  88199. /**
  88200. * Returns the bounding box size
  88201. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88202. */
  88203. get boundingBoxSize(): Vector3;
  88204. protected _rotationY: number;
  88205. /**
  88206. * Sets texture matrix rotation angle around Y axis in radians.
  88207. */
  88208. set rotationY(value: number);
  88209. /**
  88210. * Gets texture matrix rotation angle around Y axis radians.
  88211. */
  88212. get rotationY(): number;
  88213. /**
  88214. * Are mip maps generated for this texture or not.
  88215. */
  88216. get noMipmap(): boolean;
  88217. private _noMipmap;
  88218. private _files;
  88219. protected _forcedExtension: Nullable<string>;
  88220. private _extensions;
  88221. private _textureMatrix;
  88222. private _format;
  88223. private _createPolynomials;
  88224. /**
  88225. * Creates a cube texture from an array of image urls
  88226. * @param files defines an array of image urls
  88227. * @param scene defines the hosting scene
  88228. * @param noMipmap specifies if mip maps are not used
  88229. * @returns a cube texture
  88230. */
  88231. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  88232. /**
  88233. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  88234. * @param url defines the url of the prefiltered texture
  88235. * @param scene defines the scene the texture is attached to
  88236. * @param forcedExtension defines the extension of the file if different from the url
  88237. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88238. * @return the prefiltered texture
  88239. */
  88240. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  88241. /**
  88242. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  88243. * as prefiltered data.
  88244. * @param rootUrl defines the url of the texture or the root name of the six images
  88245. * @param null defines the scene or engine the texture is attached to
  88246. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  88247. * @param noMipmap defines if mipmaps should be created or not
  88248. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  88249. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  88250. * @param onError defines a callback triggered in case of error during load
  88251. * @param format defines the internal format to use for the texture once loaded
  88252. * @param prefiltered defines whether or not the texture is created from prefiltered data
  88253. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  88254. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88255. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88256. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88257. * @return the cube texture
  88258. */
  88259. 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);
  88260. /**
  88261. * Get the current class name of the texture useful for serialization or dynamic coding.
  88262. * @returns "CubeTexture"
  88263. */
  88264. getClassName(): string;
  88265. /**
  88266. * Update the url (and optional buffer) of this texture if url was null during construction.
  88267. * @param url the url of the texture
  88268. * @param forcedExtension defines the extension to use
  88269. * @param onLoad callback called when the texture is loaded (defaults to null)
  88270. * @param prefiltered Defines whether the updated texture is prefiltered or not
  88271. */
  88272. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  88273. /**
  88274. * Delays loading of the cube texture
  88275. * @param forcedExtension defines the extension to use
  88276. */
  88277. delayLoad(forcedExtension?: string): void;
  88278. /**
  88279. * Returns the reflection texture matrix
  88280. * @returns the reflection texture matrix
  88281. */
  88282. getReflectionTextureMatrix(): Matrix;
  88283. /**
  88284. * Sets the reflection texture matrix
  88285. * @param value Reflection texture matrix
  88286. */
  88287. setReflectionTextureMatrix(value: Matrix): void;
  88288. /**
  88289. * Parses text to create a cube texture
  88290. * @param parsedTexture define the serialized text to read from
  88291. * @param scene defines the hosting scene
  88292. * @param rootUrl defines the root url of the cube texture
  88293. * @returns a cube texture
  88294. */
  88295. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  88296. /**
  88297. * Makes a clone, or deep copy, of the cube texture
  88298. * @returns a new cube texture
  88299. */
  88300. clone(): CubeTexture;
  88301. }
  88302. }
  88303. declare module BABYLON {
  88304. /**
  88305. * Manages the defines for the Material
  88306. */
  88307. export class MaterialDefines {
  88308. /** @hidden */
  88309. protected _keys: string[];
  88310. private _isDirty;
  88311. /** @hidden */
  88312. _renderId: number;
  88313. /** @hidden */
  88314. _areLightsDirty: boolean;
  88315. /** @hidden */
  88316. _areLightsDisposed: boolean;
  88317. /** @hidden */
  88318. _areAttributesDirty: boolean;
  88319. /** @hidden */
  88320. _areTexturesDirty: boolean;
  88321. /** @hidden */
  88322. _areFresnelDirty: boolean;
  88323. /** @hidden */
  88324. _areMiscDirty: boolean;
  88325. /** @hidden */
  88326. _areImageProcessingDirty: boolean;
  88327. /** @hidden */
  88328. _normals: boolean;
  88329. /** @hidden */
  88330. _uvs: boolean;
  88331. /** @hidden */
  88332. _needNormals: boolean;
  88333. /** @hidden */
  88334. _needUVs: boolean;
  88335. [id: string]: any;
  88336. /**
  88337. * Specifies if the material needs to be re-calculated
  88338. */
  88339. get isDirty(): boolean;
  88340. /**
  88341. * Marks the material to indicate that it has been re-calculated
  88342. */
  88343. markAsProcessed(): void;
  88344. /**
  88345. * Marks the material to indicate that it needs to be re-calculated
  88346. */
  88347. markAsUnprocessed(): void;
  88348. /**
  88349. * Marks the material to indicate all of its defines need to be re-calculated
  88350. */
  88351. markAllAsDirty(): void;
  88352. /**
  88353. * Marks the material to indicate that image processing needs to be re-calculated
  88354. */
  88355. markAsImageProcessingDirty(): void;
  88356. /**
  88357. * Marks the material to indicate the lights need to be re-calculated
  88358. * @param disposed Defines whether the light is dirty due to dispose or not
  88359. */
  88360. markAsLightDirty(disposed?: boolean): void;
  88361. /**
  88362. * Marks the attribute state as changed
  88363. */
  88364. markAsAttributesDirty(): void;
  88365. /**
  88366. * Marks the texture state as changed
  88367. */
  88368. markAsTexturesDirty(): void;
  88369. /**
  88370. * Marks the fresnel state as changed
  88371. */
  88372. markAsFresnelDirty(): void;
  88373. /**
  88374. * Marks the misc state as changed
  88375. */
  88376. markAsMiscDirty(): void;
  88377. /**
  88378. * Rebuilds the material defines
  88379. */
  88380. rebuild(): void;
  88381. /**
  88382. * Specifies if two material defines are equal
  88383. * @param other - A material define instance to compare to
  88384. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  88385. */
  88386. isEqual(other: MaterialDefines): boolean;
  88387. /**
  88388. * Clones this instance's defines to another instance
  88389. * @param other - material defines to clone values to
  88390. */
  88391. cloneTo(other: MaterialDefines): void;
  88392. /**
  88393. * Resets the material define values
  88394. */
  88395. reset(): void;
  88396. /**
  88397. * Converts the material define values to a string
  88398. * @returns - String of material define information
  88399. */
  88400. toString(): string;
  88401. }
  88402. }
  88403. declare module BABYLON {
  88404. /**
  88405. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88406. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88407. * 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;
  88408. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88409. */
  88410. export class ColorCurves {
  88411. private _dirty;
  88412. private _tempColor;
  88413. private _globalCurve;
  88414. private _highlightsCurve;
  88415. private _midtonesCurve;
  88416. private _shadowsCurve;
  88417. private _positiveCurve;
  88418. private _negativeCurve;
  88419. private _globalHue;
  88420. private _globalDensity;
  88421. private _globalSaturation;
  88422. private _globalExposure;
  88423. /**
  88424. * Gets the global Hue value.
  88425. * 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).
  88426. */
  88427. get globalHue(): number;
  88428. /**
  88429. * Sets the global Hue value.
  88430. * 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).
  88431. */
  88432. set globalHue(value: number);
  88433. /**
  88434. * Gets the global Density value.
  88435. * 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.
  88436. * Values less than zero provide a filter of opposite hue.
  88437. */
  88438. get globalDensity(): number;
  88439. /**
  88440. * Sets the global Density value.
  88441. * 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.
  88442. * Values less than zero provide a filter of opposite hue.
  88443. */
  88444. set globalDensity(value: number);
  88445. /**
  88446. * Gets the global Saturation value.
  88447. * 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.
  88448. */
  88449. get globalSaturation(): number;
  88450. /**
  88451. * Sets the global Saturation value.
  88452. * 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.
  88453. */
  88454. set globalSaturation(value: number);
  88455. /**
  88456. * Gets the global Exposure value.
  88457. * 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.
  88458. */
  88459. get globalExposure(): number;
  88460. /**
  88461. * Sets the global Exposure value.
  88462. * 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.
  88463. */
  88464. set globalExposure(value: number);
  88465. private _highlightsHue;
  88466. private _highlightsDensity;
  88467. private _highlightsSaturation;
  88468. private _highlightsExposure;
  88469. /**
  88470. * Gets the highlights Hue value.
  88471. * 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).
  88472. */
  88473. get highlightsHue(): number;
  88474. /**
  88475. * Sets the highlights Hue value.
  88476. * 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).
  88477. */
  88478. set highlightsHue(value: number);
  88479. /**
  88480. * Gets the highlights Density value.
  88481. * 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.
  88482. * Values less than zero provide a filter of opposite hue.
  88483. */
  88484. get highlightsDensity(): number;
  88485. /**
  88486. * Sets the highlights Density value.
  88487. * 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.
  88488. * Values less than zero provide a filter of opposite hue.
  88489. */
  88490. set highlightsDensity(value: number);
  88491. /**
  88492. * Gets the highlights Saturation value.
  88493. * 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.
  88494. */
  88495. get highlightsSaturation(): number;
  88496. /**
  88497. * Sets the highlights Saturation value.
  88498. * 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.
  88499. */
  88500. set highlightsSaturation(value: number);
  88501. /**
  88502. * Gets the highlights Exposure value.
  88503. * 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.
  88504. */
  88505. get highlightsExposure(): number;
  88506. /**
  88507. * Sets the highlights Exposure value.
  88508. * 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.
  88509. */
  88510. set highlightsExposure(value: number);
  88511. private _midtonesHue;
  88512. private _midtonesDensity;
  88513. private _midtonesSaturation;
  88514. private _midtonesExposure;
  88515. /**
  88516. * Gets the midtones Hue value.
  88517. * 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).
  88518. */
  88519. get midtonesHue(): number;
  88520. /**
  88521. * Sets the midtones Hue value.
  88522. * 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).
  88523. */
  88524. set midtonesHue(value: number);
  88525. /**
  88526. * Gets the midtones Density value.
  88527. * 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.
  88528. * Values less than zero provide a filter of opposite hue.
  88529. */
  88530. get midtonesDensity(): number;
  88531. /**
  88532. * Sets the midtones Density value.
  88533. * 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.
  88534. * Values less than zero provide a filter of opposite hue.
  88535. */
  88536. set midtonesDensity(value: number);
  88537. /**
  88538. * Gets the midtones Saturation value.
  88539. * 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.
  88540. */
  88541. get midtonesSaturation(): number;
  88542. /**
  88543. * Sets the midtones Saturation value.
  88544. * 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.
  88545. */
  88546. set midtonesSaturation(value: number);
  88547. /**
  88548. * Gets the midtones Exposure value.
  88549. * 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.
  88550. */
  88551. get midtonesExposure(): number;
  88552. /**
  88553. * Sets the midtones Exposure value.
  88554. * 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.
  88555. */
  88556. set midtonesExposure(value: number);
  88557. private _shadowsHue;
  88558. private _shadowsDensity;
  88559. private _shadowsSaturation;
  88560. private _shadowsExposure;
  88561. /**
  88562. * Gets the shadows Hue value.
  88563. * 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).
  88564. */
  88565. get shadowsHue(): number;
  88566. /**
  88567. * Sets the shadows Hue value.
  88568. * 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).
  88569. */
  88570. set shadowsHue(value: number);
  88571. /**
  88572. * Gets the shadows Density value.
  88573. * 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.
  88574. * Values less than zero provide a filter of opposite hue.
  88575. */
  88576. get shadowsDensity(): number;
  88577. /**
  88578. * Sets the shadows Density value.
  88579. * 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.
  88580. * Values less than zero provide a filter of opposite hue.
  88581. */
  88582. set shadowsDensity(value: number);
  88583. /**
  88584. * Gets the shadows Saturation value.
  88585. * 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.
  88586. */
  88587. get shadowsSaturation(): number;
  88588. /**
  88589. * Sets the shadows Saturation value.
  88590. * 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.
  88591. */
  88592. set shadowsSaturation(value: number);
  88593. /**
  88594. * Gets the shadows Exposure value.
  88595. * 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.
  88596. */
  88597. get shadowsExposure(): number;
  88598. /**
  88599. * Sets the shadows Exposure value.
  88600. * 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.
  88601. */
  88602. set shadowsExposure(value: number);
  88603. /**
  88604. * Returns the class name
  88605. * @returns The class name
  88606. */
  88607. getClassName(): string;
  88608. /**
  88609. * Binds the color curves to the shader.
  88610. * @param colorCurves The color curve to bind
  88611. * @param effect The effect to bind to
  88612. * @param positiveUniform The positive uniform shader parameter
  88613. * @param neutralUniform The neutral uniform shader parameter
  88614. * @param negativeUniform The negative uniform shader parameter
  88615. */
  88616. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88617. /**
  88618. * Prepare the list of uniforms associated with the ColorCurves effects.
  88619. * @param uniformsList The list of uniforms used in the effect
  88620. */
  88621. static PrepareUniforms(uniformsList: string[]): void;
  88622. /**
  88623. * Returns color grading data based on a hue, density, saturation and exposure value.
  88624. * @param filterHue The hue of the color filter.
  88625. * @param filterDensity The density of the color filter.
  88626. * @param saturation The saturation.
  88627. * @param exposure The exposure.
  88628. * @param result The result data container.
  88629. */
  88630. private getColorGradingDataToRef;
  88631. /**
  88632. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88633. * @param value The input slider value in range [-100,100].
  88634. * @returns Adjusted value.
  88635. */
  88636. private static applyColorGradingSliderNonlinear;
  88637. /**
  88638. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88639. * @param hue The hue (H) input.
  88640. * @param saturation The saturation (S) input.
  88641. * @param brightness The brightness (B) input.
  88642. * @result An RGBA color represented as Vector4.
  88643. */
  88644. private static fromHSBToRef;
  88645. /**
  88646. * Returns a value clamped between min and max
  88647. * @param value The value to clamp
  88648. * @param min The minimum of value
  88649. * @param max The maximum of value
  88650. * @returns The clamped value.
  88651. */
  88652. private static clamp;
  88653. /**
  88654. * Clones the current color curve instance.
  88655. * @return The cloned curves
  88656. */
  88657. clone(): ColorCurves;
  88658. /**
  88659. * Serializes the current color curve instance to a json representation.
  88660. * @return a JSON representation
  88661. */
  88662. serialize(): any;
  88663. /**
  88664. * Parses the color curve from a json representation.
  88665. * @param source the JSON source to parse
  88666. * @return The parsed curves
  88667. */
  88668. static Parse(source: any): ColorCurves;
  88669. }
  88670. }
  88671. declare module BABYLON {
  88672. /**
  88673. * Interface to follow in your material defines to integrate easily the
  88674. * Image proccessing functions.
  88675. * @hidden
  88676. */
  88677. export interface IImageProcessingConfigurationDefines {
  88678. IMAGEPROCESSING: boolean;
  88679. VIGNETTE: boolean;
  88680. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88681. VIGNETTEBLENDMODEOPAQUE: boolean;
  88682. TONEMAPPING: boolean;
  88683. TONEMAPPING_ACES: boolean;
  88684. CONTRAST: boolean;
  88685. EXPOSURE: boolean;
  88686. COLORCURVES: boolean;
  88687. COLORGRADING: boolean;
  88688. COLORGRADING3D: boolean;
  88689. SAMPLER3DGREENDEPTH: boolean;
  88690. SAMPLER3DBGRMAP: boolean;
  88691. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88692. }
  88693. /**
  88694. * @hidden
  88695. */
  88696. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88697. IMAGEPROCESSING: boolean;
  88698. VIGNETTE: boolean;
  88699. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88700. VIGNETTEBLENDMODEOPAQUE: boolean;
  88701. TONEMAPPING: boolean;
  88702. TONEMAPPING_ACES: boolean;
  88703. CONTRAST: boolean;
  88704. COLORCURVES: boolean;
  88705. COLORGRADING: boolean;
  88706. COLORGRADING3D: boolean;
  88707. SAMPLER3DGREENDEPTH: boolean;
  88708. SAMPLER3DBGRMAP: boolean;
  88709. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88710. EXPOSURE: boolean;
  88711. constructor();
  88712. }
  88713. /**
  88714. * This groups together the common properties used for image processing either in direct forward pass
  88715. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88716. * or not.
  88717. */
  88718. export class ImageProcessingConfiguration {
  88719. /**
  88720. * Default tone mapping applied in BabylonJS.
  88721. */
  88722. static readonly TONEMAPPING_STANDARD: number;
  88723. /**
  88724. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88725. * to other engines rendering to increase portability.
  88726. */
  88727. static readonly TONEMAPPING_ACES: number;
  88728. /**
  88729. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88730. */
  88731. colorCurves: Nullable<ColorCurves>;
  88732. private _colorCurvesEnabled;
  88733. /**
  88734. * Gets wether the color curves effect is enabled.
  88735. */
  88736. get colorCurvesEnabled(): boolean;
  88737. /**
  88738. * Sets wether the color curves effect is enabled.
  88739. */
  88740. set colorCurvesEnabled(value: boolean);
  88741. private _colorGradingTexture;
  88742. /**
  88743. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88744. */
  88745. get colorGradingTexture(): Nullable<BaseTexture>;
  88746. /**
  88747. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88748. */
  88749. set colorGradingTexture(value: Nullable<BaseTexture>);
  88750. private _colorGradingEnabled;
  88751. /**
  88752. * Gets wether the color grading effect is enabled.
  88753. */
  88754. get colorGradingEnabled(): boolean;
  88755. /**
  88756. * Sets wether the color grading effect is enabled.
  88757. */
  88758. set colorGradingEnabled(value: boolean);
  88759. private _colorGradingWithGreenDepth;
  88760. /**
  88761. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88762. */
  88763. get colorGradingWithGreenDepth(): boolean;
  88764. /**
  88765. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88766. */
  88767. set colorGradingWithGreenDepth(value: boolean);
  88768. private _colorGradingBGR;
  88769. /**
  88770. * Gets wether the color grading texture contains BGR values.
  88771. */
  88772. get colorGradingBGR(): boolean;
  88773. /**
  88774. * Sets wether the color grading texture contains BGR values.
  88775. */
  88776. set colorGradingBGR(value: boolean);
  88777. /** @hidden */
  88778. _exposure: number;
  88779. /**
  88780. * Gets the Exposure used in the effect.
  88781. */
  88782. get exposure(): number;
  88783. /**
  88784. * Sets the Exposure used in the effect.
  88785. */
  88786. set exposure(value: number);
  88787. private _toneMappingEnabled;
  88788. /**
  88789. * Gets wether the tone mapping effect is enabled.
  88790. */
  88791. get toneMappingEnabled(): boolean;
  88792. /**
  88793. * Sets wether the tone mapping effect is enabled.
  88794. */
  88795. set toneMappingEnabled(value: boolean);
  88796. private _toneMappingType;
  88797. /**
  88798. * Gets the type of tone mapping effect.
  88799. */
  88800. get toneMappingType(): number;
  88801. /**
  88802. * Sets the type of tone mapping effect used in BabylonJS.
  88803. */
  88804. set toneMappingType(value: number);
  88805. protected _contrast: number;
  88806. /**
  88807. * Gets the contrast used in the effect.
  88808. */
  88809. get contrast(): number;
  88810. /**
  88811. * Sets the contrast used in the effect.
  88812. */
  88813. set contrast(value: number);
  88814. /**
  88815. * Vignette stretch size.
  88816. */
  88817. vignetteStretch: number;
  88818. /**
  88819. * Vignette centre X Offset.
  88820. */
  88821. vignetteCentreX: number;
  88822. /**
  88823. * Vignette centre Y Offset.
  88824. */
  88825. vignetteCentreY: number;
  88826. /**
  88827. * Vignette weight or intensity of the vignette effect.
  88828. */
  88829. vignetteWeight: number;
  88830. /**
  88831. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88832. * if vignetteEnabled is set to true.
  88833. */
  88834. vignetteColor: Color4;
  88835. /**
  88836. * Camera field of view used by the Vignette effect.
  88837. */
  88838. vignetteCameraFov: number;
  88839. private _vignetteBlendMode;
  88840. /**
  88841. * Gets the vignette blend mode allowing different kind of effect.
  88842. */
  88843. get vignetteBlendMode(): number;
  88844. /**
  88845. * Sets the vignette blend mode allowing different kind of effect.
  88846. */
  88847. set vignetteBlendMode(value: number);
  88848. private _vignetteEnabled;
  88849. /**
  88850. * Gets wether the vignette effect is enabled.
  88851. */
  88852. get vignetteEnabled(): boolean;
  88853. /**
  88854. * Sets wether the vignette effect is enabled.
  88855. */
  88856. set vignetteEnabled(value: boolean);
  88857. private _applyByPostProcess;
  88858. /**
  88859. * Gets wether the image processing is applied through a post process or not.
  88860. */
  88861. get applyByPostProcess(): boolean;
  88862. /**
  88863. * Sets wether the image processing is applied through a post process or not.
  88864. */
  88865. set applyByPostProcess(value: boolean);
  88866. private _isEnabled;
  88867. /**
  88868. * Gets wether the image processing is enabled or not.
  88869. */
  88870. get isEnabled(): boolean;
  88871. /**
  88872. * Sets wether the image processing is enabled or not.
  88873. */
  88874. set isEnabled(value: boolean);
  88875. /**
  88876. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88877. */
  88878. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88879. /**
  88880. * Method called each time the image processing information changes requires to recompile the effect.
  88881. */
  88882. protected _updateParameters(): void;
  88883. /**
  88884. * Gets the current class name.
  88885. * @return "ImageProcessingConfiguration"
  88886. */
  88887. getClassName(): string;
  88888. /**
  88889. * Prepare the list of uniforms associated with the Image Processing effects.
  88890. * @param uniforms The list of uniforms used in the effect
  88891. * @param defines the list of defines currently in use
  88892. */
  88893. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88894. /**
  88895. * Prepare the list of samplers associated with the Image Processing effects.
  88896. * @param samplersList The list of uniforms used in the effect
  88897. * @param defines the list of defines currently in use
  88898. */
  88899. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88900. /**
  88901. * Prepare the list of defines associated to the shader.
  88902. * @param defines the list of defines to complete
  88903. * @param forPostProcess Define if we are currently in post process mode or not
  88904. */
  88905. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88906. /**
  88907. * Returns true if all the image processing information are ready.
  88908. * @returns True if ready, otherwise, false
  88909. */
  88910. isReady(): boolean;
  88911. /**
  88912. * Binds the image processing to the shader.
  88913. * @param effect The effect to bind to
  88914. * @param overrideAspectRatio Override the aspect ratio of the effect
  88915. */
  88916. bind(effect: Effect, overrideAspectRatio?: number): void;
  88917. /**
  88918. * Clones the current image processing instance.
  88919. * @return The cloned image processing
  88920. */
  88921. clone(): ImageProcessingConfiguration;
  88922. /**
  88923. * Serializes the current image processing instance to a json representation.
  88924. * @return a JSON representation
  88925. */
  88926. serialize(): any;
  88927. /**
  88928. * Parses the image processing from a json representation.
  88929. * @param source the JSON source to parse
  88930. * @return The parsed image processing
  88931. */
  88932. static Parse(source: any): ImageProcessingConfiguration;
  88933. private static _VIGNETTEMODE_MULTIPLY;
  88934. private static _VIGNETTEMODE_OPAQUE;
  88935. /**
  88936. * Used to apply the vignette as a mix with the pixel color.
  88937. */
  88938. static get VIGNETTEMODE_MULTIPLY(): number;
  88939. /**
  88940. * Used to apply the vignette as a replacement of the pixel color.
  88941. */
  88942. static get VIGNETTEMODE_OPAQUE(): number;
  88943. }
  88944. }
  88945. declare module BABYLON {
  88946. /** @hidden */
  88947. export var postprocessVertexShader: {
  88948. name: string;
  88949. shader: string;
  88950. };
  88951. }
  88952. declare module BABYLON {
  88953. /**
  88954. * Type used to define a render target texture size (either with a number or with a rect width and height)
  88955. */
  88956. export type RenderTargetTextureSize = number | {
  88957. width: number;
  88958. height: number;
  88959. layers?: number;
  88960. };
  88961. interface ThinEngine {
  88962. /**
  88963. * Creates a new render target texture
  88964. * @param size defines the size of the texture
  88965. * @param options defines the options used to create the texture
  88966. * @returns a new render target texture stored in an InternalTexture
  88967. */
  88968. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88969. /**
  88970. * Creates a depth stencil texture.
  88971. * This is only available in WebGL 2 or with the depth texture extension available.
  88972. * @param size The size of face edge in the texture.
  88973. * @param options The options defining the texture.
  88974. * @returns The texture
  88975. */
  88976. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  88977. /** @hidden */
  88978. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  88979. }
  88980. }
  88981. declare module BABYLON {
  88982. /**
  88983. * Defines the kind of connection point for node based material
  88984. */
  88985. export enum NodeMaterialBlockConnectionPointTypes {
  88986. /** Float */
  88987. Float = 1,
  88988. /** Int */
  88989. Int = 2,
  88990. /** Vector2 */
  88991. Vector2 = 4,
  88992. /** Vector3 */
  88993. Vector3 = 8,
  88994. /** Vector4 */
  88995. Vector4 = 16,
  88996. /** Color3 */
  88997. Color3 = 32,
  88998. /** Color4 */
  88999. Color4 = 64,
  89000. /** Matrix */
  89001. Matrix = 128,
  89002. /** Custom object */
  89003. Object = 256,
  89004. /** Detect type based on connection */
  89005. AutoDetect = 1024,
  89006. /** Output type that will be defined by input type */
  89007. BasedOnInput = 2048
  89008. }
  89009. }
  89010. declare module BABYLON {
  89011. /**
  89012. * Enum used to define the target of a block
  89013. */
  89014. export enum NodeMaterialBlockTargets {
  89015. /** Vertex shader */
  89016. Vertex = 1,
  89017. /** Fragment shader */
  89018. Fragment = 2,
  89019. /** Neutral */
  89020. Neutral = 4,
  89021. /** Vertex and Fragment */
  89022. VertexAndFragment = 3
  89023. }
  89024. }
  89025. declare module BABYLON {
  89026. /**
  89027. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  89028. */
  89029. export enum NodeMaterialBlockConnectionPointMode {
  89030. /** Value is an uniform */
  89031. Uniform = 0,
  89032. /** Value is a mesh attribute */
  89033. Attribute = 1,
  89034. /** Value is a varying between vertex and fragment shaders */
  89035. Varying = 2,
  89036. /** Mode is undefined */
  89037. Undefined = 3
  89038. }
  89039. }
  89040. declare module BABYLON {
  89041. /**
  89042. * Enum used to define system values e.g. values automatically provided by the system
  89043. */
  89044. export enum NodeMaterialSystemValues {
  89045. /** World */
  89046. World = 1,
  89047. /** View */
  89048. View = 2,
  89049. /** Projection */
  89050. Projection = 3,
  89051. /** ViewProjection */
  89052. ViewProjection = 4,
  89053. /** WorldView */
  89054. WorldView = 5,
  89055. /** WorldViewProjection */
  89056. WorldViewProjection = 6,
  89057. /** CameraPosition */
  89058. CameraPosition = 7,
  89059. /** Fog Color */
  89060. FogColor = 8,
  89061. /** Delta time */
  89062. DeltaTime = 9
  89063. }
  89064. }
  89065. declare module BABYLON {
  89066. /** Defines supported spaces */
  89067. export enum Space {
  89068. /** Local (object) space */
  89069. LOCAL = 0,
  89070. /** World space */
  89071. WORLD = 1,
  89072. /** Bone space */
  89073. BONE = 2
  89074. }
  89075. /** Defines the 3 main axes */
  89076. export class Axis {
  89077. /** X axis */
  89078. static X: Vector3;
  89079. /** Y axis */
  89080. static Y: Vector3;
  89081. /** Z axis */
  89082. static Z: Vector3;
  89083. }
  89084. }
  89085. declare module BABYLON {
  89086. /**
  89087. * Represents a camera frustum
  89088. */
  89089. export class Frustum {
  89090. /**
  89091. * Gets the planes representing the frustum
  89092. * @param transform matrix to be applied to the returned planes
  89093. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89094. */
  89095. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89096. /**
  89097. * Gets the near frustum plane transformed by the transform matrix
  89098. * @param transform transformation matrix to be applied to the resulting frustum plane
  89099. * @param frustumPlane the resuling frustum plane
  89100. */
  89101. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89102. /**
  89103. * Gets the far frustum plane transformed by the transform matrix
  89104. * @param transform transformation matrix to be applied to the resulting frustum plane
  89105. * @param frustumPlane the resuling frustum plane
  89106. */
  89107. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89108. /**
  89109. * Gets the left frustum plane transformed by the transform matrix
  89110. * @param transform transformation matrix to be applied to the resulting frustum plane
  89111. * @param frustumPlane the resuling frustum plane
  89112. */
  89113. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89114. /**
  89115. * Gets the right frustum plane transformed by the transform matrix
  89116. * @param transform transformation matrix to be applied to the resulting frustum plane
  89117. * @param frustumPlane the resuling frustum plane
  89118. */
  89119. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89120. /**
  89121. * Gets the top frustum plane transformed by the transform matrix
  89122. * @param transform transformation matrix to be applied to the resulting frustum plane
  89123. * @param frustumPlane the resuling frustum plane
  89124. */
  89125. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89126. /**
  89127. * Gets the bottom frustum plane transformed by the transform matrix
  89128. * @param transform transformation matrix to be applied to the resulting frustum plane
  89129. * @param frustumPlane the resuling frustum plane
  89130. */
  89131. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89132. /**
  89133. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  89134. * @param transform transformation matrix to be applied to the resulting frustum planes
  89135. * @param frustumPlanes the resuling frustum planes
  89136. */
  89137. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  89138. }
  89139. }
  89140. declare module BABYLON {
  89141. /**
  89142. * Interface for the size containing width and height
  89143. */
  89144. export interface ISize {
  89145. /**
  89146. * Width
  89147. */
  89148. width: number;
  89149. /**
  89150. * Heighht
  89151. */
  89152. height: number;
  89153. }
  89154. /**
  89155. * Size containing widht and height
  89156. */
  89157. export class Size implements ISize {
  89158. /**
  89159. * Width
  89160. */
  89161. width: number;
  89162. /**
  89163. * Height
  89164. */
  89165. height: number;
  89166. /**
  89167. * Creates a Size object from the given width and height (floats).
  89168. * @param width width of the new size
  89169. * @param height height of the new size
  89170. */
  89171. constructor(width: number, height: number);
  89172. /**
  89173. * Returns a string with the Size width and height
  89174. * @returns a string with the Size width and height
  89175. */
  89176. toString(): string;
  89177. /**
  89178. * "Size"
  89179. * @returns the string "Size"
  89180. */
  89181. getClassName(): string;
  89182. /**
  89183. * Returns the Size hash code.
  89184. * @returns a hash code for a unique width and height
  89185. */
  89186. getHashCode(): number;
  89187. /**
  89188. * Updates the current size from the given one.
  89189. * @param src the given size
  89190. */
  89191. copyFrom(src: Size): void;
  89192. /**
  89193. * Updates in place the current Size from the given floats.
  89194. * @param width width of the new size
  89195. * @param height height of the new size
  89196. * @returns the updated Size.
  89197. */
  89198. copyFromFloats(width: number, height: number): Size;
  89199. /**
  89200. * Updates in place the current Size from the given floats.
  89201. * @param width width to set
  89202. * @param height height to set
  89203. * @returns the updated Size.
  89204. */
  89205. set(width: number, height: number): Size;
  89206. /**
  89207. * Multiplies the width and height by numbers
  89208. * @param w factor to multiple the width by
  89209. * @param h factor to multiple the height by
  89210. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  89211. */
  89212. multiplyByFloats(w: number, h: number): Size;
  89213. /**
  89214. * Clones the size
  89215. * @returns a new Size copied from the given one.
  89216. */
  89217. clone(): Size;
  89218. /**
  89219. * True if the current Size and the given one width and height are strictly equal.
  89220. * @param other the other size to compare against
  89221. * @returns True if the current Size and the given one width and height are strictly equal.
  89222. */
  89223. equals(other: Size): boolean;
  89224. /**
  89225. * The surface of the Size : width * height (float).
  89226. */
  89227. get surface(): number;
  89228. /**
  89229. * Create a new size of zero
  89230. * @returns a new Size set to (0.0, 0.0)
  89231. */
  89232. static Zero(): Size;
  89233. /**
  89234. * Sums the width and height of two sizes
  89235. * @param otherSize size to add to this size
  89236. * @returns a new Size set as the addition result of the current Size and the given one.
  89237. */
  89238. add(otherSize: Size): Size;
  89239. /**
  89240. * Subtracts the width and height of two
  89241. * @param otherSize size to subtract to this size
  89242. * @returns a new Size set as the subtraction result of the given one from the current Size.
  89243. */
  89244. subtract(otherSize: Size): Size;
  89245. /**
  89246. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  89247. * @param start starting size to lerp between
  89248. * @param end end size to lerp between
  89249. * @param amount amount to lerp between the start and end values
  89250. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  89251. */
  89252. static Lerp(start: Size, end: Size, amount: number): Size;
  89253. }
  89254. }
  89255. declare module BABYLON {
  89256. /**
  89257. * Contains position and normal vectors for a vertex
  89258. */
  89259. export class PositionNormalVertex {
  89260. /** the position of the vertex (defaut: 0,0,0) */
  89261. position: Vector3;
  89262. /** the normal of the vertex (defaut: 0,1,0) */
  89263. normal: Vector3;
  89264. /**
  89265. * Creates a PositionNormalVertex
  89266. * @param position the position of the vertex (defaut: 0,0,0)
  89267. * @param normal the normal of the vertex (defaut: 0,1,0)
  89268. */
  89269. constructor(
  89270. /** the position of the vertex (defaut: 0,0,0) */
  89271. position?: Vector3,
  89272. /** the normal of the vertex (defaut: 0,1,0) */
  89273. normal?: Vector3);
  89274. /**
  89275. * Clones the PositionNormalVertex
  89276. * @returns the cloned PositionNormalVertex
  89277. */
  89278. clone(): PositionNormalVertex;
  89279. }
  89280. /**
  89281. * Contains position, normal and uv vectors for a vertex
  89282. */
  89283. export class PositionNormalTextureVertex {
  89284. /** the position of the vertex (defaut: 0,0,0) */
  89285. position: Vector3;
  89286. /** the normal of the vertex (defaut: 0,1,0) */
  89287. normal: Vector3;
  89288. /** the uv of the vertex (default: 0,0) */
  89289. uv: Vector2;
  89290. /**
  89291. * Creates a PositionNormalTextureVertex
  89292. * @param position the position of the vertex (defaut: 0,0,0)
  89293. * @param normal the normal of the vertex (defaut: 0,1,0)
  89294. * @param uv the uv of the vertex (default: 0,0)
  89295. */
  89296. constructor(
  89297. /** the position of the vertex (defaut: 0,0,0) */
  89298. position?: Vector3,
  89299. /** the normal of the vertex (defaut: 0,1,0) */
  89300. normal?: Vector3,
  89301. /** the uv of the vertex (default: 0,0) */
  89302. uv?: Vector2);
  89303. /**
  89304. * Clones the PositionNormalTextureVertex
  89305. * @returns the cloned PositionNormalTextureVertex
  89306. */
  89307. clone(): PositionNormalTextureVertex;
  89308. }
  89309. }
  89310. declare module BABYLON {
  89311. /**
  89312. * Enum defining the type of animations supported by InputBlock
  89313. */
  89314. export enum AnimatedInputBlockTypes {
  89315. /** No animation */
  89316. None = 0,
  89317. /** Time based animation. Will only work for floats */
  89318. Time = 1
  89319. }
  89320. }
  89321. declare module BABYLON {
  89322. /**
  89323. * Interface describing all the common properties and methods a shadow light needs to implement.
  89324. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  89325. * as well as binding the different shadow properties to the effects.
  89326. */
  89327. export interface IShadowLight extends Light {
  89328. /**
  89329. * The light id in the scene (used in scene.findLighById for instance)
  89330. */
  89331. id: string;
  89332. /**
  89333. * The position the shdow will be casted from.
  89334. */
  89335. position: Vector3;
  89336. /**
  89337. * In 2d mode (needCube being false), the direction used to cast the shadow.
  89338. */
  89339. direction: Vector3;
  89340. /**
  89341. * The transformed position. Position of the light in world space taking parenting in account.
  89342. */
  89343. transformedPosition: Vector3;
  89344. /**
  89345. * The transformed direction. Direction of the light in world space taking parenting in account.
  89346. */
  89347. transformedDirection: Vector3;
  89348. /**
  89349. * The friendly name of the light in the scene.
  89350. */
  89351. name: string;
  89352. /**
  89353. * Defines the shadow projection clipping minimum z value.
  89354. */
  89355. shadowMinZ: number;
  89356. /**
  89357. * Defines the shadow projection clipping maximum z value.
  89358. */
  89359. shadowMaxZ: number;
  89360. /**
  89361. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89362. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89363. */
  89364. computeTransformedInformation(): boolean;
  89365. /**
  89366. * Gets the scene the light belongs to.
  89367. * @returns The scene
  89368. */
  89369. getScene(): Scene;
  89370. /**
  89371. * Callback defining a custom Projection Matrix Builder.
  89372. * This can be used to override the default projection matrix computation.
  89373. */
  89374. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89375. /**
  89376. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89377. * @param matrix The materix to updated with the projection information
  89378. * @param viewMatrix The transform matrix of the light
  89379. * @param renderList The list of mesh to render in the map
  89380. * @returns The current light
  89381. */
  89382. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89383. /**
  89384. * Gets the current depth scale used in ESM.
  89385. * @returns The scale
  89386. */
  89387. getDepthScale(): number;
  89388. /**
  89389. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89390. * @returns true if a cube texture needs to be use
  89391. */
  89392. needCube(): boolean;
  89393. /**
  89394. * Detects if the projection matrix requires to be recomputed this frame.
  89395. * @returns true if it requires to be recomputed otherwise, false.
  89396. */
  89397. needProjectionMatrixCompute(): boolean;
  89398. /**
  89399. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89400. */
  89401. forceProjectionMatrixCompute(): void;
  89402. /**
  89403. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89404. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89405. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89406. */
  89407. getShadowDirection(faceIndex?: number): Vector3;
  89408. /**
  89409. * Gets the minZ used for shadow according to both the scene and the light.
  89410. * @param activeCamera The camera we are returning the min for
  89411. * @returns the depth min z
  89412. */
  89413. getDepthMinZ(activeCamera: Camera): number;
  89414. /**
  89415. * Gets the maxZ used for shadow according to both the scene and the light.
  89416. * @param activeCamera The camera we are returning the max for
  89417. * @returns the depth max z
  89418. */
  89419. getDepthMaxZ(activeCamera: Camera): number;
  89420. }
  89421. /**
  89422. * Base implementation IShadowLight
  89423. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  89424. */
  89425. export abstract class ShadowLight extends Light implements IShadowLight {
  89426. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  89427. protected _position: Vector3;
  89428. protected _setPosition(value: Vector3): void;
  89429. /**
  89430. * Sets the position the shadow will be casted from. Also use as the light position for both
  89431. * point and spot lights.
  89432. */
  89433. get position(): Vector3;
  89434. /**
  89435. * Sets the position the shadow will be casted from. Also use as the light position for both
  89436. * point and spot lights.
  89437. */
  89438. set position(value: Vector3);
  89439. protected _direction: Vector3;
  89440. protected _setDirection(value: Vector3): void;
  89441. /**
  89442. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  89443. * Also use as the light direction on spot and directional lights.
  89444. */
  89445. get direction(): Vector3;
  89446. /**
  89447. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  89448. * Also use as the light direction on spot and directional lights.
  89449. */
  89450. set direction(value: Vector3);
  89451. protected _shadowMinZ: number;
  89452. /**
  89453. * Gets the shadow projection clipping minimum z value.
  89454. */
  89455. get shadowMinZ(): number;
  89456. /**
  89457. * Sets the shadow projection clipping minimum z value.
  89458. */
  89459. set shadowMinZ(value: number);
  89460. protected _shadowMaxZ: number;
  89461. /**
  89462. * Sets the shadow projection clipping maximum z value.
  89463. */
  89464. get shadowMaxZ(): number;
  89465. /**
  89466. * Gets the shadow projection clipping maximum z value.
  89467. */
  89468. set shadowMaxZ(value: number);
  89469. /**
  89470. * Callback defining a custom Projection Matrix Builder.
  89471. * This can be used to override the default projection matrix computation.
  89472. */
  89473. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89474. /**
  89475. * The transformed position. Position of the light in world space taking parenting in account.
  89476. */
  89477. transformedPosition: Vector3;
  89478. /**
  89479. * The transformed direction. Direction of the light in world space taking parenting in account.
  89480. */
  89481. transformedDirection: Vector3;
  89482. private _needProjectionMatrixCompute;
  89483. /**
  89484. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89485. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89486. */
  89487. computeTransformedInformation(): boolean;
  89488. /**
  89489. * Return the depth scale used for the shadow map.
  89490. * @returns the depth scale.
  89491. */
  89492. getDepthScale(): number;
  89493. /**
  89494. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89495. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89496. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89497. */
  89498. getShadowDirection(faceIndex?: number): Vector3;
  89499. /**
  89500. * Returns the ShadowLight absolute position in the World.
  89501. * @returns the position vector in world space
  89502. */
  89503. getAbsolutePosition(): Vector3;
  89504. /**
  89505. * Sets the ShadowLight direction toward the passed target.
  89506. * @param target The point to target in local space
  89507. * @returns the updated ShadowLight direction
  89508. */
  89509. setDirectionToTarget(target: Vector3): Vector3;
  89510. /**
  89511. * Returns the light rotation in euler definition.
  89512. * @returns the x y z rotation in local space.
  89513. */
  89514. getRotation(): Vector3;
  89515. /**
  89516. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89517. * @returns true if a cube texture needs to be use
  89518. */
  89519. needCube(): boolean;
  89520. /**
  89521. * Detects if the projection matrix requires to be recomputed this frame.
  89522. * @returns true if it requires to be recomputed otherwise, false.
  89523. */
  89524. needProjectionMatrixCompute(): boolean;
  89525. /**
  89526. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89527. */
  89528. forceProjectionMatrixCompute(): void;
  89529. /** @hidden */
  89530. _initCache(): void;
  89531. /** @hidden */
  89532. _isSynchronized(): boolean;
  89533. /**
  89534. * Computes the world matrix of the node
  89535. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89536. * @returns the world matrix
  89537. */
  89538. computeWorldMatrix(force?: boolean): Matrix;
  89539. /**
  89540. * Gets the minZ used for shadow according to both the scene and the light.
  89541. * @param activeCamera The camera we are returning the min for
  89542. * @returns the depth min z
  89543. */
  89544. getDepthMinZ(activeCamera: Camera): number;
  89545. /**
  89546. * Gets the maxZ used for shadow according to both the scene and the light.
  89547. * @param activeCamera The camera we are returning the max for
  89548. * @returns the depth max z
  89549. */
  89550. getDepthMaxZ(activeCamera: Camera): number;
  89551. /**
  89552. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89553. * @param matrix The materix to updated with the projection information
  89554. * @param viewMatrix The transform matrix of the light
  89555. * @param renderList The list of mesh to render in the map
  89556. * @returns The current light
  89557. */
  89558. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89559. }
  89560. }
  89561. declare module BABYLON {
  89562. /** @hidden */
  89563. export var packingFunctions: {
  89564. name: string;
  89565. shader: string;
  89566. };
  89567. }
  89568. declare module BABYLON {
  89569. /** @hidden */
  89570. export var bayerDitherFunctions: {
  89571. name: string;
  89572. shader: string;
  89573. };
  89574. }
  89575. declare module BABYLON {
  89576. /** @hidden */
  89577. export var shadowMapFragmentDeclaration: {
  89578. name: string;
  89579. shader: string;
  89580. };
  89581. }
  89582. declare module BABYLON {
  89583. /** @hidden */
  89584. export var clipPlaneFragmentDeclaration: {
  89585. name: string;
  89586. shader: string;
  89587. };
  89588. }
  89589. declare module BABYLON {
  89590. /** @hidden */
  89591. export var clipPlaneFragment: {
  89592. name: string;
  89593. shader: string;
  89594. };
  89595. }
  89596. declare module BABYLON {
  89597. /** @hidden */
  89598. export var shadowMapFragment: {
  89599. name: string;
  89600. shader: string;
  89601. };
  89602. }
  89603. declare module BABYLON {
  89604. /** @hidden */
  89605. export var shadowMapPixelShader: {
  89606. name: string;
  89607. shader: string;
  89608. };
  89609. }
  89610. declare module BABYLON {
  89611. /** @hidden */
  89612. export var bonesDeclaration: {
  89613. name: string;
  89614. shader: string;
  89615. };
  89616. }
  89617. declare module BABYLON {
  89618. /** @hidden */
  89619. export var morphTargetsVertexGlobalDeclaration: {
  89620. name: string;
  89621. shader: string;
  89622. };
  89623. }
  89624. declare module BABYLON {
  89625. /** @hidden */
  89626. export var morphTargetsVertexDeclaration: {
  89627. name: string;
  89628. shader: string;
  89629. };
  89630. }
  89631. declare module BABYLON {
  89632. /** @hidden */
  89633. export var instancesDeclaration: {
  89634. name: string;
  89635. shader: string;
  89636. };
  89637. }
  89638. declare module BABYLON {
  89639. /** @hidden */
  89640. export var helperFunctions: {
  89641. name: string;
  89642. shader: string;
  89643. };
  89644. }
  89645. declare module BABYLON {
  89646. /** @hidden */
  89647. export var shadowMapVertexDeclaration: {
  89648. name: string;
  89649. shader: string;
  89650. };
  89651. }
  89652. declare module BABYLON {
  89653. /** @hidden */
  89654. export var clipPlaneVertexDeclaration: {
  89655. name: string;
  89656. shader: string;
  89657. };
  89658. }
  89659. declare module BABYLON {
  89660. /** @hidden */
  89661. export var morphTargetsVertex: {
  89662. name: string;
  89663. shader: string;
  89664. };
  89665. }
  89666. declare module BABYLON {
  89667. /** @hidden */
  89668. export var instancesVertex: {
  89669. name: string;
  89670. shader: string;
  89671. };
  89672. }
  89673. declare module BABYLON {
  89674. /** @hidden */
  89675. export var bonesVertex: {
  89676. name: string;
  89677. shader: string;
  89678. };
  89679. }
  89680. declare module BABYLON {
  89681. /** @hidden */
  89682. export var shadowMapVertexNormalBias: {
  89683. name: string;
  89684. shader: string;
  89685. };
  89686. }
  89687. declare module BABYLON {
  89688. /** @hidden */
  89689. export var shadowMapVertexMetric: {
  89690. name: string;
  89691. shader: string;
  89692. };
  89693. }
  89694. declare module BABYLON {
  89695. /** @hidden */
  89696. export var clipPlaneVertex: {
  89697. name: string;
  89698. shader: string;
  89699. };
  89700. }
  89701. declare module BABYLON {
  89702. /** @hidden */
  89703. export var shadowMapVertexShader: {
  89704. name: string;
  89705. shader: string;
  89706. };
  89707. }
  89708. declare module BABYLON {
  89709. /** @hidden */
  89710. export var depthBoxBlurPixelShader: {
  89711. name: string;
  89712. shader: string;
  89713. };
  89714. }
  89715. declare module BABYLON {
  89716. /** @hidden */
  89717. export var shadowMapFragmentSoftTransparentShadow: {
  89718. name: string;
  89719. shader: string;
  89720. };
  89721. }
  89722. declare module BABYLON {
  89723. /**
  89724. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  89725. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  89726. */
  89727. export class EffectFallbacks implements IEffectFallbacks {
  89728. private _defines;
  89729. private _currentRank;
  89730. private _maxRank;
  89731. private _mesh;
  89732. /**
  89733. * Removes the fallback from the bound mesh.
  89734. */
  89735. unBindMesh(): void;
  89736. /**
  89737. * Adds a fallback on the specified property.
  89738. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89739. * @param define The name of the define in the shader
  89740. */
  89741. addFallback(rank: number, define: string): void;
  89742. /**
  89743. * Sets the mesh to use CPU skinning when needing to fallback.
  89744. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89745. * @param mesh The mesh to use the fallbacks.
  89746. */
  89747. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  89748. /**
  89749. * Checks to see if more fallbacks are still availible.
  89750. */
  89751. get hasMoreFallbacks(): boolean;
  89752. /**
  89753. * Removes the defines that should be removed when falling back.
  89754. * @param currentDefines defines the current define statements for the shader.
  89755. * @param effect defines the current effect we try to compile
  89756. * @returns The resulting defines with defines of the current rank removed.
  89757. */
  89758. reduce(currentDefines: string, effect: Effect): string;
  89759. }
  89760. }
  89761. declare module BABYLON {
  89762. /**
  89763. * Interface used to define Action
  89764. */
  89765. export interface IAction {
  89766. /**
  89767. * Trigger for the action
  89768. */
  89769. trigger: number;
  89770. /** Options of the trigger */
  89771. triggerOptions: any;
  89772. /**
  89773. * Gets the trigger parameters
  89774. * @returns the trigger parameters
  89775. */
  89776. getTriggerParameter(): any;
  89777. /**
  89778. * Internal only - executes current action event
  89779. * @hidden
  89780. */
  89781. _executeCurrent(evt?: ActionEvent): void;
  89782. /**
  89783. * Serialize placeholder for child classes
  89784. * @param parent of child
  89785. * @returns the serialized object
  89786. */
  89787. serialize(parent: any): any;
  89788. /**
  89789. * Internal only
  89790. * @hidden
  89791. */
  89792. _prepare(): void;
  89793. /**
  89794. * Internal only - manager for action
  89795. * @hidden
  89796. */
  89797. _actionManager: Nullable<AbstractActionManager>;
  89798. /**
  89799. * Adds action to chain of actions, may be a DoNothingAction
  89800. * @param action defines the next action to execute
  89801. * @returns The action passed in
  89802. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89803. */
  89804. then(action: IAction): IAction;
  89805. }
  89806. /**
  89807. * The action to be carried out following a trigger
  89808. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  89809. */
  89810. export class Action implements IAction {
  89811. /** the trigger, with or without parameters, for the action */
  89812. triggerOptions: any;
  89813. /**
  89814. * Trigger for the action
  89815. */
  89816. trigger: number;
  89817. /**
  89818. * Internal only - manager for action
  89819. * @hidden
  89820. */
  89821. _actionManager: ActionManager;
  89822. private _nextActiveAction;
  89823. private _child;
  89824. private _condition?;
  89825. private _triggerParameter;
  89826. /**
  89827. * An event triggered prior to action being executed.
  89828. */
  89829. onBeforeExecuteObservable: Observable<Action>;
  89830. /**
  89831. * Creates a new Action
  89832. * @param triggerOptions the trigger, with or without parameters, for the action
  89833. * @param condition an optional determinant of action
  89834. */
  89835. constructor(
  89836. /** the trigger, with or without parameters, for the action */
  89837. triggerOptions: any, condition?: Condition);
  89838. /**
  89839. * Internal only
  89840. * @hidden
  89841. */
  89842. _prepare(): void;
  89843. /**
  89844. * Gets the trigger parameters
  89845. * @returns the trigger parameters
  89846. */
  89847. getTriggerParameter(): any;
  89848. /**
  89849. * Internal only - executes current action event
  89850. * @hidden
  89851. */
  89852. _executeCurrent(evt?: ActionEvent): void;
  89853. /**
  89854. * Execute placeholder for child classes
  89855. * @param evt optional action event
  89856. */
  89857. execute(evt?: ActionEvent): void;
  89858. /**
  89859. * Skips to next active action
  89860. */
  89861. skipToNextActiveAction(): void;
  89862. /**
  89863. * Adds action to chain of actions, may be a DoNothingAction
  89864. * @param action defines the next action to execute
  89865. * @returns The action passed in
  89866. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89867. */
  89868. then(action: Action): Action;
  89869. /**
  89870. * Internal only
  89871. * @hidden
  89872. */
  89873. _getProperty(propertyPath: string): string;
  89874. /**
  89875. * Internal only
  89876. * @hidden
  89877. */
  89878. _getEffectiveTarget(target: any, propertyPath: string): any;
  89879. /**
  89880. * Serialize placeholder for child classes
  89881. * @param parent of child
  89882. * @returns the serialized object
  89883. */
  89884. serialize(parent: any): any;
  89885. /**
  89886. * Internal only called by serialize
  89887. * @hidden
  89888. */
  89889. protected _serialize(serializedAction: any, parent?: any): any;
  89890. /**
  89891. * Internal only
  89892. * @hidden
  89893. */
  89894. static _SerializeValueAsString: (value: any) => string;
  89895. /**
  89896. * Internal only
  89897. * @hidden
  89898. */
  89899. static _GetTargetProperty: (target: Scene | Node) => {
  89900. name: string;
  89901. targetType: string;
  89902. value: string;
  89903. };
  89904. }
  89905. }
  89906. declare module BABYLON {
  89907. /**
  89908. * A Condition applied to an Action
  89909. */
  89910. export class Condition {
  89911. /**
  89912. * Internal only - manager for action
  89913. * @hidden
  89914. */
  89915. _actionManager: ActionManager;
  89916. /**
  89917. * Internal only
  89918. * @hidden
  89919. */
  89920. _evaluationId: number;
  89921. /**
  89922. * Internal only
  89923. * @hidden
  89924. */
  89925. _currentResult: boolean;
  89926. /**
  89927. * Creates a new Condition
  89928. * @param actionManager the manager of the action the condition is applied to
  89929. */
  89930. constructor(actionManager: ActionManager);
  89931. /**
  89932. * Check if the current condition is valid
  89933. * @returns a boolean
  89934. */
  89935. isValid(): boolean;
  89936. /**
  89937. * Internal only
  89938. * @hidden
  89939. */
  89940. _getProperty(propertyPath: string): string;
  89941. /**
  89942. * Internal only
  89943. * @hidden
  89944. */
  89945. _getEffectiveTarget(target: any, propertyPath: string): any;
  89946. /**
  89947. * Serialize placeholder for child classes
  89948. * @returns the serialized object
  89949. */
  89950. serialize(): any;
  89951. /**
  89952. * Internal only
  89953. * @hidden
  89954. */
  89955. protected _serialize(serializedCondition: any): any;
  89956. }
  89957. /**
  89958. * Defines specific conditional operators as extensions of Condition
  89959. */
  89960. export class ValueCondition extends Condition {
  89961. /** path to specify the property of the target the conditional operator uses */
  89962. propertyPath: string;
  89963. /** the value compared by the conditional operator against the current value of the property */
  89964. value: any;
  89965. /** the conditional operator, default ValueCondition.IsEqual */
  89966. operator: number;
  89967. /**
  89968. * Internal only
  89969. * @hidden
  89970. */
  89971. private static _IsEqual;
  89972. /**
  89973. * Internal only
  89974. * @hidden
  89975. */
  89976. private static _IsDifferent;
  89977. /**
  89978. * Internal only
  89979. * @hidden
  89980. */
  89981. private static _IsGreater;
  89982. /**
  89983. * Internal only
  89984. * @hidden
  89985. */
  89986. private static _IsLesser;
  89987. /**
  89988. * returns the number for IsEqual
  89989. */
  89990. static get IsEqual(): number;
  89991. /**
  89992. * Returns the number for IsDifferent
  89993. */
  89994. static get IsDifferent(): number;
  89995. /**
  89996. * Returns the number for IsGreater
  89997. */
  89998. static get IsGreater(): number;
  89999. /**
  90000. * Returns the number for IsLesser
  90001. */
  90002. static get IsLesser(): number;
  90003. /**
  90004. * Internal only The action manager for the condition
  90005. * @hidden
  90006. */
  90007. _actionManager: ActionManager;
  90008. /**
  90009. * Internal only
  90010. * @hidden
  90011. */
  90012. private _target;
  90013. /**
  90014. * Internal only
  90015. * @hidden
  90016. */
  90017. private _effectiveTarget;
  90018. /**
  90019. * Internal only
  90020. * @hidden
  90021. */
  90022. private _property;
  90023. /**
  90024. * Creates a new ValueCondition
  90025. * @param actionManager manager for the action the condition applies to
  90026. * @param target for the action
  90027. * @param propertyPath path to specify the property of the target the conditional operator uses
  90028. * @param value the value compared by the conditional operator against the current value of the property
  90029. * @param operator the conditional operator, default ValueCondition.IsEqual
  90030. */
  90031. constructor(actionManager: ActionManager, target: any,
  90032. /** path to specify the property of the target the conditional operator uses */
  90033. propertyPath: string,
  90034. /** the value compared by the conditional operator against the current value of the property */
  90035. value: any,
  90036. /** the conditional operator, default ValueCondition.IsEqual */
  90037. operator?: number);
  90038. /**
  90039. * Compares the given value with the property value for the specified conditional operator
  90040. * @returns the result of the comparison
  90041. */
  90042. isValid(): boolean;
  90043. /**
  90044. * Serialize the ValueCondition into a JSON compatible object
  90045. * @returns serialization object
  90046. */
  90047. serialize(): any;
  90048. /**
  90049. * Gets the name of the conditional operator for the ValueCondition
  90050. * @param operator the conditional operator
  90051. * @returns the name
  90052. */
  90053. static GetOperatorName(operator: number): string;
  90054. }
  90055. /**
  90056. * Defines a predicate condition as an extension of Condition
  90057. */
  90058. export class PredicateCondition extends Condition {
  90059. /** defines the predicate function used to validate the condition */
  90060. predicate: () => boolean;
  90061. /**
  90062. * Internal only - manager for action
  90063. * @hidden
  90064. */
  90065. _actionManager: ActionManager;
  90066. /**
  90067. * Creates a new PredicateCondition
  90068. * @param actionManager manager for the action the condition applies to
  90069. * @param predicate defines the predicate function used to validate the condition
  90070. */
  90071. constructor(actionManager: ActionManager,
  90072. /** defines the predicate function used to validate the condition */
  90073. predicate: () => boolean);
  90074. /**
  90075. * @returns the validity of the predicate condition
  90076. */
  90077. isValid(): boolean;
  90078. }
  90079. /**
  90080. * Defines a state condition as an extension of Condition
  90081. */
  90082. export class StateCondition extends Condition {
  90083. /** Value to compare with target state */
  90084. value: string;
  90085. /**
  90086. * Internal only - manager for action
  90087. * @hidden
  90088. */
  90089. _actionManager: ActionManager;
  90090. /**
  90091. * Internal only
  90092. * @hidden
  90093. */
  90094. private _target;
  90095. /**
  90096. * Creates a new StateCondition
  90097. * @param actionManager manager for the action the condition applies to
  90098. * @param target of the condition
  90099. * @param value to compare with target state
  90100. */
  90101. constructor(actionManager: ActionManager, target: any,
  90102. /** Value to compare with target state */
  90103. value: string);
  90104. /**
  90105. * Gets a boolean indicating if the current condition is met
  90106. * @returns the validity of the state
  90107. */
  90108. isValid(): boolean;
  90109. /**
  90110. * Serialize the StateCondition into a JSON compatible object
  90111. * @returns serialization object
  90112. */
  90113. serialize(): any;
  90114. }
  90115. }
  90116. declare module BABYLON {
  90117. /**
  90118. * This defines an action responsible to toggle a boolean once triggered.
  90119. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90120. */
  90121. export class SwitchBooleanAction extends Action {
  90122. /**
  90123. * The path to the boolean property in the target object
  90124. */
  90125. propertyPath: string;
  90126. private _target;
  90127. private _effectiveTarget;
  90128. private _property;
  90129. /**
  90130. * Instantiate the action
  90131. * @param triggerOptions defines the trigger options
  90132. * @param target defines the object containing the boolean
  90133. * @param propertyPath defines the path to the boolean property in the target object
  90134. * @param condition defines the trigger related conditions
  90135. */
  90136. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90137. /** @hidden */
  90138. _prepare(): void;
  90139. /**
  90140. * Execute the action toggle the boolean value.
  90141. */
  90142. execute(): void;
  90143. /**
  90144. * Serializes the actions and its related information.
  90145. * @param parent defines the object to serialize in
  90146. * @returns the serialized object
  90147. */
  90148. serialize(parent: any): any;
  90149. }
  90150. /**
  90151. * This defines an action responsible to set a the state field of the target
  90152. * to a desired value once triggered.
  90153. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90154. */
  90155. export class SetStateAction extends Action {
  90156. /**
  90157. * The value to store in the state field.
  90158. */
  90159. value: string;
  90160. private _target;
  90161. /**
  90162. * Instantiate the action
  90163. * @param triggerOptions defines the trigger options
  90164. * @param target defines the object containing the state property
  90165. * @param value defines the value to store in the state field
  90166. * @param condition defines the trigger related conditions
  90167. */
  90168. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90169. /**
  90170. * Execute the action and store the value on the target state property.
  90171. */
  90172. execute(): void;
  90173. /**
  90174. * Serializes the actions and its related information.
  90175. * @param parent defines the object to serialize in
  90176. * @returns the serialized object
  90177. */
  90178. serialize(parent: any): any;
  90179. }
  90180. /**
  90181. * This defines an action responsible to set a property of the target
  90182. * to a desired value once triggered.
  90183. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90184. */
  90185. export class SetValueAction extends Action {
  90186. /**
  90187. * The path of the property to set in the target.
  90188. */
  90189. propertyPath: string;
  90190. /**
  90191. * The value to set in the property
  90192. */
  90193. value: any;
  90194. private _target;
  90195. private _effectiveTarget;
  90196. private _property;
  90197. /**
  90198. * Instantiate the action
  90199. * @param triggerOptions defines the trigger options
  90200. * @param target defines the object containing the property
  90201. * @param propertyPath defines the path of the property to set in the target
  90202. * @param value defines the value to set in the property
  90203. * @param condition defines the trigger related conditions
  90204. */
  90205. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90206. /** @hidden */
  90207. _prepare(): void;
  90208. /**
  90209. * Execute the action and set the targetted property to the desired value.
  90210. */
  90211. execute(): void;
  90212. /**
  90213. * Serializes the actions and its related information.
  90214. * @param parent defines the object to serialize in
  90215. * @returns the serialized object
  90216. */
  90217. serialize(parent: any): any;
  90218. }
  90219. /**
  90220. * This defines an action responsible to increment the target value
  90221. * to a desired value once triggered.
  90222. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90223. */
  90224. export class IncrementValueAction extends Action {
  90225. /**
  90226. * The path of the property to increment in the target.
  90227. */
  90228. propertyPath: string;
  90229. /**
  90230. * The value we should increment the property by.
  90231. */
  90232. value: any;
  90233. private _target;
  90234. private _effectiveTarget;
  90235. private _property;
  90236. /**
  90237. * Instantiate the action
  90238. * @param triggerOptions defines the trigger options
  90239. * @param target defines the object containing the property
  90240. * @param propertyPath defines the path of the property to increment in the target
  90241. * @param value defines the value value we should increment the property by
  90242. * @param condition defines the trigger related conditions
  90243. */
  90244. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90245. /** @hidden */
  90246. _prepare(): void;
  90247. /**
  90248. * Execute the action and increment the target of the value amount.
  90249. */
  90250. execute(): void;
  90251. /**
  90252. * Serializes the actions and its related information.
  90253. * @param parent defines the object to serialize in
  90254. * @returns the serialized object
  90255. */
  90256. serialize(parent: any): any;
  90257. }
  90258. /**
  90259. * This defines an action responsible to start an animation once triggered.
  90260. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90261. */
  90262. export class PlayAnimationAction extends Action {
  90263. /**
  90264. * Where the animation should start (animation frame)
  90265. */
  90266. from: number;
  90267. /**
  90268. * Where the animation should stop (animation frame)
  90269. */
  90270. to: number;
  90271. /**
  90272. * Define if the animation should loop or stop after the first play.
  90273. */
  90274. loop?: boolean;
  90275. private _target;
  90276. /**
  90277. * Instantiate the action
  90278. * @param triggerOptions defines the trigger options
  90279. * @param target defines the target animation or animation name
  90280. * @param from defines from where the animation should start (animation frame)
  90281. * @param end defines where the animation should stop (animation frame)
  90282. * @param loop defines if the animation should loop or stop after the first play
  90283. * @param condition defines the trigger related conditions
  90284. */
  90285. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90286. /** @hidden */
  90287. _prepare(): void;
  90288. /**
  90289. * Execute the action and play the animation.
  90290. */
  90291. execute(): void;
  90292. /**
  90293. * Serializes the actions and its related information.
  90294. * @param parent defines the object to serialize in
  90295. * @returns the serialized object
  90296. */
  90297. serialize(parent: any): any;
  90298. }
  90299. /**
  90300. * This defines an action responsible to stop an animation once triggered.
  90301. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90302. */
  90303. export class StopAnimationAction extends Action {
  90304. private _target;
  90305. /**
  90306. * Instantiate the action
  90307. * @param triggerOptions defines the trigger options
  90308. * @param target defines the target animation or animation name
  90309. * @param condition defines the trigger related conditions
  90310. */
  90311. constructor(triggerOptions: any, target: any, condition?: Condition);
  90312. /** @hidden */
  90313. _prepare(): void;
  90314. /**
  90315. * Execute the action and stop the animation.
  90316. */
  90317. execute(): void;
  90318. /**
  90319. * Serializes the actions and its related information.
  90320. * @param parent defines the object to serialize in
  90321. * @returns the serialized object
  90322. */
  90323. serialize(parent: any): any;
  90324. }
  90325. /**
  90326. * This defines an action responsible that does nothing once triggered.
  90327. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90328. */
  90329. export class DoNothingAction extends Action {
  90330. /**
  90331. * Instantiate the action
  90332. * @param triggerOptions defines the trigger options
  90333. * @param condition defines the trigger related conditions
  90334. */
  90335. constructor(triggerOptions?: any, condition?: Condition);
  90336. /**
  90337. * Execute the action and do nothing.
  90338. */
  90339. execute(): void;
  90340. /**
  90341. * Serializes the actions and its related information.
  90342. * @param parent defines the object to serialize in
  90343. * @returns the serialized object
  90344. */
  90345. serialize(parent: any): any;
  90346. }
  90347. /**
  90348. * This defines an action responsible to trigger several actions once triggered.
  90349. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90350. */
  90351. export class CombineAction extends Action {
  90352. /**
  90353. * The list of aggregated animations to run.
  90354. */
  90355. children: Action[];
  90356. /**
  90357. * Instantiate the action
  90358. * @param triggerOptions defines the trigger options
  90359. * @param children defines the list of aggregated animations to run
  90360. * @param condition defines the trigger related conditions
  90361. */
  90362. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90363. /** @hidden */
  90364. _prepare(): void;
  90365. /**
  90366. * Execute the action and executes all the aggregated actions.
  90367. */
  90368. execute(evt: ActionEvent): void;
  90369. /**
  90370. * Serializes the actions and its related information.
  90371. * @param parent defines the object to serialize in
  90372. * @returns the serialized object
  90373. */
  90374. serialize(parent: any): any;
  90375. }
  90376. /**
  90377. * This defines an action responsible to run code (external event) once triggered.
  90378. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90379. */
  90380. export class ExecuteCodeAction extends Action {
  90381. /**
  90382. * The callback function to run.
  90383. */
  90384. func: (evt: ActionEvent) => void;
  90385. /**
  90386. * Instantiate the action
  90387. * @param triggerOptions defines the trigger options
  90388. * @param func defines the callback function to run
  90389. * @param condition defines the trigger related conditions
  90390. */
  90391. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90392. /**
  90393. * Execute the action and run the attached code.
  90394. */
  90395. execute(evt: ActionEvent): void;
  90396. }
  90397. /**
  90398. * This defines an action responsible to set the parent property of the target once triggered.
  90399. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90400. */
  90401. export class SetParentAction extends Action {
  90402. private _parent;
  90403. private _target;
  90404. /**
  90405. * Instantiate the action
  90406. * @param triggerOptions defines the trigger options
  90407. * @param target defines the target containing the parent property
  90408. * @param parent defines from where the animation should start (animation frame)
  90409. * @param condition defines the trigger related conditions
  90410. */
  90411. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90412. /** @hidden */
  90413. _prepare(): void;
  90414. /**
  90415. * Execute the action and set the parent property.
  90416. */
  90417. execute(): void;
  90418. /**
  90419. * Serializes the actions and its related information.
  90420. * @param parent defines the object to serialize in
  90421. * @returns the serialized object
  90422. */
  90423. serialize(parent: any): any;
  90424. }
  90425. }
  90426. declare module BABYLON {
  90427. /**
  90428. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90429. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90430. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90431. */
  90432. export class ActionManager extends AbstractActionManager {
  90433. /**
  90434. * Nothing
  90435. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90436. */
  90437. static readonly NothingTrigger: number;
  90438. /**
  90439. * On pick
  90440. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90441. */
  90442. static readonly OnPickTrigger: number;
  90443. /**
  90444. * On left pick
  90445. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90446. */
  90447. static readonly OnLeftPickTrigger: number;
  90448. /**
  90449. * On right pick
  90450. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90451. */
  90452. static readonly OnRightPickTrigger: number;
  90453. /**
  90454. * On center pick
  90455. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90456. */
  90457. static readonly OnCenterPickTrigger: number;
  90458. /**
  90459. * On pick down
  90460. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90461. */
  90462. static readonly OnPickDownTrigger: number;
  90463. /**
  90464. * On double pick
  90465. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90466. */
  90467. static readonly OnDoublePickTrigger: number;
  90468. /**
  90469. * On pick up
  90470. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90471. */
  90472. static readonly OnPickUpTrigger: number;
  90473. /**
  90474. * On pick out.
  90475. * This trigger will only be raised if you also declared a OnPickDown
  90476. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90477. */
  90478. static readonly OnPickOutTrigger: number;
  90479. /**
  90480. * On long press
  90481. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90482. */
  90483. static readonly OnLongPressTrigger: number;
  90484. /**
  90485. * On pointer over
  90486. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90487. */
  90488. static readonly OnPointerOverTrigger: number;
  90489. /**
  90490. * On pointer out
  90491. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90492. */
  90493. static readonly OnPointerOutTrigger: number;
  90494. /**
  90495. * On every frame
  90496. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90497. */
  90498. static readonly OnEveryFrameTrigger: number;
  90499. /**
  90500. * On intersection enter
  90501. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90502. */
  90503. static readonly OnIntersectionEnterTrigger: number;
  90504. /**
  90505. * On intersection exit
  90506. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90507. */
  90508. static readonly OnIntersectionExitTrigger: number;
  90509. /**
  90510. * On key down
  90511. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90512. */
  90513. static readonly OnKeyDownTrigger: number;
  90514. /**
  90515. * On key up
  90516. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90517. */
  90518. static readonly OnKeyUpTrigger: number;
  90519. private _scene;
  90520. /**
  90521. * Creates a new action manager
  90522. * @param scene defines the hosting scene
  90523. */
  90524. constructor(scene: Scene);
  90525. /**
  90526. * Releases all associated resources
  90527. */
  90528. dispose(): void;
  90529. /**
  90530. * Gets hosting scene
  90531. * @returns the hosting scene
  90532. */
  90533. getScene(): Scene;
  90534. /**
  90535. * Does this action manager handles actions of any of the given triggers
  90536. * @param triggers defines the triggers to be tested
  90537. * @return a boolean indicating whether one (or more) of the triggers is handled
  90538. */
  90539. hasSpecificTriggers(triggers: number[]): boolean;
  90540. /**
  90541. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90542. * speed.
  90543. * @param triggerA defines the trigger to be tested
  90544. * @param triggerB defines the trigger to be tested
  90545. * @return a boolean indicating whether one (or more) of the triggers is handled
  90546. */
  90547. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90548. /**
  90549. * Does this action manager handles actions of a given trigger
  90550. * @param trigger defines the trigger to be tested
  90551. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90552. * @return whether the trigger is handled
  90553. */
  90554. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90555. /**
  90556. * Does this action manager has pointer triggers
  90557. */
  90558. get hasPointerTriggers(): boolean;
  90559. /**
  90560. * Does this action manager has pick triggers
  90561. */
  90562. get hasPickTriggers(): boolean;
  90563. /**
  90564. * Registers an action to this action manager
  90565. * @param action defines the action to be registered
  90566. * @return the action amended (prepared) after registration
  90567. */
  90568. registerAction(action: IAction): Nullable<IAction>;
  90569. /**
  90570. * Unregisters an action to this action manager
  90571. * @param action defines the action to be unregistered
  90572. * @return a boolean indicating whether the action has been unregistered
  90573. */
  90574. unregisterAction(action: IAction): Boolean;
  90575. /**
  90576. * Process a specific trigger
  90577. * @param trigger defines the trigger to process
  90578. * @param evt defines the event details to be processed
  90579. */
  90580. processTrigger(trigger: number, evt?: IActionEvent): void;
  90581. /** @hidden */
  90582. _getEffectiveTarget(target: any, propertyPath: string): any;
  90583. /** @hidden */
  90584. _getProperty(propertyPath: string): string;
  90585. /**
  90586. * Serialize this manager to a JSON object
  90587. * @param name defines the property name to store this manager
  90588. * @returns a JSON representation of this manager
  90589. */
  90590. serialize(name: string): any;
  90591. /**
  90592. * Creates a new ActionManager from a JSON data
  90593. * @param parsedActions defines the JSON data to read from
  90594. * @param object defines the hosting mesh
  90595. * @param scene defines the hosting scene
  90596. */
  90597. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  90598. /**
  90599. * Get a trigger name by index
  90600. * @param trigger defines the trigger index
  90601. * @returns a trigger name
  90602. */
  90603. static GetTriggerName(trigger: number): string;
  90604. }
  90605. }
  90606. declare module BABYLON {
  90607. /**
  90608. * Class used to represent a sprite
  90609. * @see https://doc.babylonjs.com/babylon101/sprites
  90610. */
  90611. export class Sprite implements IAnimatable {
  90612. /** defines the name */
  90613. name: string;
  90614. /** Gets or sets the current world position */
  90615. position: Vector3;
  90616. /** Gets or sets the main color */
  90617. color: Color4;
  90618. /** Gets or sets the width */
  90619. width: number;
  90620. /** Gets or sets the height */
  90621. height: number;
  90622. /** Gets or sets rotation angle */
  90623. angle: number;
  90624. /** Gets or sets the cell index in the sprite sheet */
  90625. cellIndex: number;
  90626. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  90627. cellRef: string;
  90628. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  90629. invertU: boolean;
  90630. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  90631. invertV: boolean;
  90632. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  90633. disposeWhenFinishedAnimating: boolean;
  90634. /** Gets the list of attached animations */
  90635. animations: Nullable<Array<Animation>>;
  90636. /** Gets or sets a boolean indicating if the sprite can be picked */
  90637. isPickable: boolean;
  90638. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  90639. useAlphaForPicking: boolean;
  90640. /** @hidden */
  90641. _xOffset: number;
  90642. /** @hidden */
  90643. _yOffset: number;
  90644. /** @hidden */
  90645. _xSize: number;
  90646. /** @hidden */
  90647. _ySize: number;
  90648. /**
  90649. * Gets or sets the associated action manager
  90650. */
  90651. actionManager: Nullable<ActionManager>;
  90652. /**
  90653. * An event triggered when the control has been disposed
  90654. */
  90655. onDisposeObservable: Observable<Sprite>;
  90656. private _animationStarted;
  90657. private _loopAnimation;
  90658. private _fromIndex;
  90659. private _toIndex;
  90660. private _delay;
  90661. private _direction;
  90662. private _manager;
  90663. private _time;
  90664. private _onAnimationEnd;
  90665. /**
  90666. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  90667. */
  90668. isVisible: boolean;
  90669. /**
  90670. * Gets or sets the sprite size
  90671. */
  90672. get size(): number;
  90673. set size(value: number);
  90674. /**
  90675. * Returns a boolean indicating if the animation is started
  90676. */
  90677. get animationStarted(): boolean;
  90678. /**
  90679. * Gets or sets the unique id of the sprite
  90680. */
  90681. uniqueId: number;
  90682. /**
  90683. * Gets the manager of this sprite
  90684. */
  90685. get manager(): ISpriteManager;
  90686. /**
  90687. * Creates a new Sprite
  90688. * @param name defines the name
  90689. * @param manager defines the manager
  90690. */
  90691. constructor(
  90692. /** defines the name */
  90693. name: string, manager: ISpriteManager);
  90694. /**
  90695. * Returns the string "Sprite"
  90696. * @returns "Sprite"
  90697. */
  90698. getClassName(): string;
  90699. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  90700. get fromIndex(): number;
  90701. set fromIndex(value: number);
  90702. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  90703. get toIndex(): number;
  90704. set toIndex(value: number);
  90705. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  90706. get loopAnimation(): boolean;
  90707. set loopAnimation(value: boolean);
  90708. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  90709. get delay(): number;
  90710. set delay(value: number);
  90711. /**
  90712. * Starts an animation
  90713. * @param from defines the initial key
  90714. * @param to defines the end key
  90715. * @param loop defines if the animation must loop
  90716. * @param delay defines the start delay (in ms)
  90717. * @param onAnimationEnd defines a callback to call when animation ends
  90718. */
  90719. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  90720. /** Stops current animation (if any) */
  90721. stopAnimation(): void;
  90722. /** @hidden */
  90723. _animate(deltaTime: number): void;
  90724. /** Release associated resources */
  90725. dispose(): void;
  90726. /**
  90727. * Serializes the sprite to a JSON object
  90728. * @returns the JSON object
  90729. */
  90730. serialize(): any;
  90731. /**
  90732. * Parses a JSON object to create a new sprite
  90733. * @param parsedSprite The JSON object to parse
  90734. * @param manager defines the hosting manager
  90735. * @returns the new sprite
  90736. */
  90737. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  90738. }
  90739. }
  90740. declare module BABYLON {
  90741. /**
  90742. * Information about the result of picking within a scene
  90743. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  90744. */
  90745. export class PickingInfo {
  90746. /** @hidden */
  90747. _pickingUnavailable: boolean;
  90748. /**
  90749. * If the pick collided with an object
  90750. */
  90751. hit: boolean;
  90752. /**
  90753. * Distance away where the pick collided
  90754. */
  90755. distance: number;
  90756. /**
  90757. * The location of pick collision
  90758. */
  90759. pickedPoint: Nullable<Vector3>;
  90760. /**
  90761. * The mesh corresponding the the pick collision
  90762. */
  90763. pickedMesh: Nullable<AbstractMesh>;
  90764. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  90765. bu: number;
  90766. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  90767. bv: number;
  90768. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90769. faceId: number;
  90770. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90771. subMeshFaceId: number;
  90772. /** Id of the the submesh that was picked */
  90773. subMeshId: number;
  90774. /** If a sprite was picked, this will be the sprite the pick collided with */
  90775. pickedSprite: Nullable<Sprite>;
  90776. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  90777. thinInstanceIndex: number;
  90778. /**
  90779. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  90780. */
  90781. originMesh: Nullable<AbstractMesh>;
  90782. /**
  90783. * The ray that was used to perform the picking.
  90784. */
  90785. ray: Nullable<Ray>;
  90786. /**
  90787. * Gets the normal correspodning to the face the pick collided with
  90788. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  90789. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  90790. * @returns The normal correspodning to the face the pick collided with
  90791. */
  90792. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  90793. /**
  90794. * Gets the texture coordinates of where the pick occured
  90795. * @returns the vector containing the coordnates of the texture
  90796. */
  90797. getTextureCoordinates(): Nullable<Vector2>;
  90798. }
  90799. }
  90800. declare module BABYLON {
  90801. /**
  90802. * Class representing a ray with position and direction
  90803. */
  90804. export class Ray {
  90805. /** origin point */
  90806. origin: Vector3;
  90807. /** direction */
  90808. direction: Vector3;
  90809. /** length of the ray */
  90810. length: number;
  90811. private static readonly _TmpVector3;
  90812. private _tmpRay;
  90813. /**
  90814. * Creates a new ray
  90815. * @param origin origin point
  90816. * @param direction direction
  90817. * @param length length of the ray
  90818. */
  90819. constructor(
  90820. /** origin point */
  90821. origin: Vector3,
  90822. /** direction */
  90823. direction: Vector3,
  90824. /** length of the ray */
  90825. length?: number);
  90826. /**
  90827. * Checks if the ray intersects a box
  90828. * This does not account for the ray lenght by design to improve perfs.
  90829. * @param minimum bound of the box
  90830. * @param maximum bound of the box
  90831. * @param intersectionTreshold extra extend to be added to the box in all direction
  90832. * @returns if the box was hit
  90833. */
  90834. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  90835. /**
  90836. * Checks if the ray intersects a box
  90837. * This does not account for the ray lenght by design to improve perfs.
  90838. * @param box the bounding box to check
  90839. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  90840. * @returns if the box was hit
  90841. */
  90842. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  90843. /**
  90844. * If the ray hits a sphere
  90845. * @param sphere the bounding sphere to check
  90846. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  90847. * @returns true if it hits the sphere
  90848. */
  90849. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  90850. /**
  90851. * If the ray hits a triange
  90852. * @param vertex0 triangle vertex
  90853. * @param vertex1 triangle vertex
  90854. * @param vertex2 triangle vertex
  90855. * @returns intersection information if hit
  90856. */
  90857. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  90858. /**
  90859. * Checks if ray intersects a plane
  90860. * @param plane the plane to check
  90861. * @returns the distance away it was hit
  90862. */
  90863. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  90864. /**
  90865. * Calculate the intercept of a ray on a given axis
  90866. * @param axis to check 'x' | 'y' | 'z'
  90867. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  90868. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  90869. */
  90870. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  90871. /**
  90872. * Checks if ray intersects a mesh
  90873. * @param mesh the mesh to check
  90874. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90875. * @returns picking info of the intersecton
  90876. */
  90877. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  90878. /**
  90879. * Checks if ray intersects a mesh
  90880. * @param meshes the meshes to check
  90881. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90882. * @param results array to store result in
  90883. * @returns Array of picking infos
  90884. */
  90885. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  90886. private _comparePickingInfo;
  90887. private static smallnum;
  90888. private static rayl;
  90889. /**
  90890. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  90891. * @param sega the first point of the segment to test the intersection against
  90892. * @param segb the second point of the segment to test the intersection against
  90893. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  90894. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  90895. */
  90896. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  90897. /**
  90898. * Update the ray from viewport position
  90899. * @param x position
  90900. * @param y y position
  90901. * @param viewportWidth viewport width
  90902. * @param viewportHeight viewport height
  90903. * @param world world matrix
  90904. * @param view view matrix
  90905. * @param projection projection matrix
  90906. * @returns this ray updated
  90907. */
  90908. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90909. /**
  90910. * Creates a ray with origin and direction of 0,0,0
  90911. * @returns the new ray
  90912. */
  90913. static Zero(): Ray;
  90914. /**
  90915. * Creates a new ray from screen space and viewport
  90916. * @param x position
  90917. * @param y y position
  90918. * @param viewportWidth viewport width
  90919. * @param viewportHeight viewport height
  90920. * @param world world matrix
  90921. * @param view view matrix
  90922. * @param projection projection matrix
  90923. * @returns new ray
  90924. */
  90925. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90926. /**
  90927. * 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
  90928. * transformed to the given world matrix.
  90929. * @param origin The origin point
  90930. * @param end The end point
  90931. * @param world a matrix to transform the ray to. Default is the identity matrix.
  90932. * @returns the new ray
  90933. */
  90934. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  90935. /**
  90936. * Transforms a ray by a matrix
  90937. * @param ray ray to transform
  90938. * @param matrix matrix to apply
  90939. * @returns the resulting new ray
  90940. */
  90941. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  90942. /**
  90943. * Transforms a ray by a matrix
  90944. * @param ray ray to transform
  90945. * @param matrix matrix to apply
  90946. * @param result ray to store result in
  90947. */
  90948. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  90949. /**
  90950. * Unproject a ray from screen space to object space
  90951. * @param sourceX defines the screen space x coordinate to use
  90952. * @param sourceY defines the screen space y coordinate to use
  90953. * @param viewportWidth defines the current width of the viewport
  90954. * @param viewportHeight defines the current height of the viewport
  90955. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  90956. * @param view defines the view matrix to use
  90957. * @param projection defines the projection matrix to use
  90958. */
  90959. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  90960. }
  90961. /**
  90962. * Type used to define predicate used to select faces when a mesh intersection is detected
  90963. */
  90964. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  90965. interface Scene {
  90966. /** @hidden */
  90967. _tempPickingRay: Nullable<Ray>;
  90968. /** @hidden */
  90969. _cachedRayForTransform: Ray;
  90970. /** @hidden */
  90971. _pickWithRayInverseMatrix: Matrix;
  90972. /** @hidden */
  90973. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90974. /** @hidden */
  90975. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90976. /** @hidden */
  90977. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90978. }
  90979. }
  90980. declare module BABYLON {
  90981. /**
  90982. * Groups all the scene component constants in one place to ease maintenance.
  90983. * @hidden
  90984. */
  90985. export class SceneComponentConstants {
  90986. static readonly NAME_EFFECTLAYER: string;
  90987. static readonly NAME_LAYER: string;
  90988. static readonly NAME_LENSFLARESYSTEM: string;
  90989. static readonly NAME_BOUNDINGBOXRENDERER: string;
  90990. static readonly NAME_PARTICLESYSTEM: string;
  90991. static readonly NAME_GAMEPAD: string;
  90992. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  90993. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  90994. static readonly NAME_PREPASSRENDERER: string;
  90995. static readonly NAME_DEPTHRENDERER: string;
  90996. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  90997. static readonly NAME_SPRITE: string;
  90998. static readonly NAME_SUBSURFACE: string;
  90999. static readonly NAME_OUTLINERENDERER: string;
  91000. static readonly NAME_PROCEDURALTEXTURE: string;
  91001. static readonly NAME_SHADOWGENERATOR: string;
  91002. static readonly NAME_OCTREE: string;
  91003. static readonly NAME_PHYSICSENGINE: string;
  91004. static readonly NAME_AUDIO: string;
  91005. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  91006. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91007. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  91008. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91009. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  91010. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  91011. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  91012. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  91013. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  91014. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  91015. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  91016. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  91017. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  91018. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  91019. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  91020. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  91021. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  91022. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  91023. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  91024. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  91025. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  91026. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  91027. static readonly STEP_AFTERRENDER_AUDIO: number;
  91028. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  91029. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  91030. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  91031. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  91032. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  91033. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  91034. static readonly STEP_POINTERMOVE_SPRITE: number;
  91035. static readonly STEP_POINTERDOWN_SPRITE: number;
  91036. static readonly STEP_POINTERUP_SPRITE: number;
  91037. }
  91038. /**
  91039. * This represents a scene component.
  91040. *
  91041. * This is used to decouple the dependency the scene is having on the different workloads like
  91042. * layers, post processes...
  91043. */
  91044. export interface ISceneComponent {
  91045. /**
  91046. * The name of the component. Each component must have a unique name.
  91047. */
  91048. name: string;
  91049. /**
  91050. * The scene the component belongs to.
  91051. */
  91052. scene: Scene;
  91053. /**
  91054. * Register the component to one instance of a scene.
  91055. */
  91056. register(): void;
  91057. /**
  91058. * Rebuilds the elements related to this component in case of
  91059. * context lost for instance.
  91060. */
  91061. rebuild(): void;
  91062. /**
  91063. * Disposes the component and the associated ressources.
  91064. */
  91065. dispose(): void;
  91066. }
  91067. /**
  91068. * This represents a SERIALIZABLE scene component.
  91069. *
  91070. * This extends Scene Component to add Serialization methods on top.
  91071. */
  91072. export interface ISceneSerializableComponent extends ISceneComponent {
  91073. /**
  91074. * Adds all the elements from the container to the scene
  91075. * @param container the container holding the elements
  91076. */
  91077. addFromContainer(container: AbstractScene): void;
  91078. /**
  91079. * Removes all the elements in the container from the scene
  91080. * @param container contains the elements to remove
  91081. * @param dispose if the removed element should be disposed (default: false)
  91082. */
  91083. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91084. /**
  91085. * Serializes the component data to the specified json object
  91086. * @param serializationObject The object to serialize to
  91087. */
  91088. serialize(serializationObject: any): void;
  91089. }
  91090. /**
  91091. * Strong typing of a Mesh related stage step action
  91092. */
  91093. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91094. /**
  91095. * Strong typing of a Evaluate Sub Mesh related stage step action
  91096. */
  91097. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91098. /**
  91099. * Strong typing of a Active Mesh related stage step action
  91100. */
  91101. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  91102. /**
  91103. * Strong typing of a Camera related stage step action
  91104. */
  91105. export type CameraStageAction = (camera: Camera) => void;
  91106. /**
  91107. * Strong typing of a Camera Frame buffer related stage step action
  91108. */
  91109. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91110. /**
  91111. * Strong typing of a Render Target related stage step action
  91112. */
  91113. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91114. /**
  91115. * Strong typing of a RenderingGroup related stage step action
  91116. */
  91117. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91118. /**
  91119. * Strong typing of a Mesh Render related stage step action
  91120. */
  91121. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91122. /**
  91123. * Strong typing of a simple stage step action
  91124. */
  91125. export type SimpleStageAction = () => void;
  91126. /**
  91127. * Strong typing of a render target action.
  91128. */
  91129. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91130. /**
  91131. * Strong typing of a pointer move action.
  91132. */
  91133. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91134. /**
  91135. * Strong typing of a pointer up/down action.
  91136. */
  91137. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91138. /**
  91139. * Representation of a stage in the scene (Basically a list of ordered steps)
  91140. * @hidden
  91141. */
  91142. export class Stage<T extends Function> extends Array<{
  91143. index: number;
  91144. component: ISceneComponent;
  91145. action: T;
  91146. }> {
  91147. /**
  91148. * Hide ctor from the rest of the world.
  91149. * @param items The items to add.
  91150. */
  91151. private constructor();
  91152. /**
  91153. * Creates a new Stage.
  91154. * @returns A new instance of a Stage
  91155. */
  91156. static Create<T extends Function>(): Stage<T>;
  91157. /**
  91158. * Registers a step in an ordered way in the targeted stage.
  91159. * @param index Defines the position to register the step in
  91160. * @param component Defines the component attached to the step
  91161. * @param action Defines the action to launch during the step
  91162. */
  91163. registerStep(index: number, component: ISceneComponent, action: T): void;
  91164. /**
  91165. * Clears all the steps from the stage.
  91166. */
  91167. clear(): void;
  91168. }
  91169. }
  91170. declare module BABYLON {
  91171. interface Scene {
  91172. /** @hidden */
  91173. _pointerOverSprite: Nullable<Sprite>;
  91174. /** @hidden */
  91175. _pickedDownSprite: Nullable<Sprite>;
  91176. /** @hidden */
  91177. _tempSpritePickingRay: Nullable<Ray>;
  91178. /**
  91179. * All of the sprite managers added to this scene
  91180. * @see https://doc.babylonjs.com/babylon101/sprites
  91181. */
  91182. spriteManagers: Array<ISpriteManager>;
  91183. /**
  91184. * An event triggered when sprites rendering is about to start
  91185. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91186. */
  91187. onBeforeSpritesRenderingObservable: Observable<Scene>;
  91188. /**
  91189. * An event triggered when sprites rendering is done
  91190. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91191. */
  91192. onAfterSpritesRenderingObservable: Observable<Scene>;
  91193. /** @hidden */
  91194. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91195. /** Launch a ray to try to pick a sprite in the scene
  91196. * @param x position on screen
  91197. * @param y position on screen
  91198. * @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
  91199. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91200. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91201. * @returns a PickingInfo
  91202. */
  91203. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91204. /** Use the given ray to pick a sprite in the scene
  91205. * @param ray The ray (in world space) to use to pick meshes
  91206. * @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
  91207. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91208. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91209. * @returns a PickingInfo
  91210. */
  91211. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91212. /** @hidden */
  91213. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91214. /** Launch a ray to try to pick sprites in the scene
  91215. * @param x position on screen
  91216. * @param y position on screen
  91217. * @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
  91218. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91219. * @returns a PickingInfo array
  91220. */
  91221. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91222. /** Use the given ray to pick sprites in the scene
  91223. * @param ray The ray (in world space) to use to pick meshes
  91224. * @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
  91225. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91226. * @returns a PickingInfo array
  91227. */
  91228. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91229. /**
  91230. * Force the sprite under the pointer
  91231. * @param sprite defines the sprite to use
  91232. */
  91233. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  91234. /**
  91235. * Gets the sprite under the pointer
  91236. * @returns a Sprite or null if no sprite is under the pointer
  91237. */
  91238. getPointerOverSprite(): Nullable<Sprite>;
  91239. }
  91240. /**
  91241. * Defines the sprite scene component responsible to manage sprites
  91242. * in a given scene.
  91243. */
  91244. export class SpriteSceneComponent implements ISceneComponent {
  91245. /**
  91246. * The component name helpfull to identify the component in the list of scene components.
  91247. */
  91248. readonly name: string;
  91249. /**
  91250. * The scene the component belongs to.
  91251. */
  91252. scene: Scene;
  91253. /** @hidden */
  91254. private _spritePredicate;
  91255. /**
  91256. * Creates a new instance of the component for the given scene
  91257. * @param scene Defines the scene to register the component in
  91258. */
  91259. constructor(scene: Scene);
  91260. /**
  91261. * Registers the component in a given scene
  91262. */
  91263. register(): void;
  91264. /**
  91265. * Rebuilds the elements related to this component in case of
  91266. * context lost for instance.
  91267. */
  91268. rebuild(): void;
  91269. /**
  91270. * Disposes the component and the associated ressources.
  91271. */
  91272. dispose(): void;
  91273. private _pickSpriteButKeepRay;
  91274. private _pointerMove;
  91275. private _pointerDown;
  91276. private _pointerUp;
  91277. }
  91278. }
  91279. declare module BABYLON {
  91280. /** @hidden */
  91281. export var fogFragmentDeclaration: {
  91282. name: string;
  91283. shader: string;
  91284. };
  91285. }
  91286. declare module BABYLON {
  91287. /** @hidden */
  91288. export var fogFragment: {
  91289. name: string;
  91290. shader: string;
  91291. };
  91292. }
  91293. declare module BABYLON {
  91294. /** @hidden */
  91295. export var spritesPixelShader: {
  91296. name: string;
  91297. shader: string;
  91298. };
  91299. }
  91300. declare module BABYLON {
  91301. /** @hidden */
  91302. export var fogVertexDeclaration: {
  91303. name: string;
  91304. shader: string;
  91305. };
  91306. }
  91307. declare module BABYLON {
  91308. /** @hidden */
  91309. export var spritesVertexShader: {
  91310. name: string;
  91311. shader: string;
  91312. };
  91313. }
  91314. declare module BABYLON {
  91315. /**
  91316. * Defines the minimum interface to fullfil in order to be a sprite manager.
  91317. */
  91318. export interface ISpriteManager extends IDisposable {
  91319. /**
  91320. * Gets manager's name
  91321. */
  91322. name: string;
  91323. /**
  91324. * Restricts the camera to viewing objects with the same layerMask.
  91325. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  91326. */
  91327. layerMask: number;
  91328. /**
  91329. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91330. */
  91331. isPickable: boolean;
  91332. /**
  91333. * Gets the hosting scene
  91334. */
  91335. scene: Scene;
  91336. /**
  91337. * Specifies the rendering group id for this mesh (0 by default)
  91338. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91339. */
  91340. renderingGroupId: number;
  91341. /**
  91342. * Defines the list of sprites managed by the manager.
  91343. */
  91344. sprites: Array<Sprite>;
  91345. /**
  91346. * Gets or sets the spritesheet texture
  91347. */
  91348. texture: Texture;
  91349. /** Defines the default width of a cell in the spritesheet */
  91350. cellWidth: number;
  91351. /** Defines the default height of a cell in the spritesheet */
  91352. cellHeight: number;
  91353. /**
  91354. * Tests the intersection of a sprite with a specific ray.
  91355. * @param ray The ray we are sending to test the collision
  91356. * @param camera The camera space we are sending rays in
  91357. * @param predicate A predicate allowing excluding sprites from the list of object to test
  91358. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91359. * @returns picking info or null.
  91360. */
  91361. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91362. /**
  91363. * Intersects the sprites with a ray
  91364. * @param ray defines the ray to intersect with
  91365. * @param camera defines the current active camera
  91366. * @param predicate defines a predicate used to select candidate sprites
  91367. * @returns null if no hit or a PickingInfo array
  91368. */
  91369. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91370. /**
  91371. * Renders the list of sprites on screen.
  91372. */
  91373. render(): void;
  91374. }
  91375. /**
  91376. * Class used to manage multiple sprites on the same spritesheet
  91377. * @see https://doc.babylonjs.com/babylon101/sprites
  91378. */
  91379. export class SpriteManager implements ISpriteManager {
  91380. /** defines the manager's name */
  91381. name: string;
  91382. /** Define the Url to load snippets */
  91383. static SnippetUrl: string;
  91384. /** Snippet ID if the manager was created from the snippet server */
  91385. snippetId: string;
  91386. /** Gets the list of sprites */
  91387. sprites: Sprite[];
  91388. /** Gets or sets the rendering group id (0 by default) */
  91389. renderingGroupId: number;
  91390. /** Gets or sets camera layer mask */
  91391. layerMask: number;
  91392. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  91393. fogEnabled: boolean;
  91394. /** Gets or sets a boolean indicating if the sprites are pickable */
  91395. isPickable: boolean;
  91396. /** Defines the default width of a cell in the spritesheet */
  91397. cellWidth: number;
  91398. /** Defines the default height of a cell in the spritesheet */
  91399. cellHeight: number;
  91400. /** Associative array from JSON sprite data file */
  91401. private _cellData;
  91402. /** Array of sprite names from JSON sprite data file */
  91403. private _spriteMap;
  91404. /** True when packed cell data from JSON file is ready*/
  91405. private _packedAndReady;
  91406. private _textureContent;
  91407. private _useInstancing;
  91408. /**
  91409. * An event triggered when the manager is disposed.
  91410. */
  91411. onDisposeObservable: Observable<SpriteManager>;
  91412. private _onDisposeObserver;
  91413. /**
  91414. * Callback called when the manager is disposed
  91415. */
  91416. set onDispose(callback: () => void);
  91417. private _capacity;
  91418. private _fromPacked;
  91419. private _spriteTexture;
  91420. private _epsilon;
  91421. private _scene;
  91422. private _vertexData;
  91423. private _buffer;
  91424. private _vertexBuffers;
  91425. private _spriteBuffer;
  91426. private _indexBuffer;
  91427. private _effectBase;
  91428. private _effectFog;
  91429. private _vertexBufferSize;
  91430. /**
  91431. * Gets or sets the unique id of the sprite
  91432. */
  91433. uniqueId: number;
  91434. /**
  91435. * Gets the array of sprites
  91436. */
  91437. get children(): Sprite[];
  91438. /**
  91439. * Gets the hosting scene
  91440. */
  91441. get scene(): Scene;
  91442. /**
  91443. * Gets the capacity of the manager
  91444. */
  91445. get capacity(): number;
  91446. /**
  91447. * Gets or sets the spritesheet texture
  91448. */
  91449. get texture(): Texture;
  91450. set texture(value: Texture);
  91451. private _blendMode;
  91452. /**
  91453. * Blend mode use to render the particle, it can be any of
  91454. * the static Constants.ALPHA_x properties provided in this class.
  91455. * Default value is Constants.ALPHA_COMBINE
  91456. */
  91457. get blendMode(): number;
  91458. set blendMode(blendMode: number);
  91459. /** Disables writing to the depth buffer when rendering the sprites.
  91460. * It can be handy to disable depth writing when using textures without alpha channel
  91461. * and setting some specific blend modes.
  91462. */
  91463. disableDepthWrite: boolean;
  91464. /**
  91465. * Creates a new sprite manager
  91466. * @param name defines the manager's name
  91467. * @param imgUrl defines the sprite sheet url
  91468. * @param capacity defines the maximum allowed number of sprites
  91469. * @param cellSize defines the size of a sprite cell
  91470. * @param scene defines the hosting scene
  91471. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  91472. * @param samplingMode defines the smapling mode to use with spritesheet
  91473. * @param fromPacked set to false; do not alter
  91474. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  91475. */
  91476. constructor(
  91477. /** defines the manager's name */
  91478. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  91479. /**
  91480. * Returns the string "SpriteManager"
  91481. * @returns "SpriteManager"
  91482. */
  91483. getClassName(): string;
  91484. private _makePacked;
  91485. private _appendSpriteVertex;
  91486. private _checkTextureAlpha;
  91487. /**
  91488. * Intersects the sprites with a ray
  91489. * @param ray defines the ray to intersect with
  91490. * @param camera defines the current active camera
  91491. * @param predicate defines a predicate used to select candidate sprites
  91492. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  91493. * @returns null if no hit or a PickingInfo
  91494. */
  91495. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91496. /**
  91497. * Intersects the sprites with a ray
  91498. * @param ray defines the ray to intersect with
  91499. * @param camera defines the current active camera
  91500. * @param predicate defines a predicate used to select candidate sprites
  91501. * @returns null if no hit or a PickingInfo array
  91502. */
  91503. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91504. /**
  91505. * Render all child sprites
  91506. */
  91507. render(): void;
  91508. /**
  91509. * Release associated resources
  91510. */
  91511. dispose(): void;
  91512. /**
  91513. * Serializes the sprite manager to a JSON object
  91514. * @param serializeTexture defines if the texture must be serialized as well
  91515. * @returns the JSON object
  91516. */
  91517. serialize(serializeTexture?: boolean): any;
  91518. /**
  91519. * Parses a JSON object to create a new sprite manager.
  91520. * @param parsedManager The JSON object to parse
  91521. * @param scene The scene to create the sprite managerin
  91522. * @param rootUrl The root url to use to load external dependencies like texture
  91523. * @returns the new sprite manager
  91524. */
  91525. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  91526. /**
  91527. * Creates a sprite manager from a snippet saved in a remote file
  91528. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  91529. * @param url defines the url to load from
  91530. * @param scene defines the hosting scene
  91531. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91532. * @returns a promise that will resolve to the new sprite manager
  91533. */
  91534. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91535. /**
  91536. * Creates a sprite manager from a snippet saved by the sprite editor
  91537. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  91538. * @param scene defines the hosting scene
  91539. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91540. * @returns a promise that will resolve to the new sprite manager
  91541. */
  91542. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91543. }
  91544. }
  91545. declare module BABYLON {
  91546. /** Interface used by value gradients (color, factor, ...) */
  91547. export interface IValueGradient {
  91548. /**
  91549. * Gets or sets the gradient value (between 0 and 1)
  91550. */
  91551. gradient: number;
  91552. }
  91553. /** Class used to store color4 gradient */
  91554. export class ColorGradient implements IValueGradient {
  91555. /**
  91556. * Gets or sets the gradient value (between 0 and 1)
  91557. */
  91558. gradient: number;
  91559. /**
  91560. * Gets or sets first associated color
  91561. */
  91562. color1: Color4;
  91563. /**
  91564. * Gets or sets second associated color
  91565. */
  91566. color2?: Color4 | undefined;
  91567. /**
  91568. * Creates a new color4 gradient
  91569. * @param gradient gets or sets the gradient value (between 0 and 1)
  91570. * @param color1 gets or sets first associated color
  91571. * @param color2 gets or sets first second color
  91572. */
  91573. constructor(
  91574. /**
  91575. * Gets or sets the gradient value (between 0 and 1)
  91576. */
  91577. gradient: number,
  91578. /**
  91579. * Gets or sets first associated color
  91580. */
  91581. color1: Color4,
  91582. /**
  91583. * Gets or sets second associated color
  91584. */
  91585. color2?: Color4 | undefined);
  91586. /**
  91587. * Will get a color picked randomly between color1 and color2.
  91588. * If color2 is undefined then color1 will be used
  91589. * @param result defines the target Color4 to store the result in
  91590. */
  91591. getColorToRef(result: Color4): void;
  91592. }
  91593. /** Class used to store color 3 gradient */
  91594. export class Color3Gradient implements IValueGradient {
  91595. /**
  91596. * Gets or sets the gradient value (between 0 and 1)
  91597. */
  91598. gradient: number;
  91599. /**
  91600. * Gets or sets the associated color
  91601. */
  91602. color: Color3;
  91603. /**
  91604. * Creates a new color3 gradient
  91605. * @param gradient gets or sets the gradient value (between 0 and 1)
  91606. * @param color gets or sets associated color
  91607. */
  91608. constructor(
  91609. /**
  91610. * Gets or sets the gradient value (between 0 and 1)
  91611. */
  91612. gradient: number,
  91613. /**
  91614. * Gets or sets the associated color
  91615. */
  91616. color: Color3);
  91617. }
  91618. /** Class used to store factor gradient */
  91619. export class FactorGradient implements IValueGradient {
  91620. /**
  91621. * Gets or sets the gradient value (between 0 and 1)
  91622. */
  91623. gradient: number;
  91624. /**
  91625. * Gets or sets first associated factor
  91626. */
  91627. factor1: number;
  91628. /**
  91629. * Gets or sets second associated factor
  91630. */
  91631. factor2?: number | undefined;
  91632. /**
  91633. * Creates a new factor gradient
  91634. * @param gradient gets or sets the gradient value (between 0 and 1)
  91635. * @param factor1 gets or sets first associated factor
  91636. * @param factor2 gets or sets second associated factor
  91637. */
  91638. constructor(
  91639. /**
  91640. * Gets or sets the gradient value (between 0 and 1)
  91641. */
  91642. gradient: number,
  91643. /**
  91644. * Gets or sets first associated factor
  91645. */
  91646. factor1: number,
  91647. /**
  91648. * Gets or sets second associated factor
  91649. */
  91650. factor2?: number | undefined);
  91651. /**
  91652. * Will get a number picked randomly between factor1 and factor2.
  91653. * If factor2 is undefined then factor1 will be used
  91654. * @returns the picked number
  91655. */
  91656. getFactor(): number;
  91657. }
  91658. /**
  91659. * Helper used to simplify some generic gradient tasks
  91660. */
  91661. export class GradientHelper {
  91662. /**
  91663. * Gets the current gradient from an array of IValueGradient
  91664. * @param ratio defines the current ratio to get
  91665. * @param gradients defines the array of IValueGradient
  91666. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91667. */
  91668. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91669. }
  91670. }
  91671. declare module BABYLON {
  91672. interface ThinEngine {
  91673. /**
  91674. * Creates a raw texture
  91675. * @param data defines the data to store in the texture
  91676. * @param width defines the width of the texture
  91677. * @param height defines the height of the texture
  91678. * @param format defines the format of the data
  91679. * @param generateMipMaps defines if the engine should generate the mip levels
  91680. * @param invertY defines if data must be stored with Y axis inverted
  91681. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91682. * @param compression defines the compression used (null by default)
  91683. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91684. * @returns the raw texture inside an InternalTexture
  91685. */
  91686. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  91687. /**
  91688. * Update a raw texture
  91689. * @param texture defines the texture to update
  91690. * @param data defines the data to store in the texture
  91691. * @param format defines the format of the data
  91692. * @param invertY defines if data must be stored with Y axis inverted
  91693. */
  91694. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91695. /**
  91696. * Update a raw texture
  91697. * @param texture defines the texture to update
  91698. * @param data defines the data to store in the texture
  91699. * @param format defines the format of the data
  91700. * @param invertY defines if data must be stored with Y axis inverted
  91701. * @param compression defines the compression used (null by default)
  91702. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91703. */
  91704. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  91705. /**
  91706. * Creates a new raw cube texture
  91707. * @param data defines the array of data to use to create each face
  91708. * @param size defines the size of the textures
  91709. * @param format defines the format of the data
  91710. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91711. * @param generateMipMaps defines if the engine should generate the mip levels
  91712. * @param invertY defines if data must be stored with Y axis inverted
  91713. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91714. * @param compression defines the compression used (null by default)
  91715. * @returns the cube texture as an InternalTexture
  91716. */
  91717. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  91718. /**
  91719. * Update a raw cube texture
  91720. * @param texture defines the texture to udpdate
  91721. * @param data defines the data to store
  91722. * @param format defines the data format
  91723. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91724. * @param invertY defines if data must be stored with Y axis inverted
  91725. */
  91726. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  91727. /**
  91728. * Update a raw cube texture
  91729. * @param texture defines the texture to udpdate
  91730. * @param data defines the data to store
  91731. * @param format defines the data format
  91732. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91733. * @param invertY defines if data must be stored with Y axis inverted
  91734. * @param compression defines the compression used (null by default)
  91735. */
  91736. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  91737. /**
  91738. * Update a raw cube texture
  91739. * @param texture defines the texture to udpdate
  91740. * @param data defines the data to store
  91741. * @param format defines the data format
  91742. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91743. * @param invertY defines if data must be stored with Y axis inverted
  91744. * @param compression defines the compression used (null by default)
  91745. * @param level defines which level of the texture to update
  91746. */
  91747. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  91748. /**
  91749. * Creates a new raw cube texture from a specified url
  91750. * @param url defines the url where the data is located
  91751. * @param scene defines the current scene
  91752. * @param size defines the size of the textures
  91753. * @param format defines the format of the data
  91754. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91755. * @param noMipmap defines if the engine should avoid generating the mip levels
  91756. * @param callback defines a callback used to extract texture data from loaded data
  91757. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91758. * @param onLoad defines a callback called when texture is loaded
  91759. * @param onError defines a callback called if there is an error
  91760. * @returns the cube texture as an InternalTexture
  91761. */
  91762. 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;
  91763. /**
  91764. * Creates a new raw cube texture from a specified url
  91765. * @param url defines the url where the data is located
  91766. * @param scene defines the current scene
  91767. * @param size defines the size of the textures
  91768. * @param format defines the format of the data
  91769. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91770. * @param noMipmap defines if the engine should avoid generating the mip levels
  91771. * @param callback defines a callback used to extract texture data from loaded data
  91772. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91773. * @param onLoad defines a callback called when texture is loaded
  91774. * @param onError defines a callback called if there is an error
  91775. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91776. * @param invertY defines if data must be stored with Y axis inverted
  91777. * @returns the cube texture as an InternalTexture
  91778. */
  91779. 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;
  91780. /**
  91781. * Creates a new raw 3D texture
  91782. * @param data defines the data used to create the texture
  91783. * @param width defines the width of the texture
  91784. * @param height defines the height of the texture
  91785. * @param depth defines the depth of the texture
  91786. * @param format defines the format of the texture
  91787. * @param generateMipMaps defines if the engine must generate mip levels
  91788. * @param invertY defines if data must be stored with Y axis inverted
  91789. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91790. * @param compression defines the compressed used (can be null)
  91791. * @param textureType defines the compressed used (can be null)
  91792. * @returns a new raw 3D texture (stored in an InternalTexture)
  91793. */
  91794. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91795. /**
  91796. * Update a raw 3D texture
  91797. * @param texture defines the texture to update
  91798. * @param data defines the data to store
  91799. * @param format defines the data format
  91800. * @param invertY defines if data must be stored with Y axis inverted
  91801. */
  91802. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91803. /**
  91804. * Update a raw 3D texture
  91805. * @param texture defines the texture to update
  91806. * @param data defines the data to store
  91807. * @param format defines the data format
  91808. * @param invertY defines if data must be stored with Y axis inverted
  91809. * @param compression defines the used compression (can be null)
  91810. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91811. */
  91812. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91813. /**
  91814. * Creates a new raw 2D array texture
  91815. * @param data defines the data used to create the texture
  91816. * @param width defines the width of the texture
  91817. * @param height defines the height of the texture
  91818. * @param depth defines the number of layers of the texture
  91819. * @param format defines the format of the texture
  91820. * @param generateMipMaps defines if the engine must generate mip levels
  91821. * @param invertY defines if data must be stored with Y axis inverted
  91822. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91823. * @param compression defines the compressed used (can be null)
  91824. * @param textureType defines the compressed used (can be null)
  91825. * @returns a new raw 2D array texture (stored in an InternalTexture)
  91826. */
  91827. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91828. /**
  91829. * Update a raw 2D array texture
  91830. * @param texture defines the texture to update
  91831. * @param data defines the data to store
  91832. * @param format defines the data format
  91833. * @param invertY defines if data must be stored with Y axis inverted
  91834. */
  91835. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91836. /**
  91837. * Update a raw 2D array texture
  91838. * @param texture defines the texture to update
  91839. * @param data defines the data to store
  91840. * @param format defines the data format
  91841. * @param invertY defines if data must be stored with Y axis inverted
  91842. * @param compression defines the used compression (can be null)
  91843. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91844. */
  91845. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91846. }
  91847. }
  91848. declare module BABYLON {
  91849. /**
  91850. * Raw texture can help creating a texture directly from an array of data.
  91851. * This can be super useful if you either get the data from an uncompressed source or
  91852. * if you wish to create your texture pixel by pixel.
  91853. */
  91854. export class RawTexture extends Texture {
  91855. /**
  91856. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91857. */
  91858. format: number;
  91859. /**
  91860. * Instantiates a new RawTexture.
  91861. * Raw texture can help creating a texture directly from an array of data.
  91862. * This can be super useful if you either get the data from an uncompressed source or
  91863. * if you wish to create your texture pixel by pixel.
  91864. * @param data define the array of data to use to create the texture
  91865. * @param width define the width of the texture
  91866. * @param height define the height of the texture
  91867. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91868. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91869. * @param generateMipMaps define whether mip maps should be generated or not
  91870. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91871. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91872. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91873. */
  91874. constructor(data: ArrayBufferView, width: number, height: number,
  91875. /**
  91876. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91877. */
  91878. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  91879. /**
  91880. * Updates the texture underlying data.
  91881. * @param data Define the new data of the texture
  91882. */
  91883. update(data: ArrayBufferView): void;
  91884. /**
  91885. * Creates a luminance texture from some data.
  91886. * @param data Define the texture data
  91887. * @param width Define the width of the texture
  91888. * @param height Define the height of the texture
  91889. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91890. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91891. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91892. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91893. * @returns the luminance texture
  91894. */
  91895. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91896. /**
  91897. * Creates a luminance alpha texture from some data.
  91898. * @param data Define the texture data
  91899. * @param width Define the width of the texture
  91900. * @param height Define the height of the texture
  91901. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91902. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91903. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91904. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91905. * @returns the luminance alpha texture
  91906. */
  91907. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91908. /**
  91909. * Creates an alpha texture from some data.
  91910. * @param data Define the texture data
  91911. * @param width Define the width of the texture
  91912. * @param height Define the height of the texture
  91913. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91914. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91915. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91916. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91917. * @returns the alpha texture
  91918. */
  91919. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91920. /**
  91921. * Creates a RGB texture from some data.
  91922. * @param data Define the texture data
  91923. * @param width Define the width of the texture
  91924. * @param height Define the height of the texture
  91925. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91926. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91927. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91928. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91929. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91930. * @returns the RGB alpha texture
  91931. */
  91932. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91933. /**
  91934. * Creates a RGBA texture from some data.
  91935. * @param data Define the texture data
  91936. * @param width Define the width of the texture
  91937. * @param height Define the height of the texture
  91938. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91939. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91940. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91941. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91942. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91943. * @returns the RGBA texture
  91944. */
  91945. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91946. /**
  91947. * Creates a R texture from some data.
  91948. * @param data Define the texture data
  91949. * @param width Define the width of the texture
  91950. * @param height Define the height of the texture
  91951. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91952. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91953. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91954. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91955. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91956. * @returns the R texture
  91957. */
  91958. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91959. }
  91960. }
  91961. declare module BABYLON {
  91962. interface ThinEngine {
  91963. /**
  91964. * Update a dynamic index buffer
  91965. * @param indexBuffer defines the target index buffer
  91966. * @param indices defines the data to update
  91967. * @param offset defines the offset in the target index buffer where update should start
  91968. */
  91969. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91970. /**
  91971. * Updates a dynamic vertex buffer.
  91972. * @param vertexBuffer the vertex buffer to update
  91973. * @param data the data used to update the vertex buffer
  91974. * @param byteOffset the byte offset of the data
  91975. * @param byteLength the byte length of the data
  91976. */
  91977. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91978. }
  91979. }
  91980. declare module BABYLON {
  91981. interface AbstractScene {
  91982. /**
  91983. * The list of procedural textures added to the scene
  91984. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91985. */
  91986. proceduralTextures: Array<ProceduralTexture>;
  91987. }
  91988. /**
  91989. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  91990. * in a given scene.
  91991. */
  91992. export class ProceduralTextureSceneComponent implements ISceneComponent {
  91993. /**
  91994. * The component name helpfull to identify the component in the list of scene components.
  91995. */
  91996. readonly name: string;
  91997. /**
  91998. * The scene the component belongs to.
  91999. */
  92000. scene: Scene;
  92001. /**
  92002. * Creates a new instance of the component for the given scene
  92003. * @param scene Defines the scene to register the component in
  92004. */
  92005. constructor(scene: Scene);
  92006. /**
  92007. * Registers the component in a given scene
  92008. */
  92009. register(): void;
  92010. /**
  92011. * Rebuilds the elements related to this component in case of
  92012. * context lost for instance.
  92013. */
  92014. rebuild(): void;
  92015. /**
  92016. * Disposes the component and the associated ressources.
  92017. */
  92018. dispose(): void;
  92019. private _beforeClear;
  92020. }
  92021. }
  92022. declare module BABYLON {
  92023. interface ThinEngine {
  92024. /**
  92025. * Creates a new render target cube texture
  92026. * @param size defines the size of the texture
  92027. * @param options defines the options used to create the texture
  92028. * @returns a new render target cube texture stored in an InternalTexture
  92029. */
  92030. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  92031. }
  92032. }
  92033. declare module BABYLON {
  92034. /** @hidden */
  92035. export var proceduralVertexShader: {
  92036. name: string;
  92037. shader: string;
  92038. };
  92039. }
  92040. declare module BABYLON {
  92041. /**
  92042. * 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.
  92043. * This is the base class of any Procedural texture and contains most of the shareable code.
  92044. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92045. */
  92046. export class ProceduralTexture extends Texture {
  92047. /**
  92048. * Define if the texture is enabled or not (disabled texture will not render)
  92049. */
  92050. isEnabled: boolean;
  92051. /**
  92052. * Define if the texture must be cleared before rendering (default is true)
  92053. */
  92054. autoClear: boolean;
  92055. /**
  92056. * Callback called when the texture is generated
  92057. */
  92058. onGenerated: () => void;
  92059. /**
  92060. * Event raised when the texture is generated
  92061. */
  92062. onGeneratedObservable: Observable<ProceduralTexture>;
  92063. /**
  92064. * Event raised before the texture is generated
  92065. */
  92066. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  92067. /**
  92068. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  92069. */
  92070. nodeMaterialSource: Nullable<NodeMaterial>;
  92071. /** @hidden */
  92072. _generateMipMaps: boolean;
  92073. /** @hidden **/
  92074. _effect: Effect;
  92075. /** @hidden */
  92076. _textures: {
  92077. [key: string]: Texture;
  92078. };
  92079. /** @hidden */
  92080. protected _fallbackTexture: Nullable<Texture>;
  92081. private _size;
  92082. private _currentRefreshId;
  92083. private _frameId;
  92084. private _refreshRate;
  92085. private _vertexBuffers;
  92086. private _indexBuffer;
  92087. private _uniforms;
  92088. private _samplers;
  92089. private _fragment;
  92090. private _floats;
  92091. private _ints;
  92092. private _floatsArrays;
  92093. private _colors3;
  92094. private _colors4;
  92095. private _vectors2;
  92096. private _vectors3;
  92097. private _matrices;
  92098. private _fallbackTextureUsed;
  92099. private _fullEngine;
  92100. private _cachedDefines;
  92101. private _contentUpdateId;
  92102. private _contentData;
  92103. /**
  92104. * Instantiates a new procedural texture.
  92105. * 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.
  92106. * This is the base class of any Procedural texture and contains most of the shareable code.
  92107. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92108. * @param name Define the name of the texture
  92109. * @param size Define the size of the texture to create
  92110. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92111. * @param scene Define the scene the texture belongs to
  92112. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92113. * @param generateMipMaps Define if the texture should creates mip maps or not
  92114. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92115. */
  92116. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  92117. /**
  92118. * The effect that is created when initializing the post process.
  92119. * @returns The created effect corresponding the the postprocess.
  92120. */
  92121. getEffect(): Effect;
  92122. /**
  92123. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  92124. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  92125. */
  92126. getContent(): Nullable<ArrayBufferView>;
  92127. private _createIndexBuffer;
  92128. /** @hidden */
  92129. _rebuild(): void;
  92130. /**
  92131. * Resets the texture in order to recreate its associated resources.
  92132. * This can be called in case of context loss
  92133. */
  92134. reset(): void;
  92135. protected _getDefines(): string;
  92136. /**
  92137. * Is the texture ready to be used ? (rendered at least once)
  92138. * @returns true if ready, otherwise, false.
  92139. */
  92140. isReady(): boolean;
  92141. /**
  92142. * Resets the refresh counter of the texture and start bak from scratch.
  92143. * Could be useful to regenerate the texture if it is setup to render only once.
  92144. */
  92145. resetRefreshCounter(): void;
  92146. /**
  92147. * Set the fragment shader to use in order to render the texture.
  92148. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  92149. */
  92150. setFragment(fragment: any): void;
  92151. /**
  92152. * Define the refresh rate of the texture or the rendering frequency.
  92153. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92154. */
  92155. get refreshRate(): number;
  92156. set refreshRate(value: number);
  92157. /** @hidden */
  92158. _shouldRender(): boolean;
  92159. /**
  92160. * Get the size the texture is rendering at.
  92161. * @returns the size (on cube texture it is always squared)
  92162. */
  92163. getRenderSize(): RenderTargetTextureSize;
  92164. /**
  92165. * Resize the texture to new value.
  92166. * @param size Define the new size the texture should have
  92167. * @param generateMipMaps Define whether the new texture should create mip maps
  92168. */
  92169. resize(size: number, generateMipMaps: boolean): void;
  92170. private _checkUniform;
  92171. /**
  92172. * Set a texture in the shader program used to render.
  92173. * @param name Define the name of the uniform samplers as defined in the shader
  92174. * @param texture Define the texture to bind to this sampler
  92175. * @return the texture itself allowing "fluent" like uniform updates
  92176. */
  92177. setTexture(name: string, texture: Texture): ProceduralTexture;
  92178. /**
  92179. * Set a float in the shader.
  92180. * @param name Define the name of the uniform as defined in the shader
  92181. * @param value Define the value to give to the uniform
  92182. * @return the texture itself allowing "fluent" like uniform updates
  92183. */
  92184. setFloat(name: string, value: number): ProceduralTexture;
  92185. /**
  92186. * Set a int in the shader.
  92187. * @param name Define the name of the uniform as defined in the shader
  92188. * @param value Define the value to give to the uniform
  92189. * @return the texture itself allowing "fluent" like uniform updates
  92190. */
  92191. setInt(name: string, value: number): ProceduralTexture;
  92192. /**
  92193. * Set an array of floats in the shader.
  92194. * @param name Define the name of the uniform as defined in the shader
  92195. * @param value Define the value to give to the uniform
  92196. * @return the texture itself allowing "fluent" like uniform updates
  92197. */
  92198. setFloats(name: string, value: number[]): ProceduralTexture;
  92199. /**
  92200. * Set a vec3 in the shader from a Color3.
  92201. * @param name Define the name of the uniform as defined in the shader
  92202. * @param value Define the value to give to the uniform
  92203. * @return the texture itself allowing "fluent" like uniform updates
  92204. */
  92205. setColor3(name: string, value: Color3): ProceduralTexture;
  92206. /**
  92207. * Set a vec4 in the shader from a Color4.
  92208. * @param name Define the name of the uniform as defined in the shader
  92209. * @param value Define the value to give to the uniform
  92210. * @return the texture itself allowing "fluent" like uniform updates
  92211. */
  92212. setColor4(name: string, value: Color4): ProceduralTexture;
  92213. /**
  92214. * Set a vec2 in the shader from a Vector2.
  92215. * @param name Define the name of the uniform as defined in the shader
  92216. * @param value Define the value to give to the uniform
  92217. * @return the texture itself allowing "fluent" like uniform updates
  92218. */
  92219. setVector2(name: string, value: Vector2): ProceduralTexture;
  92220. /**
  92221. * Set a vec3 in the shader from a Vector3.
  92222. * @param name Define the name of the uniform as defined in the shader
  92223. * @param value Define the value to give to the uniform
  92224. * @return the texture itself allowing "fluent" like uniform updates
  92225. */
  92226. setVector3(name: string, value: Vector3): ProceduralTexture;
  92227. /**
  92228. * Set a mat4 in the shader from a MAtrix.
  92229. * @param name Define the name of the uniform as defined in the shader
  92230. * @param value Define the value to give to the uniform
  92231. * @return the texture itself allowing "fluent" like uniform updates
  92232. */
  92233. setMatrix(name: string, value: Matrix): ProceduralTexture;
  92234. /**
  92235. * Render the texture to its associated render target.
  92236. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  92237. */
  92238. render(useCameraPostProcess?: boolean): void;
  92239. /**
  92240. * Clone the texture.
  92241. * @returns the cloned texture
  92242. */
  92243. clone(): ProceduralTexture;
  92244. /**
  92245. * Dispose the texture and release its asoociated resources.
  92246. */
  92247. dispose(): void;
  92248. }
  92249. }
  92250. declare module BABYLON {
  92251. /**
  92252. * This represents the base class for particle system in Babylon.
  92253. * 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.
  92254. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92255. * @example https://doc.babylonjs.com/babylon101/particles
  92256. */
  92257. export class BaseParticleSystem {
  92258. /**
  92259. * Source color is added to the destination color without alpha affecting the result
  92260. */
  92261. static BLENDMODE_ONEONE: number;
  92262. /**
  92263. * Blend current color and particle color using particle’s alpha
  92264. */
  92265. static BLENDMODE_STANDARD: number;
  92266. /**
  92267. * Add current color and particle color multiplied by particle’s alpha
  92268. */
  92269. static BLENDMODE_ADD: number;
  92270. /**
  92271. * Multiply current color with particle color
  92272. */
  92273. static BLENDMODE_MULTIPLY: number;
  92274. /**
  92275. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  92276. */
  92277. static BLENDMODE_MULTIPLYADD: number;
  92278. /**
  92279. * List of animations used by the particle system.
  92280. */
  92281. animations: Animation[];
  92282. /**
  92283. * Gets or sets the unique id of the particle system
  92284. */
  92285. uniqueId: number;
  92286. /**
  92287. * The id of the Particle system.
  92288. */
  92289. id: string;
  92290. /**
  92291. * The friendly name of the Particle system.
  92292. */
  92293. name: string;
  92294. /**
  92295. * Snippet ID if the particle system was created from the snippet server
  92296. */
  92297. snippetId: string;
  92298. /**
  92299. * The rendering group used by the Particle system to chose when to render.
  92300. */
  92301. renderingGroupId: number;
  92302. /**
  92303. * The emitter represents the Mesh or position we are attaching the particle system to.
  92304. */
  92305. emitter: Nullable<AbstractMesh | Vector3>;
  92306. /**
  92307. * The maximum number of particles to emit per frame
  92308. */
  92309. emitRate: number;
  92310. /**
  92311. * If you want to launch only a few particles at once, that can be done, as well.
  92312. */
  92313. manualEmitCount: number;
  92314. /**
  92315. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92316. */
  92317. updateSpeed: number;
  92318. /**
  92319. * The amount of time the particle system is running (depends of the overall update speed).
  92320. */
  92321. targetStopDuration: number;
  92322. /**
  92323. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92324. */
  92325. disposeOnStop: boolean;
  92326. /**
  92327. * Minimum power of emitting particles.
  92328. */
  92329. minEmitPower: number;
  92330. /**
  92331. * Maximum power of emitting particles.
  92332. */
  92333. maxEmitPower: number;
  92334. /**
  92335. * Minimum life time of emitting particles.
  92336. */
  92337. minLifeTime: number;
  92338. /**
  92339. * Maximum life time of emitting particles.
  92340. */
  92341. maxLifeTime: number;
  92342. /**
  92343. * Minimum Size of emitting particles.
  92344. */
  92345. minSize: number;
  92346. /**
  92347. * Maximum Size of emitting particles.
  92348. */
  92349. maxSize: number;
  92350. /**
  92351. * Minimum scale of emitting particles on X axis.
  92352. */
  92353. minScaleX: number;
  92354. /**
  92355. * Maximum scale of emitting particles on X axis.
  92356. */
  92357. maxScaleX: number;
  92358. /**
  92359. * Minimum scale of emitting particles on Y axis.
  92360. */
  92361. minScaleY: number;
  92362. /**
  92363. * Maximum scale of emitting particles on Y axis.
  92364. */
  92365. maxScaleY: number;
  92366. /**
  92367. * Gets or sets the minimal initial rotation in radians.
  92368. */
  92369. minInitialRotation: number;
  92370. /**
  92371. * Gets or sets the maximal initial rotation in radians.
  92372. */
  92373. maxInitialRotation: number;
  92374. /**
  92375. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92376. */
  92377. minAngularSpeed: number;
  92378. /**
  92379. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92380. */
  92381. maxAngularSpeed: number;
  92382. /**
  92383. * The texture used to render each particle. (this can be a spritesheet)
  92384. */
  92385. particleTexture: Nullable<BaseTexture>;
  92386. /**
  92387. * The layer mask we are rendering the particles through.
  92388. */
  92389. layerMask: number;
  92390. /**
  92391. * This can help using your own shader to render the particle system.
  92392. * The according effect will be created
  92393. */
  92394. customShader: any;
  92395. /**
  92396. * By default particle system starts as soon as they are created. This prevents the
  92397. * automatic start to happen and let you decide when to start emitting particles.
  92398. */
  92399. preventAutoStart: boolean;
  92400. private _noiseTexture;
  92401. /**
  92402. * Gets or sets a texture used to add random noise to particle positions
  92403. */
  92404. get noiseTexture(): Nullable<ProceduralTexture>;
  92405. set noiseTexture(value: Nullable<ProceduralTexture>);
  92406. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92407. noiseStrength: Vector3;
  92408. /**
  92409. * Callback triggered when the particle animation is ending.
  92410. */
  92411. onAnimationEnd: Nullable<() => void>;
  92412. /**
  92413. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  92414. */
  92415. blendMode: number;
  92416. /**
  92417. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  92418. * to override the particles.
  92419. */
  92420. forceDepthWrite: boolean;
  92421. /** 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 */
  92422. preWarmCycles: number;
  92423. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  92424. preWarmStepOffset: number;
  92425. /**
  92426. * 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)
  92427. */
  92428. spriteCellChangeSpeed: number;
  92429. /**
  92430. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92431. */
  92432. startSpriteCellID: number;
  92433. /**
  92434. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92435. */
  92436. endSpriteCellID: number;
  92437. /**
  92438. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92439. */
  92440. spriteCellWidth: number;
  92441. /**
  92442. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92443. */
  92444. spriteCellHeight: number;
  92445. /**
  92446. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92447. */
  92448. spriteRandomStartCell: boolean;
  92449. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92450. translationPivot: Vector2;
  92451. /** @hidden */
  92452. protected _isAnimationSheetEnabled: boolean;
  92453. /**
  92454. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92455. */
  92456. beginAnimationOnStart: boolean;
  92457. /**
  92458. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92459. */
  92460. beginAnimationFrom: number;
  92461. /**
  92462. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92463. */
  92464. beginAnimationTo: number;
  92465. /**
  92466. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92467. */
  92468. beginAnimationLoop: boolean;
  92469. /**
  92470. * Gets or sets a world offset applied to all particles
  92471. */
  92472. worldOffset: Vector3;
  92473. /**
  92474. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  92475. */
  92476. get isAnimationSheetEnabled(): boolean;
  92477. set isAnimationSheetEnabled(value: boolean);
  92478. /**
  92479. * Get hosting scene
  92480. * @returns the scene
  92481. */
  92482. getScene(): Nullable<Scene>;
  92483. /**
  92484. * You can use gravity if you want to give an orientation to your particles.
  92485. */
  92486. gravity: Vector3;
  92487. protected _colorGradients: Nullable<Array<ColorGradient>>;
  92488. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  92489. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  92490. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  92491. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  92492. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  92493. protected _dragGradients: Nullable<Array<FactorGradient>>;
  92494. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  92495. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  92496. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  92497. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  92498. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  92499. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  92500. /**
  92501. * Defines the delay in milliseconds before starting the system (0 by default)
  92502. */
  92503. startDelay: number;
  92504. /**
  92505. * Gets the current list of drag gradients.
  92506. * You must use addDragGradient and removeDragGradient to udpate this list
  92507. * @returns the list of drag gradients
  92508. */
  92509. getDragGradients(): Nullable<Array<FactorGradient>>;
  92510. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92511. limitVelocityDamping: number;
  92512. /**
  92513. * Gets the current list of limit velocity gradients.
  92514. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92515. * @returns the list of limit velocity gradients
  92516. */
  92517. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92518. /**
  92519. * Gets the current list of color gradients.
  92520. * You must use addColorGradient and removeColorGradient to udpate this list
  92521. * @returns the list of color gradients
  92522. */
  92523. getColorGradients(): Nullable<Array<ColorGradient>>;
  92524. /**
  92525. * Gets the current list of size gradients.
  92526. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92527. * @returns the list of size gradients
  92528. */
  92529. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92530. /**
  92531. * Gets the current list of color remap gradients.
  92532. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92533. * @returns the list of color remap gradients
  92534. */
  92535. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92536. /**
  92537. * Gets the current list of alpha remap gradients.
  92538. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92539. * @returns the list of alpha remap gradients
  92540. */
  92541. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92542. /**
  92543. * Gets the current list of life time gradients.
  92544. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92545. * @returns the list of life time gradients
  92546. */
  92547. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92548. /**
  92549. * Gets the current list of angular speed gradients.
  92550. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92551. * @returns the list of angular speed gradients
  92552. */
  92553. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92554. /**
  92555. * Gets the current list of velocity gradients.
  92556. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92557. * @returns the list of velocity gradients
  92558. */
  92559. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92560. /**
  92561. * Gets the current list of start size gradients.
  92562. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92563. * @returns the list of start size gradients
  92564. */
  92565. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92566. /**
  92567. * Gets the current list of emit rate gradients.
  92568. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92569. * @returns the list of emit rate gradients
  92570. */
  92571. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92572. /**
  92573. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92574. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92575. */
  92576. get direction1(): Vector3;
  92577. set direction1(value: Vector3);
  92578. /**
  92579. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92580. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92581. */
  92582. get direction2(): Vector3;
  92583. set direction2(value: Vector3);
  92584. /**
  92585. * 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.
  92586. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92587. */
  92588. get minEmitBox(): Vector3;
  92589. set minEmitBox(value: Vector3);
  92590. /**
  92591. * 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.
  92592. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92593. */
  92594. get maxEmitBox(): Vector3;
  92595. set maxEmitBox(value: Vector3);
  92596. /**
  92597. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92598. */
  92599. color1: Color4;
  92600. /**
  92601. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92602. */
  92603. color2: Color4;
  92604. /**
  92605. * Color the particle will have at the end of its lifetime
  92606. */
  92607. colorDead: Color4;
  92608. /**
  92609. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  92610. */
  92611. textureMask: Color4;
  92612. /**
  92613. * The particle emitter type defines the emitter used by the particle system.
  92614. * It can be for example box, sphere, or cone...
  92615. */
  92616. particleEmitterType: IParticleEmitterType;
  92617. /** @hidden */
  92618. _isSubEmitter: boolean;
  92619. /**
  92620. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92621. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92622. */
  92623. billboardMode: number;
  92624. protected _isBillboardBased: boolean;
  92625. /**
  92626. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92627. */
  92628. get isBillboardBased(): boolean;
  92629. set isBillboardBased(value: boolean);
  92630. /**
  92631. * The scene the particle system belongs to.
  92632. */
  92633. protected _scene: Nullable<Scene>;
  92634. /**
  92635. * The engine the particle system belongs to.
  92636. */
  92637. protected _engine: ThinEngine;
  92638. /**
  92639. * Local cache of defines for image processing.
  92640. */
  92641. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  92642. /**
  92643. * Default configuration related to image processing available in the standard Material.
  92644. */
  92645. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  92646. /**
  92647. * Gets the image processing configuration used either in this material.
  92648. */
  92649. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  92650. /**
  92651. * Sets the Default image processing configuration used either in the this material.
  92652. *
  92653. * If sets to null, the scene one is in use.
  92654. */
  92655. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  92656. /**
  92657. * Attaches a new image processing configuration to the Standard Material.
  92658. * @param configuration
  92659. */
  92660. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  92661. /** @hidden */
  92662. protected _reset(): void;
  92663. /** @hidden */
  92664. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  92665. /**
  92666. * Instantiates a particle system.
  92667. * 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.
  92668. * @param name The name of the particle system
  92669. */
  92670. constructor(name: string);
  92671. /**
  92672. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92673. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92674. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92675. * @returns the emitter
  92676. */
  92677. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92678. /**
  92679. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92680. * @param radius The radius of the hemisphere to emit from
  92681. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92682. * @returns the emitter
  92683. */
  92684. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  92685. /**
  92686. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92687. * @param radius The radius of the sphere to emit from
  92688. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92689. * @returns the emitter
  92690. */
  92691. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  92692. /**
  92693. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92694. * @param radius The radius of the sphere to emit from
  92695. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92696. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92697. * @returns the emitter
  92698. */
  92699. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  92700. /**
  92701. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92702. * @param radius The radius of the emission cylinder
  92703. * @param height The height of the emission cylinder
  92704. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92705. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92706. * @returns the emitter
  92707. */
  92708. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  92709. /**
  92710. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92711. * @param radius The radius of the cylinder to emit from
  92712. * @param height The height of the emission cylinder
  92713. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92714. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92715. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92716. * @returns the emitter
  92717. */
  92718. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  92719. /**
  92720. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92721. * @param radius The radius of the cone to emit from
  92722. * @param angle The base angle of the cone
  92723. * @returns the emitter
  92724. */
  92725. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  92726. /**
  92727. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92728. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92729. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92730. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92731. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92732. * @returns the emitter
  92733. */
  92734. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92735. }
  92736. }
  92737. declare module BABYLON {
  92738. /**
  92739. * Type of sub emitter
  92740. */
  92741. export enum SubEmitterType {
  92742. /**
  92743. * Attached to the particle over it's lifetime
  92744. */
  92745. ATTACHED = 0,
  92746. /**
  92747. * Created when the particle dies
  92748. */
  92749. END = 1
  92750. }
  92751. /**
  92752. * Sub emitter class used to emit particles from an existing particle
  92753. */
  92754. export class SubEmitter {
  92755. /**
  92756. * the particle system to be used by the sub emitter
  92757. */
  92758. particleSystem: ParticleSystem;
  92759. /**
  92760. * Type of the submitter (Default: END)
  92761. */
  92762. type: SubEmitterType;
  92763. /**
  92764. * 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)
  92765. * Note: This only is supported when using an emitter of type Mesh
  92766. */
  92767. inheritDirection: boolean;
  92768. /**
  92769. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  92770. */
  92771. inheritedVelocityAmount: number;
  92772. /**
  92773. * Creates a sub emitter
  92774. * @param particleSystem the particle system to be used by the sub emitter
  92775. */
  92776. constructor(
  92777. /**
  92778. * the particle system to be used by the sub emitter
  92779. */
  92780. particleSystem: ParticleSystem);
  92781. /**
  92782. * Clones the sub emitter
  92783. * @returns the cloned sub emitter
  92784. */
  92785. clone(): SubEmitter;
  92786. /**
  92787. * Serialize current object to a JSON object
  92788. * @returns the serialized object
  92789. */
  92790. serialize(): any;
  92791. /** @hidden */
  92792. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  92793. /**
  92794. * Creates a new SubEmitter from a serialized JSON version
  92795. * @param serializationObject defines the JSON object to read from
  92796. * @param sceneOrEngine defines the hosting scene or the hosting engine
  92797. * @param rootUrl defines the rootUrl for data loading
  92798. * @returns a new SubEmitter
  92799. */
  92800. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  92801. /** Release associated resources */
  92802. dispose(): void;
  92803. }
  92804. }
  92805. declare module BABYLON {
  92806. /** @hidden */
  92807. export var imageProcessingDeclaration: {
  92808. name: string;
  92809. shader: string;
  92810. };
  92811. }
  92812. declare module BABYLON {
  92813. /** @hidden */
  92814. export var imageProcessingFunctions: {
  92815. name: string;
  92816. shader: string;
  92817. };
  92818. }
  92819. declare module BABYLON {
  92820. /** @hidden */
  92821. export var particlesPixelShader: {
  92822. name: string;
  92823. shader: string;
  92824. };
  92825. }
  92826. declare module BABYLON {
  92827. /** @hidden */
  92828. export var particlesVertexShader: {
  92829. name: string;
  92830. shader: string;
  92831. };
  92832. }
  92833. declare module BABYLON {
  92834. /**
  92835. * Interface used to define entities containing multiple clip planes
  92836. */
  92837. export interface IClipPlanesHolder {
  92838. /**
  92839. * Gets or sets the active clipplane 1
  92840. */
  92841. clipPlane: Nullable<Plane>;
  92842. /**
  92843. * Gets or sets the active clipplane 2
  92844. */
  92845. clipPlane2: Nullable<Plane>;
  92846. /**
  92847. * Gets or sets the active clipplane 3
  92848. */
  92849. clipPlane3: Nullable<Plane>;
  92850. /**
  92851. * Gets or sets the active clipplane 4
  92852. */
  92853. clipPlane4: Nullable<Plane>;
  92854. /**
  92855. * Gets or sets the active clipplane 5
  92856. */
  92857. clipPlane5: Nullable<Plane>;
  92858. /**
  92859. * Gets or sets the active clipplane 6
  92860. */
  92861. clipPlane6: Nullable<Plane>;
  92862. }
  92863. }
  92864. declare module BABYLON {
  92865. /**
  92866. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  92867. *
  92868. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  92869. *
  92870. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  92871. */
  92872. export class ThinMaterialHelper {
  92873. /**
  92874. * Binds the clip plane information from the holder to the effect.
  92875. * @param effect The effect we are binding the data to
  92876. * @param holder The entity containing the clip plane information
  92877. */
  92878. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  92879. }
  92880. }
  92881. declare module BABYLON {
  92882. interface ThinEngine {
  92883. /**
  92884. * Sets alpha constants used by some alpha blending modes
  92885. * @param r defines the red component
  92886. * @param g defines the green component
  92887. * @param b defines the blue component
  92888. * @param a defines the alpha component
  92889. */
  92890. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  92891. /**
  92892. * Sets the current alpha mode
  92893. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  92894. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  92895. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92896. */
  92897. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  92898. /**
  92899. * Gets the current alpha mode
  92900. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92901. * @returns the current alpha mode
  92902. */
  92903. getAlphaMode(): number;
  92904. /**
  92905. * Sets the current alpha equation
  92906. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  92907. */
  92908. setAlphaEquation(equation: number): void;
  92909. /**
  92910. * Gets the current alpha equation.
  92911. * @returns the current alpha equation
  92912. */
  92913. getAlphaEquation(): number;
  92914. }
  92915. }
  92916. declare module BABYLON {
  92917. /**
  92918. * This represents a particle system in Babylon.
  92919. * 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.
  92920. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92921. * @example https://doc.babylonjs.com/babylon101/particles
  92922. */
  92923. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  92924. /**
  92925. * Billboard mode will only apply to Y axis
  92926. */
  92927. static readonly BILLBOARDMODE_Y: number;
  92928. /**
  92929. * Billboard mode will apply to all axes
  92930. */
  92931. static readonly BILLBOARDMODE_ALL: number;
  92932. /**
  92933. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  92934. */
  92935. static readonly BILLBOARDMODE_STRETCHED: number;
  92936. /**
  92937. * This function can be defined to provide custom update for active particles.
  92938. * This function will be called instead of regular update (age, position, color, etc.).
  92939. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  92940. */
  92941. updateFunction: (particles: Particle[]) => void;
  92942. private _emitterWorldMatrix;
  92943. /**
  92944. * This function can be defined to specify initial direction for every new particle.
  92945. * It by default use the emitterType defined function
  92946. */
  92947. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92948. /**
  92949. * This function can be defined to specify initial position for every new particle.
  92950. * It by default use the emitterType defined function
  92951. */
  92952. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92953. /**
  92954. * @hidden
  92955. */
  92956. _inheritedVelocityOffset: Vector3;
  92957. /**
  92958. * An event triggered when the system is disposed
  92959. */
  92960. onDisposeObservable: Observable<IParticleSystem>;
  92961. private _onDisposeObserver;
  92962. /**
  92963. * Sets a callback that will be triggered when the system is disposed
  92964. */
  92965. set onDispose(callback: () => void);
  92966. private _particles;
  92967. private _epsilon;
  92968. private _capacity;
  92969. private _stockParticles;
  92970. private _newPartsExcess;
  92971. private _vertexData;
  92972. private _vertexBuffer;
  92973. private _vertexBuffers;
  92974. private _spriteBuffer;
  92975. private _indexBuffer;
  92976. private _effect;
  92977. private _customEffect;
  92978. private _cachedDefines;
  92979. private _scaledColorStep;
  92980. private _colorDiff;
  92981. private _scaledDirection;
  92982. private _scaledGravity;
  92983. private _currentRenderId;
  92984. private _alive;
  92985. private _useInstancing;
  92986. private _started;
  92987. private _stopped;
  92988. private _actualFrame;
  92989. private _scaledUpdateSpeed;
  92990. private _vertexBufferSize;
  92991. /** @hidden */
  92992. _currentEmitRateGradient: Nullable<FactorGradient>;
  92993. /** @hidden */
  92994. _currentEmitRate1: number;
  92995. /** @hidden */
  92996. _currentEmitRate2: number;
  92997. /** @hidden */
  92998. _currentStartSizeGradient: Nullable<FactorGradient>;
  92999. /** @hidden */
  93000. _currentStartSize1: number;
  93001. /** @hidden */
  93002. _currentStartSize2: number;
  93003. private readonly _rawTextureWidth;
  93004. private _rampGradientsTexture;
  93005. private _useRampGradients;
  93006. /** Gets or sets a matrix to use to compute projection */
  93007. defaultProjectionMatrix: Matrix;
  93008. /** Gets or sets a matrix to use to compute view */
  93009. defaultViewMatrix: Matrix;
  93010. /** Gets or sets a boolean indicating that ramp gradients must be used
  93011. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93012. */
  93013. get useRampGradients(): boolean;
  93014. set useRampGradients(value: boolean);
  93015. /**
  93016. * 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.
  93017. * 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: [])
  93018. */
  93019. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  93020. private _subEmitters;
  93021. /**
  93022. * @hidden
  93023. * If the particle systems emitter should be disposed when the particle system is disposed
  93024. */
  93025. _disposeEmitterOnDispose: boolean;
  93026. /**
  93027. * The current active Sub-systems, this property is used by the root particle system only.
  93028. */
  93029. activeSubSystems: Array<ParticleSystem>;
  93030. /**
  93031. * Specifies if the particles are updated in emitter local space or world space
  93032. */
  93033. isLocal: boolean;
  93034. private _rootParticleSystem;
  93035. /**
  93036. * Gets the current list of active particles
  93037. */
  93038. get particles(): Particle[];
  93039. /**
  93040. * Gets the number of particles active at the same time.
  93041. * @returns The number of active particles.
  93042. */
  93043. getActiveCount(): number;
  93044. /**
  93045. * Returns the string "ParticleSystem"
  93046. * @returns a string containing the class name
  93047. */
  93048. getClassName(): string;
  93049. /**
  93050. * Gets a boolean indicating that the system is stopping
  93051. * @returns true if the system is currently stopping
  93052. */
  93053. isStopping(): boolean;
  93054. /**
  93055. * Gets the custom effect used to render the particles
  93056. * @param blendMode Blend mode for which the effect should be retrieved
  93057. * @returns The effect
  93058. */
  93059. getCustomEffect(blendMode?: number): Nullable<Effect>;
  93060. /**
  93061. * Sets the custom effect used to render the particles
  93062. * @param effect The effect to set
  93063. * @param blendMode Blend mode for which the effect should be set
  93064. */
  93065. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  93066. /** @hidden */
  93067. private _onBeforeDrawParticlesObservable;
  93068. /**
  93069. * Observable that will be called just before the particles are drawn
  93070. */
  93071. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  93072. /**
  93073. * Gets the name of the particle vertex shader
  93074. */
  93075. get vertexShaderName(): string;
  93076. /**
  93077. * Instantiates a particle system.
  93078. * 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.
  93079. * @param name The name of the particle system
  93080. * @param capacity The max number of particles alive at the same time
  93081. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  93082. * @param customEffect a custom effect used to change the way particles are rendered by default
  93083. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  93084. * @param epsilon Offset used to render the particles
  93085. */
  93086. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  93087. private _addFactorGradient;
  93088. private _removeFactorGradient;
  93089. /**
  93090. * Adds a new life time gradient
  93091. * @param gradient defines the gradient to use (between 0 and 1)
  93092. * @param factor defines the life time factor to affect to the specified gradient
  93093. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93094. * @returns the current particle system
  93095. */
  93096. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93097. /**
  93098. * Remove a specific life time gradient
  93099. * @param gradient defines the gradient to remove
  93100. * @returns the current particle system
  93101. */
  93102. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93103. /**
  93104. * Adds a new size gradient
  93105. * @param gradient defines the gradient to use (between 0 and 1)
  93106. * @param factor defines the size factor to affect to the specified gradient
  93107. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93108. * @returns the current particle system
  93109. */
  93110. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93111. /**
  93112. * Remove a specific size gradient
  93113. * @param gradient defines the gradient to remove
  93114. * @returns the current particle system
  93115. */
  93116. removeSizeGradient(gradient: number): IParticleSystem;
  93117. /**
  93118. * Adds a new color remap gradient
  93119. * @param gradient defines the gradient to use (between 0 and 1)
  93120. * @param min defines the color remap minimal range
  93121. * @param max defines the color remap maximal range
  93122. * @returns the current particle system
  93123. */
  93124. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93125. /**
  93126. * Remove a specific color remap gradient
  93127. * @param gradient defines the gradient to remove
  93128. * @returns the current particle system
  93129. */
  93130. removeColorRemapGradient(gradient: number): IParticleSystem;
  93131. /**
  93132. * Adds a new alpha remap gradient
  93133. * @param gradient defines the gradient to use (between 0 and 1)
  93134. * @param min defines the alpha remap minimal range
  93135. * @param max defines the alpha remap maximal range
  93136. * @returns the current particle system
  93137. */
  93138. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93139. /**
  93140. * Remove a specific alpha remap gradient
  93141. * @param gradient defines the gradient to remove
  93142. * @returns the current particle system
  93143. */
  93144. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  93145. /**
  93146. * Adds a new angular speed gradient
  93147. * @param gradient defines the gradient to use (between 0 and 1)
  93148. * @param factor defines the angular speed to affect to the specified gradient
  93149. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93150. * @returns the current particle system
  93151. */
  93152. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93153. /**
  93154. * Remove a specific angular speed gradient
  93155. * @param gradient defines the gradient to remove
  93156. * @returns the current particle system
  93157. */
  93158. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93159. /**
  93160. * Adds a new velocity gradient
  93161. * @param gradient defines the gradient to use (between 0 and 1)
  93162. * @param factor defines the velocity to affect to the specified gradient
  93163. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93164. * @returns the current particle system
  93165. */
  93166. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93167. /**
  93168. * Remove a specific velocity gradient
  93169. * @param gradient defines the gradient to remove
  93170. * @returns the current particle system
  93171. */
  93172. removeVelocityGradient(gradient: number): IParticleSystem;
  93173. /**
  93174. * Adds a new limit velocity gradient
  93175. * @param gradient defines the gradient to use (between 0 and 1)
  93176. * @param factor defines the limit velocity value to affect to the specified gradient
  93177. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93178. * @returns the current particle system
  93179. */
  93180. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93181. /**
  93182. * Remove a specific limit velocity gradient
  93183. * @param gradient defines the gradient to remove
  93184. * @returns the current particle system
  93185. */
  93186. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93187. /**
  93188. * Adds a new drag gradient
  93189. * @param gradient defines the gradient to use (between 0 and 1)
  93190. * @param factor defines the drag value to affect to the specified gradient
  93191. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93192. * @returns the current particle system
  93193. */
  93194. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93195. /**
  93196. * Remove a specific drag gradient
  93197. * @param gradient defines the gradient to remove
  93198. * @returns the current particle system
  93199. */
  93200. removeDragGradient(gradient: number): IParticleSystem;
  93201. /**
  93202. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93203. * @param gradient defines the gradient to use (between 0 and 1)
  93204. * @param factor defines the emit rate value to affect to the specified gradient
  93205. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93206. * @returns the current particle system
  93207. */
  93208. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93209. /**
  93210. * Remove a specific emit rate gradient
  93211. * @param gradient defines the gradient to remove
  93212. * @returns the current particle system
  93213. */
  93214. removeEmitRateGradient(gradient: number): IParticleSystem;
  93215. /**
  93216. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93217. * @param gradient defines the gradient to use (between 0 and 1)
  93218. * @param factor defines the start size value to affect to the specified gradient
  93219. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93220. * @returns the current particle system
  93221. */
  93222. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93223. /**
  93224. * Remove a specific start size gradient
  93225. * @param gradient defines the gradient to remove
  93226. * @returns the current particle system
  93227. */
  93228. removeStartSizeGradient(gradient: number): IParticleSystem;
  93229. private _createRampGradientTexture;
  93230. /**
  93231. * Gets the current list of ramp gradients.
  93232. * You must use addRampGradient and removeRampGradient to udpate this list
  93233. * @returns the list of ramp gradients
  93234. */
  93235. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93236. /** Force the system to rebuild all gradients that need to be resync */
  93237. forceRefreshGradients(): void;
  93238. private _syncRampGradientTexture;
  93239. /**
  93240. * Adds a new ramp gradient used to remap particle colors
  93241. * @param gradient defines the gradient to use (between 0 and 1)
  93242. * @param color defines the color to affect to the specified gradient
  93243. * @returns the current particle system
  93244. */
  93245. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  93246. /**
  93247. * Remove a specific ramp gradient
  93248. * @param gradient defines the gradient to remove
  93249. * @returns the current particle system
  93250. */
  93251. removeRampGradient(gradient: number): ParticleSystem;
  93252. /**
  93253. * Adds a new color gradient
  93254. * @param gradient defines the gradient to use (between 0 and 1)
  93255. * @param color1 defines the color to affect to the specified gradient
  93256. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93257. * @returns this particle system
  93258. */
  93259. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93260. /**
  93261. * Remove a specific color gradient
  93262. * @param gradient defines the gradient to remove
  93263. * @returns this particle system
  93264. */
  93265. removeColorGradient(gradient: number): IParticleSystem;
  93266. private _fetchR;
  93267. protected _reset(): void;
  93268. private _resetEffect;
  93269. private _createVertexBuffers;
  93270. private _createIndexBuffer;
  93271. /**
  93272. * Gets the maximum number of particles active at the same time.
  93273. * @returns The max number of active particles.
  93274. */
  93275. getCapacity(): number;
  93276. /**
  93277. * Gets whether there are still active particles in the system.
  93278. * @returns True if it is alive, otherwise false.
  93279. */
  93280. isAlive(): boolean;
  93281. /**
  93282. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93283. * @returns True if it has been started, otherwise false.
  93284. */
  93285. isStarted(): boolean;
  93286. private _prepareSubEmitterInternalArray;
  93287. /**
  93288. * Starts the particle system and begins to emit
  93289. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  93290. */
  93291. start(delay?: number): void;
  93292. /**
  93293. * Stops the particle system.
  93294. * @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.
  93295. */
  93296. stop(stopSubEmitters?: boolean): void;
  93297. /**
  93298. * Remove all active particles
  93299. */
  93300. reset(): void;
  93301. /**
  93302. * @hidden (for internal use only)
  93303. */
  93304. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  93305. /**
  93306. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  93307. * Its lifetime will start back at 0.
  93308. */
  93309. recycleParticle: (particle: Particle) => void;
  93310. private _stopSubEmitters;
  93311. private _createParticle;
  93312. private _removeFromRoot;
  93313. private _emitFromParticle;
  93314. private _update;
  93315. /** @hidden */
  93316. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  93317. /** @hidden */
  93318. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  93319. /**
  93320. * Fill the defines array according to the current settings of the particle system
  93321. * @param defines Array to be updated
  93322. * @param blendMode blend mode to take into account when updating the array
  93323. */
  93324. fillDefines(defines: Array<string>, blendMode: number): void;
  93325. /**
  93326. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93327. * @param uniforms Uniforms array to fill
  93328. * @param attributes Attributes array to fill
  93329. * @param samplers Samplers array to fill
  93330. */
  93331. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93332. /** @hidden */
  93333. private _getEffect;
  93334. /**
  93335. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  93336. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  93337. */
  93338. animate(preWarmOnly?: boolean): void;
  93339. private _appendParticleVertices;
  93340. /**
  93341. * Rebuilds the particle system.
  93342. */
  93343. rebuild(): void;
  93344. /**
  93345. * Is this system ready to be used/rendered
  93346. * @return true if the system is ready
  93347. */
  93348. isReady(): boolean;
  93349. private _render;
  93350. /**
  93351. * Renders the particle system in its current state.
  93352. * @returns the current number of particles
  93353. */
  93354. render(): number;
  93355. /**
  93356. * Disposes the particle system and free the associated resources
  93357. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93358. */
  93359. dispose(disposeTexture?: boolean): void;
  93360. /**
  93361. * Clones the particle system.
  93362. * @param name The name of the cloned object
  93363. * @param newEmitter The new emitter to use
  93364. * @returns the cloned particle system
  93365. */
  93366. clone(name: string, newEmitter: any): ParticleSystem;
  93367. /**
  93368. * Serializes the particle system to a JSON object
  93369. * @param serializeTexture defines if the texture must be serialized as well
  93370. * @returns the JSON object
  93371. */
  93372. serialize(serializeTexture?: boolean): any;
  93373. /** @hidden */
  93374. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  93375. /** @hidden */
  93376. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  93377. /**
  93378. * Parses a JSON object to create a particle system.
  93379. * @param parsedParticleSystem The JSON object to parse
  93380. * @param sceneOrEngine The scene or the engine to create the particle system in
  93381. * @param rootUrl The root url to use to load external dependencies like texture
  93382. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  93383. * @returns the Parsed particle system
  93384. */
  93385. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  93386. }
  93387. }
  93388. declare module BABYLON {
  93389. /**
  93390. * A particle represents one of the element emitted by a particle system.
  93391. * This is mainly define by its coordinates, direction, velocity and age.
  93392. */
  93393. export class Particle {
  93394. /**
  93395. * The particle system the particle belongs to.
  93396. */
  93397. particleSystem: ParticleSystem;
  93398. private static _Count;
  93399. /**
  93400. * Unique ID of the particle
  93401. */
  93402. id: number;
  93403. /**
  93404. * The world position of the particle in the scene.
  93405. */
  93406. position: Vector3;
  93407. /**
  93408. * The world direction of the particle in the scene.
  93409. */
  93410. direction: Vector3;
  93411. /**
  93412. * The color of the particle.
  93413. */
  93414. color: Color4;
  93415. /**
  93416. * The color change of the particle per step.
  93417. */
  93418. colorStep: Color4;
  93419. /**
  93420. * Defines how long will the life of the particle be.
  93421. */
  93422. lifeTime: number;
  93423. /**
  93424. * The current age of the particle.
  93425. */
  93426. age: number;
  93427. /**
  93428. * The current size of the particle.
  93429. */
  93430. size: number;
  93431. /**
  93432. * The current scale of the particle.
  93433. */
  93434. scale: Vector2;
  93435. /**
  93436. * The current angle of the particle.
  93437. */
  93438. angle: number;
  93439. /**
  93440. * Defines how fast is the angle changing.
  93441. */
  93442. angularSpeed: number;
  93443. /**
  93444. * Defines the cell index used by the particle to be rendered from a sprite.
  93445. */
  93446. cellIndex: number;
  93447. /**
  93448. * The information required to support color remapping
  93449. */
  93450. remapData: Vector4;
  93451. /** @hidden */
  93452. _randomCellOffset?: number;
  93453. /** @hidden */
  93454. _initialDirection: Nullable<Vector3>;
  93455. /** @hidden */
  93456. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  93457. /** @hidden */
  93458. _initialStartSpriteCellID: number;
  93459. /** @hidden */
  93460. _initialEndSpriteCellID: number;
  93461. /** @hidden */
  93462. _currentColorGradient: Nullable<ColorGradient>;
  93463. /** @hidden */
  93464. _currentColor1: Color4;
  93465. /** @hidden */
  93466. _currentColor2: Color4;
  93467. /** @hidden */
  93468. _currentSizeGradient: Nullable<FactorGradient>;
  93469. /** @hidden */
  93470. _currentSize1: number;
  93471. /** @hidden */
  93472. _currentSize2: number;
  93473. /** @hidden */
  93474. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  93475. /** @hidden */
  93476. _currentAngularSpeed1: number;
  93477. /** @hidden */
  93478. _currentAngularSpeed2: number;
  93479. /** @hidden */
  93480. _currentVelocityGradient: Nullable<FactorGradient>;
  93481. /** @hidden */
  93482. _currentVelocity1: number;
  93483. /** @hidden */
  93484. _currentVelocity2: number;
  93485. /** @hidden */
  93486. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  93487. /** @hidden */
  93488. _currentLimitVelocity1: number;
  93489. /** @hidden */
  93490. _currentLimitVelocity2: number;
  93491. /** @hidden */
  93492. _currentDragGradient: Nullable<FactorGradient>;
  93493. /** @hidden */
  93494. _currentDrag1: number;
  93495. /** @hidden */
  93496. _currentDrag2: number;
  93497. /** @hidden */
  93498. _randomNoiseCoordinates1: Vector3;
  93499. /** @hidden */
  93500. _randomNoiseCoordinates2: Vector3;
  93501. /** @hidden */
  93502. _localPosition?: Vector3;
  93503. /**
  93504. * Creates a new instance Particle
  93505. * @param particleSystem the particle system the particle belongs to
  93506. */
  93507. constructor(
  93508. /**
  93509. * The particle system the particle belongs to.
  93510. */
  93511. particleSystem: ParticleSystem);
  93512. private updateCellInfoFromSystem;
  93513. /**
  93514. * Defines how the sprite cell index is updated for the particle
  93515. */
  93516. updateCellIndex(): void;
  93517. /** @hidden */
  93518. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  93519. /** @hidden */
  93520. _inheritParticleInfoToSubEmitters(): void;
  93521. /** @hidden */
  93522. _reset(): void;
  93523. /**
  93524. * Copy the properties of particle to another one.
  93525. * @param other the particle to copy the information to.
  93526. */
  93527. copyTo(other: Particle): void;
  93528. }
  93529. }
  93530. declare module BABYLON {
  93531. /**
  93532. * Particle emitter represents a volume emitting particles.
  93533. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  93534. */
  93535. export interface IParticleEmitterType {
  93536. /**
  93537. * Called by the particle System when the direction is computed for the created particle.
  93538. * @param worldMatrix is the world matrix of the particle system
  93539. * @param directionToUpdate is the direction vector to update with the result
  93540. * @param particle is the particle we are computed the direction for
  93541. * @param isLocal defines if the direction should be set in local space
  93542. */
  93543. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93544. /**
  93545. * Called by the particle System when the position is computed for the created particle.
  93546. * @param worldMatrix is the world matrix of the particle system
  93547. * @param positionToUpdate is the position vector to update with the result
  93548. * @param particle is the particle we are computed the position for
  93549. * @param isLocal defines if the position should be set in local space
  93550. */
  93551. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93552. /**
  93553. * Clones the current emitter and returns a copy of it
  93554. * @returns the new emitter
  93555. */
  93556. clone(): IParticleEmitterType;
  93557. /**
  93558. * Called by the GPUParticleSystem to setup the update shader
  93559. * @param effect defines the update shader
  93560. */
  93561. applyToShader(effect: Effect): void;
  93562. /**
  93563. * Returns a string to use to update the GPU particles update shader
  93564. * @returns the effect defines string
  93565. */
  93566. getEffectDefines(): string;
  93567. /**
  93568. * Returns a string representing the class name
  93569. * @returns a string containing the class name
  93570. */
  93571. getClassName(): string;
  93572. /**
  93573. * Serializes the particle system to a JSON object.
  93574. * @returns the JSON object
  93575. */
  93576. serialize(): any;
  93577. /**
  93578. * Parse properties from a JSON object
  93579. * @param serializationObject defines the JSON object
  93580. * @param scene defines the hosting scene
  93581. */
  93582. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93583. }
  93584. }
  93585. declare module BABYLON {
  93586. /**
  93587. * Particle emitter emitting particles from the inside of a box.
  93588. * It emits the particles randomly between 2 given directions.
  93589. */
  93590. export class BoxParticleEmitter implements IParticleEmitterType {
  93591. /**
  93592. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93593. */
  93594. direction1: Vector3;
  93595. /**
  93596. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93597. */
  93598. direction2: Vector3;
  93599. /**
  93600. * 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.
  93601. */
  93602. minEmitBox: Vector3;
  93603. /**
  93604. * 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.
  93605. */
  93606. maxEmitBox: Vector3;
  93607. /**
  93608. * Creates a new instance BoxParticleEmitter
  93609. */
  93610. constructor();
  93611. /**
  93612. * Called by the particle System when the direction is computed for the created particle.
  93613. * @param worldMatrix is the world matrix of the particle system
  93614. * @param directionToUpdate is the direction vector to update with the result
  93615. * @param particle is the particle we are computed the direction for
  93616. * @param isLocal defines if the direction should be set in local space
  93617. */
  93618. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93619. /**
  93620. * Called by the particle System when the position is computed for the created particle.
  93621. * @param worldMatrix is the world matrix of the particle system
  93622. * @param positionToUpdate is the position vector to update with the result
  93623. * @param particle is the particle we are computed the position for
  93624. * @param isLocal defines if the position should be set in local space
  93625. */
  93626. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93627. /**
  93628. * Clones the current emitter and returns a copy of it
  93629. * @returns the new emitter
  93630. */
  93631. clone(): BoxParticleEmitter;
  93632. /**
  93633. * Called by the GPUParticleSystem to setup the update shader
  93634. * @param effect defines the update shader
  93635. */
  93636. applyToShader(effect: Effect): void;
  93637. /**
  93638. * Returns a string to use to update the GPU particles update shader
  93639. * @returns a string containng the defines string
  93640. */
  93641. getEffectDefines(): string;
  93642. /**
  93643. * Returns the string "BoxParticleEmitter"
  93644. * @returns a string containing the class name
  93645. */
  93646. getClassName(): string;
  93647. /**
  93648. * Serializes the particle system to a JSON object.
  93649. * @returns the JSON object
  93650. */
  93651. serialize(): any;
  93652. /**
  93653. * Parse properties from a JSON object
  93654. * @param serializationObject defines the JSON object
  93655. */
  93656. parse(serializationObject: any): void;
  93657. }
  93658. }
  93659. declare module BABYLON {
  93660. /**
  93661. * Particle emitter emitting particles from the inside of a cone.
  93662. * It emits the particles alongside the cone volume from the base to the particle.
  93663. * The emission direction might be randomized.
  93664. */
  93665. export class ConeParticleEmitter implements IParticleEmitterType {
  93666. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93667. directionRandomizer: number;
  93668. private _radius;
  93669. private _angle;
  93670. private _height;
  93671. /**
  93672. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  93673. */
  93674. radiusRange: number;
  93675. /**
  93676. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  93677. */
  93678. heightRange: number;
  93679. /**
  93680. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  93681. */
  93682. emitFromSpawnPointOnly: boolean;
  93683. /**
  93684. * Gets or sets the radius of the emission cone
  93685. */
  93686. get radius(): number;
  93687. set radius(value: number);
  93688. /**
  93689. * Gets or sets the angle of the emission cone
  93690. */
  93691. get angle(): number;
  93692. set angle(value: number);
  93693. private _buildHeight;
  93694. /**
  93695. * Creates a new instance ConeParticleEmitter
  93696. * @param radius the radius of the emission cone (1 by default)
  93697. * @param angle the cone base angle (PI by default)
  93698. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  93699. */
  93700. constructor(radius?: number, angle?: number,
  93701. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93702. directionRandomizer?: number);
  93703. /**
  93704. * Called by the particle System when the direction is computed for the created particle.
  93705. * @param worldMatrix is the world matrix of the particle system
  93706. * @param directionToUpdate is the direction vector to update with the result
  93707. * @param particle is the particle we are computed the direction for
  93708. * @param isLocal defines if the direction should be set in local space
  93709. */
  93710. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93711. /**
  93712. * Called by the particle System when the position is computed for the created particle.
  93713. * @param worldMatrix is the world matrix of the particle system
  93714. * @param positionToUpdate is the position vector to update with the result
  93715. * @param particle is the particle we are computed the position for
  93716. * @param isLocal defines if the position should be set in local space
  93717. */
  93718. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93719. /**
  93720. * Clones the current emitter and returns a copy of it
  93721. * @returns the new emitter
  93722. */
  93723. clone(): ConeParticleEmitter;
  93724. /**
  93725. * Called by the GPUParticleSystem to setup the update shader
  93726. * @param effect defines the update shader
  93727. */
  93728. applyToShader(effect: Effect): void;
  93729. /**
  93730. * Returns a string to use to update the GPU particles update shader
  93731. * @returns a string containng the defines string
  93732. */
  93733. getEffectDefines(): string;
  93734. /**
  93735. * Returns the string "ConeParticleEmitter"
  93736. * @returns a string containing the class name
  93737. */
  93738. getClassName(): string;
  93739. /**
  93740. * Serializes the particle system to a JSON object.
  93741. * @returns the JSON object
  93742. */
  93743. serialize(): any;
  93744. /**
  93745. * Parse properties from a JSON object
  93746. * @param serializationObject defines the JSON object
  93747. */
  93748. parse(serializationObject: any): void;
  93749. }
  93750. }
  93751. declare module BABYLON {
  93752. /**
  93753. * Particle emitter emitting particles from the inside of a cylinder.
  93754. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  93755. */
  93756. export class CylinderParticleEmitter implements IParticleEmitterType {
  93757. /**
  93758. * The radius of the emission cylinder.
  93759. */
  93760. radius: number;
  93761. /**
  93762. * The height of the emission cylinder.
  93763. */
  93764. height: number;
  93765. /**
  93766. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93767. */
  93768. radiusRange: number;
  93769. /**
  93770. * How much to randomize the particle direction [0-1].
  93771. */
  93772. directionRandomizer: number;
  93773. /**
  93774. * Creates a new instance CylinderParticleEmitter
  93775. * @param radius the radius of the emission cylinder (1 by default)
  93776. * @param height the height of the emission cylinder (1 by default)
  93777. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93778. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93779. */
  93780. constructor(
  93781. /**
  93782. * The radius of the emission cylinder.
  93783. */
  93784. radius?: number,
  93785. /**
  93786. * The height of the emission cylinder.
  93787. */
  93788. height?: number,
  93789. /**
  93790. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93791. */
  93792. radiusRange?: number,
  93793. /**
  93794. * How much to randomize the particle direction [0-1].
  93795. */
  93796. directionRandomizer?: number);
  93797. /**
  93798. * Called by the particle System when the direction is computed for the created particle.
  93799. * @param worldMatrix is the world matrix of the particle system
  93800. * @param directionToUpdate is the direction vector to update with the result
  93801. * @param particle is the particle we are computed the direction for
  93802. * @param isLocal defines if the direction should be set in local space
  93803. */
  93804. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93805. /**
  93806. * Called by the particle System when the position is computed for the created particle.
  93807. * @param worldMatrix is the world matrix of the particle system
  93808. * @param positionToUpdate is the position vector to update with the result
  93809. * @param particle is the particle we are computed the position for
  93810. * @param isLocal defines if the position should be set in local space
  93811. */
  93812. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93813. /**
  93814. * Clones the current emitter and returns a copy of it
  93815. * @returns the new emitter
  93816. */
  93817. clone(): CylinderParticleEmitter;
  93818. /**
  93819. * Called by the GPUParticleSystem to setup the update shader
  93820. * @param effect defines the update shader
  93821. */
  93822. applyToShader(effect: Effect): void;
  93823. /**
  93824. * Returns a string to use to update the GPU particles update shader
  93825. * @returns a string containng the defines string
  93826. */
  93827. getEffectDefines(): string;
  93828. /**
  93829. * Returns the string "CylinderParticleEmitter"
  93830. * @returns a string containing the class name
  93831. */
  93832. getClassName(): string;
  93833. /**
  93834. * Serializes the particle system to a JSON object.
  93835. * @returns the JSON object
  93836. */
  93837. serialize(): any;
  93838. /**
  93839. * Parse properties from a JSON object
  93840. * @param serializationObject defines the JSON object
  93841. */
  93842. parse(serializationObject: any): void;
  93843. }
  93844. /**
  93845. * Particle emitter emitting particles from the inside of a cylinder.
  93846. * It emits the particles randomly between two vectors.
  93847. */
  93848. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  93849. /**
  93850. * The min limit of the emission direction.
  93851. */
  93852. direction1: Vector3;
  93853. /**
  93854. * The max limit of the emission direction.
  93855. */
  93856. direction2: Vector3;
  93857. /**
  93858. * Creates a new instance CylinderDirectedParticleEmitter
  93859. * @param radius the radius of the emission cylinder (1 by default)
  93860. * @param height the height of the emission cylinder (1 by default)
  93861. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93862. * @param direction1 the min limit of the emission direction (up vector by default)
  93863. * @param direction2 the max limit of the emission direction (up vector by default)
  93864. */
  93865. constructor(radius?: number, height?: number, radiusRange?: number,
  93866. /**
  93867. * The min limit of the emission direction.
  93868. */
  93869. direction1?: Vector3,
  93870. /**
  93871. * The max limit of the emission direction.
  93872. */
  93873. direction2?: Vector3);
  93874. /**
  93875. * Called by the particle System when the direction is computed for the created particle.
  93876. * @param worldMatrix is the world matrix of the particle system
  93877. * @param directionToUpdate is the direction vector to update with the result
  93878. * @param particle is the particle we are computed the direction for
  93879. */
  93880. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93881. /**
  93882. * Clones the current emitter and returns a copy of it
  93883. * @returns the new emitter
  93884. */
  93885. clone(): CylinderDirectedParticleEmitter;
  93886. /**
  93887. * Called by the GPUParticleSystem to setup the update shader
  93888. * @param effect defines the update shader
  93889. */
  93890. applyToShader(effect: Effect): void;
  93891. /**
  93892. * Returns a string to use to update the GPU particles update shader
  93893. * @returns a string containng the defines string
  93894. */
  93895. getEffectDefines(): string;
  93896. /**
  93897. * Returns the string "CylinderDirectedParticleEmitter"
  93898. * @returns a string containing the class name
  93899. */
  93900. getClassName(): string;
  93901. /**
  93902. * Serializes the particle system to a JSON object.
  93903. * @returns the JSON object
  93904. */
  93905. serialize(): any;
  93906. /**
  93907. * Parse properties from a JSON object
  93908. * @param serializationObject defines the JSON object
  93909. */
  93910. parse(serializationObject: any): void;
  93911. }
  93912. }
  93913. declare module BABYLON {
  93914. /**
  93915. * Particle emitter emitting particles from the inside of a hemisphere.
  93916. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  93917. */
  93918. export class HemisphericParticleEmitter implements IParticleEmitterType {
  93919. /**
  93920. * The radius of the emission hemisphere.
  93921. */
  93922. radius: number;
  93923. /**
  93924. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93925. */
  93926. radiusRange: number;
  93927. /**
  93928. * How much to randomize the particle direction [0-1].
  93929. */
  93930. directionRandomizer: number;
  93931. /**
  93932. * Creates a new instance HemisphericParticleEmitter
  93933. * @param radius the radius of the emission hemisphere (1 by default)
  93934. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93935. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93936. */
  93937. constructor(
  93938. /**
  93939. * The radius of the emission hemisphere.
  93940. */
  93941. radius?: number,
  93942. /**
  93943. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93944. */
  93945. radiusRange?: number,
  93946. /**
  93947. * How much to randomize the particle direction [0-1].
  93948. */
  93949. directionRandomizer?: number);
  93950. /**
  93951. * Called by the particle System when the direction is computed for the created particle.
  93952. * @param worldMatrix is the world matrix of the particle system
  93953. * @param directionToUpdate is the direction vector to update with the result
  93954. * @param particle is the particle we are computed the direction for
  93955. * @param isLocal defines if the direction should be set in local space
  93956. */
  93957. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93958. /**
  93959. * Called by the particle System when the position is computed for the created particle.
  93960. * @param worldMatrix is the world matrix of the particle system
  93961. * @param positionToUpdate is the position vector to update with the result
  93962. * @param particle is the particle we are computed the position for
  93963. * @param isLocal defines if the position should be set in local space
  93964. */
  93965. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93966. /**
  93967. * Clones the current emitter and returns a copy of it
  93968. * @returns the new emitter
  93969. */
  93970. clone(): HemisphericParticleEmitter;
  93971. /**
  93972. * Called by the GPUParticleSystem to setup the update shader
  93973. * @param effect defines the update shader
  93974. */
  93975. applyToShader(effect: Effect): void;
  93976. /**
  93977. * Returns a string to use to update the GPU particles update shader
  93978. * @returns a string containng the defines string
  93979. */
  93980. getEffectDefines(): string;
  93981. /**
  93982. * Returns the string "HemisphericParticleEmitter"
  93983. * @returns a string containing the class name
  93984. */
  93985. getClassName(): string;
  93986. /**
  93987. * Serializes the particle system to a JSON object.
  93988. * @returns the JSON object
  93989. */
  93990. serialize(): any;
  93991. /**
  93992. * Parse properties from a JSON object
  93993. * @param serializationObject defines the JSON object
  93994. */
  93995. parse(serializationObject: any): void;
  93996. }
  93997. }
  93998. declare module BABYLON {
  93999. /**
  94000. * Particle emitter emitting particles from a point.
  94001. * It emits the particles randomly between 2 given directions.
  94002. */
  94003. export class PointParticleEmitter implements IParticleEmitterType {
  94004. /**
  94005. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94006. */
  94007. direction1: Vector3;
  94008. /**
  94009. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94010. */
  94011. direction2: Vector3;
  94012. /**
  94013. * Creates a new instance PointParticleEmitter
  94014. */
  94015. constructor();
  94016. /**
  94017. * Called by the particle System when the direction is computed for the created particle.
  94018. * @param worldMatrix is the world matrix of the particle system
  94019. * @param directionToUpdate is the direction vector to update with the result
  94020. * @param particle is the particle we are computed the direction for
  94021. * @param isLocal defines if the direction should be set in local space
  94022. */
  94023. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94024. /**
  94025. * Called by the particle System when the position is computed for the created particle.
  94026. * @param worldMatrix is the world matrix of the particle system
  94027. * @param positionToUpdate is the position vector to update with the result
  94028. * @param particle is the particle we are computed the position for
  94029. * @param isLocal defines if the position should be set in local space
  94030. */
  94031. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94032. /**
  94033. * Clones the current emitter and returns a copy of it
  94034. * @returns the new emitter
  94035. */
  94036. clone(): PointParticleEmitter;
  94037. /**
  94038. * Called by the GPUParticleSystem to setup the update shader
  94039. * @param effect defines the update shader
  94040. */
  94041. applyToShader(effect: Effect): void;
  94042. /**
  94043. * Returns a string to use to update the GPU particles update shader
  94044. * @returns a string containng the defines string
  94045. */
  94046. getEffectDefines(): string;
  94047. /**
  94048. * Returns the string "PointParticleEmitter"
  94049. * @returns a string containing the class name
  94050. */
  94051. getClassName(): string;
  94052. /**
  94053. * Serializes the particle system to a JSON object.
  94054. * @returns the JSON object
  94055. */
  94056. serialize(): any;
  94057. /**
  94058. * Parse properties from a JSON object
  94059. * @param serializationObject defines the JSON object
  94060. */
  94061. parse(serializationObject: any): void;
  94062. }
  94063. }
  94064. declare module BABYLON {
  94065. /**
  94066. * Particle emitter emitting particles from the inside of a sphere.
  94067. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  94068. */
  94069. export class SphereParticleEmitter implements IParticleEmitterType {
  94070. /**
  94071. * The radius of the emission sphere.
  94072. */
  94073. radius: number;
  94074. /**
  94075. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94076. */
  94077. radiusRange: number;
  94078. /**
  94079. * How much to randomize the particle direction [0-1].
  94080. */
  94081. directionRandomizer: number;
  94082. /**
  94083. * Creates a new instance SphereParticleEmitter
  94084. * @param radius the radius of the emission sphere (1 by default)
  94085. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94086. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94087. */
  94088. constructor(
  94089. /**
  94090. * The radius of the emission sphere.
  94091. */
  94092. radius?: number,
  94093. /**
  94094. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94095. */
  94096. radiusRange?: number,
  94097. /**
  94098. * How much to randomize the particle direction [0-1].
  94099. */
  94100. directionRandomizer?: number);
  94101. /**
  94102. * Called by the particle System when the direction is computed for the created particle.
  94103. * @param worldMatrix is the world matrix of the particle system
  94104. * @param directionToUpdate is the direction vector to update with the result
  94105. * @param particle is the particle we are computed the direction for
  94106. * @param isLocal defines if the direction should be set in local space
  94107. */
  94108. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94109. /**
  94110. * Called by the particle System when the position is computed for the created particle.
  94111. * @param worldMatrix is the world matrix of the particle system
  94112. * @param positionToUpdate is the position vector to update with the result
  94113. * @param particle is the particle we are computed the position for
  94114. * @param isLocal defines if the position should be set in local space
  94115. */
  94116. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94117. /**
  94118. * Clones the current emitter and returns a copy of it
  94119. * @returns the new emitter
  94120. */
  94121. clone(): SphereParticleEmitter;
  94122. /**
  94123. * Called by the GPUParticleSystem to setup the update shader
  94124. * @param effect defines the update shader
  94125. */
  94126. applyToShader(effect: Effect): void;
  94127. /**
  94128. * Returns a string to use to update the GPU particles update shader
  94129. * @returns a string containng the defines string
  94130. */
  94131. getEffectDefines(): string;
  94132. /**
  94133. * Returns the string "SphereParticleEmitter"
  94134. * @returns a string containing the class name
  94135. */
  94136. getClassName(): string;
  94137. /**
  94138. * Serializes the particle system to a JSON object.
  94139. * @returns the JSON object
  94140. */
  94141. serialize(): any;
  94142. /**
  94143. * Parse properties from a JSON object
  94144. * @param serializationObject defines the JSON object
  94145. */
  94146. parse(serializationObject: any): void;
  94147. }
  94148. /**
  94149. * Particle emitter emitting particles from the inside of a sphere.
  94150. * It emits the particles randomly between two vectors.
  94151. */
  94152. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  94153. /**
  94154. * The min limit of the emission direction.
  94155. */
  94156. direction1: Vector3;
  94157. /**
  94158. * The max limit of the emission direction.
  94159. */
  94160. direction2: Vector3;
  94161. /**
  94162. * Creates a new instance SphereDirectedParticleEmitter
  94163. * @param radius the radius of the emission sphere (1 by default)
  94164. * @param direction1 the min limit of the emission direction (up vector by default)
  94165. * @param direction2 the max limit of the emission direction (up vector by default)
  94166. */
  94167. constructor(radius?: number,
  94168. /**
  94169. * The min limit of the emission direction.
  94170. */
  94171. direction1?: Vector3,
  94172. /**
  94173. * The max limit of the emission direction.
  94174. */
  94175. direction2?: Vector3);
  94176. /**
  94177. * Called by the particle System when the direction is computed for the created particle.
  94178. * @param worldMatrix is the world matrix of the particle system
  94179. * @param directionToUpdate is the direction vector to update with the result
  94180. * @param particle is the particle we are computed the direction for
  94181. */
  94182. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94183. /**
  94184. * Clones the current emitter and returns a copy of it
  94185. * @returns the new emitter
  94186. */
  94187. clone(): SphereDirectedParticleEmitter;
  94188. /**
  94189. * Called by the GPUParticleSystem to setup the update shader
  94190. * @param effect defines the update shader
  94191. */
  94192. applyToShader(effect: Effect): void;
  94193. /**
  94194. * Returns a string to use to update the GPU particles update shader
  94195. * @returns a string containng the defines string
  94196. */
  94197. getEffectDefines(): string;
  94198. /**
  94199. * Returns the string "SphereDirectedParticleEmitter"
  94200. * @returns a string containing the class name
  94201. */
  94202. getClassName(): string;
  94203. /**
  94204. * Serializes the particle system to a JSON object.
  94205. * @returns the JSON object
  94206. */
  94207. serialize(): any;
  94208. /**
  94209. * Parse properties from a JSON object
  94210. * @param serializationObject defines the JSON object
  94211. */
  94212. parse(serializationObject: any): void;
  94213. }
  94214. }
  94215. declare module BABYLON {
  94216. /**
  94217. * Particle emitter emitting particles from a custom list of positions.
  94218. */
  94219. export class CustomParticleEmitter implements IParticleEmitterType {
  94220. /**
  94221. * Gets or sets the position generator that will create the inital position of each particle.
  94222. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94223. */
  94224. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  94225. /**
  94226. * Gets or sets the destination generator that will create the final destination of each particle.
  94227. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94228. */
  94229. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  94230. /**
  94231. * Creates a new instance CustomParticleEmitter
  94232. */
  94233. constructor();
  94234. /**
  94235. * Called by the particle System when the direction is computed for the created particle.
  94236. * @param worldMatrix is the world matrix of the particle system
  94237. * @param directionToUpdate is the direction vector to update with the result
  94238. * @param particle is the particle we are computed the direction for
  94239. * @param isLocal defines if the direction should be set in local space
  94240. */
  94241. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94242. /**
  94243. * Called by the particle System when the position is computed for the created particle.
  94244. * @param worldMatrix is the world matrix of the particle system
  94245. * @param positionToUpdate is the position vector to update with the result
  94246. * @param particle is the particle we are computed the position for
  94247. * @param isLocal defines if the position should be set in local space
  94248. */
  94249. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94250. /**
  94251. * Clones the current emitter and returns a copy of it
  94252. * @returns the new emitter
  94253. */
  94254. clone(): CustomParticleEmitter;
  94255. /**
  94256. * Called by the GPUParticleSystem to setup the update shader
  94257. * @param effect defines the update shader
  94258. */
  94259. applyToShader(effect: Effect): void;
  94260. /**
  94261. * Returns a string to use to update the GPU particles update shader
  94262. * @returns a string containng the defines string
  94263. */
  94264. getEffectDefines(): string;
  94265. /**
  94266. * Returns the string "PointParticleEmitter"
  94267. * @returns a string containing the class name
  94268. */
  94269. getClassName(): string;
  94270. /**
  94271. * Serializes the particle system to a JSON object.
  94272. * @returns the JSON object
  94273. */
  94274. serialize(): any;
  94275. /**
  94276. * Parse properties from a JSON object
  94277. * @param serializationObject defines the JSON object
  94278. */
  94279. parse(serializationObject: any): void;
  94280. }
  94281. }
  94282. declare module BABYLON {
  94283. /**
  94284. * Particle emitter emitting particles from the inside of a box.
  94285. * It emits the particles randomly between 2 given directions.
  94286. */
  94287. export class MeshParticleEmitter implements IParticleEmitterType {
  94288. private _indices;
  94289. private _positions;
  94290. private _normals;
  94291. private _storedNormal;
  94292. private _mesh;
  94293. /**
  94294. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94295. */
  94296. direction1: Vector3;
  94297. /**
  94298. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94299. */
  94300. direction2: Vector3;
  94301. /**
  94302. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  94303. */
  94304. useMeshNormalsForDirection: boolean;
  94305. /** Defines the mesh to use as source */
  94306. get mesh(): Nullable<AbstractMesh>;
  94307. set mesh(value: Nullable<AbstractMesh>);
  94308. /**
  94309. * Creates a new instance MeshParticleEmitter
  94310. * @param mesh defines the mesh to use as source
  94311. */
  94312. constructor(mesh?: Nullable<AbstractMesh>);
  94313. /**
  94314. * Called by the particle System when the direction is computed for the created particle.
  94315. * @param worldMatrix is the world matrix of the particle system
  94316. * @param directionToUpdate is the direction vector to update with the result
  94317. * @param particle is the particle we are computed the direction for
  94318. * @param isLocal defines if the direction should be set in local space
  94319. */
  94320. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94321. /**
  94322. * Called by the particle System when the position is computed for the created particle.
  94323. * @param worldMatrix is the world matrix of the particle system
  94324. * @param positionToUpdate is the position vector to update with the result
  94325. * @param particle is the particle we are computed the position for
  94326. * @param isLocal defines if the position should be set in local space
  94327. */
  94328. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94329. /**
  94330. * Clones the current emitter and returns a copy of it
  94331. * @returns the new emitter
  94332. */
  94333. clone(): MeshParticleEmitter;
  94334. /**
  94335. * Called by the GPUParticleSystem to setup the update shader
  94336. * @param effect defines the update shader
  94337. */
  94338. applyToShader(effect: Effect): void;
  94339. /**
  94340. * Returns a string to use to update the GPU particles update shader
  94341. * @returns a string containng the defines string
  94342. */
  94343. getEffectDefines(): string;
  94344. /**
  94345. * Returns the string "BoxParticleEmitter"
  94346. * @returns a string containing the class name
  94347. */
  94348. getClassName(): string;
  94349. /**
  94350. * Serializes the particle system to a JSON object.
  94351. * @returns the JSON object
  94352. */
  94353. serialize(): any;
  94354. /**
  94355. * Parse properties from a JSON object
  94356. * @param serializationObject defines the JSON object
  94357. * @param scene defines the hosting scene
  94358. */
  94359. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94360. }
  94361. }
  94362. declare module BABYLON {
  94363. /**
  94364. * Interface representing a particle system in Babylon.js.
  94365. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  94366. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  94367. */
  94368. export interface IParticleSystem {
  94369. /**
  94370. * List of animations used by the particle system.
  94371. */
  94372. animations: Animation[];
  94373. /**
  94374. * The id of the Particle system.
  94375. */
  94376. id: string;
  94377. /**
  94378. * The name of the Particle system.
  94379. */
  94380. name: string;
  94381. /**
  94382. * The emitter represents the Mesh or position we are attaching the particle system to.
  94383. */
  94384. emitter: Nullable<AbstractMesh | Vector3>;
  94385. /**
  94386. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  94387. */
  94388. isBillboardBased: boolean;
  94389. /**
  94390. * The rendering group used by the Particle system to chose when to render.
  94391. */
  94392. renderingGroupId: number;
  94393. /**
  94394. * The layer mask we are rendering the particles through.
  94395. */
  94396. layerMask: number;
  94397. /**
  94398. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  94399. */
  94400. updateSpeed: number;
  94401. /**
  94402. * The amount of time the particle system is running (depends of the overall update speed).
  94403. */
  94404. targetStopDuration: number;
  94405. /**
  94406. * The texture used to render each particle. (this can be a spritesheet)
  94407. */
  94408. particleTexture: Nullable<BaseTexture>;
  94409. /**
  94410. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  94411. */
  94412. blendMode: number;
  94413. /**
  94414. * Minimum life time of emitting particles.
  94415. */
  94416. minLifeTime: number;
  94417. /**
  94418. * Maximum life time of emitting particles.
  94419. */
  94420. maxLifeTime: number;
  94421. /**
  94422. * Minimum Size of emitting particles.
  94423. */
  94424. minSize: number;
  94425. /**
  94426. * Maximum Size of emitting particles.
  94427. */
  94428. maxSize: number;
  94429. /**
  94430. * Minimum scale of emitting particles on X axis.
  94431. */
  94432. minScaleX: number;
  94433. /**
  94434. * Maximum scale of emitting particles on X axis.
  94435. */
  94436. maxScaleX: number;
  94437. /**
  94438. * Minimum scale of emitting particles on Y axis.
  94439. */
  94440. minScaleY: number;
  94441. /**
  94442. * Maximum scale of emitting particles on Y axis.
  94443. */
  94444. maxScaleY: number;
  94445. /**
  94446. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94447. */
  94448. color1: Color4;
  94449. /**
  94450. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94451. */
  94452. color2: Color4;
  94453. /**
  94454. * Color the particle will have at the end of its lifetime.
  94455. */
  94456. colorDead: Color4;
  94457. /**
  94458. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  94459. */
  94460. emitRate: number;
  94461. /**
  94462. * You can use gravity if you want to give an orientation to your particles.
  94463. */
  94464. gravity: Vector3;
  94465. /**
  94466. * Minimum power of emitting particles.
  94467. */
  94468. minEmitPower: number;
  94469. /**
  94470. * Maximum power of emitting particles.
  94471. */
  94472. maxEmitPower: number;
  94473. /**
  94474. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  94475. */
  94476. minAngularSpeed: number;
  94477. /**
  94478. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  94479. */
  94480. maxAngularSpeed: number;
  94481. /**
  94482. * Gets or sets the minimal initial rotation in radians.
  94483. */
  94484. minInitialRotation: number;
  94485. /**
  94486. * Gets or sets the maximal initial rotation in radians.
  94487. */
  94488. maxInitialRotation: number;
  94489. /**
  94490. * The particle emitter type defines the emitter used by the particle system.
  94491. * It can be for example box, sphere, or cone...
  94492. */
  94493. particleEmitterType: Nullable<IParticleEmitterType>;
  94494. /**
  94495. * Defines the delay in milliseconds before starting the system (0 by default)
  94496. */
  94497. startDelay: number;
  94498. /**
  94499. * 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
  94500. */
  94501. preWarmCycles: number;
  94502. /**
  94503. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  94504. */
  94505. preWarmStepOffset: number;
  94506. /**
  94507. * 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)
  94508. */
  94509. spriteCellChangeSpeed: number;
  94510. /**
  94511. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  94512. */
  94513. startSpriteCellID: number;
  94514. /**
  94515. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  94516. */
  94517. endSpriteCellID: number;
  94518. /**
  94519. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  94520. */
  94521. spriteCellWidth: number;
  94522. /**
  94523. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  94524. */
  94525. spriteCellHeight: number;
  94526. /**
  94527. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  94528. */
  94529. spriteRandomStartCell: boolean;
  94530. /**
  94531. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  94532. */
  94533. isAnimationSheetEnabled: boolean;
  94534. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  94535. translationPivot: Vector2;
  94536. /**
  94537. * Gets or sets a texture used to add random noise to particle positions
  94538. */
  94539. noiseTexture: Nullable<BaseTexture>;
  94540. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  94541. noiseStrength: Vector3;
  94542. /**
  94543. * Gets or sets the billboard mode to use when isBillboardBased = true.
  94544. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  94545. */
  94546. billboardMode: number;
  94547. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  94548. limitVelocityDamping: number;
  94549. /**
  94550. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  94551. */
  94552. beginAnimationOnStart: boolean;
  94553. /**
  94554. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  94555. */
  94556. beginAnimationFrom: number;
  94557. /**
  94558. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  94559. */
  94560. beginAnimationTo: number;
  94561. /**
  94562. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  94563. */
  94564. beginAnimationLoop: boolean;
  94565. /**
  94566. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  94567. */
  94568. disposeOnStop: boolean;
  94569. /**
  94570. * Specifies if the particles are updated in emitter local space or world space
  94571. */
  94572. isLocal: boolean;
  94573. /** Snippet ID if the particle system was created from the snippet server */
  94574. snippetId: string;
  94575. /** Gets or sets a matrix to use to compute projection */
  94576. defaultProjectionMatrix: Matrix;
  94577. /**
  94578. * Gets the maximum number of particles active at the same time.
  94579. * @returns The max number of active particles.
  94580. */
  94581. getCapacity(): number;
  94582. /**
  94583. * Gets the number of particles active at the same time.
  94584. * @returns The number of active particles.
  94585. */
  94586. getActiveCount(): number;
  94587. /**
  94588. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94589. * @returns True if it has been started, otherwise false.
  94590. */
  94591. isStarted(): boolean;
  94592. /**
  94593. * Animates the particle system for this frame.
  94594. */
  94595. animate(): void;
  94596. /**
  94597. * Renders the particle system in its current state.
  94598. * @returns the current number of particles
  94599. */
  94600. render(): number;
  94601. /**
  94602. * Dispose the particle system and frees its associated resources.
  94603. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94604. */
  94605. dispose(disposeTexture?: boolean): void;
  94606. /**
  94607. * An event triggered when the system is disposed
  94608. */
  94609. onDisposeObservable: Observable<IParticleSystem>;
  94610. /**
  94611. * Clones the particle system.
  94612. * @param name The name of the cloned object
  94613. * @param newEmitter The new emitter to use
  94614. * @returns the cloned particle system
  94615. */
  94616. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  94617. /**
  94618. * Serializes the particle system to a JSON object
  94619. * @param serializeTexture defines if the texture must be serialized as well
  94620. * @returns the JSON object
  94621. */
  94622. serialize(serializeTexture: boolean): any;
  94623. /**
  94624. * Rebuild the particle system
  94625. */
  94626. rebuild(): void;
  94627. /** Force the system to rebuild all gradients that need to be resync */
  94628. forceRefreshGradients(): void;
  94629. /**
  94630. * Starts the particle system and begins to emit
  94631. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  94632. */
  94633. start(delay?: number): void;
  94634. /**
  94635. * Stops the particle system.
  94636. */
  94637. stop(): void;
  94638. /**
  94639. * Remove all active particles
  94640. */
  94641. reset(): void;
  94642. /**
  94643. * Gets a boolean indicating that the system is stopping
  94644. * @returns true if the system is currently stopping
  94645. */
  94646. isStopping(): boolean;
  94647. /**
  94648. * Is this system ready to be used/rendered
  94649. * @return true if the system is ready
  94650. */
  94651. isReady(): boolean;
  94652. /**
  94653. * Returns the string "ParticleSystem"
  94654. * @returns a string containing the class name
  94655. */
  94656. getClassName(): string;
  94657. /**
  94658. * Gets the custom effect used to render the particles
  94659. * @param blendMode Blend mode for which the effect should be retrieved
  94660. * @returns The effect
  94661. */
  94662. getCustomEffect(blendMode: number): Nullable<Effect>;
  94663. /**
  94664. * Sets the custom effect used to render the particles
  94665. * @param effect The effect to set
  94666. * @param blendMode Blend mode for which the effect should be set
  94667. */
  94668. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  94669. /**
  94670. * Fill the defines array according to the current settings of the particle system
  94671. * @param defines Array to be updated
  94672. * @param blendMode blend mode to take into account when updating the array
  94673. */
  94674. fillDefines(defines: Array<string>, blendMode: number): void;
  94675. /**
  94676. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  94677. * @param uniforms Uniforms array to fill
  94678. * @param attributes Attributes array to fill
  94679. * @param samplers Samplers array to fill
  94680. */
  94681. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  94682. /**
  94683. * Observable that will be called just before the particles are drawn
  94684. */
  94685. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  94686. /**
  94687. * Gets the name of the particle vertex shader
  94688. */
  94689. vertexShaderName: string;
  94690. /**
  94691. * Adds a new color gradient
  94692. * @param gradient defines the gradient to use (between 0 and 1)
  94693. * @param color1 defines the color to affect to the specified gradient
  94694. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  94695. * @returns the current particle system
  94696. */
  94697. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  94698. /**
  94699. * Remove a specific color gradient
  94700. * @param gradient defines the gradient to remove
  94701. * @returns the current particle system
  94702. */
  94703. removeColorGradient(gradient: number): IParticleSystem;
  94704. /**
  94705. * Adds a new size gradient
  94706. * @param gradient defines the gradient to use (between 0 and 1)
  94707. * @param factor defines the size factor to affect to the specified gradient
  94708. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94709. * @returns the current particle system
  94710. */
  94711. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94712. /**
  94713. * Remove a specific size gradient
  94714. * @param gradient defines the gradient to remove
  94715. * @returns the current particle system
  94716. */
  94717. removeSizeGradient(gradient: number): IParticleSystem;
  94718. /**
  94719. * Gets the current list of color gradients.
  94720. * You must use addColorGradient and removeColorGradient to udpate this list
  94721. * @returns the list of color gradients
  94722. */
  94723. getColorGradients(): Nullable<Array<ColorGradient>>;
  94724. /**
  94725. * Gets the current list of size gradients.
  94726. * You must use addSizeGradient and removeSizeGradient to udpate this list
  94727. * @returns the list of size gradients
  94728. */
  94729. getSizeGradients(): Nullable<Array<FactorGradient>>;
  94730. /**
  94731. * Gets the current list of angular speed gradients.
  94732. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  94733. * @returns the list of angular speed gradients
  94734. */
  94735. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  94736. /**
  94737. * Adds a new angular speed gradient
  94738. * @param gradient defines the gradient to use (between 0 and 1)
  94739. * @param factor defines the angular speed to affect to the specified gradient
  94740. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94741. * @returns the current particle system
  94742. */
  94743. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94744. /**
  94745. * Remove a specific angular speed gradient
  94746. * @param gradient defines the gradient to remove
  94747. * @returns the current particle system
  94748. */
  94749. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  94750. /**
  94751. * Gets the current list of velocity gradients.
  94752. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  94753. * @returns the list of velocity gradients
  94754. */
  94755. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  94756. /**
  94757. * Adds a new velocity gradient
  94758. * @param gradient defines the gradient to use (between 0 and 1)
  94759. * @param factor defines the velocity to affect to the specified gradient
  94760. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94761. * @returns the current particle system
  94762. */
  94763. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94764. /**
  94765. * Remove a specific velocity gradient
  94766. * @param gradient defines the gradient to remove
  94767. * @returns the current particle system
  94768. */
  94769. removeVelocityGradient(gradient: number): IParticleSystem;
  94770. /**
  94771. * Gets the current list of limit velocity gradients.
  94772. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  94773. * @returns the list of limit velocity gradients
  94774. */
  94775. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  94776. /**
  94777. * Adds a new limit velocity gradient
  94778. * @param gradient defines the gradient to use (between 0 and 1)
  94779. * @param factor defines the limit velocity to affect to the specified gradient
  94780. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94781. * @returns the current particle system
  94782. */
  94783. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94784. /**
  94785. * Remove a specific limit velocity gradient
  94786. * @param gradient defines the gradient to remove
  94787. * @returns the current particle system
  94788. */
  94789. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94790. /**
  94791. * Adds a new drag gradient
  94792. * @param gradient defines the gradient to use (between 0 and 1)
  94793. * @param factor defines the drag to affect to the specified gradient
  94794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94795. * @returns the current particle system
  94796. */
  94797. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94798. /**
  94799. * Remove a specific drag gradient
  94800. * @param gradient defines the gradient to remove
  94801. * @returns the current particle system
  94802. */
  94803. removeDragGradient(gradient: number): IParticleSystem;
  94804. /**
  94805. * Gets the current list of drag gradients.
  94806. * You must use addDragGradient and removeDragGradient to udpate this list
  94807. * @returns the list of drag gradients
  94808. */
  94809. getDragGradients(): Nullable<Array<FactorGradient>>;
  94810. /**
  94811. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  94812. * @param gradient defines the gradient to use (between 0 and 1)
  94813. * @param factor defines the emit rate to affect to the specified gradient
  94814. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94815. * @returns the current particle system
  94816. */
  94817. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94818. /**
  94819. * Remove a specific emit rate gradient
  94820. * @param gradient defines the gradient to remove
  94821. * @returns the current particle system
  94822. */
  94823. removeEmitRateGradient(gradient: number): IParticleSystem;
  94824. /**
  94825. * Gets the current list of emit rate gradients.
  94826. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  94827. * @returns the list of emit rate gradients
  94828. */
  94829. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  94830. /**
  94831. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  94832. * @param gradient defines the gradient to use (between 0 and 1)
  94833. * @param factor defines the start size to affect to the specified gradient
  94834. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94835. * @returns the current particle system
  94836. */
  94837. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94838. /**
  94839. * Remove a specific start size gradient
  94840. * @param gradient defines the gradient to remove
  94841. * @returns the current particle system
  94842. */
  94843. removeStartSizeGradient(gradient: number): IParticleSystem;
  94844. /**
  94845. * Gets the current list of start size gradients.
  94846. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  94847. * @returns the list of start size gradients
  94848. */
  94849. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  94850. /**
  94851. * Adds a new life time gradient
  94852. * @param gradient defines the gradient to use (between 0 and 1)
  94853. * @param factor defines the life time factor to affect to the specified gradient
  94854. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94855. * @returns the current particle system
  94856. */
  94857. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94858. /**
  94859. * Remove a specific life time gradient
  94860. * @param gradient defines the gradient to remove
  94861. * @returns the current particle system
  94862. */
  94863. removeLifeTimeGradient(gradient: number): IParticleSystem;
  94864. /**
  94865. * Gets the current list of life time gradients.
  94866. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  94867. * @returns the list of life time gradients
  94868. */
  94869. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  94870. /**
  94871. * Gets the current list of color gradients.
  94872. * You must use addColorGradient and removeColorGradient to udpate this list
  94873. * @returns the list of color gradients
  94874. */
  94875. getColorGradients(): Nullable<Array<ColorGradient>>;
  94876. /**
  94877. * Adds a new ramp gradient used to remap particle colors
  94878. * @param gradient defines the gradient to use (between 0 and 1)
  94879. * @param color defines the color to affect to the specified gradient
  94880. * @returns the current particle system
  94881. */
  94882. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  94883. /**
  94884. * Gets the current list of ramp gradients.
  94885. * You must use addRampGradient and removeRampGradient to udpate this list
  94886. * @returns the list of ramp gradients
  94887. */
  94888. getRampGradients(): Nullable<Array<Color3Gradient>>;
  94889. /** Gets or sets a boolean indicating that ramp gradients must be used
  94890. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  94891. */
  94892. useRampGradients: boolean;
  94893. /**
  94894. * Adds a new color remap gradient
  94895. * @param gradient defines the gradient to use (between 0 and 1)
  94896. * @param min defines the color remap minimal range
  94897. * @param max defines the color remap maximal range
  94898. * @returns the current particle system
  94899. */
  94900. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94901. /**
  94902. * Gets the current list of color remap gradients.
  94903. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  94904. * @returns the list of color remap gradients
  94905. */
  94906. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  94907. /**
  94908. * Adds a new alpha remap gradient
  94909. * @param gradient defines the gradient to use (between 0 and 1)
  94910. * @param min defines the alpha remap minimal range
  94911. * @param max defines the alpha remap maximal range
  94912. * @returns the current particle system
  94913. */
  94914. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94915. /**
  94916. * Gets the current list of alpha remap gradients.
  94917. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  94918. * @returns the list of alpha remap gradients
  94919. */
  94920. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  94921. /**
  94922. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  94923. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94924. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94925. * @returns the emitter
  94926. */
  94927. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  94928. /**
  94929. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  94930. * @param radius The radius of the hemisphere to emit from
  94931. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94932. * @returns the emitter
  94933. */
  94934. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  94935. /**
  94936. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  94937. * @param radius The radius of the sphere to emit from
  94938. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94939. * @returns the emitter
  94940. */
  94941. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  94942. /**
  94943. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  94944. * @param radius The radius of the sphere to emit from
  94945. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  94946. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  94947. * @returns the emitter
  94948. */
  94949. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94950. /**
  94951. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  94952. * @param radius The radius of the emission cylinder
  94953. * @param height The height of the emission cylinder
  94954. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  94955. * @param directionRandomizer How much to randomize the particle direction [0-1]
  94956. * @returns the emitter
  94957. */
  94958. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  94959. /**
  94960. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  94961. * @param radius The radius of the cylinder to emit from
  94962. * @param height The height of the emission cylinder
  94963. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94964. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  94965. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  94966. * @returns the emitter
  94967. */
  94968. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94969. /**
  94970. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  94971. * @param radius The radius of the cone to emit from
  94972. * @param angle The base angle of the cone
  94973. * @returns the emitter
  94974. */
  94975. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  94976. /**
  94977. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  94978. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94979. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94980. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94981. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94982. * @returns the emitter
  94983. */
  94984. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  94985. /**
  94986. * Get hosting scene
  94987. * @returns the scene
  94988. */
  94989. getScene(): Nullable<Scene>;
  94990. }
  94991. }
  94992. declare module BABYLON {
  94993. /**
  94994. * 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.
  94995. * @see https://doc.babylonjs.com/how_to/transformnode
  94996. */
  94997. export class TransformNode extends Node {
  94998. /**
  94999. * Object will not rotate to face the camera
  95000. */
  95001. static BILLBOARDMODE_NONE: number;
  95002. /**
  95003. * Object will rotate to face the camera but only on the x axis
  95004. */
  95005. static BILLBOARDMODE_X: number;
  95006. /**
  95007. * Object will rotate to face the camera but only on the y axis
  95008. */
  95009. static BILLBOARDMODE_Y: number;
  95010. /**
  95011. * Object will rotate to face the camera but only on the z axis
  95012. */
  95013. static BILLBOARDMODE_Z: number;
  95014. /**
  95015. * Object will rotate to face the camera
  95016. */
  95017. static BILLBOARDMODE_ALL: number;
  95018. /**
  95019. * Object will rotate to face the camera's position instead of orientation
  95020. */
  95021. static BILLBOARDMODE_USE_POSITION: number;
  95022. private static _TmpRotation;
  95023. private static _TmpScaling;
  95024. private static _TmpTranslation;
  95025. private _forward;
  95026. private _forwardInverted;
  95027. private _up;
  95028. private _right;
  95029. private _rightInverted;
  95030. private _position;
  95031. private _rotation;
  95032. private _rotationQuaternion;
  95033. protected _scaling: Vector3;
  95034. protected _isDirty: boolean;
  95035. private _transformToBoneReferal;
  95036. private _isAbsoluteSynced;
  95037. private _billboardMode;
  95038. /**
  95039. * Gets or sets the billboard mode. Default is 0.
  95040. *
  95041. * | Value | Type | Description |
  95042. * | --- | --- | --- |
  95043. * | 0 | BILLBOARDMODE_NONE | |
  95044. * | 1 | BILLBOARDMODE_X | |
  95045. * | 2 | BILLBOARDMODE_Y | |
  95046. * | 4 | BILLBOARDMODE_Z | |
  95047. * | 7 | BILLBOARDMODE_ALL | |
  95048. *
  95049. */
  95050. get billboardMode(): number;
  95051. set billboardMode(value: number);
  95052. private _preserveParentRotationForBillboard;
  95053. /**
  95054. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  95055. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  95056. */
  95057. get preserveParentRotationForBillboard(): boolean;
  95058. set preserveParentRotationForBillboard(value: boolean);
  95059. /**
  95060. * 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
  95061. */
  95062. scalingDeterminant: number;
  95063. private _infiniteDistance;
  95064. /**
  95065. * Gets or sets the distance of the object to max, often used by skybox
  95066. */
  95067. get infiniteDistance(): boolean;
  95068. set infiniteDistance(value: boolean);
  95069. /**
  95070. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  95071. * By default the system will update normals to compensate
  95072. */
  95073. ignoreNonUniformScaling: boolean;
  95074. /**
  95075. * 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
  95076. */
  95077. reIntegrateRotationIntoRotationQuaternion: boolean;
  95078. /** @hidden */
  95079. _poseMatrix: Nullable<Matrix>;
  95080. /** @hidden */
  95081. _localMatrix: Matrix;
  95082. private _usePivotMatrix;
  95083. private _absolutePosition;
  95084. private _absoluteScaling;
  95085. private _absoluteRotationQuaternion;
  95086. private _pivotMatrix;
  95087. private _pivotMatrixInverse;
  95088. /** @hidden */
  95089. _postMultiplyPivotMatrix: boolean;
  95090. protected _isWorldMatrixFrozen: boolean;
  95091. /** @hidden */
  95092. _indexInSceneTransformNodesArray: number;
  95093. /**
  95094. * An event triggered after the world matrix is updated
  95095. */
  95096. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95097. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95098. /**
  95099. * Gets a string identifying the name of the class
  95100. * @returns "TransformNode" string
  95101. */
  95102. getClassName(): string;
  95103. /**
  95104. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95105. */
  95106. get position(): Vector3;
  95107. set position(newPosition: Vector3);
  95108. /**
  95109. * 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)).
  95110. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95111. */
  95112. get rotation(): Vector3;
  95113. set rotation(newRotation: Vector3);
  95114. /**
  95115. * 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)).
  95116. */
  95117. get scaling(): Vector3;
  95118. set scaling(newScaling: Vector3);
  95119. /**
  95120. * 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).
  95121. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  95122. */
  95123. get rotationQuaternion(): Nullable<Quaternion>;
  95124. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  95125. /**
  95126. * The forward direction of that transform in world space.
  95127. */
  95128. get forward(): Vector3;
  95129. /**
  95130. * The up direction of that transform in world space.
  95131. */
  95132. get up(): Vector3;
  95133. /**
  95134. * The right direction of that transform in world space.
  95135. */
  95136. get right(): Vector3;
  95137. /**
  95138. * Copies the parameter passed Matrix into the mesh Pose matrix.
  95139. * @param matrix the matrix to copy the pose from
  95140. * @returns this TransformNode.
  95141. */
  95142. updatePoseMatrix(matrix: Matrix): TransformNode;
  95143. /**
  95144. * Returns the mesh Pose matrix.
  95145. * @returns the pose matrix
  95146. */
  95147. getPoseMatrix(): Matrix;
  95148. /** @hidden */
  95149. _isSynchronized(): boolean;
  95150. /** @hidden */
  95151. _initCache(): void;
  95152. /**
  95153. * Flag the transform node as dirty (Forcing it to update everything)
  95154. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  95155. * @returns this transform node
  95156. */
  95157. markAsDirty(property: string): TransformNode;
  95158. /**
  95159. * Returns the current mesh absolute position.
  95160. * Returns a Vector3.
  95161. */
  95162. get absolutePosition(): Vector3;
  95163. /**
  95164. * Returns the current mesh absolute scaling.
  95165. * Returns a Vector3.
  95166. */
  95167. get absoluteScaling(): Vector3;
  95168. /**
  95169. * Returns the current mesh absolute rotation.
  95170. * Returns a Quaternion.
  95171. */
  95172. get absoluteRotationQuaternion(): Quaternion;
  95173. /**
  95174. * Sets a new matrix to apply before all other transformation
  95175. * @param matrix defines the transform matrix
  95176. * @returns the current TransformNode
  95177. */
  95178. setPreTransformMatrix(matrix: Matrix): TransformNode;
  95179. /**
  95180. * Sets a new pivot matrix to the current node
  95181. * @param matrix defines the new pivot matrix to use
  95182. * @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
  95183. * @returns the current TransformNode
  95184. */
  95185. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  95186. /**
  95187. * Returns the mesh pivot matrix.
  95188. * Default : Identity.
  95189. * @returns the matrix
  95190. */
  95191. getPivotMatrix(): Matrix;
  95192. /**
  95193. * Instantiate (when possible) or clone that node with its hierarchy
  95194. * @param newParent defines the new parent to use for the instance (or clone)
  95195. * @param options defines options to configure how copy is done
  95196. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  95197. * @returns an instance (or a clone) of the current node with its hiearchy
  95198. */
  95199. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95200. doNotInstantiate: boolean;
  95201. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95202. /**
  95203. * Prevents the World matrix to be computed any longer
  95204. * @param newWorldMatrix defines an optional matrix to use as world matrix
  95205. * @returns the TransformNode.
  95206. */
  95207. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  95208. /**
  95209. * Allows back the World matrix computation.
  95210. * @returns the TransformNode.
  95211. */
  95212. unfreezeWorldMatrix(): this;
  95213. /**
  95214. * True if the World matrix has been frozen.
  95215. */
  95216. get isWorldMatrixFrozen(): boolean;
  95217. /**
  95218. * Retuns the mesh absolute position in the World.
  95219. * @returns a Vector3.
  95220. */
  95221. getAbsolutePosition(): Vector3;
  95222. /**
  95223. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  95224. * @param absolutePosition the absolute position to set
  95225. * @returns the TransformNode.
  95226. */
  95227. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  95228. /**
  95229. * Sets the mesh position in its local space.
  95230. * @param vector3 the position to set in localspace
  95231. * @returns the TransformNode.
  95232. */
  95233. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  95234. /**
  95235. * Returns the mesh position in the local space from the current World matrix values.
  95236. * @returns a new Vector3.
  95237. */
  95238. getPositionExpressedInLocalSpace(): Vector3;
  95239. /**
  95240. * Translates the mesh along the passed Vector3 in its local space.
  95241. * @param vector3 the distance to translate in localspace
  95242. * @returns the TransformNode.
  95243. */
  95244. locallyTranslate(vector3: Vector3): TransformNode;
  95245. private static _lookAtVectorCache;
  95246. /**
  95247. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  95248. * @param targetPoint the position (must be in same space as current mesh) to look at
  95249. * @param yawCor optional yaw (y-axis) correction in radians
  95250. * @param pitchCor optional pitch (x-axis) correction in radians
  95251. * @param rollCor optional roll (z-axis) correction in radians
  95252. * @param space the choosen space of the target
  95253. * @returns the TransformNode.
  95254. */
  95255. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  95256. /**
  95257. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95258. * This Vector3 is expressed in the World space.
  95259. * @param localAxis axis to rotate
  95260. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95261. */
  95262. getDirection(localAxis: Vector3): Vector3;
  95263. /**
  95264. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  95265. * localAxis is expressed in the mesh local space.
  95266. * result is computed in the Wordl space from the mesh World matrix.
  95267. * @param localAxis axis to rotate
  95268. * @param result the resulting transformnode
  95269. * @returns this TransformNode.
  95270. */
  95271. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  95272. /**
  95273. * Sets this transform node rotation to the given local axis.
  95274. * @param localAxis the axis in local space
  95275. * @param yawCor optional yaw (y-axis) correction in radians
  95276. * @param pitchCor optional pitch (x-axis) correction in radians
  95277. * @param rollCor optional roll (z-axis) correction in radians
  95278. * @returns this TransformNode
  95279. */
  95280. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  95281. /**
  95282. * Sets a new pivot point to the current node
  95283. * @param point defines the new pivot point to use
  95284. * @param space defines if the point is in world or local space (local by default)
  95285. * @returns the current TransformNode
  95286. */
  95287. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  95288. /**
  95289. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  95290. * @returns the pivot point
  95291. */
  95292. getPivotPoint(): Vector3;
  95293. /**
  95294. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  95295. * @param result the vector3 to store the result
  95296. * @returns this TransformNode.
  95297. */
  95298. getPivotPointToRef(result: Vector3): TransformNode;
  95299. /**
  95300. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  95301. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  95302. */
  95303. getAbsolutePivotPoint(): Vector3;
  95304. /**
  95305. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  95306. * @param result vector3 to store the result
  95307. * @returns this TransformNode.
  95308. */
  95309. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  95310. /**
  95311. * Defines the passed node as the parent of the current node.
  95312. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  95313. * @see https://doc.babylonjs.com/how_to/parenting
  95314. * @param node the node ot set as the parent
  95315. * @returns this TransformNode.
  95316. */
  95317. setParent(node: Nullable<Node>): TransformNode;
  95318. private _nonUniformScaling;
  95319. /**
  95320. * True if the scaling property of this object is non uniform eg. (1,2,1)
  95321. */
  95322. get nonUniformScaling(): boolean;
  95323. /** @hidden */
  95324. _updateNonUniformScalingState(value: boolean): boolean;
  95325. /**
  95326. * Attach the current TransformNode to another TransformNode associated with a bone
  95327. * @param bone Bone affecting the TransformNode
  95328. * @param affectedTransformNode TransformNode associated with the bone
  95329. * @returns this object
  95330. */
  95331. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  95332. /**
  95333. * Detach the transform node if its associated with a bone
  95334. * @returns this object
  95335. */
  95336. detachFromBone(): TransformNode;
  95337. private static _rotationAxisCache;
  95338. /**
  95339. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  95340. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95341. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95342. * The passed axis is also normalized.
  95343. * @param axis the axis to rotate around
  95344. * @param amount the amount to rotate in radians
  95345. * @param space Space to rotate in (Default: local)
  95346. * @returns the TransformNode.
  95347. */
  95348. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  95349. /**
  95350. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  95351. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95352. * The passed axis is also normalized. .
  95353. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  95354. * @param point the point to rotate around
  95355. * @param axis the axis to rotate around
  95356. * @param amount the amount to rotate in radians
  95357. * @returns the TransformNode
  95358. */
  95359. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  95360. /**
  95361. * Translates the mesh along the axis vector for the passed distance in the given space.
  95362. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95363. * @param axis the axis to translate in
  95364. * @param distance the distance to translate
  95365. * @param space Space to rotate in (Default: local)
  95366. * @returns the TransformNode.
  95367. */
  95368. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  95369. /**
  95370. * Adds a rotation step to the mesh current rotation.
  95371. * x, y, z are Euler angles expressed in radians.
  95372. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  95373. * This means this rotation is made in the mesh local space only.
  95374. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  95375. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  95376. * ```javascript
  95377. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  95378. * ```
  95379. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  95380. * 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.
  95381. * @param x Rotation to add
  95382. * @param y Rotation to add
  95383. * @param z Rotation to add
  95384. * @returns the TransformNode.
  95385. */
  95386. addRotation(x: number, y: number, z: number): TransformNode;
  95387. /**
  95388. * @hidden
  95389. */
  95390. protected _getEffectiveParent(): Nullable<Node>;
  95391. /**
  95392. * Computes the world matrix of the node
  95393. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95394. * @returns the world matrix
  95395. */
  95396. computeWorldMatrix(force?: boolean): Matrix;
  95397. /**
  95398. * Resets this nodeTransform's local matrix to Matrix.Identity().
  95399. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  95400. */
  95401. resetLocalMatrix(independentOfChildren?: boolean): void;
  95402. protected _afterComputeWorldMatrix(): void;
  95403. /**
  95404. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95405. * @param func callback function to add
  95406. *
  95407. * @returns the TransformNode.
  95408. */
  95409. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95410. /**
  95411. * Removes a registered callback function.
  95412. * @param func callback function to remove
  95413. * @returns the TransformNode.
  95414. */
  95415. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95416. /**
  95417. * Gets the position of the current mesh in camera space
  95418. * @param camera defines the camera to use
  95419. * @returns a position
  95420. */
  95421. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  95422. /**
  95423. * Returns the distance from the mesh to the active camera
  95424. * @param camera defines the camera to use
  95425. * @returns the distance
  95426. */
  95427. getDistanceToCamera(camera?: Nullable<Camera>): number;
  95428. /**
  95429. * Clone the current transform node
  95430. * @param name Name of the new clone
  95431. * @param newParent New parent for the clone
  95432. * @param doNotCloneChildren Do not clone children hierarchy
  95433. * @returns the new transform node
  95434. */
  95435. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  95436. /**
  95437. * Serializes the objects information.
  95438. * @param currentSerializationObject defines the object to serialize in
  95439. * @returns the serialized object
  95440. */
  95441. serialize(currentSerializationObject?: any): any;
  95442. /**
  95443. * Returns a new TransformNode object parsed from the source provided.
  95444. * @param parsedTransformNode is the source.
  95445. * @param scene the scne the object belongs to
  95446. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95447. * @returns a new TransformNode object parsed from the source provided.
  95448. */
  95449. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  95450. /**
  95451. * Get all child-transformNodes of this node
  95452. * @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
  95453. * @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
  95454. * @returns an array of TransformNode
  95455. */
  95456. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  95457. /**
  95458. * Releases resources associated with this transform node.
  95459. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95460. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95461. */
  95462. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95463. /**
  95464. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95465. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95466. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95467. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95468. * @returns the current mesh
  95469. */
  95470. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  95471. private _syncAbsoluteScalingAndRotation;
  95472. }
  95473. }
  95474. declare module BABYLON {
  95475. /**
  95476. * Class used to override all child animations of a given target
  95477. */
  95478. export class AnimationPropertiesOverride {
  95479. /**
  95480. * Gets or sets a value indicating if animation blending must be used
  95481. */
  95482. enableBlending: boolean;
  95483. /**
  95484. * Gets or sets the blending speed to use when enableBlending is true
  95485. */
  95486. blendingSpeed: number;
  95487. /**
  95488. * Gets or sets the default loop mode to use
  95489. */
  95490. loopMode: number;
  95491. }
  95492. }
  95493. declare module BABYLON {
  95494. /**
  95495. * Class used to store bone information
  95496. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95497. */
  95498. export class Bone extends Node {
  95499. /**
  95500. * defines the bone name
  95501. */
  95502. name: string;
  95503. private static _tmpVecs;
  95504. private static _tmpQuat;
  95505. private static _tmpMats;
  95506. /**
  95507. * Gets the list of child bones
  95508. */
  95509. children: Bone[];
  95510. /** Gets the animations associated with this bone */
  95511. animations: Animation[];
  95512. /**
  95513. * Gets or sets bone length
  95514. */
  95515. length: number;
  95516. /**
  95517. * @hidden Internal only
  95518. * Set this value to map this bone to a different index in the transform matrices
  95519. * Set this value to -1 to exclude the bone from the transform matrices
  95520. */
  95521. _index: Nullable<number>;
  95522. private _skeleton;
  95523. private _localMatrix;
  95524. private _restPose;
  95525. private _bindPose;
  95526. private _baseMatrix;
  95527. private _absoluteTransform;
  95528. private _invertedAbsoluteTransform;
  95529. private _parent;
  95530. private _scalingDeterminant;
  95531. private _worldTransform;
  95532. private _localScaling;
  95533. private _localRotation;
  95534. private _localPosition;
  95535. private _needToDecompose;
  95536. private _needToCompose;
  95537. /** @hidden */
  95538. _linkedTransformNode: Nullable<TransformNode>;
  95539. /** @hidden */
  95540. _waitingTransformNodeId: Nullable<string>;
  95541. /** @hidden */
  95542. get _matrix(): Matrix;
  95543. /** @hidden */
  95544. set _matrix(value: Matrix);
  95545. /**
  95546. * Create a new bone
  95547. * @param name defines the bone name
  95548. * @param skeleton defines the parent skeleton
  95549. * @param parentBone defines the parent (can be null if the bone is the root)
  95550. * @param localMatrix defines the local matrix
  95551. * @param restPose defines the rest pose matrix
  95552. * @param baseMatrix defines the base matrix
  95553. * @param index defines index of the bone in the hiearchy
  95554. */
  95555. constructor(
  95556. /**
  95557. * defines the bone name
  95558. */
  95559. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  95560. /**
  95561. * Gets the current object class name.
  95562. * @return the class name
  95563. */
  95564. getClassName(): string;
  95565. /**
  95566. * Gets the parent skeleton
  95567. * @returns a skeleton
  95568. */
  95569. getSkeleton(): Skeleton;
  95570. /**
  95571. * Gets parent bone
  95572. * @returns a bone or null if the bone is the root of the bone hierarchy
  95573. */
  95574. getParent(): Nullable<Bone>;
  95575. /**
  95576. * Returns an array containing the root bones
  95577. * @returns an array containing the root bones
  95578. */
  95579. getChildren(): Array<Bone>;
  95580. /**
  95581. * Gets the node index in matrix array generated for rendering
  95582. * @returns the node index
  95583. */
  95584. getIndex(): number;
  95585. /**
  95586. * Sets the parent bone
  95587. * @param parent defines the parent (can be null if the bone is the root)
  95588. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95589. */
  95590. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  95591. /**
  95592. * Gets the local matrix
  95593. * @returns a matrix
  95594. */
  95595. getLocalMatrix(): Matrix;
  95596. /**
  95597. * Gets the base matrix (initial matrix which remains unchanged)
  95598. * @returns a matrix
  95599. */
  95600. getBaseMatrix(): Matrix;
  95601. /**
  95602. * Gets the rest pose matrix
  95603. * @returns a matrix
  95604. */
  95605. getRestPose(): Matrix;
  95606. /**
  95607. * Sets the rest pose matrix
  95608. * @param matrix the local-space rest pose to set for this bone
  95609. */
  95610. setRestPose(matrix: Matrix): void;
  95611. /**
  95612. * Gets the bind pose matrix
  95613. * @returns the bind pose matrix
  95614. */
  95615. getBindPose(): Matrix;
  95616. /**
  95617. * Sets the bind pose matrix
  95618. * @param matrix the local-space bind pose to set for this bone
  95619. */
  95620. setBindPose(matrix: Matrix): void;
  95621. /**
  95622. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  95623. */
  95624. getWorldMatrix(): Matrix;
  95625. /**
  95626. * Sets the local matrix to rest pose matrix
  95627. */
  95628. returnToRest(): void;
  95629. /**
  95630. * Gets the inverse of the absolute transform matrix.
  95631. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  95632. * @returns a matrix
  95633. */
  95634. getInvertedAbsoluteTransform(): Matrix;
  95635. /**
  95636. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  95637. * @returns a matrix
  95638. */
  95639. getAbsoluteTransform(): Matrix;
  95640. /**
  95641. * Links with the given transform node.
  95642. * The local matrix of this bone is copied from the transform node every frame.
  95643. * @param transformNode defines the transform node to link to
  95644. */
  95645. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  95646. /**
  95647. * Gets the node used to drive the bone's transformation
  95648. * @returns a transform node or null
  95649. */
  95650. getTransformNode(): Nullable<TransformNode>;
  95651. /** Gets or sets current position (in local space) */
  95652. get position(): Vector3;
  95653. set position(newPosition: Vector3);
  95654. /** Gets or sets current rotation (in local space) */
  95655. get rotation(): Vector3;
  95656. set rotation(newRotation: Vector3);
  95657. /** Gets or sets current rotation quaternion (in local space) */
  95658. get rotationQuaternion(): Quaternion;
  95659. set rotationQuaternion(newRotation: Quaternion);
  95660. /** Gets or sets current scaling (in local space) */
  95661. get scaling(): Vector3;
  95662. set scaling(newScaling: Vector3);
  95663. /**
  95664. * Gets the animation properties override
  95665. */
  95666. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95667. private _decompose;
  95668. private _compose;
  95669. /**
  95670. * Update the base and local matrices
  95671. * @param matrix defines the new base or local matrix
  95672. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95673. * @param updateLocalMatrix defines if the local matrix should be updated
  95674. */
  95675. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  95676. /** @hidden */
  95677. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  95678. /**
  95679. * Flag the bone as dirty (Forcing it to update everything)
  95680. */
  95681. markAsDirty(): void;
  95682. /** @hidden */
  95683. _markAsDirtyAndCompose(): void;
  95684. private _markAsDirtyAndDecompose;
  95685. /**
  95686. * Translate the bone in local or world space
  95687. * @param vec The amount to translate the bone
  95688. * @param space The space that the translation is in
  95689. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95690. */
  95691. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95692. /**
  95693. * Set the postion of the bone in local or world space
  95694. * @param position The position to set the bone
  95695. * @param space The space that the position is in
  95696. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95697. */
  95698. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95699. /**
  95700. * Set the absolute position of the bone (world space)
  95701. * @param position The position to set the bone
  95702. * @param mesh The mesh that this bone is attached to
  95703. */
  95704. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  95705. /**
  95706. * Scale the bone on the x, y and z axes (in local space)
  95707. * @param x The amount to scale the bone on the x axis
  95708. * @param y The amount to scale the bone on the y axis
  95709. * @param z The amount to scale the bone on the z axis
  95710. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  95711. */
  95712. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  95713. /**
  95714. * Set the bone scaling in local space
  95715. * @param scale defines the scaling vector
  95716. */
  95717. setScale(scale: Vector3): void;
  95718. /**
  95719. * Gets the current scaling in local space
  95720. * @returns the current scaling vector
  95721. */
  95722. getScale(): Vector3;
  95723. /**
  95724. * Gets the current scaling in local space and stores it in a target vector
  95725. * @param result defines the target vector
  95726. */
  95727. getScaleToRef(result: Vector3): void;
  95728. /**
  95729. * Set the yaw, pitch, and roll of the bone in local or world space
  95730. * @param yaw The rotation of the bone on the y axis
  95731. * @param pitch The rotation of the bone on the x axis
  95732. * @param roll The rotation of the bone on the z axis
  95733. * @param space The space that the axes of rotation are in
  95734. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95735. */
  95736. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  95737. /**
  95738. * Add a rotation to the bone on an axis in local or world space
  95739. * @param axis The axis to rotate the bone on
  95740. * @param amount The amount to rotate the bone
  95741. * @param space The space that the axis is in
  95742. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95743. */
  95744. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  95745. /**
  95746. * Set the rotation of the bone to a particular axis angle in local or world space
  95747. * @param axis The axis to rotate the bone on
  95748. * @param angle The angle that the bone should be rotated to
  95749. * @param space The space that the axis is in
  95750. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95751. */
  95752. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  95753. /**
  95754. * Set the euler rotation of the bone in local or world space
  95755. * @param rotation The euler rotation that the bone should be set to
  95756. * @param space The space that the rotation is in
  95757. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95758. */
  95759. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95760. /**
  95761. * Set the quaternion rotation of the bone in local or world space
  95762. * @param quat The quaternion rotation that the bone should be set to
  95763. * @param space The space that the rotation is in
  95764. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95765. */
  95766. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  95767. /**
  95768. * Set the rotation matrix of the bone in local or world space
  95769. * @param rotMat The rotation matrix that the bone should be set to
  95770. * @param space The space that the rotation is in
  95771. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95772. */
  95773. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  95774. private _rotateWithMatrix;
  95775. private _getNegativeRotationToRef;
  95776. /**
  95777. * Get the position of the bone in local or world space
  95778. * @param space The space that the returned position is in
  95779. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95780. * @returns The position of the bone
  95781. */
  95782. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95783. /**
  95784. * Copy the position of the bone to a vector3 in local or world space
  95785. * @param space The space that the returned position is in
  95786. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95787. * @param result The vector3 to copy the position to
  95788. */
  95789. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  95790. /**
  95791. * Get the absolute position of the bone (world space)
  95792. * @param mesh The mesh that this bone is attached to
  95793. * @returns The absolute position of the bone
  95794. */
  95795. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  95796. /**
  95797. * Copy the absolute position of the bone (world space) to the result param
  95798. * @param mesh The mesh that this bone is attached to
  95799. * @param result The vector3 to copy the absolute position to
  95800. */
  95801. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  95802. /**
  95803. * Compute the absolute transforms of this bone and its children
  95804. */
  95805. computeAbsoluteTransforms(): void;
  95806. /**
  95807. * Get the world direction from an axis that is in the local space of the bone
  95808. * @param localAxis The local direction that is used to compute the world direction
  95809. * @param mesh The mesh that this bone is attached to
  95810. * @returns The world direction
  95811. */
  95812. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95813. /**
  95814. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  95815. * @param localAxis The local direction that is used to compute the world direction
  95816. * @param mesh The mesh that this bone is attached to
  95817. * @param result The vector3 that the world direction will be copied to
  95818. */
  95819. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95820. /**
  95821. * Get the euler rotation of the bone in local or world space
  95822. * @param space The space that the rotation should be in
  95823. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95824. * @returns The euler rotation
  95825. */
  95826. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95827. /**
  95828. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  95829. * @param space The space that the rotation should be in
  95830. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95831. * @param result The vector3 that the rotation should be copied to
  95832. */
  95833. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95834. /**
  95835. * Get the quaternion rotation of the bone in either local or world space
  95836. * @param space The space that the rotation should be in
  95837. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95838. * @returns The quaternion rotation
  95839. */
  95840. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  95841. /**
  95842. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  95843. * @param space The space that the rotation should be in
  95844. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95845. * @param result The quaternion that the rotation should be copied to
  95846. */
  95847. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  95848. /**
  95849. * Get the rotation matrix of the bone in local or world space
  95850. * @param space The space that the rotation should be in
  95851. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95852. * @returns The rotation matrix
  95853. */
  95854. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  95855. /**
  95856. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  95857. * @param space The space that the rotation should be in
  95858. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95859. * @param result The quaternion that the rotation should be copied to
  95860. */
  95861. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  95862. /**
  95863. * Get the world position of a point that is in the local space of the bone
  95864. * @param position The local position
  95865. * @param mesh The mesh that this bone is attached to
  95866. * @returns The world position
  95867. */
  95868. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95869. /**
  95870. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  95871. * @param position The local position
  95872. * @param mesh The mesh that this bone is attached to
  95873. * @param result The vector3 that the world position should be copied to
  95874. */
  95875. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95876. /**
  95877. * Get the local position of a point that is in world space
  95878. * @param position The world position
  95879. * @param mesh The mesh that this bone is attached to
  95880. * @returns The local position
  95881. */
  95882. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95883. /**
  95884. * Get the local position of a point that is in world space and copy it to the result param
  95885. * @param position The world position
  95886. * @param mesh The mesh that this bone is attached to
  95887. * @param result The vector3 that the local position should be copied to
  95888. */
  95889. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95890. /**
  95891. * Set the current local matrix as the restPose for this bone.
  95892. */
  95893. setCurrentPoseAsRest(): void;
  95894. }
  95895. }
  95896. declare module BABYLON {
  95897. /**
  95898. * Defines a runtime animation
  95899. */
  95900. export class RuntimeAnimation {
  95901. private _events;
  95902. /**
  95903. * The current frame of the runtime animation
  95904. */
  95905. private _currentFrame;
  95906. /**
  95907. * The animation used by the runtime animation
  95908. */
  95909. private _animation;
  95910. /**
  95911. * The target of the runtime animation
  95912. */
  95913. private _target;
  95914. /**
  95915. * The initiating animatable
  95916. */
  95917. private _host;
  95918. /**
  95919. * The original value of the runtime animation
  95920. */
  95921. private _originalValue;
  95922. /**
  95923. * The original blend value of the runtime animation
  95924. */
  95925. private _originalBlendValue;
  95926. /**
  95927. * The offsets cache of the runtime animation
  95928. */
  95929. private _offsetsCache;
  95930. /**
  95931. * The high limits cache of the runtime animation
  95932. */
  95933. private _highLimitsCache;
  95934. /**
  95935. * Specifies if the runtime animation has been stopped
  95936. */
  95937. private _stopped;
  95938. /**
  95939. * The blending factor of the runtime animation
  95940. */
  95941. private _blendingFactor;
  95942. /**
  95943. * The BabylonJS scene
  95944. */
  95945. private _scene;
  95946. /**
  95947. * The current value of the runtime animation
  95948. */
  95949. private _currentValue;
  95950. /** @hidden */
  95951. _animationState: _IAnimationState;
  95952. /**
  95953. * The active target of the runtime animation
  95954. */
  95955. private _activeTargets;
  95956. private _currentActiveTarget;
  95957. private _directTarget;
  95958. /**
  95959. * The target path of the runtime animation
  95960. */
  95961. private _targetPath;
  95962. /**
  95963. * The weight of the runtime animation
  95964. */
  95965. private _weight;
  95966. /**
  95967. * The ratio offset of the runtime animation
  95968. */
  95969. private _ratioOffset;
  95970. /**
  95971. * The previous delay of the runtime animation
  95972. */
  95973. private _previousDelay;
  95974. /**
  95975. * The previous ratio of the runtime animation
  95976. */
  95977. private _previousRatio;
  95978. private _enableBlending;
  95979. private _keys;
  95980. private _minFrame;
  95981. private _maxFrame;
  95982. private _minValue;
  95983. private _maxValue;
  95984. private _targetIsArray;
  95985. /**
  95986. * Gets the current frame of the runtime animation
  95987. */
  95988. get currentFrame(): number;
  95989. /**
  95990. * Gets the weight of the runtime animation
  95991. */
  95992. get weight(): number;
  95993. /**
  95994. * Gets the current value of the runtime animation
  95995. */
  95996. get currentValue(): any;
  95997. /**
  95998. * Gets the target path of the runtime animation
  95999. */
  96000. get targetPath(): string;
  96001. /**
  96002. * Gets the actual target of the runtime animation
  96003. */
  96004. get target(): any;
  96005. /**
  96006. * Gets the additive state of the runtime animation
  96007. */
  96008. get isAdditive(): boolean;
  96009. /** @hidden */
  96010. _onLoop: () => void;
  96011. /**
  96012. * Create a new RuntimeAnimation object
  96013. * @param target defines the target of the animation
  96014. * @param animation defines the source animation object
  96015. * @param scene defines the hosting scene
  96016. * @param host defines the initiating Animatable
  96017. */
  96018. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  96019. private _preparePath;
  96020. /**
  96021. * Gets the animation from the runtime animation
  96022. */
  96023. get animation(): Animation;
  96024. /**
  96025. * Resets the runtime animation to the beginning
  96026. * @param restoreOriginal defines whether to restore the target property to the original value
  96027. */
  96028. reset(restoreOriginal?: boolean): void;
  96029. /**
  96030. * Specifies if the runtime animation is stopped
  96031. * @returns Boolean specifying if the runtime animation is stopped
  96032. */
  96033. isStopped(): boolean;
  96034. /**
  96035. * Disposes of the runtime animation
  96036. */
  96037. dispose(): void;
  96038. /**
  96039. * Apply the interpolated value to the target
  96040. * @param currentValue defines the value computed by the animation
  96041. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  96042. */
  96043. setValue(currentValue: any, weight: number): void;
  96044. private _getOriginalValues;
  96045. private _setValue;
  96046. /**
  96047. * Gets the loop pmode of the runtime animation
  96048. * @returns Loop Mode
  96049. */
  96050. private _getCorrectLoopMode;
  96051. /**
  96052. * Move the current animation to a given frame
  96053. * @param frame defines the frame to move to
  96054. */
  96055. goToFrame(frame: number): void;
  96056. /**
  96057. * @hidden Internal use only
  96058. */
  96059. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  96060. /**
  96061. * Execute the current animation
  96062. * @param delay defines the delay to add to the current frame
  96063. * @param from defines the lower bound of the animation range
  96064. * @param to defines the upper bound of the animation range
  96065. * @param loop defines if the current animation must loop
  96066. * @param speedRatio defines the current speed ratio
  96067. * @param weight defines the weight of the animation (default is -1 so no weight)
  96068. * @param onLoop optional callback called when animation loops
  96069. * @returns a boolean indicating if the animation is running
  96070. */
  96071. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  96072. }
  96073. }
  96074. declare module BABYLON {
  96075. /**
  96076. * Class used to store an actual running animation
  96077. */
  96078. export class Animatable {
  96079. /** defines the target object */
  96080. target: any;
  96081. /** defines the starting frame number (default is 0) */
  96082. fromFrame: number;
  96083. /** defines the ending frame number (default is 100) */
  96084. toFrame: number;
  96085. /** defines if the animation must loop (default is false) */
  96086. loopAnimation: boolean;
  96087. /** defines a callback to call when animation ends if it is not looping */
  96088. onAnimationEnd?: (() => void) | null | undefined;
  96089. /** defines a callback to call when animation loops */
  96090. onAnimationLoop?: (() => void) | null | undefined;
  96091. /** defines whether the animation should be evaluated additively */
  96092. isAdditive: boolean;
  96093. private _localDelayOffset;
  96094. private _pausedDelay;
  96095. private _runtimeAnimations;
  96096. private _paused;
  96097. private _scene;
  96098. private _speedRatio;
  96099. private _weight;
  96100. private _syncRoot;
  96101. /**
  96102. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96103. * This will only apply for non looping animation (default is true)
  96104. */
  96105. disposeOnEnd: boolean;
  96106. /**
  96107. * Gets a boolean indicating if the animation has started
  96108. */
  96109. animationStarted: boolean;
  96110. /**
  96111. * Observer raised when the animation ends
  96112. */
  96113. onAnimationEndObservable: Observable<Animatable>;
  96114. /**
  96115. * Observer raised when the animation loops
  96116. */
  96117. onAnimationLoopObservable: Observable<Animatable>;
  96118. /**
  96119. * Gets the root Animatable used to synchronize and normalize animations
  96120. */
  96121. get syncRoot(): Nullable<Animatable>;
  96122. /**
  96123. * Gets the current frame of the first RuntimeAnimation
  96124. * Used to synchronize Animatables
  96125. */
  96126. get masterFrame(): number;
  96127. /**
  96128. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  96129. */
  96130. get weight(): number;
  96131. set weight(value: number);
  96132. /**
  96133. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  96134. */
  96135. get speedRatio(): number;
  96136. set speedRatio(value: number);
  96137. /**
  96138. * Creates a new Animatable
  96139. * @param scene defines the hosting scene
  96140. * @param target defines the target object
  96141. * @param fromFrame defines the starting frame number (default is 0)
  96142. * @param toFrame defines the ending frame number (default is 100)
  96143. * @param loopAnimation defines if the animation must loop (default is false)
  96144. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  96145. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  96146. * @param animations defines a group of animation to add to the new Animatable
  96147. * @param onAnimationLoop defines a callback to call when animation loops
  96148. * @param isAdditive defines whether the animation should be evaluated additively
  96149. */
  96150. constructor(scene: Scene,
  96151. /** defines the target object */
  96152. target: any,
  96153. /** defines the starting frame number (default is 0) */
  96154. fromFrame?: number,
  96155. /** defines the ending frame number (default is 100) */
  96156. toFrame?: number,
  96157. /** defines if the animation must loop (default is false) */
  96158. loopAnimation?: boolean, speedRatio?: number,
  96159. /** defines a callback to call when animation ends if it is not looping */
  96160. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  96161. /** defines a callback to call when animation loops */
  96162. onAnimationLoop?: (() => void) | null | undefined,
  96163. /** defines whether the animation should be evaluated additively */
  96164. isAdditive?: boolean);
  96165. /**
  96166. * Synchronize and normalize current Animatable with a source Animatable
  96167. * This is useful when using animation weights and when animations are not of the same length
  96168. * @param root defines the root Animatable to synchronize with
  96169. * @returns the current Animatable
  96170. */
  96171. syncWith(root: Animatable): Animatable;
  96172. /**
  96173. * Gets the list of runtime animations
  96174. * @returns an array of RuntimeAnimation
  96175. */
  96176. getAnimations(): RuntimeAnimation[];
  96177. /**
  96178. * Adds more animations to the current animatable
  96179. * @param target defines the target of the animations
  96180. * @param animations defines the new animations to add
  96181. */
  96182. appendAnimations(target: any, animations: Animation[]): void;
  96183. /**
  96184. * Gets the source animation for a specific property
  96185. * @param property defines the propertyu to look for
  96186. * @returns null or the source animation for the given property
  96187. */
  96188. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  96189. /**
  96190. * Gets the runtime animation for a specific property
  96191. * @param property defines the propertyu to look for
  96192. * @returns null or the runtime animation for the given property
  96193. */
  96194. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  96195. /**
  96196. * Resets the animatable to its original state
  96197. */
  96198. reset(): void;
  96199. /**
  96200. * Allows the animatable to blend with current running animations
  96201. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96202. * @param blendingSpeed defines the blending speed to use
  96203. */
  96204. enableBlending(blendingSpeed: number): void;
  96205. /**
  96206. * Disable animation blending
  96207. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96208. */
  96209. disableBlending(): void;
  96210. /**
  96211. * Jump directly to a given frame
  96212. * @param frame defines the frame to jump to
  96213. */
  96214. goToFrame(frame: number): void;
  96215. /**
  96216. * Pause the animation
  96217. */
  96218. pause(): void;
  96219. /**
  96220. * Restart the animation
  96221. */
  96222. restart(): void;
  96223. private _raiseOnAnimationEnd;
  96224. /**
  96225. * Stop and delete the current animation
  96226. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  96227. * @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)
  96228. */
  96229. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  96230. /**
  96231. * Wait asynchronously for the animation to end
  96232. * @returns a promise which will be fullfilled when the animation ends
  96233. */
  96234. waitAsync(): Promise<Animatable>;
  96235. /** @hidden */
  96236. _animate(delay: number): boolean;
  96237. }
  96238. interface Scene {
  96239. /** @hidden */
  96240. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  96241. /** @hidden */
  96242. _processLateAnimationBindingsForMatrices(holder: {
  96243. totalWeight: number;
  96244. totalAdditiveWeight: number;
  96245. animations: RuntimeAnimation[];
  96246. additiveAnimations: RuntimeAnimation[];
  96247. originalValue: Matrix;
  96248. }): any;
  96249. /** @hidden */
  96250. _processLateAnimationBindingsForQuaternions(holder: {
  96251. totalWeight: number;
  96252. totalAdditiveWeight: number;
  96253. animations: RuntimeAnimation[];
  96254. additiveAnimations: RuntimeAnimation[];
  96255. originalValue: Quaternion;
  96256. }, refQuaternion: Quaternion): Quaternion;
  96257. /** @hidden */
  96258. _processLateAnimationBindings(): void;
  96259. /**
  96260. * Will start the animation sequence of a given target
  96261. * @param target defines the target
  96262. * @param from defines from which frame should animation start
  96263. * @param to defines until which frame should animation run.
  96264. * @param weight defines the weight to apply to the animation (1.0 by default)
  96265. * @param loop defines if the animation loops
  96266. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96267. * @param onAnimationEnd defines the function to be executed when the animation ends
  96268. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96269. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96270. * @param onAnimationLoop defines the callback to call when an animation loops
  96271. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96272. * @returns the animatable object created for this animation
  96273. */
  96274. 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;
  96275. /**
  96276. * Will start the animation sequence of a given target
  96277. * @param target defines the target
  96278. * @param from defines from which frame should animation start
  96279. * @param to defines until which frame should animation run.
  96280. * @param loop defines if the animation loops
  96281. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96282. * @param onAnimationEnd defines the function to be executed when the animation ends
  96283. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96284. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96285. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  96286. * @param onAnimationLoop defines the callback to call when an animation loops
  96287. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96288. * @returns the animatable object created for this animation
  96289. */
  96290. 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;
  96291. /**
  96292. * Will start the animation sequence of a given target and its hierarchy
  96293. * @param target defines the target
  96294. * @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.
  96295. * @param from defines from which frame should animation start
  96296. * @param to defines until which frame should animation run.
  96297. * @param loop defines if the animation loops
  96298. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96299. * @param onAnimationEnd defines the function to be executed when the animation ends
  96300. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96301. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96302. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96303. * @param onAnimationLoop defines the callback to call when an animation loops
  96304. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96305. * @returns the list of created animatables
  96306. */
  96307. 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[];
  96308. /**
  96309. * Begin a new animation on a given node
  96310. * @param target defines the target where the animation will take place
  96311. * @param animations defines the list of animations to start
  96312. * @param from defines the initial value
  96313. * @param to defines the final value
  96314. * @param loop defines if you want animation to loop (off by default)
  96315. * @param speedRatio defines the speed ratio to apply to all animations
  96316. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96317. * @param onAnimationLoop defines the callback to call when an animation loops
  96318. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96319. * @returns the list of created animatables
  96320. */
  96321. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  96322. /**
  96323. * Begin a new animation on a given node and its hierarchy
  96324. * @param target defines the root node where the animation will take place
  96325. * @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.
  96326. * @param animations defines the list of animations to start
  96327. * @param from defines the initial value
  96328. * @param to defines the final value
  96329. * @param loop defines if you want animation to loop (off by default)
  96330. * @param speedRatio defines the speed ratio to apply to all animations
  96331. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96332. * @param onAnimationLoop defines the callback to call when an animation loops
  96333. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96334. * @returns the list of animatables created for all nodes
  96335. */
  96336. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  96337. /**
  96338. * Gets the animatable associated with a specific target
  96339. * @param target defines the target of the animatable
  96340. * @returns the required animatable if found
  96341. */
  96342. getAnimatableByTarget(target: any): Nullable<Animatable>;
  96343. /**
  96344. * Gets all animatables associated with a given target
  96345. * @param target defines the target to look animatables for
  96346. * @returns an array of Animatables
  96347. */
  96348. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  96349. /**
  96350. * Stops and removes all animations that have been applied to the scene
  96351. */
  96352. stopAllAnimations(): void;
  96353. /**
  96354. * Gets the current delta time used by animation engine
  96355. */
  96356. deltaTime: number;
  96357. }
  96358. interface Bone {
  96359. /**
  96360. * Copy an animation range from another bone
  96361. * @param source defines the source bone
  96362. * @param rangeName defines the range name to copy
  96363. * @param frameOffset defines the frame offset
  96364. * @param rescaleAsRequired defines if rescaling must be applied if required
  96365. * @param skelDimensionsRatio defines the scaling ratio
  96366. * @returns true if operation was successful
  96367. */
  96368. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  96369. }
  96370. }
  96371. declare module BABYLON {
  96372. /**
  96373. * Class used to handle skinning animations
  96374. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96375. */
  96376. export class Skeleton implements IAnimatable {
  96377. /** defines the skeleton name */
  96378. name: string;
  96379. /** defines the skeleton Id */
  96380. id: string;
  96381. /**
  96382. * Defines the list of child bones
  96383. */
  96384. bones: Bone[];
  96385. /**
  96386. * Defines an estimate of the dimension of the skeleton at rest
  96387. */
  96388. dimensionsAtRest: Vector3;
  96389. /**
  96390. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  96391. */
  96392. needInitialSkinMatrix: boolean;
  96393. /**
  96394. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  96395. */
  96396. overrideMesh: Nullable<AbstractMesh>;
  96397. /**
  96398. * Gets the list of animations attached to this skeleton
  96399. */
  96400. animations: Array<Animation>;
  96401. private _scene;
  96402. private _isDirty;
  96403. private _transformMatrices;
  96404. private _transformMatrixTexture;
  96405. private _meshesWithPoseMatrix;
  96406. private _animatables;
  96407. private _identity;
  96408. private _synchronizedWithMesh;
  96409. private _ranges;
  96410. private _lastAbsoluteTransformsUpdateId;
  96411. private _canUseTextureForBones;
  96412. private _uniqueId;
  96413. /** @hidden */
  96414. _numBonesWithLinkedTransformNode: number;
  96415. /** @hidden */
  96416. _hasWaitingData: Nullable<boolean>;
  96417. /** @hidden */
  96418. _waitingOverrideMeshId: Nullable<string>;
  96419. /**
  96420. * Specifies if the skeleton should be serialized
  96421. */
  96422. doNotSerialize: boolean;
  96423. private _useTextureToStoreBoneMatrices;
  96424. /**
  96425. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  96426. * Please note that this option is not available if the hardware does not support it
  96427. */
  96428. get useTextureToStoreBoneMatrices(): boolean;
  96429. set useTextureToStoreBoneMatrices(value: boolean);
  96430. private _animationPropertiesOverride;
  96431. /**
  96432. * Gets or sets the animation properties override
  96433. */
  96434. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96435. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96436. /**
  96437. * List of inspectable custom properties (used by the Inspector)
  96438. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96439. */
  96440. inspectableCustomProperties: IInspectable[];
  96441. /**
  96442. * An observable triggered before computing the skeleton's matrices
  96443. */
  96444. onBeforeComputeObservable: Observable<Skeleton>;
  96445. /**
  96446. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  96447. */
  96448. get isUsingTextureForMatrices(): boolean;
  96449. /**
  96450. * Gets the unique ID of this skeleton
  96451. */
  96452. get uniqueId(): number;
  96453. /**
  96454. * Creates a new skeleton
  96455. * @param name defines the skeleton name
  96456. * @param id defines the skeleton Id
  96457. * @param scene defines the hosting scene
  96458. */
  96459. constructor(
  96460. /** defines the skeleton name */
  96461. name: string,
  96462. /** defines the skeleton Id */
  96463. id: string, scene: Scene);
  96464. /**
  96465. * Gets the current object class name.
  96466. * @return the class name
  96467. */
  96468. getClassName(): string;
  96469. /**
  96470. * Returns an array containing the root bones
  96471. * @returns an array containing the root bones
  96472. */
  96473. getChildren(): Array<Bone>;
  96474. /**
  96475. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  96476. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96477. * @returns a Float32Array containing matrices data
  96478. */
  96479. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  96480. /**
  96481. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  96482. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96483. * @returns a raw texture containing the data
  96484. */
  96485. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  96486. /**
  96487. * Gets the current hosting scene
  96488. * @returns a scene object
  96489. */
  96490. getScene(): Scene;
  96491. /**
  96492. * Gets a string representing the current skeleton data
  96493. * @param fullDetails defines a boolean indicating if we want a verbose version
  96494. * @returns a string representing the current skeleton data
  96495. */
  96496. toString(fullDetails?: boolean): string;
  96497. /**
  96498. * Get bone's index searching by name
  96499. * @param name defines bone's name to search for
  96500. * @return the indice of the bone. Returns -1 if not found
  96501. */
  96502. getBoneIndexByName(name: string): number;
  96503. /**
  96504. * Creater a new animation range
  96505. * @param name defines the name of the range
  96506. * @param from defines the start key
  96507. * @param to defines the end key
  96508. */
  96509. createAnimationRange(name: string, from: number, to: number): void;
  96510. /**
  96511. * Delete a specific animation range
  96512. * @param name defines the name of the range
  96513. * @param deleteFrames defines if frames must be removed as well
  96514. */
  96515. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  96516. /**
  96517. * Gets a specific animation range
  96518. * @param name defines the name of the range to look for
  96519. * @returns the requested animation range or null if not found
  96520. */
  96521. getAnimationRange(name: string): Nullable<AnimationRange>;
  96522. /**
  96523. * Gets the list of all animation ranges defined on this skeleton
  96524. * @returns an array
  96525. */
  96526. getAnimationRanges(): Nullable<AnimationRange>[];
  96527. /**
  96528. * Copy animation range from a source skeleton.
  96529. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  96530. * @param source defines the source skeleton
  96531. * @param name defines the name of the range to copy
  96532. * @param rescaleAsRequired defines if rescaling must be applied if required
  96533. * @returns true if operation was successful
  96534. */
  96535. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  96536. /**
  96537. * Forces the skeleton to go to rest pose
  96538. */
  96539. returnToRest(): void;
  96540. private _getHighestAnimationFrame;
  96541. /**
  96542. * Begin a specific animation range
  96543. * @param name defines the name of the range to start
  96544. * @param loop defines if looping must be turned on (false by default)
  96545. * @param speedRatio defines the speed ratio to apply (1 by default)
  96546. * @param onAnimationEnd defines a callback which will be called when animation will end
  96547. * @returns a new animatable
  96548. */
  96549. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  96550. /**
  96551. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  96552. * @param skeleton defines the Skeleton containing the animation range to convert
  96553. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  96554. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  96555. * @returns the original skeleton
  96556. */
  96557. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  96558. /** @hidden */
  96559. _markAsDirty(): void;
  96560. /** @hidden */
  96561. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96562. /** @hidden */
  96563. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96564. private _computeTransformMatrices;
  96565. /**
  96566. * Build all resources required to render a skeleton
  96567. */
  96568. prepare(): void;
  96569. /**
  96570. * Gets the list of animatables currently running for this skeleton
  96571. * @returns an array of animatables
  96572. */
  96573. getAnimatables(): IAnimatable[];
  96574. /**
  96575. * Clone the current skeleton
  96576. * @param name defines the name of the new skeleton
  96577. * @param id defines the id of the new skeleton
  96578. * @returns the new skeleton
  96579. */
  96580. clone(name: string, id?: string): Skeleton;
  96581. /**
  96582. * Enable animation blending for this skeleton
  96583. * @param blendingSpeed defines the blending speed to apply
  96584. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96585. */
  96586. enableBlending(blendingSpeed?: number): void;
  96587. /**
  96588. * Releases all resources associated with the current skeleton
  96589. */
  96590. dispose(): void;
  96591. /**
  96592. * Serialize the skeleton in a JSON object
  96593. * @returns a JSON object
  96594. */
  96595. serialize(): any;
  96596. /**
  96597. * Creates a new skeleton from serialized data
  96598. * @param parsedSkeleton defines the serialized data
  96599. * @param scene defines the hosting scene
  96600. * @returns a new skeleton
  96601. */
  96602. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  96603. /**
  96604. * Compute all node absolute transforms
  96605. * @param forceUpdate defines if computation must be done even if cache is up to date
  96606. */
  96607. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  96608. /**
  96609. * Gets the root pose matrix
  96610. * @returns a matrix
  96611. */
  96612. getPoseMatrix(): Nullable<Matrix>;
  96613. /**
  96614. * Sorts bones per internal index
  96615. */
  96616. sortBones(): void;
  96617. private _sortBones;
  96618. /**
  96619. * Set the current local matrix as the restPose for all bones in the skeleton.
  96620. */
  96621. setCurrentPoseAsRest(): void;
  96622. }
  96623. }
  96624. declare module BABYLON {
  96625. /**
  96626. * Creates an instance based on a source mesh.
  96627. */
  96628. export class InstancedMesh extends AbstractMesh {
  96629. private _sourceMesh;
  96630. private _currentLOD;
  96631. /** @hidden */
  96632. _indexInSourceMeshInstanceArray: number;
  96633. constructor(name: string, source: Mesh);
  96634. /**
  96635. * Returns the string "InstancedMesh".
  96636. */
  96637. getClassName(): string;
  96638. /** Gets the list of lights affecting that mesh */
  96639. get lightSources(): Light[];
  96640. _resyncLightSources(): void;
  96641. _resyncLightSource(light: Light): void;
  96642. _removeLightSource(light: Light, dispose: boolean): void;
  96643. /**
  96644. * If the source mesh receives shadows
  96645. */
  96646. get receiveShadows(): boolean;
  96647. /**
  96648. * The material of the source mesh
  96649. */
  96650. get material(): Nullable<Material>;
  96651. /**
  96652. * Visibility of the source mesh
  96653. */
  96654. get visibility(): number;
  96655. /**
  96656. * Skeleton of the source mesh
  96657. */
  96658. get skeleton(): Nullable<Skeleton>;
  96659. /**
  96660. * Rendering ground id of the source mesh
  96661. */
  96662. get renderingGroupId(): number;
  96663. set renderingGroupId(value: number);
  96664. /**
  96665. * Returns the total number of vertices (integer).
  96666. */
  96667. getTotalVertices(): number;
  96668. /**
  96669. * Returns a positive integer : the total number of indices in this mesh geometry.
  96670. * @returns the numner of indices or zero if the mesh has no geometry.
  96671. */
  96672. getTotalIndices(): number;
  96673. /**
  96674. * The source mesh of the instance
  96675. */
  96676. get sourceMesh(): Mesh;
  96677. /**
  96678. * Creates a new InstancedMesh object from the mesh model.
  96679. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96680. * @param name defines the name of the new instance
  96681. * @returns a new InstancedMesh
  96682. */
  96683. createInstance(name: string): InstancedMesh;
  96684. /**
  96685. * Is this node ready to be used/rendered
  96686. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  96687. * @return {boolean} is it ready
  96688. */
  96689. isReady(completeCheck?: boolean): boolean;
  96690. /**
  96691. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96692. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  96693. * @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.
  96694. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  96695. */
  96696. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  96697. /**
  96698. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96699. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96700. * The `data` are either a numeric array either a Float32Array.
  96701. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  96702. * 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).
  96703. * Note that a new underlying VertexBuffer object is created each call.
  96704. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96705. *
  96706. * Possible `kind` values :
  96707. * - VertexBuffer.PositionKind
  96708. * - VertexBuffer.UVKind
  96709. * - VertexBuffer.UV2Kind
  96710. * - VertexBuffer.UV3Kind
  96711. * - VertexBuffer.UV4Kind
  96712. * - VertexBuffer.UV5Kind
  96713. * - VertexBuffer.UV6Kind
  96714. * - VertexBuffer.ColorKind
  96715. * - VertexBuffer.MatricesIndicesKind
  96716. * - VertexBuffer.MatricesIndicesExtraKind
  96717. * - VertexBuffer.MatricesWeightsKind
  96718. * - VertexBuffer.MatricesWeightsExtraKind
  96719. *
  96720. * Returns the Mesh.
  96721. */
  96722. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96723. /**
  96724. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96725. * If the mesh has no geometry, it is simply returned as it is.
  96726. * The `data` are either a numeric array either a Float32Array.
  96727. * No new underlying VertexBuffer object is created.
  96728. * 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.
  96729. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  96730. *
  96731. * Possible `kind` values :
  96732. * - VertexBuffer.PositionKind
  96733. * - VertexBuffer.UVKind
  96734. * - VertexBuffer.UV2Kind
  96735. * - VertexBuffer.UV3Kind
  96736. * - VertexBuffer.UV4Kind
  96737. * - VertexBuffer.UV5Kind
  96738. * - VertexBuffer.UV6Kind
  96739. * - VertexBuffer.ColorKind
  96740. * - VertexBuffer.MatricesIndicesKind
  96741. * - VertexBuffer.MatricesIndicesExtraKind
  96742. * - VertexBuffer.MatricesWeightsKind
  96743. * - VertexBuffer.MatricesWeightsExtraKind
  96744. *
  96745. * Returns the Mesh.
  96746. */
  96747. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  96748. /**
  96749. * Sets the mesh indices.
  96750. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  96751. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96752. * This method creates a new index buffer each call.
  96753. * Returns the Mesh.
  96754. */
  96755. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  96756. /**
  96757. * Boolean : True if the mesh owns the requested kind of data.
  96758. */
  96759. isVerticesDataPresent(kind: string): boolean;
  96760. /**
  96761. * Returns an array of indices (IndicesArray).
  96762. */
  96763. getIndices(): Nullable<IndicesArray>;
  96764. get _positions(): Nullable<Vector3[]>;
  96765. /**
  96766. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96767. * This means the mesh underlying bounding box and sphere are recomputed.
  96768. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96769. * @returns the current mesh
  96770. */
  96771. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  96772. /** @hidden */
  96773. _preActivate(): InstancedMesh;
  96774. /** @hidden */
  96775. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96776. /** @hidden */
  96777. _postActivate(): void;
  96778. getWorldMatrix(): Matrix;
  96779. get isAnInstance(): boolean;
  96780. /**
  96781. * Returns the current associated LOD AbstractMesh.
  96782. */
  96783. getLOD(camera: Camera): AbstractMesh;
  96784. /** @hidden */
  96785. _preActivateForIntermediateRendering(renderId: number): Mesh;
  96786. /** @hidden */
  96787. _syncSubMeshes(): InstancedMesh;
  96788. /** @hidden */
  96789. _generatePointsArray(): boolean;
  96790. /** @hidden */
  96791. _updateBoundingInfo(): AbstractMesh;
  96792. /**
  96793. * Creates a new InstancedMesh from the current mesh.
  96794. * - name (string) : the cloned mesh name
  96795. * - newParent (optional Node) : the optional Node to parent the clone to.
  96796. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  96797. *
  96798. * Returns the clone.
  96799. */
  96800. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  96801. /**
  96802. * Disposes the InstancedMesh.
  96803. * Returns nothing.
  96804. */
  96805. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96806. }
  96807. interface Mesh {
  96808. /**
  96809. * Register a custom buffer that will be instanced
  96810. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96811. * @param kind defines the buffer kind
  96812. * @param stride defines the stride in floats
  96813. */
  96814. registerInstancedBuffer(kind: string, stride: number): void;
  96815. /**
  96816. * true to use the edge renderer for all instances of this mesh
  96817. */
  96818. edgesShareWithInstances: boolean;
  96819. /** @hidden */
  96820. _userInstancedBuffersStorage: {
  96821. data: {
  96822. [key: string]: Float32Array;
  96823. };
  96824. sizes: {
  96825. [key: string]: number;
  96826. };
  96827. vertexBuffers: {
  96828. [key: string]: Nullable<VertexBuffer>;
  96829. };
  96830. strides: {
  96831. [key: string]: number;
  96832. };
  96833. };
  96834. }
  96835. interface AbstractMesh {
  96836. /**
  96837. * Object used to store instanced buffers defined by user
  96838. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96839. */
  96840. instancedBuffers: {
  96841. [key: string]: any;
  96842. };
  96843. }
  96844. }
  96845. declare module BABYLON {
  96846. /**
  96847. * Defines the options associated with the creation of a shader material.
  96848. */
  96849. export interface IShaderMaterialOptions {
  96850. /**
  96851. * Does the material work in alpha blend mode
  96852. */
  96853. needAlphaBlending: boolean;
  96854. /**
  96855. * Does the material work in alpha test mode
  96856. */
  96857. needAlphaTesting: boolean;
  96858. /**
  96859. * The list of attribute names used in the shader
  96860. */
  96861. attributes: string[];
  96862. /**
  96863. * The list of unifrom names used in the shader
  96864. */
  96865. uniforms: string[];
  96866. /**
  96867. * The list of UBO names used in the shader
  96868. */
  96869. uniformBuffers: string[];
  96870. /**
  96871. * The list of sampler names used in the shader
  96872. */
  96873. samplers: string[];
  96874. /**
  96875. * The list of defines used in the shader
  96876. */
  96877. defines: string[];
  96878. }
  96879. /**
  96880. * 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.
  96881. *
  96882. * This returned material effects how the mesh will look based on the code in the shaders.
  96883. *
  96884. * @see https://doc.babylonjs.com/how_to/shader_material
  96885. */
  96886. export class ShaderMaterial extends Material {
  96887. private _shaderPath;
  96888. private _options;
  96889. private _textures;
  96890. private _textureArrays;
  96891. private _floats;
  96892. private _ints;
  96893. private _floatsArrays;
  96894. private _colors3;
  96895. private _colors3Arrays;
  96896. private _colors4;
  96897. private _colors4Arrays;
  96898. private _vectors2;
  96899. private _vectors3;
  96900. private _vectors4;
  96901. private _matrices;
  96902. private _matrixArrays;
  96903. private _matrices3x3;
  96904. private _matrices2x2;
  96905. private _vectors2Arrays;
  96906. private _vectors3Arrays;
  96907. private _vectors4Arrays;
  96908. private _cachedWorldViewMatrix;
  96909. private _cachedWorldViewProjectionMatrix;
  96910. private _renderId;
  96911. private _multiview;
  96912. private _cachedDefines;
  96913. /** Define the Url to load snippets */
  96914. static SnippetUrl: string;
  96915. /** Snippet ID if the material was created from the snippet server */
  96916. snippetId: string;
  96917. /**
  96918. * Instantiate a new shader material.
  96919. * 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.
  96920. * This returned material effects how the mesh will look based on the code in the shaders.
  96921. * @see https://doc.babylonjs.com/how_to/shader_material
  96922. * @param name Define the name of the material in the scene
  96923. * @param scene Define the scene the material belongs to
  96924. * @param shaderPath Defines the route to the shader code in one of three ways:
  96925. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  96926. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  96927. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  96928. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  96929. * @param options Define the options used to create the shader
  96930. */
  96931. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  96932. /**
  96933. * Gets the shader path used to define the shader code
  96934. * It can be modified to trigger a new compilation
  96935. */
  96936. get shaderPath(): any;
  96937. /**
  96938. * Sets the shader path used to define the shader code
  96939. * It can be modified to trigger a new compilation
  96940. */
  96941. set shaderPath(shaderPath: any);
  96942. /**
  96943. * Gets the options used to compile the shader.
  96944. * They can be modified to trigger a new compilation
  96945. */
  96946. get options(): IShaderMaterialOptions;
  96947. /**
  96948. * Gets the current class name of the material e.g. "ShaderMaterial"
  96949. * Mainly use in serialization.
  96950. * @returns the class name
  96951. */
  96952. getClassName(): string;
  96953. /**
  96954. * Specifies if the material will require alpha blending
  96955. * @returns a boolean specifying if alpha blending is needed
  96956. */
  96957. needAlphaBlending(): boolean;
  96958. /**
  96959. * Specifies if this material should be rendered in alpha test mode
  96960. * @returns a boolean specifying if an alpha test is needed.
  96961. */
  96962. needAlphaTesting(): boolean;
  96963. private _checkUniform;
  96964. /**
  96965. * Set a texture in the shader.
  96966. * @param name Define the name of the uniform samplers as defined in the shader
  96967. * @param texture Define the texture to bind to this sampler
  96968. * @return the material itself allowing "fluent" like uniform updates
  96969. */
  96970. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  96971. /**
  96972. * Set a texture array in the shader.
  96973. * @param name Define the name of the uniform sampler array as defined in the shader
  96974. * @param textures Define the list of textures to bind to this sampler
  96975. * @return the material itself allowing "fluent" like uniform updates
  96976. */
  96977. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  96978. /**
  96979. * Set a float in the shader.
  96980. * @param name Define the name of the uniform as defined in the shader
  96981. * @param value Define the value to give to the uniform
  96982. * @return the material itself allowing "fluent" like uniform updates
  96983. */
  96984. setFloat(name: string, value: number): ShaderMaterial;
  96985. /**
  96986. * Set a int in the shader.
  96987. * @param name Define the name of the uniform as defined in the shader
  96988. * @param value Define the value to give to the uniform
  96989. * @return the material itself allowing "fluent" like uniform updates
  96990. */
  96991. setInt(name: string, value: number): ShaderMaterial;
  96992. /**
  96993. * Set an array of floats in the shader.
  96994. * @param name Define the name of the uniform as defined in the shader
  96995. * @param value Define the value to give to the uniform
  96996. * @return the material itself allowing "fluent" like uniform updates
  96997. */
  96998. setFloats(name: string, value: number[]): ShaderMaterial;
  96999. /**
  97000. * Set a vec3 in the shader from a Color3.
  97001. * @param name Define the name of the uniform as defined in the shader
  97002. * @param value Define the value to give to the uniform
  97003. * @return the material itself allowing "fluent" like uniform updates
  97004. */
  97005. setColor3(name: string, value: Color3): ShaderMaterial;
  97006. /**
  97007. * Set a vec3 array in the shader from a Color3 array.
  97008. * @param name Define the name of the uniform as defined in the shader
  97009. * @param value Define the value to give to the uniform
  97010. * @return the material itself allowing "fluent" like uniform updates
  97011. */
  97012. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  97013. /**
  97014. * Set a vec4 in the shader from a Color4.
  97015. * @param name Define the name of the uniform as defined in the shader
  97016. * @param value Define the value to give to the uniform
  97017. * @return the material itself allowing "fluent" like uniform updates
  97018. */
  97019. setColor4(name: string, value: Color4): ShaderMaterial;
  97020. /**
  97021. * Set a vec4 array in the shader from a Color4 array.
  97022. * @param name Define the name of the uniform as defined in the shader
  97023. * @param value Define the value to give to the uniform
  97024. * @return the material itself allowing "fluent" like uniform updates
  97025. */
  97026. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  97027. /**
  97028. * Set a vec2 in the shader from a Vector2.
  97029. * @param name Define the name of the uniform as defined in the shader
  97030. * @param value Define the value to give to the uniform
  97031. * @return the material itself allowing "fluent" like uniform updates
  97032. */
  97033. setVector2(name: string, value: Vector2): ShaderMaterial;
  97034. /**
  97035. * Set a vec3 in the shader from a Vector3.
  97036. * @param name Define the name of the uniform as defined in the shader
  97037. * @param value Define the value to give to the uniform
  97038. * @return the material itself allowing "fluent" like uniform updates
  97039. */
  97040. setVector3(name: string, value: Vector3): ShaderMaterial;
  97041. /**
  97042. * Set a vec4 in the shader from a Vector4.
  97043. * @param name Define the name of the uniform as defined in the shader
  97044. * @param value Define the value to give to the uniform
  97045. * @return the material itself allowing "fluent" like uniform updates
  97046. */
  97047. setVector4(name: string, value: Vector4): ShaderMaterial;
  97048. /**
  97049. * Set a mat4 in the shader from a Matrix.
  97050. * @param name Define the name of the uniform as defined in the shader
  97051. * @param value Define the value to give to the uniform
  97052. * @return the material itself allowing "fluent" like uniform updates
  97053. */
  97054. setMatrix(name: string, value: Matrix): ShaderMaterial;
  97055. /**
  97056. * Set a float32Array in the shader from a matrix array.
  97057. * @param name Define the name of the uniform as defined in the shader
  97058. * @param value Define the value to give to the uniform
  97059. * @return the material itself allowing "fluent" like uniform updates
  97060. */
  97061. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  97062. /**
  97063. * Set a mat3 in the shader from a Float32Array.
  97064. * @param name Define the name of the uniform as defined in the shader
  97065. * @param value Define the value to give to the uniform
  97066. * @return the material itself allowing "fluent" like uniform updates
  97067. */
  97068. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97069. /**
  97070. * Set a mat2 in the shader from a Float32Array.
  97071. * @param name Define the name of the uniform as defined in the shader
  97072. * @param value Define the value to give to the uniform
  97073. * @return the material itself allowing "fluent" like uniform updates
  97074. */
  97075. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97076. /**
  97077. * Set a vec2 array in the shader from a number array.
  97078. * @param name Define the name of the uniform as defined in the shader
  97079. * @param value Define the value to give to the uniform
  97080. * @return the material itself allowing "fluent" like uniform updates
  97081. */
  97082. setArray2(name: string, value: number[]): ShaderMaterial;
  97083. /**
  97084. * Set a vec3 array in the shader from a number array.
  97085. * @param name Define the name of the uniform as defined in the shader
  97086. * @param value Define the value to give to the uniform
  97087. * @return the material itself allowing "fluent" like uniform updates
  97088. */
  97089. setArray3(name: string, value: number[]): ShaderMaterial;
  97090. /**
  97091. * Set a vec4 array in the shader from a number array.
  97092. * @param name Define the name of the uniform as defined in the shader
  97093. * @param value Define the value to give to the uniform
  97094. * @return the material itself allowing "fluent" like uniform updates
  97095. */
  97096. setArray4(name: string, value: number[]): ShaderMaterial;
  97097. private _checkCache;
  97098. /**
  97099. * Specifies that the submesh is ready to be used
  97100. * @param mesh defines the mesh to check
  97101. * @param subMesh defines which submesh to check
  97102. * @param useInstances specifies that instances should be used
  97103. * @returns a boolean indicating that the submesh is ready or not
  97104. */
  97105. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97106. /**
  97107. * Checks if the material is ready to render the requested mesh
  97108. * @param mesh Define the mesh to render
  97109. * @param useInstances Define whether or not the material is used with instances
  97110. * @returns true if ready, otherwise false
  97111. */
  97112. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97113. /**
  97114. * Binds the world matrix to the material
  97115. * @param world defines the world transformation matrix
  97116. * @param effectOverride - If provided, use this effect instead of internal effect
  97117. */
  97118. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  97119. /**
  97120. * Binds the submesh to this material by preparing the effect and shader to draw
  97121. * @param world defines the world transformation matrix
  97122. * @param mesh defines the mesh containing the submesh
  97123. * @param subMesh defines the submesh to bind the material to
  97124. */
  97125. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97126. /**
  97127. * Binds the material to the mesh
  97128. * @param world defines the world transformation matrix
  97129. * @param mesh defines the mesh to bind the material to
  97130. * @param effectOverride - If provided, use this effect instead of internal effect
  97131. */
  97132. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  97133. protected _afterBind(mesh?: Mesh): void;
  97134. /**
  97135. * Gets the active textures from the material
  97136. * @returns an array of textures
  97137. */
  97138. getActiveTextures(): BaseTexture[];
  97139. /**
  97140. * Specifies if the material uses a texture
  97141. * @param texture defines the texture to check against the material
  97142. * @returns a boolean specifying if the material uses the texture
  97143. */
  97144. hasTexture(texture: BaseTexture): boolean;
  97145. /**
  97146. * Makes a duplicate of the material, and gives it a new name
  97147. * @param name defines the new name for the duplicated material
  97148. * @returns the cloned material
  97149. */
  97150. clone(name: string): ShaderMaterial;
  97151. /**
  97152. * Disposes the material
  97153. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97154. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97155. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97156. */
  97157. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97158. /**
  97159. * Serializes this material in a JSON representation
  97160. * @returns the serialized material object
  97161. */
  97162. serialize(): any;
  97163. /**
  97164. * Creates a shader material from parsed shader material data
  97165. * @param source defines the JSON represnetation of the material
  97166. * @param scene defines the hosting scene
  97167. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97168. * @returns a new material
  97169. */
  97170. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  97171. /**
  97172. * Creates a new ShaderMaterial from a snippet saved in a remote file
  97173. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  97174. * @param url defines the url to load from
  97175. * @param scene defines the hosting scene
  97176. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97177. * @returns a promise that will resolve to the new ShaderMaterial
  97178. */
  97179. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97180. /**
  97181. * Creates a ShaderMaterial from a snippet saved by the Inspector
  97182. * @param snippetId defines the snippet to load
  97183. * @param scene defines the hosting scene
  97184. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97185. * @returns a promise that will resolve to the new ShaderMaterial
  97186. */
  97187. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97188. }
  97189. }
  97190. declare module BABYLON {
  97191. /** @hidden */
  97192. export var colorPixelShader: {
  97193. name: string;
  97194. shader: string;
  97195. };
  97196. }
  97197. declare module BABYLON {
  97198. /** @hidden */
  97199. export var colorVertexShader: {
  97200. name: string;
  97201. shader: string;
  97202. };
  97203. }
  97204. declare module BABYLON {
  97205. /**
  97206. * Line mesh
  97207. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  97208. */
  97209. export class LinesMesh extends Mesh {
  97210. /**
  97211. * If vertex color should be applied to the mesh
  97212. */
  97213. readonly useVertexColor?: boolean | undefined;
  97214. /**
  97215. * If vertex alpha should be applied to the mesh
  97216. */
  97217. readonly useVertexAlpha?: boolean | undefined;
  97218. /**
  97219. * Color of the line (Default: White)
  97220. */
  97221. color: Color3;
  97222. /**
  97223. * Alpha of the line (Default: 1)
  97224. */
  97225. alpha: number;
  97226. /**
  97227. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97228. * This margin is expressed in world space coordinates, so its value may vary.
  97229. * Default value is 0.1
  97230. */
  97231. intersectionThreshold: number;
  97232. private _colorShader;
  97233. private color4;
  97234. /**
  97235. * Creates a new LinesMesh
  97236. * @param name defines the name
  97237. * @param scene defines the hosting scene
  97238. * @param parent defines the parent mesh if any
  97239. * @param source defines the optional source LinesMesh used to clone data from
  97240. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97241. * When false, achieved by calling a clone(), also passing False.
  97242. * This will make creation of children, recursive.
  97243. * @param useVertexColor defines if this LinesMesh supports vertex color
  97244. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  97245. */
  97246. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  97247. /**
  97248. * If vertex color should be applied to the mesh
  97249. */
  97250. useVertexColor?: boolean | undefined,
  97251. /**
  97252. * If vertex alpha should be applied to the mesh
  97253. */
  97254. useVertexAlpha?: boolean | undefined);
  97255. private _addClipPlaneDefine;
  97256. private _removeClipPlaneDefine;
  97257. isReady(): boolean;
  97258. /**
  97259. * Returns the string "LineMesh"
  97260. */
  97261. getClassName(): string;
  97262. /**
  97263. * @hidden
  97264. */
  97265. get material(): Material;
  97266. /**
  97267. * @hidden
  97268. */
  97269. set material(value: Material);
  97270. /**
  97271. * @hidden
  97272. */
  97273. get checkCollisions(): boolean;
  97274. /** @hidden */
  97275. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97276. /** @hidden */
  97277. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97278. /**
  97279. * Disposes of the line mesh
  97280. * @param doNotRecurse If children should be disposed
  97281. */
  97282. dispose(doNotRecurse?: boolean): void;
  97283. /**
  97284. * Returns a new LineMesh object cloned from the current one.
  97285. */
  97286. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  97287. /**
  97288. * Creates a new InstancedLinesMesh object from the mesh model.
  97289. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97290. * @param name defines the name of the new instance
  97291. * @returns a new InstancedLinesMesh
  97292. */
  97293. createInstance(name: string): InstancedLinesMesh;
  97294. }
  97295. /**
  97296. * Creates an instance based on a source LinesMesh
  97297. */
  97298. export class InstancedLinesMesh extends InstancedMesh {
  97299. /**
  97300. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97301. * This margin is expressed in world space coordinates, so its value may vary.
  97302. * Initilized with the intersectionThreshold value of the source LinesMesh
  97303. */
  97304. intersectionThreshold: number;
  97305. constructor(name: string, source: LinesMesh);
  97306. /**
  97307. * Returns the string "InstancedLinesMesh".
  97308. */
  97309. getClassName(): string;
  97310. }
  97311. }
  97312. declare module BABYLON {
  97313. /** @hidden */
  97314. export var linePixelShader: {
  97315. name: string;
  97316. shader: string;
  97317. };
  97318. }
  97319. declare module BABYLON {
  97320. /** @hidden */
  97321. export var lineVertexShader: {
  97322. name: string;
  97323. shader: string;
  97324. };
  97325. }
  97326. declare module BABYLON {
  97327. interface Scene {
  97328. /** @hidden */
  97329. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  97330. }
  97331. interface AbstractMesh {
  97332. /**
  97333. * Gets the edgesRenderer associated with the mesh
  97334. */
  97335. edgesRenderer: Nullable<EdgesRenderer>;
  97336. }
  97337. interface LinesMesh {
  97338. /**
  97339. * Enables the edge rendering mode on the mesh.
  97340. * This mode makes the mesh edges visible
  97341. * @param epsilon defines the maximal distance between two angles to detect a face
  97342. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97343. * @returns the currentAbstractMesh
  97344. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97345. */
  97346. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97347. }
  97348. interface InstancedLinesMesh {
  97349. /**
  97350. * Enables the edge rendering mode on the mesh.
  97351. * This mode makes the mesh edges visible
  97352. * @param epsilon defines the maximal distance between two angles to detect a face
  97353. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97354. * @returns the current InstancedLinesMesh
  97355. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97356. */
  97357. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  97358. }
  97359. /**
  97360. * Defines the minimum contract an Edges renderer should follow.
  97361. */
  97362. export interface IEdgesRenderer extends IDisposable {
  97363. /**
  97364. * Gets or sets a boolean indicating if the edgesRenderer is active
  97365. */
  97366. isEnabled: boolean;
  97367. /**
  97368. * Renders the edges of the attached mesh,
  97369. */
  97370. render(): void;
  97371. /**
  97372. * Checks wether or not the edges renderer is ready to render.
  97373. * @return true if ready, otherwise false.
  97374. */
  97375. isReady(): boolean;
  97376. /**
  97377. * List of instances to render in case the source mesh has instances
  97378. */
  97379. customInstances: SmartArray<Matrix>;
  97380. }
  97381. /**
  97382. * Defines the additional options of the edges renderer
  97383. */
  97384. export interface IEdgesRendererOptions {
  97385. /**
  97386. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  97387. * If not defined, the default value is true
  97388. */
  97389. useAlternateEdgeFinder?: boolean;
  97390. /**
  97391. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  97392. * If not defined, the default value is true.
  97393. * 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)
  97394. * This option is used only if useAlternateEdgeFinder = true
  97395. */
  97396. useFastVertexMerger?: boolean;
  97397. /**
  97398. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  97399. * The default value is 1e-6
  97400. * This option is used only if useAlternateEdgeFinder = true
  97401. */
  97402. epsilonVertexMerge?: number;
  97403. /**
  97404. * 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
  97405. * 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.
  97406. * This option is used only if useAlternateEdgeFinder = true
  97407. */
  97408. applyTessellation?: boolean;
  97409. /**
  97410. * 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
  97411. * The default value is 1e-6
  97412. * This option is used only if useAlternateEdgeFinder = true
  97413. */
  97414. epsilonVertexAligned?: number;
  97415. }
  97416. /**
  97417. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  97418. */
  97419. export class EdgesRenderer implements IEdgesRenderer {
  97420. /**
  97421. * Define the size of the edges with an orthographic camera
  97422. */
  97423. edgesWidthScalerForOrthographic: number;
  97424. /**
  97425. * Define the size of the edges with a perspective camera
  97426. */
  97427. edgesWidthScalerForPerspective: number;
  97428. protected _source: AbstractMesh;
  97429. protected _linesPositions: number[];
  97430. protected _linesNormals: number[];
  97431. protected _linesIndices: number[];
  97432. protected _epsilon: number;
  97433. protected _indicesCount: number;
  97434. protected _lineShader: ShaderMaterial;
  97435. protected _ib: DataBuffer;
  97436. protected _buffers: {
  97437. [key: string]: Nullable<VertexBuffer>;
  97438. };
  97439. protected _buffersForInstances: {
  97440. [key: string]: Nullable<VertexBuffer>;
  97441. };
  97442. protected _checkVerticesInsteadOfIndices: boolean;
  97443. protected _options: Nullable<IEdgesRendererOptions>;
  97444. private _meshRebuildObserver;
  97445. private _meshDisposeObserver;
  97446. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  97447. isEnabled: boolean;
  97448. /**
  97449. * List of instances to render in case the source mesh has instances
  97450. */
  97451. customInstances: SmartArray<Matrix>;
  97452. private static GetShader;
  97453. /**
  97454. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  97455. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  97456. * @param source Mesh used to create edges
  97457. * @param epsilon sum of angles in adjacency to check for edge
  97458. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  97459. * @param generateEdgesLines - should generate Lines or only prepare resources.
  97460. * @param options The options to apply when generating the edges
  97461. */
  97462. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  97463. protected _prepareRessources(): void;
  97464. /** @hidden */
  97465. _rebuild(): void;
  97466. /**
  97467. * Releases the required resources for the edges renderer
  97468. */
  97469. dispose(): void;
  97470. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  97471. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  97472. /**
  97473. * Checks if the pair of p0 and p1 is en edge
  97474. * @param faceIndex
  97475. * @param edge
  97476. * @param faceNormals
  97477. * @param p0
  97478. * @param p1
  97479. * @private
  97480. */
  97481. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  97482. /**
  97483. * push line into the position, normal and index buffer
  97484. * @protected
  97485. */
  97486. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  97487. /**
  97488. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  97489. */
  97490. private _tessellateTriangle;
  97491. private _generateEdgesLinesAlternate;
  97492. /**
  97493. * Generates lines edges from adjacencjes
  97494. * @private
  97495. */
  97496. _generateEdgesLines(): void;
  97497. /**
  97498. * Checks wether or not the edges renderer is ready to render.
  97499. * @return true if ready, otherwise false.
  97500. */
  97501. isReady(): boolean;
  97502. /**
  97503. * Renders the edges of the attached mesh,
  97504. */
  97505. render(): void;
  97506. }
  97507. /**
  97508. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  97509. */
  97510. export class LineEdgesRenderer extends EdgesRenderer {
  97511. /**
  97512. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  97513. * @param source LineMesh used to generate edges
  97514. * @param epsilon not important (specified angle for edge detection)
  97515. * @param checkVerticesInsteadOfIndices not important for LineMesh
  97516. */
  97517. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  97518. /**
  97519. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  97520. */
  97521. _generateEdgesLines(): void;
  97522. }
  97523. }
  97524. declare module BABYLON {
  97525. /**
  97526. * This represents the object necessary to create a rendering group.
  97527. * This is exclusively used and created by the rendering manager.
  97528. * To modify the behavior, you use the available helpers in your scene or meshes.
  97529. * @hidden
  97530. */
  97531. export class RenderingGroup {
  97532. index: number;
  97533. private static _zeroVector;
  97534. private _scene;
  97535. private _opaqueSubMeshes;
  97536. private _transparentSubMeshes;
  97537. private _alphaTestSubMeshes;
  97538. private _depthOnlySubMeshes;
  97539. private _particleSystems;
  97540. private _spriteManagers;
  97541. private _opaqueSortCompareFn;
  97542. private _alphaTestSortCompareFn;
  97543. private _transparentSortCompareFn;
  97544. private _renderOpaque;
  97545. private _renderAlphaTest;
  97546. private _renderTransparent;
  97547. /** @hidden */
  97548. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  97549. onBeforeTransparentRendering: () => void;
  97550. /**
  97551. * Set the opaque sort comparison function.
  97552. * If null the sub meshes will be render in the order they were created
  97553. */
  97554. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97555. /**
  97556. * Set the alpha test sort comparison function.
  97557. * If null the sub meshes will be render in the order they were created
  97558. */
  97559. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97560. /**
  97561. * Set the transparent sort comparison function.
  97562. * If null the sub meshes will be render in the order they were created
  97563. */
  97564. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97565. /**
  97566. * Creates a new rendering group.
  97567. * @param index The rendering group index
  97568. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  97569. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  97570. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  97571. */
  97572. 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>);
  97573. /**
  97574. * Render all the sub meshes contained in the group.
  97575. * @param customRenderFunction Used to override the default render behaviour of the group.
  97576. * @returns true if rendered some submeshes.
  97577. */
  97578. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  97579. /**
  97580. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  97581. * @param subMeshes The submeshes to render
  97582. */
  97583. private renderOpaqueSorted;
  97584. /**
  97585. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  97586. * @param subMeshes The submeshes to render
  97587. */
  97588. private renderAlphaTestSorted;
  97589. /**
  97590. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  97591. * @param subMeshes The submeshes to render
  97592. */
  97593. private renderTransparentSorted;
  97594. /**
  97595. * Renders the submeshes in a specified order.
  97596. * @param subMeshes The submeshes to sort before render
  97597. * @param sortCompareFn The comparison function use to sort
  97598. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  97599. * @param transparent Specifies to activate blending if true
  97600. */
  97601. private static renderSorted;
  97602. /**
  97603. * Renders the submeshes in the order they were dispatched (no sort applied).
  97604. * @param subMeshes The submeshes to render
  97605. */
  97606. private static renderUnsorted;
  97607. /**
  97608. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97609. * are rendered back to front if in the same alpha index.
  97610. *
  97611. * @param a The first submesh
  97612. * @param b The second submesh
  97613. * @returns The result of the comparison
  97614. */
  97615. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  97616. /**
  97617. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97618. * are rendered back to front.
  97619. *
  97620. * @param a The first submesh
  97621. * @param b The second submesh
  97622. * @returns The result of the comparison
  97623. */
  97624. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  97625. /**
  97626. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97627. * are rendered front to back (prevent overdraw).
  97628. *
  97629. * @param a The first submesh
  97630. * @param b The second submesh
  97631. * @returns The result of the comparison
  97632. */
  97633. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  97634. /**
  97635. * Resets the different lists of submeshes to prepare a new frame.
  97636. */
  97637. prepare(): void;
  97638. dispose(): void;
  97639. /**
  97640. * Inserts the submesh in its correct queue depending on its material.
  97641. * @param subMesh The submesh to dispatch
  97642. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97643. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97644. */
  97645. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97646. dispatchSprites(spriteManager: ISpriteManager): void;
  97647. dispatchParticles(particleSystem: IParticleSystem): void;
  97648. private _renderParticles;
  97649. private _renderSprites;
  97650. }
  97651. }
  97652. declare module BABYLON {
  97653. /**
  97654. * Interface describing the different options available in the rendering manager
  97655. * regarding Auto Clear between groups.
  97656. */
  97657. export interface IRenderingManagerAutoClearSetup {
  97658. /**
  97659. * Defines whether or not autoclear is enable.
  97660. */
  97661. autoClear: boolean;
  97662. /**
  97663. * Defines whether or not to autoclear the depth buffer.
  97664. */
  97665. depth: boolean;
  97666. /**
  97667. * Defines whether or not to autoclear the stencil buffer.
  97668. */
  97669. stencil: boolean;
  97670. }
  97671. /**
  97672. * This class is used by the onRenderingGroupObservable
  97673. */
  97674. export class RenderingGroupInfo {
  97675. /**
  97676. * The Scene that being rendered
  97677. */
  97678. scene: Scene;
  97679. /**
  97680. * The camera currently used for the rendering pass
  97681. */
  97682. camera: Nullable<Camera>;
  97683. /**
  97684. * The ID of the renderingGroup being processed
  97685. */
  97686. renderingGroupId: number;
  97687. }
  97688. /**
  97689. * This is the manager responsible of all the rendering for meshes sprites and particles.
  97690. * It is enable to manage the different groups as well as the different necessary sort functions.
  97691. * This should not be used directly aside of the few static configurations
  97692. */
  97693. export class RenderingManager {
  97694. /**
  97695. * The max id used for rendering groups (not included)
  97696. */
  97697. static MAX_RENDERINGGROUPS: number;
  97698. /**
  97699. * The min id used for rendering groups (included)
  97700. */
  97701. static MIN_RENDERINGGROUPS: number;
  97702. /**
  97703. * Used to globally prevent autoclearing scenes.
  97704. */
  97705. static AUTOCLEAR: boolean;
  97706. /**
  97707. * @hidden
  97708. */
  97709. _useSceneAutoClearSetup: boolean;
  97710. private _scene;
  97711. private _renderingGroups;
  97712. private _depthStencilBufferAlreadyCleaned;
  97713. private _autoClearDepthStencil;
  97714. private _customOpaqueSortCompareFn;
  97715. private _customAlphaTestSortCompareFn;
  97716. private _customTransparentSortCompareFn;
  97717. private _renderingGroupInfo;
  97718. /**
  97719. * Instantiates a new rendering group for a particular scene
  97720. * @param scene Defines the scene the groups belongs to
  97721. */
  97722. constructor(scene: Scene);
  97723. private _clearDepthStencilBuffer;
  97724. /**
  97725. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  97726. * @hidden
  97727. */
  97728. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  97729. /**
  97730. * Resets the different information of the group to prepare a new frame
  97731. * @hidden
  97732. */
  97733. reset(): void;
  97734. /**
  97735. * Dispose and release the group and its associated resources.
  97736. * @hidden
  97737. */
  97738. dispose(): void;
  97739. /**
  97740. * Clear the info related to rendering groups preventing retention points during dispose.
  97741. */
  97742. freeRenderingGroups(): void;
  97743. private _prepareRenderingGroup;
  97744. /**
  97745. * Add a sprite manager to the rendering manager in order to render it this frame.
  97746. * @param spriteManager Define the sprite manager to render
  97747. */
  97748. dispatchSprites(spriteManager: ISpriteManager): void;
  97749. /**
  97750. * Add a particle system to the rendering manager in order to render it this frame.
  97751. * @param particleSystem Define the particle system to render
  97752. */
  97753. dispatchParticles(particleSystem: IParticleSystem): void;
  97754. /**
  97755. * Add a submesh to the manager in order to render it this frame
  97756. * @param subMesh The submesh to dispatch
  97757. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97758. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97759. */
  97760. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97761. /**
  97762. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97763. * This allowed control for front to back rendering or reversly depending of the special needs.
  97764. *
  97765. * @param renderingGroupId The rendering group id corresponding to its index
  97766. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97767. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97768. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97769. */
  97770. 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;
  97771. /**
  97772. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97773. *
  97774. * @param renderingGroupId The rendering group id corresponding to its index
  97775. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97776. * @param depth Automatically clears depth between groups if true and autoClear is true.
  97777. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  97778. */
  97779. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  97780. /**
  97781. * Gets the current auto clear configuration for one rendering group of the rendering
  97782. * manager.
  97783. * @param index the rendering group index to get the information for
  97784. * @returns The auto clear setup for the requested rendering group
  97785. */
  97786. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97787. }
  97788. }
  97789. declare module BABYLON {
  97790. /**
  97791. * Defines the options associated with the creation of a custom shader for a shadow generator.
  97792. */
  97793. export interface ICustomShaderOptions {
  97794. /**
  97795. * Gets or sets the custom shader name to use
  97796. */
  97797. shaderName: string;
  97798. /**
  97799. * The list of attribute names used in the shader
  97800. */
  97801. attributes?: string[];
  97802. /**
  97803. * The list of unifrom names used in the shader
  97804. */
  97805. uniforms?: string[];
  97806. /**
  97807. * The list of sampler names used in the shader
  97808. */
  97809. samplers?: string[];
  97810. /**
  97811. * The list of defines used in the shader
  97812. */
  97813. defines?: string[];
  97814. }
  97815. /**
  97816. * Interface to implement to create a shadow generator compatible with BJS.
  97817. */
  97818. export interface IShadowGenerator {
  97819. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97820. id: string;
  97821. /**
  97822. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97823. * @returns The render target texture if present otherwise, null
  97824. */
  97825. getShadowMap(): Nullable<RenderTargetTexture>;
  97826. /**
  97827. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97828. * @param subMesh The submesh we want to render in the shadow map
  97829. * @param useInstances Defines wether will draw in the map using instances
  97830. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97831. * @returns true if ready otherwise, false
  97832. */
  97833. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97834. /**
  97835. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97836. * @param defines Defines of the material we want to update
  97837. * @param lightIndex Index of the light in the enabled light list of the material
  97838. */
  97839. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  97840. /**
  97841. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97842. * defined in the generator but impacting the effect).
  97843. * It implies the unifroms available on the materials are the standard BJS ones.
  97844. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97845. * @param effect The effect we are binfing the information for
  97846. */
  97847. bindShadowLight(lightIndex: string, effect: Effect): void;
  97848. /**
  97849. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97850. * (eq to shadow prjection matrix * light transform matrix)
  97851. * @returns The transform matrix used to create the shadow map
  97852. */
  97853. getTransformMatrix(): Matrix;
  97854. /**
  97855. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97856. * Cube and 2D textures for instance.
  97857. */
  97858. recreateShadowMap(): void;
  97859. /**
  97860. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97861. * @param onCompiled Callback triggered at the and of the effects compilation
  97862. * @param options Sets of optional options forcing the compilation with different modes
  97863. */
  97864. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97865. useInstances: boolean;
  97866. }>): void;
  97867. /**
  97868. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97869. * @param options Sets of optional options forcing the compilation with different modes
  97870. * @returns A promise that resolves when the compilation completes
  97871. */
  97872. forceCompilationAsync(options?: Partial<{
  97873. useInstances: boolean;
  97874. }>): Promise<void>;
  97875. /**
  97876. * Serializes the shadow generator setup to a json object.
  97877. * @returns The serialized JSON object
  97878. */
  97879. serialize(): any;
  97880. /**
  97881. * Disposes the Shadow map and related Textures and effects.
  97882. */
  97883. dispose(): void;
  97884. }
  97885. /**
  97886. * Default implementation IShadowGenerator.
  97887. * This is the main object responsible of generating shadows in the framework.
  97888. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  97889. */
  97890. export class ShadowGenerator implements IShadowGenerator {
  97891. /**
  97892. * Name of the shadow generator class
  97893. */
  97894. static CLASSNAME: string;
  97895. /**
  97896. * Shadow generator mode None: no filtering applied.
  97897. */
  97898. static readonly FILTER_NONE: number;
  97899. /**
  97900. * Shadow generator mode ESM: Exponential Shadow Mapping.
  97901. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97902. */
  97903. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  97904. /**
  97905. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  97906. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  97907. */
  97908. static readonly FILTER_POISSONSAMPLING: number;
  97909. /**
  97910. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  97911. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97912. */
  97913. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  97914. /**
  97915. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  97916. * edge artifacts on steep falloff.
  97917. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97918. */
  97919. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  97920. /**
  97921. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  97922. * edge artifacts on steep falloff.
  97923. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97924. */
  97925. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  97926. /**
  97927. * Shadow generator mode PCF: Percentage Closer Filtering
  97928. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97929. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  97930. */
  97931. static readonly FILTER_PCF: number;
  97932. /**
  97933. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  97934. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97935. * Contact Hardening
  97936. */
  97937. static readonly FILTER_PCSS: number;
  97938. /**
  97939. * Reserved for PCF and PCSS
  97940. * Highest Quality.
  97941. *
  97942. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  97943. *
  97944. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  97945. */
  97946. static readonly QUALITY_HIGH: number;
  97947. /**
  97948. * Reserved for PCF and PCSS
  97949. * Good tradeoff for quality/perf cross devices
  97950. *
  97951. * Execute PCF on a 3*3 kernel.
  97952. *
  97953. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  97954. */
  97955. static readonly QUALITY_MEDIUM: number;
  97956. /**
  97957. * Reserved for PCF and PCSS
  97958. * The lowest quality but the fastest.
  97959. *
  97960. * Execute PCF on a 1*1 kernel.
  97961. *
  97962. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  97963. */
  97964. static readonly QUALITY_LOW: number;
  97965. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97966. id: string;
  97967. /** Gets or sets the custom shader name to use */
  97968. customShaderOptions: ICustomShaderOptions;
  97969. /**
  97970. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  97971. */
  97972. onBeforeShadowMapRenderObservable: Observable<Effect>;
  97973. /**
  97974. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  97975. */
  97976. onAfterShadowMapRenderObservable: Observable<Effect>;
  97977. /**
  97978. * Observable triggered before a mesh is rendered in the shadow map.
  97979. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  97980. */
  97981. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  97982. /**
  97983. * Observable triggered after a mesh is rendered in the shadow map.
  97984. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  97985. */
  97986. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  97987. protected _bias: number;
  97988. /**
  97989. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  97990. */
  97991. get bias(): number;
  97992. /**
  97993. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  97994. */
  97995. set bias(bias: number);
  97996. protected _normalBias: number;
  97997. /**
  97998. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97999. */
  98000. get normalBias(): number;
  98001. /**
  98002. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98003. */
  98004. set normalBias(normalBias: number);
  98005. protected _blurBoxOffset: number;
  98006. /**
  98007. * Gets the blur box offset: offset applied during the blur pass.
  98008. * Only useful if useKernelBlur = false
  98009. */
  98010. get blurBoxOffset(): number;
  98011. /**
  98012. * Sets the blur box offset: offset applied during the blur pass.
  98013. * Only useful if useKernelBlur = false
  98014. */
  98015. set blurBoxOffset(value: number);
  98016. protected _blurScale: number;
  98017. /**
  98018. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  98019. * 2 means half of the size.
  98020. */
  98021. get blurScale(): number;
  98022. /**
  98023. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  98024. * 2 means half of the size.
  98025. */
  98026. set blurScale(value: number);
  98027. protected _blurKernel: number;
  98028. /**
  98029. * Gets the blur kernel: kernel size of the blur pass.
  98030. * Only useful if useKernelBlur = true
  98031. */
  98032. get blurKernel(): number;
  98033. /**
  98034. * Sets the blur kernel: kernel size of the blur pass.
  98035. * Only useful if useKernelBlur = true
  98036. */
  98037. set blurKernel(value: number);
  98038. protected _useKernelBlur: boolean;
  98039. /**
  98040. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  98041. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98042. */
  98043. get useKernelBlur(): boolean;
  98044. /**
  98045. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  98046. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98047. */
  98048. set useKernelBlur(value: boolean);
  98049. protected _depthScale: number;
  98050. /**
  98051. * Gets the depth scale used in ESM mode.
  98052. */
  98053. get depthScale(): number;
  98054. /**
  98055. * Sets the depth scale used in ESM mode.
  98056. * This can override the scale stored on the light.
  98057. */
  98058. set depthScale(value: number);
  98059. protected _validateFilter(filter: number): number;
  98060. protected _filter: number;
  98061. /**
  98062. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  98063. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98064. */
  98065. get filter(): number;
  98066. /**
  98067. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  98068. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98069. */
  98070. set filter(value: number);
  98071. /**
  98072. * Gets if the current filter is set to Poisson Sampling.
  98073. */
  98074. get usePoissonSampling(): boolean;
  98075. /**
  98076. * Sets the current filter to Poisson Sampling.
  98077. */
  98078. set usePoissonSampling(value: boolean);
  98079. /**
  98080. * Gets if the current filter is set to ESM.
  98081. */
  98082. get useExponentialShadowMap(): boolean;
  98083. /**
  98084. * Sets the current filter is to ESM.
  98085. */
  98086. set useExponentialShadowMap(value: boolean);
  98087. /**
  98088. * Gets if the current filter is set to filtered ESM.
  98089. */
  98090. get useBlurExponentialShadowMap(): boolean;
  98091. /**
  98092. * Gets if the current filter is set to filtered ESM.
  98093. */
  98094. set useBlurExponentialShadowMap(value: boolean);
  98095. /**
  98096. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98097. * exponential to prevent steep falloff artifacts).
  98098. */
  98099. get useCloseExponentialShadowMap(): boolean;
  98100. /**
  98101. * Sets the current filter to "close ESM" (using the inverse of the
  98102. * exponential to prevent steep falloff artifacts).
  98103. */
  98104. set useCloseExponentialShadowMap(value: boolean);
  98105. /**
  98106. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98107. * exponential to prevent steep falloff artifacts).
  98108. */
  98109. get useBlurCloseExponentialShadowMap(): boolean;
  98110. /**
  98111. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98112. * exponential to prevent steep falloff artifacts).
  98113. */
  98114. set useBlurCloseExponentialShadowMap(value: boolean);
  98115. /**
  98116. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  98117. */
  98118. get usePercentageCloserFiltering(): boolean;
  98119. /**
  98120. * Sets the current filter to "PCF" (percentage closer filtering).
  98121. */
  98122. set usePercentageCloserFiltering(value: boolean);
  98123. protected _filteringQuality: number;
  98124. /**
  98125. * Gets the PCF or PCSS Quality.
  98126. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98127. */
  98128. get filteringQuality(): number;
  98129. /**
  98130. * Sets the PCF or PCSS Quality.
  98131. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98132. */
  98133. set filteringQuality(filteringQuality: number);
  98134. /**
  98135. * Gets if the current filter is set to "PCSS" (contact hardening).
  98136. */
  98137. get useContactHardeningShadow(): boolean;
  98138. /**
  98139. * Sets the current filter to "PCSS" (contact hardening).
  98140. */
  98141. set useContactHardeningShadow(value: boolean);
  98142. protected _contactHardeningLightSizeUVRatio: number;
  98143. /**
  98144. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98145. * Using a ratio helps keeping shape stability independently of the map size.
  98146. *
  98147. * It does not account for the light projection as it was having too much
  98148. * instability during the light setup or during light position changes.
  98149. *
  98150. * Only valid if useContactHardeningShadow is true.
  98151. */
  98152. get contactHardeningLightSizeUVRatio(): number;
  98153. /**
  98154. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98155. * Using a ratio helps keeping shape stability independently of the map size.
  98156. *
  98157. * It does not account for the light projection as it was having too much
  98158. * instability during the light setup or during light position changes.
  98159. *
  98160. * Only valid if useContactHardeningShadow is true.
  98161. */
  98162. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  98163. protected _darkness: number;
  98164. /** Gets or sets the actual darkness of a shadow */
  98165. get darkness(): number;
  98166. set darkness(value: number);
  98167. /**
  98168. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  98169. * 0 means strongest and 1 would means no shadow.
  98170. * @returns the darkness.
  98171. */
  98172. getDarkness(): number;
  98173. /**
  98174. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  98175. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  98176. * @returns the shadow generator allowing fluent coding.
  98177. */
  98178. setDarkness(darkness: number): ShadowGenerator;
  98179. protected _transparencyShadow: boolean;
  98180. /** Gets or sets the ability to have transparent shadow */
  98181. get transparencyShadow(): boolean;
  98182. set transparencyShadow(value: boolean);
  98183. /**
  98184. * Sets the ability to have transparent shadow (boolean).
  98185. * @param transparent True if transparent else False
  98186. * @returns the shadow generator allowing fluent coding
  98187. */
  98188. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  98189. /**
  98190. * Enables or disables shadows with varying strength based on the transparency
  98191. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  98192. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  98193. * mesh.visibility * alphaTexture.a
  98194. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  98195. */
  98196. enableSoftTransparentShadow: boolean;
  98197. protected _shadowMap: Nullable<RenderTargetTexture>;
  98198. protected _shadowMap2: Nullable<RenderTargetTexture>;
  98199. /**
  98200. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98201. * @returns The render target texture if present otherwise, null
  98202. */
  98203. getShadowMap(): Nullable<RenderTargetTexture>;
  98204. /**
  98205. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  98206. * @returns The render target texture if the shadow map is present otherwise, null
  98207. */
  98208. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  98209. /**
  98210. * Gets the class name of that object
  98211. * @returns "ShadowGenerator"
  98212. */
  98213. getClassName(): string;
  98214. /**
  98215. * Helper function to add a mesh and its descendants to the list of shadow casters.
  98216. * @param mesh Mesh to add
  98217. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  98218. * @returns the Shadow Generator itself
  98219. */
  98220. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98221. /**
  98222. * Helper function to remove a mesh and its descendants from the list of shadow casters
  98223. * @param mesh Mesh to remove
  98224. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  98225. * @returns the Shadow Generator itself
  98226. */
  98227. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98228. /**
  98229. * Controls the extent to which the shadows fade out at the edge of the frustum
  98230. */
  98231. frustumEdgeFalloff: number;
  98232. protected _light: IShadowLight;
  98233. /**
  98234. * Returns the associated light object.
  98235. * @returns the light generating the shadow
  98236. */
  98237. getLight(): IShadowLight;
  98238. /**
  98239. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  98240. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  98241. * It might on the other hand introduce peter panning.
  98242. */
  98243. forceBackFacesOnly: boolean;
  98244. protected _scene: Scene;
  98245. protected _lightDirection: Vector3;
  98246. protected _effect: Effect;
  98247. protected _viewMatrix: Matrix;
  98248. protected _projectionMatrix: Matrix;
  98249. protected _transformMatrix: Matrix;
  98250. protected _cachedPosition: Vector3;
  98251. protected _cachedDirection: Vector3;
  98252. protected _cachedDefines: string;
  98253. protected _currentRenderID: number;
  98254. protected _boxBlurPostprocess: Nullable<PostProcess>;
  98255. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  98256. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  98257. protected _blurPostProcesses: PostProcess[];
  98258. protected _mapSize: number;
  98259. protected _currentFaceIndex: number;
  98260. protected _currentFaceIndexCache: number;
  98261. protected _textureType: number;
  98262. protected _defaultTextureMatrix: Matrix;
  98263. protected _storedUniqueId: Nullable<number>;
  98264. /** @hidden */
  98265. static _SceneComponentInitialization: (scene: Scene) => void;
  98266. /**
  98267. * Creates a ShadowGenerator object.
  98268. * A ShadowGenerator is the required tool to use the shadows.
  98269. * Each light casting shadows needs to use its own ShadowGenerator.
  98270. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  98271. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  98272. * @param light The light object generating the shadows.
  98273. * @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.
  98274. */
  98275. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  98276. protected _initializeGenerator(): void;
  98277. protected _createTargetRenderTexture(): void;
  98278. protected _initializeShadowMap(): void;
  98279. protected _initializeBlurRTTAndPostProcesses(): void;
  98280. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  98281. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  98282. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  98283. protected _applyFilterValues(): void;
  98284. /**
  98285. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98286. * @param onCompiled Callback triggered at the and of the effects compilation
  98287. * @param options Sets of optional options forcing the compilation with different modes
  98288. */
  98289. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98290. useInstances: boolean;
  98291. }>): void;
  98292. /**
  98293. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98294. * @param options Sets of optional options forcing the compilation with different modes
  98295. * @returns A promise that resolves when the compilation completes
  98296. */
  98297. forceCompilationAsync(options?: Partial<{
  98298. useInstances: boolean;
  98299. }>): Promise<void>;
  98300. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  98301. private _prepareShadowDefines;
  98302. /**
  98303. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98304. * @param subMesh The submesh we want to render in the shadow map
  98305. * @param useInstances Defines wether will draw in the map using instances
  98306. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98307. * @returns true if ready otherwise, false
  98308. */
  98309. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98310. /**
  98311. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98312. * @param defines Defines of the material we want to update
  98313. * @param lightIndex Index of the light in the enabled light list of the material
  98314. */
  98315. prepareDefines(defines: any, lightIndex: number): void;
  98316. /**
  98317. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98318. * defined in the generator but impacting the effect).
  98319. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98320. * @param effect The effect we are binfing the information for
  98321. */
  98322. bindShadowLight(lightIndex: string, effect: Effect): void;
  98323. /**
  98324. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98325. * (eq to shadow prjection matrix * light transform matrix)
  98326. * @returns The transform matrix used to create the shadow map
  98327. */
  98328. getTransformMatrix(): Matrix;
  98329. /**
  98330. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98331. * Cube and 2D textures for instance.
  98332. */
  98333. recreateShadowMap(): void;
  98334. protected _disposeBlurPostProcesses(): void;
  98335. protected _disposeRTTandPostProcesses(): void;
  98336. /**
  98337. * Disposes the ShadowGenerator.
  98338. * Returns nothing.
  98339. */
  98340. dispose(): void;
  98341. /**
  98342. * Serializes the shadow generator setup to a json object.
  98343. * @returns The serialized JSON object
  98344. */
  98345. serialize(): any;
  98346. /**
  98347. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  98348. * @param parsedShadowGenerator The JSON object to parse
  98349. * @param scene The scene to create the shadow map for
  98350. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  98351. * @returns The parsed shadow generator
  98352. */
  98353. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  98354. }
  98355. }
  98356. declare module BABYLON {
  98357. /**
  98358. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  98359. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  98360. * 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.
  98361. */
  98362. export abstract class Light extends Node {
  98363. /**
  98364. * Falloff Default: light is falling off following the material specification:
  98365. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  98366. */
  98367. static readonly FALLOFF_DEFAULT: number;
  98368. /**
  98369. * Falloff Physical: light is falling off following the inverse squared distance law.
  98370. */
  98371. static readonly FALLOFF_PHYSICAL: number;
  98372. /**
  98373. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  98374. * to enhance interoperability with other engines.
  98375. */
  98376. static readonly FALLOFF_GLTF: number;
  98377. /**
  98378. * Falloff Standard: light is falling off like in the standard material
  98379. * to enhance interoperability with other materials.
  98380. */
  98381. static readonly FALLOFF_STANDARD: number;
  98382. /**
  98383. * If every light affecting the material is in this lightmapMode,
  98384. * material.lightmapTexture adds or multiplies
  98385. * (depends on material.useLightmapAsShadowmap)
  98386. * after every other light calculations.
  98387. */
  98388. static readonly LIGHTMAP_DEFAULT: number;
  98389. /**
  98390. * material.lightmapTexture as only diffuse lighting from this light
  98391. * adds only specular lighting from this light
  98392. * adds dynamic shadows
  98393. */
  98394. static readonly LIGHTMAP_SPECULAR: number;
  98395. /**
  98396. * material.lightmapTexture as only lighting
  98397. * no light calculation from this light
  98398. * only adds dynamic shadows from this light
  98399. */
  98400. static readonly LIGHTMAP_SHADOWSONLY: number;
  98401. /**
  98402. * Each light type uses the default quantity according to its type:
  98403. * point/spot lights use luminous intensity
  98404. * directional lights use illuminance
  98405. */
  98406. static readonly INTENSITYMODE_AUTOMATIC: number;
  98407. /**
  98408. * lumen (lm)
  98409. */
  98410. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  98411. /**
  98412. * candela (lm/sr)
  98413. */
  98414. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  98415. /**
  98416. * lux (lm/m^2)
  98417. */
  98418. static readonly INTENSITYMODE_ILLUMINANCE: number;
  98419. /**
  98420. * nit (cd/m^2)
  98421. */
  98422. static readonly INTENSITYMODE_LUMINANCE: number;
  98423. /**
  98424. * Light type const id of the point light.
  98425. */
  98426. static readonly LIGHTTYPEID_POINTLIGHT: number;
  98427. /**
  98428. * Light type const id of the directional light.
  98429. */
  98430. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  98431. /**
  98432. * Light type const id of the spot light.
  98433. */
  98434. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  98435. /**
  98436. * Light type const id of the hemispheric light.
  98437. */
  98438. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  98439. /**
  98440. * Diffuse gives the basic color to an object.
  98441. */
  98442. diffuse: Color3;
  98443. /**
  98444. * Specular produces a highlight color on an object.
  98445. * Note: This is note affecting PBR materials.
  98446. */
  98447. specular: Color3;
  98448. /**
  98449. * Defines the falloff type for this light. This lets overrriding how punctual light are
  98450. * falling off base on range or angle.
  98451. * This can be set to any values in Light.FALLOFF_x.
  98452. *
  98453. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  98454. * other types of materials.
  98455. */
  98456. falloffType: number;
  98457. /**
  98458. * Strength of the light.
  98459. * Note: By default it is define in the framework own unit.
  98460. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  98461. */
  98462. intensity: number;
  98463. private _range;
  98464. protected _inverseSquaredRange: number;
  98465. /**
  98466. * Defines how far from the source the light is impacting in scene units.
  98467. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98468. */
  98469. get range(): number;
  98470. /**
  98471. * Defines how far from the source the light is impacting in scene units.
  98472. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98473. */
  98474. set range(value: number);
  98475. /**
  98476. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  98477. * of light.
  98478. */
  98479. private _photometricScale;
  98480. private _intensityMode;
  98481. /**
  98482. * Gets the photometric scale used to interpret the intensity.
  98483. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98484. */
  98485. get intensityMode(): number;
  98486. /**
  98487. * Sets the photometric scale used to interpret the intensity.
  98488. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98489. */
  98490. set intensityMode(value: number);
  98491. private _radius;
  98492. /**
  98493. * Gets the light radius used by PBR Materials to simulate soft area lights.
  98494. */
  98495. get radius(): number;
  98496. /**
  98497. * sets the light radius used by PBR Materials to simulate soft area lights.
  98498. */
  98499. set radius(value: number);
  98500. private _renderPriority;
  98501. /**
  98502. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  98503. * exceeding the number allowed of the materials.
  98504. */
  98505. renderPriority: number;
  98506. private _shadowEnabled;
  98507. /**
  98508. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98509. * the current shadow generator.
  98510. */
  98511. get shadowEnabled(): boolean;
  98512. /**
  98513. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98514. * the current shadow generator.
  98515. */
  98516. set shadowEnabled(value: boolean);
  98517. private _includedOnlyMeshes;
  98518. /**
  98519. * Gets the only meshes impacted by this light.
  98520. */
  98521. get includedOnlyMeshes(): AbstractMesh[];
  98522. /**
  98523. * Sets the only meshes impacted by this light.
  98524. */
  98525. set includedOnlyMeshes(value: AbstractMesh[]);
  98526. private _excludedMeshes;
  98527. /**
  98528. * Gets the meshes not impacted by this light.
  98529. */
  98530. get excludedMeshes(): AbstractMesh[];
  98531. /**
  98532. * Sets the meshes not impacted by this light.
  98533. */
  98534. set excludedMeshes(value: AbstractMesh[]);
  98535. private _excludeWithLayerMask;
  98536. /**
  98537. * Gets the layer id use to find what meshes are not impacted by the light.
  98538. * Inactive if 0
  98539. */
  98540. get excludeWithLayerMask(): number;
  98541. /**
  98542. * Sets the layer id use to find what meshes are not impacted by the light.
  98543. * Inactive if 0
  98544. */
  98545. set excludeWithLayerMask(value: number);
  98546. private _includeOnlyWithLayerMask;
  98547. /**
  98548. * Gets the layer id use to find what meshes are impacted by the light.
  98549. * Inactive if 0
  98550. */
  98551. get includeOnlyWithLayerMask(): number;
  98552. /**
  98553. * Sets the layer id use to find what meshes are impacted by the light.
  98554. * Inactive if 0
  98555. */
  98556. set includeOnlyWithLayerMask(value: number);
  98557. private _lightmapMode;
  98558. /**
  98559. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98560. */
  98561. get lightmapMode(): number;
  98562. /**
  98563. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98564. */
  98565. set lightmapMode(value: number);
  98566. /**
  98567. * Shadow generator associted to the light.
  98568. * @hidden Internal use only.
  98569. */
  98570. _shadowGenerator: Nullable<IShadowGenerator>;
  98571. /**
  98572. * @hidden Internal use only.
  98573. */
  98574. _excludedMeshesIds: string[];
  98575. /**
  98576. * @hidden Internal use only.
  98577. */
  98578. _includedOnlyMeshesIds: string[];
  98579. /**
  98580. * The current light unifom buffer.
  98581. * @hidden Internal use only.
  98582. */
  98583. _uniformBuffer: UniformBuffer;
  98584. /** @hidden */
  98585. _renderId: number;
  98586. /**
  98587. * Creates a Light object in the scene.
  98588. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98589. * @param name The firendly name of the light
  98590. * @param scene The scene the light belongs too
  98591. */
  98592. constructor(name: string, scene: Scene);
  98593. protected abstract _buildUniformLayout(): void;
  98594. /**
  98595. * Sets the passed Effect "effect" with the Light information.
  98596. * @param effect The effect to update
  98597. * @param lightIndex The index of the light in the effect to update
  98598. * @returns The light
  98599. */
  98600. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  98601. /**
  98602. * Sets the passed Effect "effect" with the Light textures.
  98603. * @param effect The effect to update
  98604. * @param lightIndex The index of the light in the effect to update
  98605. * @returns The light
  98606. */
  98607. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  98608. /**
  98609. * Binds the lights information from the scene to the effect for the given mesh.
  98610. * @param lightIndex Light index
  98611. * @param scene The scene where the light belongs to
  98612. * @param effect The effect we are binding the data to
  98613. * @param useSpecular Defines if specular is supported
  98614. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98615. */
  98616. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98617. /**
  98618. * Sets the passed Effect "effect" with the Light information.
  98619. * @param effect The effect to update
  98620. * @param lightDataUniformName The uniform used to store light data (position or direction)
  98621. * @returns The light
  98622. */
  98623. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  98624. /**
  98625. * Returns the string "Light".
  98626. * @returns the class name
  98627. */
  98628. getClassName(): string;
  98629. /** @hidden */
  98630. readonly _isLight: boolean;
  98631. /**
  98632. * Converts the light information to a readable string for debug purpose.
  98633. * @param fullDetails Supports for multiple levels of logging within scene loading
  98634. * @returns the human readable light info
  98635. */
  98636. toString(fullDetails?: boolean): string;
  98637. /** @hidden */
  98638. protected _syncParentEnabledState(): void;
  98639. /**
  98640. * Set the enabled state of this node.
  98641. * @param value - the new enabled state
  98642. */
  98643. setEnabled(value: boolean): void;
  98644. /**
  98645. * Returns the Light associated shadow generator if any.
  98646. * @return the associated shadow generator.
  98647. */
  98648. getShadowGenerator(): Nullable<IShadowGenerator>;
  98649. /**
  98650. * Returns a Vector3, the absolute light position in the World.
  98651. * @returns the world space position of the light
  98652. */
  98653. getAbsolutePosition(): Vector3;
  98654. /**
  98655. * Specifies if the light will affect the passed mesh.
  98656. * @param mesh The mesh to test against the light
  98657. * @return true the mesh is affected otherwise, false.
  98658. */
  98659. canAffectMesh(mesh: AbstractMesh): boolean;
  98660. /**
  98661. * Sort function to order lights for rendering.
  98662. * @param a First Light object to compare to second.
  98663. * @param b Second Light object to compare first.
  98664. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  98665. */
  98666. static CompareLightsPriority(a: Light, b: Light): number;
  98667. /**
  98668. * Releases resources associated with this node.
  98669. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98670. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98671. */
  98672. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98673. /**
  98674. * Returns the light type ID (integer).
  98675. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98676. */
  98677. getTypeID(): number;
  98678. /**
  98679. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  98680. * @returns the scaled intensity in intensity mode unit
  98681. */
  98682. getScaledIntensity(): number;
  98683. /**
  98684. * Returns a new Light object, named "name", from the current one.
  98685. * @param name The name of the cloned light
  98686. * @param newParent The parent of this light, if it has one
  98687. * @returns the new created light
  98688. */
  98689. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  98690. /**
  98691. * Serializes the current light into a Serialization object.
  98692. * @returns the serialized object.
  98693. */
  98694. serialize(): any;
  98695. /**
  98696. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  98697. * This new light is named "name" and added to the passed scene.
  98698. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  98699. * @param name The friendly name of the light
  98700. * @param scene The scene the new light will belong to
  98701. * @returns the constructor function
  98702. */
  98703. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  98704. /**
  98705. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  98706. * @param parsedLight The JSON representation of the light
  98707. * @param scene The scene to create the parsed light in
  98708. * @returns the created light after parsing
  98709. */
  98710. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  98711. private _hookArrayForExcluded;
  98712. private _hookArrayForIncludedOnly;
  98713. private _resyncMeshes;
  98714. /**
  98715. * Forces the meshes to update their light related information in their rendering used effects
  98716. * @hidden Internal Use Only
  98717. */
  98718. _markMeshesAsLightDirty(): void;
  98719. /**
  98720. * Recomputes the cached photometric scale if needed.
  98721. */
  98722. private _computePhotometricScale;
  98723. /**
  98724. * Returns the Photometric Scale according to the light type and intensity mode.
  98725. */
  98726. private _getPhotometricScale;
  98727. /**
  98728. * Reorder the light in the scene according to their defined priority.
  98729. * @hidden Internal Use Only
  98730. */
  98731. _reorderLightsInScene(): void;
  98732. /**
  98733. * Prepares the list of defines specific to the light type.
  98734. * @param defines the list of defines
  98735. * @param lightIndex defines the index of the light for the effect
  98736. */
  98737. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98738. }
  98739. }
  98740. declare module BABYLON {
  98741. /**
  98742. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  98743. * This is the base of the follow, arc rotate cameras and Free camera
  98744. * @see https://doc.babylonjs.com/features/cameras
  98745. */
  98746. export class TargetCamera extends Camera {
  98747. private static _RigCamTransformMatrix;
  98748. private static _TargetTransformMatrix;
  98749. private static _TargetFocalPoint;
  98750. private _tmpUpVector;
  98751. private _tmpTargetVector;
  98752. /**
  98753. * Define the current direction the camera is moving to
  98754. */
  98755. cameraDirection: Vector3;
  98756. /**
  98757. * Define the current rotation the camera is rotating to
  98758. */
  98759. cameraRotation: Vector2;
  98760. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  98761. ignoreParentScaling: boolean;
  98762. /**
  98763. * When set, the up vector of the camera will be updated by the rotation of the camera
  98764. */
  98765. updateUpVectorFromRotation: boolean;
  98766. private _tmpQuaternion;
  98767. /**
  98768. * Define the current rotation of the camera
  98769. */
  98770. rotation: Vector3;
  98771. /**
  98772. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  98773. */
  98774. rotationQuaternion: Quaternion;
  98775. /**
  98776. * Define the current speed of the camera
  98777. */
  98778. speed: number;
  98779. /**
  98780. * Add constraint to the camera to prevent it to move freely in all directions and
  98781. * around all axis.
  98782. */
  98783. noRotationConstraint: boolean;
  98784. /**
  98785. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  98786. * panning
  98787. */
  98788. invertRotation: boolean;
  98789. /**
  98790. * Speed multiplier for inverse camera panning
  98791. */
  98792. inverseRotationSpeed: number;
  98793. /**
  98794. * Define the current target of the camera as an object or a position.
  98795. */
  98796. lockedTarget: any;
  98797. /** @hidden */
  98798. _currentTarget: Vector3;
  98799. /** @hidden */
  98800. _initialFocalDistance: number;
  98801. /** @hidden */
  98802. _viewMatrix: Matrix;
  98803. /** @hidden */
  98804. _camMatrix: Matrix;
  98805. /** @hidden */
  98806. _cameraTransformMatrix: Matrix;
  98807. /** @hidden */
  98808. _cameraRotationMatrix: Matrix;
  98809. /** @hidden */
  98810. _referencePoint: Vector3;
  98811. /** @hidden */
  98812. _transformedReferencePoint: Vector3;
  98813. /** @hidden */
  98814. _reset: () => void;
  98815. private _defaultUp;
  98816. /**
  98817. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  98818. * This is the base of the follow, arc rotate cameras and Free camera
  98819. * @see https://doc.babylonjs.com/features/cameras
  98820. * @param name Defines the name of the camera in the scene
  98821. * @param position Defines the start position of the camera in the scene
  98822. * @param scene Defines the scene the camera belongs to
  98823. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98824. */
  98825. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98826. /**
  98827. * Gets the position in front of the camera at a given distance.
  98828. * @param distance The distance from the camera we want the position to be
  98829. * @returns the position
  98830. */
  98831. getFrontPosition(distance: number): Vector3;
  98832. /** @hidden */
  98833. _getLockedTargetPosition(): Nullable<Vector3>;
  98834. private _storedPosition;
  98835. private _storedRotation;
  98836. private _storedRotationQuaternion;
  98837. /**
  98838. * Store current camera state of the camera (fov, position, rotation, etc..)
  98839. * @returns the camera
  98840. */
  98841. storeState(): Camera;
  98842. /**
  98843. * Restored camera state. You must call storeState() first
  98844. * @returns whether it was successful or not
  98845. * @hidden
  98846. */
  98847. _restoreStateValues(): boolean;
  98848. /** @hidden */
  98849. _initCache(): void;
  98850. /** @hidden */
  98851. _updateCache(ignoreParentClass?: boolean): void;
  98852. /** @hidden */
  98853. _isSynchronizedViewMatrix(): boolean;
  98854. /** @hidden */
  98855. _computeLocalCameraSpeed(): number;
  98856. /**
  98857. * Defines the target the camera should look at.
  98858. * @param target Defines the new target as a Vector or a mesh
  98859. */
  98860. setTarget(target: Vector3): void;
  98861. /**
  98862. * Defines the target point of the camera.
  98863. * The camera looks towards it form the radius distance.
  98864. */
  98865. get target(): Vector3;
  98866. set target(value: Vector3);
  98867. /**
  98868. * Return the current target position of the camera. This value is expressed in local space.
  98869. * @returns the target position
  98870. */
  98871. getTarget(): Vector3;
  98872. /** @hidden */
  98873. _decideIfNeedsToMove(): boolean;
  98874. /** @hidden */
  98875. _updatePosition(): void;
  98876. /** @hidden */
  98877. _checkInputs(): void;
  98878. protected _updateCameraRotationMatrix(): void;
  98879. /**
  98880. * 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)
  98881. * @returns the current camera
  98882. */
  98883. private _rotateUpVectorWithCameraRotationMatrix;
  98884. private _cachedRotationZ;
  98885. private _cachedQuaternionRotationZ;
  98886. /** @hidden */
  98887. _getViewMatrix(): Matrix;
  98888. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  98889. /**
  98890. * @hidden
  98891. */
  98892. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  98893. /**
  98894. * @hidden
  98895. */
  98896. _updateRigCameras(): void;
  98897. private _getRigCamPositionAndTarget;
  98898. /**
  98899. * Gets the current object class name.
  98900. * @return the class name
  98901. */
  98902. getClassName(): string;
  98903. }
  98904. }
  98905. declare module BABYLON {
  98906. /**
  98907. * Gather the list of keyboard event types as constants.
  98908. */
  98909. export class KeyboardEventTypes {
  98910. /**
  98911. * The keydown event is fired when a key becomes active (pressed).
  98912. */
  98913. static readonly KEYDOWN: number;
  98914. /**
  98915. * The keyup event is fired when a key has been released.
  98916. */
  98917. static readonly KEYUP: number;
  98918. }
  98919. /**
  98920. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98921. */
  98922. export class KeyboardInfo {
  98923. /**
  98924. * Defines the type of event (KeyboardEventTypes)
  98925. */
  98926. type: number;
  98927. /**
  98928. * Defines the related dom event
  98929. */
  98930. event: KeyboardEvent;
  98931. /**
  98932. * Instantiates a new keyboard info.
  98933. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98934. * @param type Defines the type of event (KeyboardEventTypes)
  98935. * @param event Defines the related dom event
  98936. */
  98937. constructor(
  98938. /**
  98939. * Defines the type of event (KeyboardEventTypes)
  98940. */
  98941. type: number,
  98942. /**
  98943. * Defines the related dom event
  98944. */
  98945. event: KeyboardEvent);
  98946. }
  98947. /**
  98948. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98949. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  98950. */
  98951. export class KeyboardInfoPre extends KeyboardInfo {
  98952. /**
  98953. * Defines the type of event (KeyboardEventTypes)
  98954. */
  98955. type: number;
  98956. /**
  98957. * Defines the related dom event
  98958. */
  98959. event: KeyboardEvent;
  98960. /**
  98961. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  98962. */
  98963. skipOnPointerObservable: boolean;
  98964. /**
  98965. * Instantiates a new keyboard pre info.
  98966. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98967. * @param type Defines the type of event (KeyboardEventTypes)
  98968. * @param event Defines the related dom event
  98969. */
  98970. constructor(
  98971. /**
  98972. * Defines the type of event (KeyboardEventTypes)
  98973. */
  98974. type: number,
  98975. /**
  98976. * Defines the related dom event
  98977. */
  98978. event: KeyboardEvent);
  98979. }
  98980. }
  98981. declare module BABYLON {
  98982. /**
  98983. * Manage the keyboard inputs to control the movement of a free camera.
  98984. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98985. */
  98986. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  98987. /**
  98988. * Defines the camera the input is attached to.
  98989. */
  98990. camera: FreeCamera;
  98991. /**
  98992. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98993. */
  98994. keysUp: number[];
  98995. /**
  98996. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98997. */
  98998. keysUpward: number[];
  98999. /**
  99000. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99001. */
  99002. keysDown: number[];
  99003. /**
  99004. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99005. */
  99006. keysDownward: number[];
  99007. /**
  99008. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99009. */
  99010. keysLeft: number[];
  99011. /**
  99012. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99013. */
  99014. keysRight: number[];
  99015. private _keys;
  99016. private _onCanvasBlurObserver;
  99017. private _onKeyboardObserver;
  99018. private _engine;
  99019. private _scene;
  99020. /**
  99021. * Attach the input controls to a specific dom element to get the input from.
  99022. * @param element Defines the element the controls should be listened from
  99023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99024. */
  99025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99026. /**
  99027. * Detach the current controls from the specified dom element.
  99028. * @param element Defines the element to stop listening the inputs from
  99029. */
  99030. detachControl(element: Nullable<HTMLElement>): void;
  99031. /**
  99032. * Update the current camera state depending on the inputs that have been used this frame.
  99033. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99034. */
  99035. checkInputs(): void;
  99036. /**
  99037. * Gets the class name of the current intput.
  99038. * @returns the class name
  99039. */
  99040. getClassName(): string;
  99041. /** @hidden */
  99042. _onLostFocus(): void;
  99043. /**
  99044. * Get the friendly name associated with the input class.
  99045. * @returns the input friendly name
  99046. */
  99047. getSimpleName(): string;
  99048. }
  99049. }
  99050. declare module BABYLON {
  99051. /**
  99052. * Gather the list of pointer event types as constants.
  99053. */
  99054. export class PointerEventTypes {
  99055. /**
  99056. * 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.
  99057. */
  99058. static readonly POINTERDOWN: number;
  99059. /**
  99060. * The pointerup event is fired when a pointer is no longer active.
  99061. */
  99062. static readonly POINTERUP: number;
  99063. /**
  99064. * The pointermove event is fired when a pointer changes coordinates.
  99065. */
  99066. static readonly POINTERMOVE: number;
  99067. /**
  99068. * The pointerwheel event is fired when a mouse wheel has been rotated.
  99069. */
  99070. static readonly POINTERWHEEL: number;
  99071. /**
  99072. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  99073. */
  99074. static readonly POINTERPICK: number;
  99075. /**
  99076. * The pointertap event is fired when a the object has been touched and released without drag.
  99077. */
  99078. static readonly POINTERTAP: number;
  99079. /**
  99080. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  99081. */
  99082. static readonly POINTERDOUBLETAP: number;
  99083. }
  99084. /**
  99085. * Base class of pointer info types.
  99086. */
  99087. export class PointerInfoBase {
  99088. /**
  99089. * Defines the type of event (PointerEventTypes)
  99090. */
  99091. type: number;
  99092. /**
  99093. * Defines the related dom event
  99094. */
  99095. event: PointerEvent | MouseWheelEvent;
  99096. /**
  99097. * Instantiates the base class of pointers info.
  99098. * @param type Defines the type of event (PointerEventTypes)
  99099. * @param event Defines the related dom event
  99100. */
  99101. constructor(
  99102. /**
  99103. * Defines the type of event (PointerEventTypes)
  99104. */
  99105. type: number,
  99106. /**
  99107. * Defines the related dom event
  99108. */
  99109. event: PointerEvent | MouseWheelEvent);
  99110. }
  99111. /**
  99112. * This class is used to store pointer related info for the onPrePointerObservable event.
  99113. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  99114. */
  99115. export class PointerInfoPre extends PointerInfoBase {
  99116. /**
  99117. * Ray from a pointer if availible (eg. 6dof controller)
  99118. */
  99119. ray: Nullable<Ray>;
  99120. /**
  99121. * Defines the local position of the pointer on the canvas.
  99122. */
  99123. localPosition: Vector2;
  99124. /**
  99125. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  99126. */
  99127. skipOnPointerObservable: boolean;
  99128. /**
  99129. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  99130. * @param type Defines the type of event (PointerEventTypes)
  99131. * @param event Defines the related dom event
  99132. * @param localX Defines the local x coordinates of the pointer when the event occured
  99133. * @param localY Defines the local y coordinates of the pointer when the event occured
  99134. */
  99135. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  99136. }
  99137. /**
  99138. * This type contains all the data related to a pointer event in Babylon.js.
  99139. * 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.
  99140. */
  99141. export class PointerInfo extends PointerInfoBase {
  99142. /**
  99143. * Defines the picking info associated to the info (if any)\
  99144. */
  99145. pickInfo: Nullable<PickingInfo>;
  99146. /**
  99147. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  99148. * @param type Defines the type of event (PointerEventTypes)
  99149. * @param event Defines the related dom event
  99150. * @param pickInfo Defines the picking info associated to the info (if any)\
  99151. */
  99152. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  99153. /**
  99154. * Defines the picking info associated to the info (if any)\
  99155. */
  99156. pickInfo: Nullable<PickingInfo>);
  99157. }
  99158. /**
  99159. * Data relating to a touch event on the screen.
  99160. */
  99161. export interface PointerTouch {
  99162. /**
  99163. * X coordinate of touch.
  99164. */
  99165. x: number;
  99166. /**
  99167. * Y coordinate of touch.
  99168. */
  99169. y: number;
  99170. /**
  99171. * Id of touch. Unique for each finger.
  99172. */
  99173. pointerId: number;
  99174. /**
  99175. * Event type passed from DOM.
  99176. */
  99177. type: any;
  99178. }
  99179. }
  99180. declare module BABYLON {
  99181. /**
  99182. * Manage the mouse inputs to control the movement of a free camera.
  99183. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99184. */
  99185. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  99186. /**
  99187. * Define if touch is enabled in the mouse input
  99188. */
  99189. touchEnabled: boolean;
  99190. /**
  99191. * Defines the camera the input is attached to.
  99192. */
  99193. camera: FreeCamera;
  99194. /**
  99195. * Defines the buttons associated with the input to handle camera move.
  99196. */
  99197. buttons: number[];
  99198. /**
  99199. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  99200. */
  99201. angularSensibility: number;
  99202. private _pointerInput;
  99203. private _onMouseMove;
  99204. private _observer;
  99205. private previousPosition;
  99206. /**
  99207. * Observable for when a pointer move event occurs containing the move offset
  99208. */
  99209. onPointerMovedObservable: Observable<{
  99210. offsetX: number;
  99211. offsetY: number;
  99212. }>;
  99213. /**
  99214. * @hidden
  99215. * If the camera should be rotated automatically based on pointer movement
  99216. */
  99217. _allowCameraRotation: boolean;
  99218. /**
  99219. * Manage the mouse inputs to control the movement of a free camera.
  99220. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99221. * @param touchEnabled Defines if touch is enabled or not
  99222. */
  99223. constructor(
  99224. /**
  99225. * Define if touch is enabled in the mouse input
  99226. */
  99227. touchEnabled?: boolean);
  99228. /**
  99229. * Attach the input controls to a specific dom element to get the input from.
  99230. * @param element Defines the element the controls should be listened from
  99231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99232. */
  99233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99234. /**
  99235. * Called on JS contextmenu event.
  99236. * Override this method to provide functionality.
  99237. */
  99238. protected onContextMenu(evt: PointerEvent): void;
  99239. /**
  99240. * Detach the current controls from the specified dom element.
  99241. * @param element Defines the element to stop listening the inputs from
  99242. */
  99243. detachControl(element: Nullable<HTMLElement>): void;
  99244. /**
  99245. * Gets the class name of the current intput.
  99246. * @returns the class name
  99247. */
  99248. getClassName(): string;
  99249. /**
  99250. * Get the friendly name associated with the input class.
  99251. * @returns the input friendly name
  99252. */
  99253. getSimpleName(): string;
  99254. }
  99255. }
  99256. declare module BABYLON {
  99257. /**
  99258. * Manage the touch inputs to control the movement of a free camera.
  99259. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99260. */
  99261. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  99262. /**
  99263. * Define if mouse events can be treated as touch events
  99264. */
  99265. allowMouse: boolean;
  99266. /**
  99267. * Defines the camera the input is attached to.
  99268. */
  99269. camera: FreeCamera;
  99270. /**
  99271. * Defines the touch sensibility for rotation.
  99272. * The higher the faster.
  99273. */
  99274. touchAngularSensibility: number;
  99275. /**
  99276. * Defines the touch sensibility for move.
  99277. * The higher the faster.
  99278. */
  99279. touchMoveSensibility: number;
  99280. private _offsetX;
  99281. private _offsetY;
  99282. private _pointerPressed;
  99283. private _pointerInput;
  99284. private _observer;
  99285. private _onLostFocus;
  99286. /**
  99287. * Manage the touch inputs to control the movement of a free camera.
  99288. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99289. * @param allowMouse Defines if mouse events can be treated as touch events
  99290. */
  99291. constructor(
  99292. /**
  99293. * Define if mouse events can be treated as touch events
  99294. */
  99295. allowMouse?: boolean);
  99296. /**
  99297. * Attach the input controls to a specific dom element to get the input from.
  99298. * @param element Defines the element the controls should be listened from
  99299. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99300. */
  99301. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99302. /**
  99303. * Detach the current controls from the specified dom element.
  99304. * @param element Defines the element to stop listening the inputs from
  99305. */
  99306. detachControl(element: Nullable<HTMLElement>): void;
  99307. /**
  99308. * Update the current camera state depending on the inputs that have been used this frame.
  99309. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99310. */
  99311. checkInputs(): void;
  99312. /**
  99313. * Gets the class name of the current intput.
  99314. * @returns the class name
  99315. */
  99316. getClassName(): string;
  99317. /**
  99318. * Get the friendly name associated with the input class.
  99319. * @returns the input friendly name
  99320. */
  99321. getSimpleName(): string;
  99322. }
  99323. }
  99324. declare module BABYLON {
  99325. /**
  99326. * Default Inputs manager for the FreeCamera.
  99327. * It groups all the default supported inputs for ease of use.
  99328. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99329. */
  99330. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  99331. /**
  99332. * @hidden
  99333. */
  99334. _mouseInput: Nullable<FreeCameraMouseInput>;
  99335. /**
  99336. * Instantiates a new FreeCameraInputsManager.
  99337. * @param camera Defines the camera the inputs belong to
  99338. */
  99339. constructor(camera: FreeCamera);
  99340. /**
  99341. * Add keyboard input support to the input manager.
  99342. * @returns the current input manager
  99343. */
  99344. addKeyboard(): FreeCameraInputsManager;
  99345. /**
  99346. * Add mouse input support to the input manager.
  99347. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  99348. * @returns the current input manager
  99349. */
  99350. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  99351. /**
  99352. * Removes the mouse input support from the manager
  99353. * @returns the current input manager
  99354. */
  99355. removeMouse(): FreeCameraInputsManager;
  99356. /**
  99357. * Add touch input support to the input manager.
  99358. * @returns the current input manager
  99359. */
  99360. addTouch(): FreeCameraInputsManager;
  99361. /**
  99362. * Remove all attached input methods from a camera
  99363. */
  99364. clear(): void;
  99365. }
  99366. }
  99367. declare module BABYLON {
  99368. /**
  99369. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99370. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  99371. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99372. */
  99373. export class FreeCamera extends TargetCamera {
  99374. /**
  99375. * Define the collision ellipsoid of the camera.
  99376. * This is helpful to simulate a camera body like the player body around the camera
  99377. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99378. */
  99379. ellipsoid: Vector3;
  99380. /**
  99381. * Define an offset for the position of the ellipsoid around the camera.
  99382. * This can be helpful to determine the center of the body near the gravity center of the body
  99383. * instead of its head.
  99384. */
  99385. ellipsoidOffset: Vector3;
  99386. /**
  99387. * Enable or disable collisions of the camera with the rest of the scene objects.
  99388. */
  99389. checkCollisions: boolean;
  99390. /**
  99391. * Enable or disable gravity on the camera.
  99392. */
  99393. applyGravity: boolean;
  99394. /**
  99395. * Define the input manager associated to the camera.
  99396. */
  99397. inputs: FreeCameraInputsManager;
  99398. /**
  99399. * Gets the input sensibility for a mouse input. (default is 2000.0)
  99400. * Higher values reduce sensitivity.
  99401. */
  99402. get angularSensibility(): number;
  99403. /**
  99404. * Sets the input sensibility for a mouse input. (default is 2000.0)
  99405. * Higher values reduce sensitivity.
  99406. */
  99407. set angularSensibility(value: number);
  99408. /**
  99409. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99410. */
  99411. get keysUp(): number[];
  99412. set keysUp(value: number[]);
  99413. /**
  99414. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99415. */
  99416. get keysUpward(): number[];
  99417. set keysUpward(value: number[]);
  99418. /**
  99419. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99420. */
  99421. get keysDown(): number[];
  99422. set keysDown(value: number[]);
  99423. /**
  99424. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99425. */
  99426. get keysDownward(): number[];
  99427. set keysDownward(value: number[]);
  99428. /**
  99429. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99430. */
  99431. get keysLeft(): number[];
  99432. set keysLeft(value: number[]);
  99433. /**
  99434. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99435. */
  99436. get keysRight(): number[];
  99437. set keysRight(value: number[]);
  99438. /**
  99439. * Event raised when the camera collide with a mesh in the scene.
  99440. */
  99441. onCollide: (collidedMesh: AbstractMesh) => void;
  99442. private _collider;
  99443. private _needMoveForGravity;
  99444. private _oldPosition;
  99445. private _diffPosition;
  99446. private _newPosition;
  99447. /** @hidden */
  99448. _localDirection: Vector3;
  99449. /** @hidden */
  99450. _transformedDirection: Vector3;
  99451. /**
  99452. * Instantiates a Free Camera.
  99453. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99454. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  99455. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99456. * @param name Define the name of the camera in the scene
  99457. * @param position Define the start position of the camera in the scene
  99458. * @param scene Define the scene the camera belongs to
  99459. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99460. */
  99461. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99462. /**
  99463. * Attached controls to the current camera.
  99464. * @param element Defines the element the controls should be listened from
  99465. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99466. */
  99467. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99468. /**
  99469. * Detach the current controls from the camera.
  99470. * The camera will stop reacting to inputs.
  99471. * @param element Defines the element to stop listening the inputs from
  99472. */
  99473. detachControl(element: HTMLElement): void;
  99474. private _collisionMask;
  99475. /**
  99476. * Define a collision mask to limit the list of object the camera can collide with
  99477. */
  99478. get collisionMask(): number;
  99479. set collisionMask(mask: number);
  99480. /** @hidden */
  99481. _collideWithWorld(displacement: Vector3): void;
  99482. private _onCollisionPositionChange;
  99483. /** @hidden */
  99484. _checkInputs(): void;
  99485. /** @hidden */
  99486. _decideIfNeedsToMove(): boolean;
  99487. /** @hidden */
  99488. _updatePosition(): void;
  99489. /**
  99490. * Destroy the camera and release the current resources hold by it.
  99491. */
  99492. dispose(): void;
  99493. /**
  99494. * Gets the current object class name.
  99495. * @return the class name
  99496. */
  99497. getClassName(): string;
  99498. }
  99499. }
  99500. declare module BABYLON {
  99501. /**
  99502. * Represents a gamepad control stick position
  99503. */
  99504. export class StickValues {
  99505. /**
  99506. * The x component of the control stick
  99507. */
  99508. x: number;
  99509. /**
  99510. * The y component of the control stick
  99511. */
  99512. y: number;
  99513. /**
  99514. * Initializes the gamepad x and y control stick values
  99515. * @param x The x component of the gamepad control stick value
  99516. * @param y The y component of the gamepad control stick value
  99517. */
  99518. constructor(
  99519. /**
  99520. * The x component of the control stick
  99521. */
  99522. x: number,
  99523. /**
  99524. * The y component of the control stick
  99525. */
  99526. y: number);
  99527. }
  99528. /**
  99529. * An interface which manages callbacks for gamepad button changes
  99530. */
  99531. export interface GamepadButtonChanges {
  99532. /**
  99533. * Called when a gamepad has been changed
  99534. */
  99535. changed: boolean;
  99536. /**
  99537. * Called when a gamepad press event has been triggered
  99538. */
  99539. pressChanged: boolean;
  99540. /**
  99541. * Called when a touch event has been triggered
  99542. */
  99543. touchChanged: boolean;
  99544. /**
  99545. * Called when a value has changed
  99546. */
  99547. valueChanged: boolean;
  99548. }
  99549. /**
  99550. * Represents a gamepad
  99551. */
  99552. export class Gamepad {
  99553. /**
  99554. * The id of the gamepad
  99555. */
  99556. id: string;
  99557. /**
  99558. * The index of the gamepad
  99559. */
  99560. index: number;
  99561. /**
  99562. * The browser gamepad
  99563. */
  99564. browserGamepad: any;
  99565. /**
  99566. * Specifies what type of gamepad this represents
  99567. */
  99568. type: number;
  99569. private _leftStick;
  99570. private _rightStick;
  99571. /** @hidden */
  99572. _isConnected: boolean;
  99573. private _leftStickAxisX;
  99574. private _leftStickAxisY;
  99575. private _rightStickAxisX;
  99576. private _rightStickAxisY;
  99577. /**
  99578. * Triggered when the left control stick has been changed
  99579. */
  99580. private _onleftstickchanged;
  99581. /**
  99582. * Triggered when the right control stick has been changed
  99583. */
  99584. private _onrightstickchanged;
  99585. /**
  99586. * Represents a gamepad controller
  99587. */
  99588. static GAMEPAD: number;
  99589. /**
  99590. * Represents a generic controller
  99591. */
  99592. static GENERIC: number;
  99593. /**
  99594. * Represents an XBox controller
  99595. */
  99596. static XBOX: number;
  99597. /**
  99598. * Represents a pose-enabled controller
  99599. */
  99600. static POSE_ENABLED: number;
  99601. /**
  99602. * Represents an Dual Shock controller
  99603. */
  99604. static DUALSHOCK: number;
  99605. /**
  99606. * Specifies whether the left control stick should be Y-inverted
  99607. */
  99608. protected _invertLeftStickY: boolean;
  99609. /**
  99610. * Specifies if the gamepad has been connected
  99611. */
  99612. get isConnected(): boolean;
  99613. /**
  99614. * Initializes the gamepad
  99615. * @param id The id of the gamepad
  99616. * @param index The index of the gamepad
  99617. * @param browserGamepad The browser gamepad
  99618. * @param leftStickX The x component of the left joystick
  99619. * @param leftStickY The y component of the left joystick
  99620. * @param rightStickX The x component of the right joystick
  99621. * @param rightStickY The y component of the right joystick
  99622. */
  99623. constructor(
  99624. /**
  99625. * The id of the gamepad
  99626. */
  99627. id: string,
  99628. /**
  99629. * The index of the gamepad
  99630. */
  99631. index: number,
  99632. /**
  99633. * The browser gamepad
  99634. */
  99635. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  99636. /**
  99637. * Callback triggered when the left joystick has changed
  99638. * @param callback
  99639. */
  99640. onleftstickchanged(callback: (values: StickValues) => void): void;
  99641. /**
  99642. * Callback triggered when the right joystick has changed
  99643. * @param callback
  99644. */
  99645. onrightstickchanged(callback: (values: StickValues) => void): void;
  99646. /**
  99647. * Gets the left joystick
  99648. */
  99649. get leftStick(): StickValues;
  99650. /**
  99651. * Sets the left joystick values
  99652. */
  99653. set leftStick(newValues: StickValues);
  99654. /**
  99655. * Gets the right joystick
  99656. */
  99657. get rightStick(): StickValues;
  99658. /**
  99659. * Sets the right joystick value
  99660. */
  99661. set rightStick(newValues: StickValues);
  99662. /**
  99663. * Updates the gamepad joystick positions
  99664. */
  99665. update(): void;
  99666. /**
  99667. * Disposes the gamepad
  99668. */
  99669. dispose(): void;
  99670. }
  99671. /**
  99672. * Represents a generic gamepad
  99673. */
  99674. export class GenericPad extends Gamepad {
  99675. private _buttons;
  99676. private _onbuttondown;
  99677. private _onbuttonup;
  99678. /**
  99679. * Observable triggered when a button has been pressed
  99680. */
  99681. onButtonDownObservable: Observable<number>;
  99682. /**
  99683. * Observable triggered when a button has been released
  99684. */
  99685. onButtonUpObservable: Observable<number>;
  99686. /**
  99687. * Callback triggered when a button has been pressed
  99688. * @param callback Called when a button has been pressed
  99689. */
  99690. onbuttondown(callback: (buttonPressed: number) => void): void;
  99691. /**
  99692. * Callback triggered when a button has been released
  99693. * @param callback Called when a button has been released
  99694. */
  99695. onbuttonup(callback: (buttonReleased: number) => void): void;
  99696. /**
  99697. * Initializes the generic gamepad
  99698. * @param id The id of the generic gamepad
  99699. * @param index The index of the generic gamepad
  99700. * @param browserGamepad The browser gamepad
  99701. */
  99702. constructor(id: string, index: number, browserGamepad: any);
  99703. private _setButtonValue;
  99704. /**
  99705. * Updates the generic gamepad
  99706. */
  99707. update(): void;
  99708. /**
  99709. * Disposes the generic gamepad
  99710. */
  99711. dispose(): void;
  99712. }
  99713. }
  99714. declare module BABYLON {
  99715. /**
  99716. * Defines the types of pose enabled controllers that are supported
  99717. */
  99718. export enum PoseEnabledControllerType {
  99719. /**
  99720. * HTC Vive
  99721. */
  99722. VIVE = 0,
  99723. /**
  99724. * Oculus Rift
  99725. */
  99726. OCULUS = 1,
  99727. /**
  99728. * Windows mixed reality
  99729. */
  99730. WINDOWS = 2,
  99731. /**
  99732. * Samsung gear VR
  99733. */
  99734. GEAR_VR = 3,
  99735. /**
  99736. * Google Daydream
  99737. */
  99738. DAYDREAM = 4,
  99739. /**
  99740. * Generic
  99741. */
  99742. GENERIC = 5
  99743. }
  99744. /**
  99745. * Defines the MutableGamepadButton interface for the state of a gamepad button
  99746. */
  99747. export interface MutableGamepadButton {
  99748. /**
  99749. * Value of the button/trigger
  99750. */
  99751. value: number;
  99752. /**
  99753. * If the button/trigger is currently touched
  99754. */
  99755. touched: boolean;
  99756. /**
  99757. * If the button/trigger is currently pressed
  99758. */
  99759. pressed: boolean;
  99760. }
  99761. /**
  99762. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  99763. * @hidden
  99764. */
  99765. export interface ExtendedGamepadButton extends GamepadButton {
  99766. /**
  99767. * If the button/trigger is currently pressed
  99768. */
  99769. readonly pressed: boolean;
  99770. /**
  99771. * If the button/trigger is currently touched
  99772. */
  99773. readonly touched: boolean;
  99774. /**
  99775. * Value of the button/trigger
  99776. */
  99777. readonly value: number;
  99778. }
  99779. /** @hidden */
  99780. export interface _GamePadFactory {
  99781. /**
  99782. * Returns whether or not the current gamepad can be created for this type of controller.
  99783. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99784. * @returns true if it can be created, otherwise false
  99785. */
  99786. canCreate(gamepadInfo: any): boolean;
  99787. /**
  99788. * Creates a new instance of the Gamepad.
  99789. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99790. * @returns the new gamepad instance
  99791. */
  99792. create(gamepadInfo: any): Gamepad;
  99793. }
  99794. /**
  99795. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99796. */
  99797. export class PoseEnabledControllerHelper {
  99798. /** @hidden */
  99799. static _ControllerFactories: _GamePadFactory[];
  99800. /** @hidden */
  99801. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  99802. /**
  99803. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99804. * @param vrGamepad the gamepad to initialized
  99805. * @returns a vr controller of the type the gamepad identified as
  99806. */
  99807. static InitiateController(vrGamepad: any): Gamepad;
  99808. }
  99809. /**
  99810. * Defines the PoseEnabledController object that contains state of a vr capable controller
  99811. */
  99812. export class PoseEnabledController extends Gamepad implements PoseControlled {
  99813. /**
  99814. * If the controller is used in a webXR session
  99815. */
  99816. isXR: boolean;
  99817. private _deviceRoomPosition;
  99818. private _deviceRoomRotationQuaternion;
  99819. /**
  99820. * The device position in babylon space
  99821. */
  99822. devicePosition: Vector3;
  99823. /**
  99824. * The device rotation in babylon space
  99825. */
  99826. deviceRotationQuaternion: Quaternion;
  99827. /**
  99828. * The scale factor of the device in babylon space
  99829. */
  99830. deviceScaleFactor: number;
  99831. /**
  99832. * (Likely devicePosition should be used instead) The device position in its room space
  99833. */
  99834. position: Vector3;
  99835. /**
  99836. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  99837. */
  99838. rotationQuaternion: Quaternion;
  99839. /**
  99840. * The type of controller (Eg. Windows mixed reality)
  99841. */
  99842. controllerType: PoseEnabledControllerType;
  99843. protected _calculatedPosition: Vector3;
  99844. private _calculatedRotation;
  99845. /**
  99846. * The raw pose from the device
  99847. */
  99848. rawPose: DevicePose;
  99849. private _trackPosition;
  99850. private _maxRotationDistFromHeadset;
  99851. private _draggedRoomRotation;
  99852. /**
  99853. * @hidden
  99854. */
  99855. _disableTrackPosition(fixedPosition: Vector3): void;
  99856. /**
  99857. * Internal, the mesh attached to the controller
  99858. * @hidden
  99859. */
  99860. _mesh: Nullable<AbstractMesh>;
  99861. private _poseControlledCamera;
  99862. private _leftHandSystemQuaternion;
  99863. /**
  99864. * Internal, matrix used to convert room space to babylon space
  99865. * @hidden
  99866. */
  99867. _deviceToWorld: Matrix;
  99868. /**
  99869. * Node to be used when casting a ray from the controller
  99870. * @hidden
  99871. */
  99872. _pointingPoseNode: Nullable<TransformNode>;
  99873. /**
  99874. * Name of the child mesh that can be used to cast a ray from the controller
  99875. */
  99876. static readonly POINTING_POSE: string;
  99877. /**
  99878. * Creates a new PoseEnabledController from a gamepad
  99879. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  99880. */
  99881. constructor(browserGamepad: any);
  99882. private _workingMatrix;
  99883. /**
  99884. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  99885. */
  99886. update(): void;
  99887. /**
  99888. * Updates only the pose device and mesh without doing any button event checking
  99889. */
  99890. protected _updatePoseAndMesh(): void;
  99891. /**
  99892. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  99893. * @param poseData raw pose fromthe device
  99894. */
  99895. updateFromDevice(poseData: DevicePose): void;
  99896. /**
  99897. * @hidden
  99898. */
  99899. _meshAttachedObservable: Observable<AbstractMesh>;
  99900. /**
  99901. * Attaches a mesh to the controller
  99902. * @param mesh the mesh to be attached
  99903. */
  99904. attachToMesh(mesh: AbstractMesh): void;
  99905. /**
  99906. * Attaches the controllers mesh to a camera
  99907. * @param camera the camera the mesh should be attached to
  99908. */
  99909. attachToPoseControlledCamera(camera: TargetCamera): void;
  99910. /**
  99911. * Disposes of the controller
  99912. */
  99913. dispose(): void;
  99914. /**
  99915. * The mesh that is attached to the controller
  99916. */
  99917. get mesh(): Nullable<AbstractMesh>;
  99918. /**
  99919. * Gets the ray of the controller in the direction the controller is pointing
  99920. * @param length the length the resulting ray should be
  99921. * @returns a ray in the direction the controller is pointing
  99922. */
  99923. getForwardRay(length?: number): Ray;
  99924. }
  99925. }
  99926. declare module BABYLON {
  99927. /**
  99928. * Defines the WebVRController object that represents controllers tracked in 3D space
  99929. */
  99930. export abstract class WebVRController extends PoseEnabledController {
  99931. /**
  99932. * Internal, the default controller model for the controller
  99933. */
  99934. protected _defaultModel: Nullable<AbstractMesh>;
  99935. /**
  99936. * Fired when the trigger state has changed
  99937. */
  99938. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  99939. /**
  99940. * Fired when the main button state has changed
  99941. */
  99942. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99943. /**
  99944. * Fired when the secondary button state has changed
  99945. */
  99946. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99947. /**
  99948. * Fired when the pad state has changed
  99949. */
  99950. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  99951. /**
  99952. * Fired when controllers stick values have changed
  99953. */
  99954. onPadValuesChangedObservable: Observable<StickValues>;
  99955. /**
  99956. * Array of button availible on the controller
  99957. */
  99958. protected _buttons: Array<MutableGamepadButton>;
  99959. private _onButtonStateChange;
  99960. /**
  99961. * Fired when a controller button's state has changed
  99962. * @param callback the callback containing the button that was modified
  99963. */
  99964. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  99965. /**
  99966. * X and Y axis corresponding to the controllers joystick
  99967. */
  99968. pad: StickValues;
  99969. /**
  99970. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  99971. */
  99972. hand: string;
  99973. /**
  99974. * The default controller model for the controller
  99975. */
  99976. get defaultModel(): Nullable<AbstractMesh>;
  99977. /**
  99978. * Creates a new WebVRController from a gamepad
  99979. * @param vrGamepad the gamepad that the WebVRController should be created from
  99980. */
  99981. constructor(vrGamepad: any);
  99982. /**
  99983. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  99984. */
  99985. update(): void;
  99986. /**
  99987. * Function to be called when a button is modified
  99988. */
  99989. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99990. /**
  99991. * Loads a mesh and attaches it to the controller
  99992. * @param scene the scene the mesh should be added to
  99993. * @param meshLoaded callback for when the mesh has been loaded
  99994. */
  99995. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99996. private _setButtonValue;
  99997. private _changes;
  99998. private _checkChanges;
  99999. /**
  100000. * Disposes of th webVRCOntroller
  100001. */
  100002. dispose(): void;
  100003. }
  100004. }
  100005. declare module BABYLON {
  100006. /**
  100007. * The HemisphericLight simulates the ambient environment light,
  100008. * so the passed direction is the light reflection direction, not the incoming direction.
  100009. */
  100010. export class HemisphericLight extends Light {
  100011. /**
  100012. * The groundColor is the light in the opposite direction to the one specified during creation.
  100013. * 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.
  100014. */
  100015. groundColor: Color3;
  100016. /**
  100017. * The light reflection direction, not the incoming direction.
  100018. */
  100019. direction: Vector3;
  100020. /**
  100021. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  100022. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  100023. * The HemisphericLight can't cast shadows.
  100024. * Documentation : https://doc.babylonjs.com/babylon101/lights
  100025. * @param name The friendly name of the light
  100026. * @param direction The direction of the light reflection
  100027. * @param scene The scene the light belongs to
  100028. */
  100029. constructor(name: string, direction: Vector3, scene: Scene);
  100030. protected _buildUniformLayout(): void;
  100031. /**
  100032. * Returns the string "HemisphericLight".
  100033. * @return The class name
  100034. */
  100035. getClassName(): string;
  100036. /**
  100037. * Sets the HemisphericLight direction towards the passed target (Vector3).
  100038. * Returns the updated direction.
  100039. * @param target The target the direction should point to
  100040. * @return The computed direction
  100041. */
  100042. setDirectionToTarget(target: Vector3): Vector3;
  100043. /**
  100044. * Returns the shadow generator associated to the light.
  100045. * @returns Always null for hemispheric lights because it does not support shadows.
  100046. */
  100047. getShadowGenerator(): Nullable<IShadowGenerator>;
  100048. /**
  100049. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  100050. * @param effect The effect to update
  100051. * @param lightIndex The index of the light in the effect to update
  100052. * @returns The hemispheric light
  100053. */
  100054. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  100055. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  100056. /**
  100057. * Computes the world matrix of the node
  100058. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  100059. * @param useWasUpdatedFlag defines a reserved property
  100060. * @returns the world matrix
  100061. */
  100062. computeWorldMatrix(): Matrix;
  100063. /**
  100064. * Returns the integer 3.
  100065. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  100066. */
  100067. getTypeID(): number;
  100068. /**
  100069. * Prepares the list of defines specific to the light type.
  100070. * @param defines the list of defines
  100071. * @param lightIndex defines the index of the light for the effect
  100072. */
  100073. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  100074. }
  100075. }
  100076. declare module BABYLON {
  100077. /** @hidden */
  100078. export var vrMultiviewToSingleviewPixelShader: {
  100079. name: string;
  100080. shader: string;
  100081. };
  100082. }
  100083. declare module BABYLON {
  100084. /**
  100085. * Renders to multiple views with a single draw call
  100086. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  100087. */
  100088. export class MultiviewRenderTarget extends RenderTargetTexture {
  100089. /**
  100090. * Creates a multiview render target
  100091. * @param scene scene used with the render target
  100092. * @param size the size of the render target (used for each view)
  100093. */
  100094. constructor(scene: Scene, size?: number | {
  100095. width: number;
  100096. height: number;
  100097. } | {
  100098. ratio: number;
  100099. });
  100100. /**
  100101. * @hidden
  100102. * @param faceIndex the face index, if its a cube texture
  100103. */
  100104. _bindFrameBuffer(faceIndex?: number): void;
  100105. /**
  100106. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100107. * @returns the view count
  100108. */
  100109. getViewCount(): number;
  100110. }
  100111. }
  100112. declare module BABYLON {
  100113. interface Engine {
  100114. /**
  100115. * Creates a new multiview render target
  100116. * @param width defines the width of the texture
  100117. * @param height defines the height of the texture
  100118. * @returns the created multiview texture
  100119. */
  100120. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  100121. /**
  100122. * Binds a multiview framebuffer to be drawn to
  100123. * @param multiviewTexture texture to bind
  100124. */
  100125. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  100126. }
  100127. interface Camera {
  100128. /**
  100129. * @hidden
  100130. * 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)
  100131. */
  100132. _useMultiviewToSingleView: boolean;
  100133. /**
  100134. * @hidden
  100135. * 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)
  100136. */
  100137. _multiviewTexture: Nullable<RenderTargetTexture>;
  100138. /**
  100139. * @hidden
  100140. * ensures the multiview texture of the camera exists and has the specified width/height
  100141. * @param width height to set on the multiview texture
  100142. * @param height width to set on the multiview texture
  100143. */
  100144. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  100145. }
  100146. interface Scene {
  100147. /** @hidden */
  100148. _transformMatrixR: Matrix;
  100149. /** @hidden */
  100150. _multiviewSceneUbo: Nullable<UniformBuffer>;
  100151. /** @hidden */
  100152. _createMultiviewUbo(): void;
  100153. /** @hidden */
  100154. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  100155. /** @hidden */
  100156. _renderMultiviewToSingleView(camera: Camera): void;
  100157. }
  100158. }
  100159. declare module BABYLON {
  100160. /**
  100161. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  100162. * This will not be used for webXR as it supports displaying texture arrays directly
  100163. */
  100164. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  100165. /**
  100166. * Gets a string identifying the name of the class
  100167. * @returns "VRMultiviewToSingleviewPostProcess" string
  100168. */
  100169. getClassName(): string;
  100170. /**
  100171. * Initializes a VRMultiviewToSingleview
  100172. * @param name name of the post process
  100173. * @param camera camera to be applied to
  100174. * @param scaleFactor scaling factor to the size of the output texture
  100175. */
  100176. constructor(name: string, camera: Camera, scaleFactor: number);
  100177. }
  100178. }
  100179. declare module BABYLON {
  100180. /**
  100181. * Interface used to define additional presentation attributes
  100182. */
  100183. export interface IVRPresentationAttributes {
  100184. /**
  100185. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  100186. */
  100187. highRefreshRate: boolean;
  100188. /**
  100189. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  100190. */
  100191. foveationLevel: number;
  100192. }
  100193. interface Engine {
  100194. /** @hidden */
  100195. _vrDisplay: any;
  100196. /** @hidden */
  100197. _vrSupported: boolean;
  100198. /** @hidden */
  100199. _oldSize: Size;
  100200. /** @hidden */
  100201. _oldHardwareScaleFactor: number;
  100202. /** @hidden */
  100203. _vrExclusivePointerMode: boolean;
  100204. /** @hidden */
  100205. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  100206. /** @hidden */
  100207. _onVRDisplayPointerRestricted: () => void;
  100208. /** @hidden */
  100209. _onVRDisplayPointerUnrestricted: () => void;
  100210. /** @hidden */
  100211. _onVrDisplayConnect: Nullable<(display: any) => void>;
  100212. /** @hidden */
  100213. _onVrDisplayDisconnect: Nullable<() => void>;
  100214. /** @hidden */
  100215. _onVrDisplayPresentChange: Nullable<() => void>;
  100216. /**
  100217. * Observable signaled when VR display mode changes
  100218. */
  100219. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  100220. /**
  100221. * Observable signaled when VR request present is complete
  100222. */
  100223. onVRRequestPresentComplete: Observable<boolean>;
  100224. /**
  100225. * Observable signaled when VR request present starts
  100226. */
  100227. onVRRequestPresentStart: Observable<Engine>;
  100228. /**
  100229. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  100230. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  100231. */
  100232. isInVRExclusivePointerMode: boolean;
  100233. /**
  100234. * Gets a boolean indicating if a webVR device was detected
  100235. * @returns true if a webVR device was detected
  100236. */
  100237. isVRDevicePresent(): boolean;
  100238. /**
  100239. * Gets the current webVR device
  100240. * @returns the current webVR device (or null)
  100241. */
  100242. getVRDevice(): any;
  100243. /**
  100244. * Initializes a webVR display and starts listening to display change events
  100245. * The onVRDisplayChangedObservable will be notified upon these changes
  100246. * @returns A promise containing a VRDisplay and if vr is supported
  100247. */
  100248. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  100249. /** @hidden */
  100250. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  100251. /**
  100252. * Gets or sets the presentation attributes used to configure VR rendering
  100253. */
  100254. vrPresentationAttributes?: IVRPresentationAttributes;
  100255. /**
  100256. * Call this function to switch to webVR mode
  100257. * Will do nothing if webVR is not supported or if there is no webVR device
  100258. * @param options the webvr options provided to the camera. mainly used for multiview
  100259. * @see https://doc.babylonjs.com/how_to/webvr_camera
  100260. */
  100261. enableVR(options: WebVROptions): void;
  100262. /** @hidden */
  100263. _onVRFullScreenTriggered(): void;
  100264. }
  100265. }
  100266. declare module BABYLON {
  100267. /**
  100268. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  100269. * IMPORTANT!! The data is right-hand data.
  100270. * @export
  100271. * @interface DevicePose
  100272. */
  100273. export interface DevicePose {
  100274. /**
  100275. * The position of the device, values in array are [x,y,z].
  100276. */
  100277. readonly position: Nullable<Float32Array>;
  100278. /**
  100279. * The linearVelocity of the device, values in array are [x,y,z].
  100280. */
  100281. readonly linearVelocity: Nullable<Float32Array>;
  100282. /**
  100283. * The linearAcceleration of the device, values in array are [x,y,z].
  100284. */
  100285. readonly linearAcceleration: Nullable<Float32Array>;
  100286. /**
  100287. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  100288. */
  100289. readonly orientation: Nullable<Float32Array>;
  100290. /**
  100291. * The angularVelocity of the device, values in array are [x,y,z].
  100292. */
  100293. readonly angularVelocity: Nullable<Float32Array>;
  100294. /**
  100295. * The angularAcceleration of the device, values in array are [x,y,z].
  100296. */
  100297. readonly angularAcceleration: Nullable<Float32Array>;
  100298. }
  100299. /**
  100300. * Interface representing a pose controlled object in Babylon.
  100301. * A pose controlled object has both regular pose values as well as pose values
  100302. * from an external device such as a VR head mounted display
  100303. */
  100304. export interface PoseControlled {
  100305. /**
  100306. * The position of the object in babylon space.
  100307. */
  100308. position: Vector3;
  100309. /**
  100310. * The rotation quaternion of the object in babylon space.
  100311. */
  100312. rotationQuaternion: Quaternion;
  100313. /**
  100314. * The position of the device in babylon space.
  100315. */
  100316. devicePosition?: Vector3;
  100317. /**
  100318. * The rotation quaternion of the device in babylon space.
  100319. */
  100320. deviceRotationQuaternion: Quaternion;
  100321. /**
  100322. * The raw pose coming from the device.
  100323. */
  100324. rawPose: Nullable<DevicePose>;
  100325. /**
  100326. * The scale of the device to be used when translating from device space to babylon space.
  100327. */
  100328. deviceScaleFactor: number;
  100329. /**
  100330. * Updates the poseControlled values based on the input device pose.
  100331. * @param poseData the pose data to update the object with
  100332. */
  100333. updateFromDevice(poseData: DevicePose): void;
  100334. }
  100335. /**
  100336. * Set of options to customize the webVRCamera
  100337. */
  100338. export interface WebVROptions {
  100339. /**
  100340. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  100341. */
  100342. trackPosition?: boolean;
  100343. /**
  100344. * Sets the scale of the vrDevice in babylon space. (default: 1)
  100345. */
  100346. positionScale?: number;
  100347. /**
  100348. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  100349. */
  100350. displayName?: string;
  100351. /**
  100352. * Should the native controller meshes be initialized. (default: true)
  100353. */
  100354. controllerMeshes?: boolean;
  100355. /**
  100356. * Creating a default HemiLight only on controllers. (default: true)
  100357. */
  100358. defaultLightingOnControllers?: boolean;
  100359. /**
  100360. * If you don't want to use the default VR button of the helper. (default: false)
  100361. */
  100362. useCustomVRButton?: boolean;
  100363. /**
  100364. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  100365. */
  100366. customVRButton?: HTMLButtonElement;
  100367. /**
  100368. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  100369. */
  100370. rayLength?: number;
  100371. /**
  100372. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  100373. */
  100374. defaultHeight?: number;
  100375. /**
  100376. * If multiview should be used if availible (default: false)
  100377. */
  100378. useMultiview?: boolean;
  100379. }
  100380. /**
  100381. * This represents a WebVR camera.
  100382. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  100383. * @example https://doc.babylonjs.com/how_to/webvr_camera
  100384. */
  100385. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  100386. private webVROptions;
  100387. /**
  100388. * @hidden
  100389. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  100390. */
  100391. _vrDevice: any;
  100392. /**
  100393. * The rawPose of the vrDevice.
  100394. */
  100395. rawPose: Nullable<DevicePose>;
  100396. private _onVREnabled;
  100397. private _specsVersion;
  100398. private _attached;
  100399. private _frameData;
  100400. protected _descendants: Array<Node>;
  100401. private _deviceRoomPosition;
  100402. /** @hidden */
  100403. _deviceRoomRotationQuaternion: Quaternion;
  100404. private _standingMatrix;
  100405. /**
  100406. * Represents device position in babylon space.
  100407. */
  100408. devicePosition: Vector3;
  100409. /**
  100410. * Represents device rotation in babylon space.
  100411. */
  100412. deviceRotationQuaternion: Quaternion;
  100413. /**
  100414. * The scale of the device to be used when translating from device space to babylon space.
  100415. */
  100416. deviceScaleFactor: number;
  100417. private _deviceToWorld;
  100418. private _worldToDevice;
  100419. /**
  100420. * References to the webVR controllers for the vrDevice.
  100421. */
  100422. controllers: Array<WebVRController>;
  100423. /**
  100424. * Emits an event when a controller is attached.
  100425. */
  100426. onControllersAttachedObservable: Observable<WebVRController[]>;
  100427. /**
  100428. * Emits an event when a controller's mesh has been loaded;
  100429. */
  100430. onControllerMeshLoadedObservable: Observable<WebVRController>;
  100431. /**
  100432. * Emits an event when the HMD's pose has been updated.
  100433. */
  100434. onPoseUpdatedFromDeviceObservable: Observable<any>;
  100435. private _poseSet;
  100436. /**
  100437. * If the rig cameras be used as parent instead of this camera.
  100438. */
  100439. rigParenting: boolean;
  100440. private _lightOnControllers;
  100441. private _defaultHeight?;
  100442. /**
  100443. * Instantiates a WebVRFreeCamera.
  100444. * @param name The name of the WebVRFreeCamera
  100445. * @param position The starting anchor position for the camera
  100446. * @param scene The scene the camera belongs to
  100447. * @param webVROptions a set of customizable options for the webVRCamera
  100448. */
  100449. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  100450. /**
  100451. * Gets the device distance from the ground in meters.
  100452. * @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.
  100453. */
  100454. deviceDistanceToRoomGround(): number;
  100455. /**
  100456. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100457. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  100458. */
  100459. useStandingMatrix(callback?: (bool: boolean) => void): void;
  100460. /**
  100461. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100462. * @returns A promise with a boolean set to if the standing matrix is supported.
  100463. */
  100464. useStandingMatrixAsync(): Promise<boolean>;
  100465. /**
  100466. * Disposes the camera
  100467. */
  100468. dispose(): void;
  100469. /**
  100470. * Gets a vrController by name.
  100471. * @param name The name of the controller to retreive
  100472. * @returns the controller matching the name specified or null if not found
  100473. */
  100474. getControllerByName(name: string): Nullable<WebVRController>;
  100475. private _leftController;
  100476. /**
  100477. * The controller corresponding to the users left hand.
  100478. */
  100479. get leftController(): Nullable<WebVRController>;
  100480. private _rightController;
  100481. /**
  100482. * The controller corresponding to the users right hand.
  100483. */
  100484. get rightController(): Nullable<WebVRController>;
  100485. /**
  100486. * Casts a ray forward from the vrCamera's gaze.
  100487. * @param length Length of the ray (default: 100)
  100488. * @returns the ray corresponding to the gaze
  100489. */
  100490. getForwardRay(length?: number): Ray;
  100491. /**
  100492. * @hidden
  100493. * Updates the camera based on device's frame data
  100494. */
  100495. _checkInputs(): void;
  100496. /**
  100497. * Updates the poseControlled values based on the input device pose.
  100498. * @param poseData Pose coming from the device
  100499. */
  100500. updateFromDevice(poseData: DevicePose): void;
  100501. private _htmlElementAttached;
  100502. private _detachIfAttached;
  100503. /**
  100504. * WebVR's attach control will start broadcasting frames to the device.
  100505. * Note that in certain browsers (chrome for example) this function must be called
  100506. * within a user-interaction callback. Example:
  100507. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  100508. *
  100509. * @param element html element to attach the vrDevice to
  100510. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  100511. */
  100512. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100513. /**
  100514. * Detaches the camera from the html element and disables VR
  100515. *
  100516. * @param element html element to detach from
  100517. */
  100518. detachControl(element: HTMLElement): void;
  100519. /**
  100520. * @returns the name of this class
  100521. */
  100522. getClassName(): string;
  100523. /**
  100524. * Calls resetPose on the vrDisplay
  100525. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  100526. */
  100527. resetToCurrentRotation(): void;
  100528. /**
  100529. * @hidden
  100530. * Updates the rig cameras (left and right eye)
  100531. */
  100532. _updateRigCameras(): void;
  100533. private _workingVector;
  100534. private _oneVector;
  100535. private _workingMatrix;
  100536. private updateCacheCalled;
  100537. private _correctPositionIfNotTrackPosition;
  100538. /**
  100539. * @hidden
  100540. * Updates the cached values of the camera
  100541. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  100542. */
  100543. _updateCache(ignoreParentClass?: boolean): void;
  100544. /**
  100545. * @hidden
  100546. * Get current device position in babylon world
  100547. */
  100548. _computeDevicePosition(): void;
  100549. /**
  100550. * Updates the current device position and rotation in the babylon world
  100551. */
  100552. update(): void;
  100553. /**
  100554. * @hidden
  100555. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  100556. * @returns an identity matrix
  100557. */
  100558. _getViewMatrix(): Matrix;
  100559. private _tmpMatrix;
  100560. /**
  100561. * This function is called by the two RIG cameras.
  100562. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  100563. * @hidden
  100564. */
  100565. _getWebVRViewMatrix(): Matrix;
  100566. /** @hidden */
  100567. _getWebVRProjectionMatrix(): Matrix;
  100568. private _onGamepadConnectedObserver;
  100569. private _onGamepadDisconnectedObserver;
  100570. private _updateCacheWhenTrackingDisabledObserver;
  100571. /**
  100572. * Initializes the controllers and their meshes
  100573. */
  100574. initControllers(): void;
  100575. }
  100576. }
  100577. declare module BABYLON {
  100578. /**
  100579. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  100580. *
  100581. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  100582. *
  100583. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  100584. */
  100585. export class MaterialHelper {
  100586. /**
  100587. * Bind the current view position to an effect.
  100588. * @param effect The effect to be bound
  100589. * @param scene The scene the eyes position is used from
  100590. * @param variableName name of the shader variable that will hold the eye position
  100591. */
  100592. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  100593. /**
  100594. * Helps preparing the defines values about the UVs in used in the effect.
  100595. * UVs are shared as much as we can accross channels in the shaders.
  100596. * @param texture The texture we are preparing the UVs for
  100597. * @param defines The defines to update
  100598. * @param key The channel key "diffuse", "specular"... used in the shader
  100599. */
  100600. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  100601. /**
  100602. * Binds a texture matrix value to its corrsponding uniform
  100603. * @param texture The texture to bind the matrix for
  100604. * @param uniformBuffer The uniform buffer receivin the data
  100605. * @param key The channel key "diffuse", "specular"... used in the shader
  100606. */
  100607. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  100608. /**
  100609. * Gets the current status of the fog (should it be enabled?)
  100610. * @param mesh defines the mesh to evaluate for fog support
  100611. * @param scene defines the hosting scene
  100612. * @returns true if fog must be enabled
  100613. */
  100614. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  100615. /**
  100616. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  100617. * @param mesh defines the current mesh
  100618. * @param scene defines the current scene
  100619. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  100620. * @param pointsCloud defines if point cloud rendering has to be turned on
  100621. * @param fogEnabled defines if fog has to be turned on
  100622. * @param alphaTest defines if alpha testing has to be turned on
  100623. * @param defines defines the current list of defines
  100624. */
  100625. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  100626. /**
  100627. * Helper used to prepare the list of defines associated with frame values for shader compilation
  100628. * @param scene defines the current scene
  100629. * @param engine defines the current engine
  100630. * @param defines specifies the list of active defines
  100631. * @param useInstances defines if instances have to be turned on
  100632. * @param useClipPlane defines if clip plane have to be turned on
  100633. * @param useInstances defines if instances have to be turned on
  100634. * @param useThinInstances defines if thin instances have to be turned on
  100635. */
  100636. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  100637. /**
  100638. * Prepares the defines for bones
  100639. * @param mesh The mesh containing the geometry data we will draw
  100640. * @param defines The defines to update
  100641. */
  100642. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  100643. /**
  100644. * Prepares the defines for morph targets
  100645. * @param mesh The mesh containing the geometry data we will draw
  100646. * @param defines The defines to update
  100647. */
  100648. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  100649. /**
  100650. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  100651. * @param mesh The mesh containing the geometry data we will draw
  100652. * @param defines The defines to update
  100653. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  100654. * @param useBones Precise whether bones should be used or not (override mesh info)
  100655. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  100656. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  100657. * @returns false if defines are considered not dirty and have not been checked
  100658. */
  100659. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  100660. /**
  100661. * Prepares the defines related to multiview
  100662. * @param scene The scene we are intending to draw
  100663. * @param defines The defines to update
  100664. */
  100665. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  100666. /**
  100667. * Prepares the defines related to the prepass
  100668. * @param scene The scene we are intending to draw
  100669. * @param defines The defines to update
  100670. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  100671. */
  100672. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  100673. /**
  100674. * Prepares the defines related to the light information passed in parameter
  100675. * @param scene The scene we are intending to draw
  100676. * @param mesh The mesh the effect is compiling for
  100677. * @param light The light the effect is compiling for
  100678. * @param lightIndex The index of the light
  100679. * @param defines The defines to update
  100680. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100681. * @param state Defines the current state regarding what is needed (normals, etc...)
  100682. */
  100683. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  100684. needNormals: boolean;
  100685. needRebuild: boolean;
  100686. shadowEnabled: boolean;
  100687. specularEnabled: boolean;
  100688. lightmapMode: boolean;
  100689. }): void;
  100690. /**
  100691. * Prepares the defines related to the light information passed in parameter
  100692. * @param scene The scene we are intending to draw
  100693. * @param mesh The mesh the effect is compiling for
  100694. * @param defines The defines to update
  100695. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100696. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  100697. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  100698. * @returns true if normals will be required for the rest of the effect
  100699. */
  100700. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  100701. /**
  100702. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  100703. * @param lightIndex defines the light index
  100704. * @param uniformsList The uniform list
  100705. * @param samplersList The sampler list
  100706. * @param projectedLightTexture defines if projected texture must be used
  100707. * @param uniformBuffersList defines an optional list of uniform buffers
  100708. */
  100709. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  100710. /**
  100711. * Prepares the uniforms and samplers list to be used in the effect
  100712. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  100713. * @param samplersList The sampler list
  100714. * @param defines The defines helping in the list generation
  100715. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  100716. */
  100717. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  100718. /**
  100719. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  100720. * @param defines The defines to update while falling back
  100721. * @param fallbacks The authorized effect fallbacks
  100722. * @param maxSimultaneousLights The maximum number of lights allowed
  100723. * @param rank the current rank of the Effect
  100724. * @returns The newly affected rank
  100725. */
  100726. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  100727. private static _TmpMorphInfluencers;
  100728. /**
  100729. * Prepares the list of attributes required for morph targets according to the effect defines.
  100730. * @param attribs The current list of supported attribs
  100731. * @param mesh The mesh to prepare the morph targets attributes for
  100732. * @param influencers The number of influencers
  100733. */
  100734. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  100735. /**
  100736. * Prepares the list of attributes required for morph targets according to the effect defines.
  100737. * @param attribs The current list of supported attribs
  100738. * @param mesh The mesh to prepare the morph targets attributes for
  100739. * @param defines The current Defines of the effect
  100740. */
  100741. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  100742. /**
  100743. * Prepares the list of attributes required for bones according to the effect defines.
  100744. * @param attribs The current list of supported attribs
  100745. * @param mesh The mesh to prepare the bones attributes for
  100746. * @param defines The current Defines of the effect
  100747. * @param fallbacks The current efffect fallback strategy
  100748. */
  100749. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  100750. /**
  100751. * Check and prepare the list of attributes required for instances according to the effect defines.
  100752. * @param attribs The current list of supported attribs
  100753. * @param defines The current MaterialDefines of the effect
  100754. */
  100755. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  100756. /**
  100757. * Add the list of attributes required for instances to the attribs array.
  100758. * @param attribs The current list of supported attribs
  100759. */
  100760. static PushAttributesForInstances(attribs: string[]): void;
  100761. /**
  100762. * Binds the light information to the effect.
  100763. * @param light The light containing the generator
  100764. * @param effect The effect we are binding the data to
  100765. * @param lightIndex The light index in the effect used to render
  100766. */
  100767. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  100768. /**
  100769. * Binds the lights information from the scene to the effect for the given mesh.
  100770. * @param light Light to bind
  100771. * @param lightIndex Light index
  100772. * @param scene The scene where the light belongs to
  100773. * @param effect The effect we are binding the data to
  100774. * @param useSpecular Defines if specular is supported
  100775. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100776. */
  100777. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  100778. /**
  100779. * Binds the lights information from the scene to the effect for the given mesh.
  100780. * @param scene The scene the lights belongs to
  100781. * @param mesh The mesh we are binding the information to render
  100782. * @param effect The effect we are binding the data to
  100783. * @param defines The generated defines for the effect
  100784. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  100785. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100786. */
  100787. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  100788. private static _tempFogColor;
  100789. /**
  100790. * Binds the fog information from the scene to the effect for the given mesh.
  100791. * @param scene The scene the lights belongs to
  100792. * @param mesh The mesh we are binding the information to render
  100793. * @param effect The effect we are binding the data to
  100794. * @param linearSpace Defines if the fog effect is applied in linear space
  100795. */
  100796. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  100797. /**
  100798. * Binds the bones information from the mesh to the effect.
  100799. * @param mesh The mesh we are binding the information to render
  100800. * @param effect The effect we are binding the data to
  100801. */
  100802. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  100803. /**
  100804. * Binds the morph targets information from the mesh to the effect.
  100805. * @param abstractMesh The mesh we are binding the information to render
  100806. * @param effect The effect we are binding the data to
  100807. */
  100808. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  100809. /**
  100810. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  100811. * @param defines The generated defines used in the effect
  100812. * @param effect The effect we are binding the data to
  100813. * @param scene The scene we are willing to render with logarithmic scale for
  100814. */
  100815. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  100816. /**
  100817. * Binds the clip plane information from the scene to the effect.
  100818. * @param scene The scene the clip plane information are extracted from
  100819. * @param effect The effect we are binding the data to
  100820. */
  100821. static BindClipPlane(effect: Effect, scene: Scene): void;
  100822. }
  100823. }
  100824. declare module BABYLON {
  100825. /**
  100826. * Block used to expose an input value
  100827. */
  100828. export class InputBlock extends NodeMaterialBlock {
  100829. private _mode;
  100830. private _associatedVariableName;
  100831. private _storedValue;
  100832. private _valueCallback;
  100833. private _type;
  100834. private _animationType;
  100835. /** Gets or set a value used to limit the range of float values */
  100836. min: number;
  100837. /** Gets or set a value used to limit the range of float values */
  100838. max: number;
  100839. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  100840. isBoolean: boolean;
  100841. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  100842. matrixMode: number;
  100843. /** @hidden */
  100844. _systemValue: Nullable<NodeMaterialSystemValues>;
  100845. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  100846. isConstant: boolean;
  100847. /** Gets or sets the group to use to display this block in the Inspector */
  100848. groupInInspector: string;
  100849. /** Gets an observable raised when the value is changed */
  100850. onValueChangedObservable: Observable<InputBlock>;
  100851. /**
  100852. * Gets or sets the connection point type (default is float)
  100853. */
  100854. get type(): NodeMaterialBlockConnectionPointTypes;
  100855. /**
  100856. * Creates a new InputBlock
  100857. * @param name defines the block name
  100858. * @param target defines the target of that block (Vertex by default)
  100859. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  100860. */
  100861. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  100862. /**
  100863. * Validates if a name is a reserve word.
  100864. * @param newName the new name to be given to the node.
  100865. * @returns false if the name is a reserve word, else true.
  100866. */
  100867. validateBlockName(newName: string): boolean;
  100868. /**
  100869. * Gets the output component
  100870. */
  100871. get output(): NodeMaterialConnectionPoint;
  100872. /**
  100873. * Set the source of this connection point to a vertex attribute
  100874. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  100875. * @returns the current connection point
  100876. */
  100877. setAsAttribute(attributeName?: string): InputBlock;
  100878. /**
  100879. * Set the source of this connection point to a system value
  100880. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  100881. * @returns the current connection point
  100882. */
  100883. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  100884. /**
  100885. * Gets or sets the value of that point.
  100886. * Please note that this value will be ignored if valueCallback is defined
  100887. */
  100888. get value(): any;
  100889. set value(value: any);
  100890. /**
  100891. * Gets or sets a callback used to get the value of that point.
  100892. * Please note that setting this value will force the connection point to ignore the value property
  100893. */
  100894. get valueCallback(): () => any;
  100895. set valueCallback(value: () => any);
  100896. /**
  100897. * Gets or sets the associated variable name in the shader
  100898. */
  100899. get associatedVariableName(): string;
  100900. set associatedVariableName(value: string);
  100901. /** Gets or sets the type of animation applied to the input */
  100902. get animationType(): AnimatedInputBlockTypes;
  100903. set animationType(value: AnimatedInputBlockTypes);
  100904. /**
  100905. * Gets a boolean indicating that this connection point not defined yet
  100906. */
  100907. get isUndefined(): boolean;
  100908. /**
  100909. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  100910. * In this case the connection point name must be the name of the uniform to use.
  100911. * Can only be set on inputs
  100912. */
  100913. get isUniform(): boolean;
  100914. set isUniform(value: boolean);
  100915. /**
  100916. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  100917. * In this case the connection point name must be the name of the attribute to use
  100918. * Can only be set on inputs
  100919. */
  100920. get isAttribute(): boolean;
  100921. set isAttribute(value: boolean);
  100922. /**
  100923. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  100924. * Can only be set on exit points
  100925. */
  100926. get isVarying(): boolean;
  100927. set isVarying(value: boolean);
  100928. /**
  100929. * Gets a boolean indicating that the current connection point is a system value
  100930. */
  100931. get isSystemValue(): boolean;
  100932. /**
  100933. * Gets or sets the current well known value or null if not defined as a system value
  100934. */
  100935. get systemValue(): Nullable<NodeMaterialSystemValues>;
  100936. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  100937. /**
  100938. * Gets the current class name
  100939. * @returns the class name
  100940. */
  100941. getClassName(): string;
  100942. /**
  100943. * Animate the input if animationType !== None
  100944. * @param scene defines the rendering scene
  100945. */
  100946. animate(scene: Scene): void;
  100947. private _emitDefine;
  100948. initialize(state: NodeMaterialBuildState): void;
  100949. /**
  100950. * Set the input block to its default value (based on its type)
  100951. */
  100952. setDefaultValue(): void;
  100953. private _emitConstant;
  100954. /** @hidden */
  100955. get _noContextSwitch(): boolean;
  100956. private _emit;
  100957. /** @hidden */
  100958. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  100959. /** @hidden */
  100960. _transmit(effect: Effect, scene: Scene): void;
  100961. protected _buildBlock(state: NodeMaterialBuildState): void;
  100962. protected _dumpPropertiesCode(): string;
  100963. dispose(): void;
  100964. serialize(): any;
  100965. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100966. }
  100967. }
  100968. declare module BABYLON {
  100969. /**
  100970. * Enum used to define the compatibility state between two connection points
  100971. */
  100972. export enum NodeMaterialConnectionPointCompatibilityStates {
  100973. /** Points are compatibles */
  100974. Compatible = 0,
  100975. /** Points are incompatible because of their types */
  100976. TypeIncompatible = 1,
  100977. /** Points are incompatible because of their targets (vertex vs fragment) */
  100978. TargetIncompatible = 2
  100979. }
  100980. /**
  100981. * Defines the direction of a connection point
  100982. */
  100983. export enum NodeMaterialConnectionPointDirection {
  100984. /** Input */
  100985. Input = 0,
  100986. /** Output */
  100987. Output = 1
  100988. }
  100989. /**
  100990. * Defines a connection point for a block
  100991. */
  100992. export class NodeMaterialConnectionPoint {
  100993. /** @hidden */
  100994. _ownerBlock: NodeMaterialBlock;
  100995. /** @hidden */
  100996. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  100997. private _endpoints;
  100998. private _associatedVariableName;
  100999. private _direction;
  101000. /** @hidden */
  101001. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101002. /** @hidden */
  101003. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101004. private _type;
  101005. /** @hidden */
  101006. _enforceAssociatedVariableName: boolean;
  101007. /** Gets the direction of the point */
  101008. get direction(): NodeMaterialConnectionPointDirection;
  101009. /** Indicates that this connection point needs dual validation before being connected to another point */
  101010. needDualDirectionValidation: boolean;
  101011. /**
  101012. * Gets or sets the additional types supported by this connection point
  101013. */
  101014. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101015. /**
  101016. * Gets or sets the additional types excluded by this connection point
  101017. */
  101018. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101019. /**
  101020. * Observable triggered when this point is connected
  101021. */
  101022. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  101023. /**
  101024. * Gets or sets the associated variable name in the shader
  101025. */
  101026. get associatedVariableName(): string;
  101027. set associatedVariableName(value: string);
  101028. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  101029. get innerType(): NodeMaterialBlockConnectionPointTypes;
  101030. /**
  101031. * Gets or sets the connection point type (default is float)
  101032. */
  101033. get type(): NodeMaterialBlockConnectionPointTypes;
  101034. set type(value: NodeMaterialBlockConnectionPointTypes);
  101035. /**
  101036. * Gets or sets the connection point name
  101037. */
  101038. name: string;
  101039. /**
  101040. * Gets or sets the connection point name
  101041. */
  101042. displayName: string;
  101043. /**
  101044. * Gets or sets a boolean indicating that this connection point can be omitted
  101045. */
  101046. isOptional: boolean;
  101047. /**
  101048. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  101049. */
  101050. isExposedOnFrame: boolean;
  101051. /**
  101052. * Gets or sets number indicating the position that the port is exposed to on a frame
  101053. */
  101054. exposedPortPosition: number;
  101055. /**
  101056. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  101057. */
  101058. define: string;
  101059. /** @hidden */
  101060. _prioritizeVertex: boolean;
  101061. private _target;
  101062. /** Gets or sets the target of that connection point */
  101063. get target(): NodeMaterialBlockTargets;
  101064. set target(value: NodeMaterialBlockTargets);
  101065. /**
  101066. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  101067. */
  101068. get isConnected(): boolean;
  101069. /**
  101070. * Gets a boolean indicating that the current point is connected to an input block
  101071. */
  101072. get isConnectedToInputBlock(): boolean;
  101073. /**
  101074. * Gets a the connected input block (if any)
  101075. */
  101076. get connectInputBlock(): Nullable<InputBlock>;
  101077. /** Get the other side of the connection (if any) */
  101078. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  101079. /** Get the block that owns this connection point */
  101080. get ownerBlock(): NodeMaterialBlock;
  101081. /** Get the block connected on the other side of this connection (if any) */
  101082. get sourceBlock(): Nullable<NodeMaterialBlock>;
  101083. /** Get the block connected on the endpoints of this connection (if any) */
  101084. get connectedBlocks(): Array<NodeMaterialBlock>;
  101085. /** Gets the list of connected endpoints */
  101086. get endpoints(): NodeMaterialConnectionPoint[];
  101087. /** Gets a boolean indicating if that output point is connected to at least one input */
  101088. get hasEndpoints(): boolean;
  101089. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  101090. get isConnectedInVertexShader(): boolean;
  101091. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  101092. get isConnectedInFragmentShader(): boolean;
  101093. /**
  101094. * Creates a block suitable to be used as an input for this input point.
  101095. * If null is returned, a block based on the point type will be created.
  101096. * @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
  101097. */
  101098. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101099. /**
  101100. * Creates a new connection point
  101101. * @param name defines the connection point name
  101102. * @param ownerBlock defines the block hosting this connection point
  101103. * @param direction defines the direction of the connection point
  101104. */
  101105. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  101106. /**
  101107. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  101108. * @returns the class name
  101109. */
  101110. getClassName(): string;
  101111. /**
  101112. * Gets a boolean indicating if the current point can be connected to another point
  101113. * @param connectionPoint defines the other connection point
  101114. * @returns a boolean
  101115. */
  101116. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  101117. /**
  101118. * Gets a number indicating if the current point can be connected to another point
  101119. * @param connectionPoint defines the other connection point
  101120. * @returns a number defining the compatibility state
  101121. */
  101122. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101123. /**
  101124. * Connect this point to another connection point
  101125. * @param connectionPoint defines the other connection point
  101126. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  101127. * @returns the current connection point
  101128. */
  101129. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  101130. /**
  101131. * Disconnect this point from one of his endpoint
  101132. * @param endpoint defines the other connection point
  101133. * @returns the current connection point
  101134. */
  101135. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  101136. /**
  101137. * Serializes this point in a JSON representation
  101138. * @param isInput defines if the connection point is an input (default is true)
  101139. * @returns the serialized point object
  101140. */
  101141. serialize(isInput?: boolean): any;
  101142. /**
  101143. * Release resources
  101144. */
  101145. dispose(): void;
  101146. }
  101147. }
  101148. declare module BABYLON {
  101149. /**
  101150. * Enum used to define the material modes
  101151. */
  101152. export enum NodeMaterialModes {
  101153. /** Regular material */
  101154. Material = 0,
  101155. /** For post process */
  101156. PostProcess = 1,
  101157. /** For particle system */
  101158. Particle = 2,
  101159. /** For procedural texture */
  101160. ProceduralTexture = 3
  101161. }
  101162. }
  101163. declare module BABYLON {
  101164. /**
  101165. * Block used to read a texture from a sampler
  101166. */
  101167. export class TextureBlock extends NodeMaterialBlock {
  101168. private _defineName;
  101169. private _linearDefineName;
  101170. private _gammaDefineName;
  101171. private _tempTextureRead;
  101172. private _samplerName;
  101173. private _transformedUVName;
  101174. private _textureTransformName;
  101175. private _textureInfoName;
  101176. private _mainUVName;
  101177. private _mainUVDefineName;
  101178. private _fragmentOnly;
  101179. /**
  101180. * Gets or sets the texture associated with the node
  101181. */
  101182. texture: Nullable<Texture>;
  101183. /**
  101184. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101185. */
  101186. convertToGammaSpace: boolean;
  101187. /**
  101188. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101189. */
  101190. convertToLinearSpace: boolean;
  101191. /**
  101192. * Create a new TextureBlock
  101193. * @param name defines the block name
  101194. */
  101195. constructor(name: string, fragmentOnly?: boolean);
  101196. /**
  101197. * Gets the current class name
  101198. * @returns the class name
  101199. */
  101200. getClassName(): string;
  101201. /**
  101202. * Gets the uv input component
  101203. */
  101204. get uv(): NodeMaterialConnectionPoint;
  101205. /**
  101206. * Gets the rgba output component
  101207. */
  101208. get rgba(): NodeMaterialConnectionPoint;
  101209. /**
  101210. * Gets the rgb output component
  101211. */
  101212. get rgb(): NodeMaterialConnectionPoint;
  101213. /**
  101214. * Gets the r output component
  101215. */
  101216. get r(): NodeMaterialConnectionPoint;
  101217. /**
  101218. * Gets the g output component
  101219. */
  101220. get g(): NodeMaterialConnectionPoint;
  101221. /**
  101222. * Gets the b output component
  101223. */
  101224. get b(): NodeMaterialConnectionPoint;
  101225. /**
  101226. * Gets the a output component
  101227. */
  101228. get a(): NodeMaterialConnectionPoint;
  101229. get target(): NodeMaterialBlockTargets;
  101230. autoConfigure(material: NodeMaterial): void;
  101231. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101232. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101233. isReady(): boolean;
  101234. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101235. private get _isMixed();
  101236. private _injectVertexCode;
  101237. private _writeTextureRead;
  101238. private _writeOutput;
  101239. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101240. protected _dumpPropertiesCode(): string;
  101241. serialize(): any;
  101242. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101243. }
  101244. }
  101245. declare module BABYLON {
  101246. /** @hidden */
  101247. export var reflectionFunction: {
  101248. name: string;
  101249. shader: string;
  101250. };
  101251. }
  101252. declare module BABYLON {
  101253. /**
  101254. * Base block used to read a reflection texture from a sampler
  101255. */
  101256. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  101257. /** @hidden */
  101258. _define3DName: string;
  101259. /** @hidden */
  101260. _defineCubicName: string;
  101261. /** @hidden */
  101262. _defineExplicitName: string;
  101263. /** @hidden */
  101264. _defineProjectionName: string;
  101265. /** @hidden */
  101266. _defineLocalCubicName: string;
  101267. /** @hidden */
  101268. _defineSphericalName: string;
  101269. /** @hidden */
  101270. _definePlanarName: string;
  101271. /** @hidden */
  101272. _defineEquirectangularName: string;
  101273. /** @hidden */
  101274. _defineMirroredEquirectangularFixedName: string;
  101275. /** @hidden */
  101276. _defineEquirectangularFixedName: string;
  101277. /** @hidden */
  101278. _defineSkyboxName: string;
  101279. /** @hidden */
  101280. _defineOppositeZ: string;
  101281. /** @hidden */
  101282. _cubeSamplerName: string;
  101283. /** @hidden */
  101284. _2DSamplerName: string;
  101285. protected _positionUVWName: string;
  101286. protected _directionWName: string;
  101287. protected _reflectionVectorName: string;
  101288. /** @hidden */
  101289. _reflectionCoordsName: string;
  101290. /** @hidden */
  101291. _reflectionMatrixName: string;
  101292. protected _reflectionColorName: string;
  101293. /**
  101294. * Gets or sets the texture associated with the node
  101295. */
  101296. texture: Nullable<BaseTexture>;
  101297. /**
  101298. * Create a new ReflectionTextureBaseBlock
  101299. * @param name defines the block name
  101300. */
  101301. constructor(name: string);
  101302. /**
  101303. * Gets the current class name
  101304. * @returns the class name
  101305. */
  101306. getClassName(): string;
  101307. /**
  101308. * Gets the world position input component
  101309. */
  101310. abstract get position(): NodeMaterialConnectionPoint;
  101311. /**
  101312. * Gets the world position input component
  101313. */
  101314. abstract get worldPosition(): NodeMaterialConnectionPoint;
  101315. /**
  101316. * Gets the world normal input component
  101317. */
  101318. abstract get worldNormal(): NodeMaterialConnectionPoint;
  101319. /**
  101320. * Gets the world input component
  101321. */
  101322. abstract get world(): NodeMaterialConnectionPoint;
  101323. /**
  101324. * Gets the camera (or eye) position component
  101325. */
  101326. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  101327. /**
  101328. * Gets the view input component
  101329. */
  101330. abstract get view(): NodeMaterialConnectionPoint;
  101331. protected _getTexture(): Nullable<BaseTexture>;
  101332. autoConfigure(material: NodeMaterial): void;
  101333. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101334. isReady(): boolean;
  101335. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101336. /**
  101337. * Gets the code to inject in the vertex shader
  101338. * @param state current state of the node material building
  101339. * @returns the shader code
  101340. */
  101341. handleVertexSide(state: NodeMaterialBuildState): string;
  101342. /**
  101343. * Handles the inits for the fragment code path
  101344. * @param state node material build state
  101345. */
  101346. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  101347. /**
  101348. * Generates the reflection coords code for the fragment code path
  101349. * @param worldNormalVarName name of the world normal variable
  101350. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  101351. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  101352. * @returns the shader code
  101353. */
  101354. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  101355. /**
  101356. * Generates the reflection color code for the fragment code path
  101357. * @param lodVarName name of the lod variable
  101358. * @param swizzleLookupTexture swizzle to use for the final color variable
  101359. * @returns the shader code
  101360. */
  101361. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  101362. /**
  101363. * Generates the code corresponding to the connected output points
  101364. * @param state node material build state
  101365. * @param varName name of the variable to output
  101366. * @returns the shader code
  101367. */
  101368. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  101369. protected _buildBlock(state: NodeMaterialBuildState): this;
  101370. protected _dumpPropertiesCode(): string;
  101371. serialize(): any;
  101372. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101373. }
  101374. }
  101375. declare module BABYLON {
  101376. /**
  101377. * Defines a connection point to be used for points with a custom object type
  101378. */
  101379. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  101380. private _blockType;
  101381. private _blockName;
  101382. private _nameForCheking?;
  101383. /**
  101384. * Creates a new connection point
  101385. * @param name defines the connection point name
  101386. * @param ownerBlock defines the block hosting this connection point
  101387. * @param direction defines the direction of the connection point
  101388. */
  101389. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  101390. /**
  101391. * Gets a number indicating if the current point can be connected to another point
  101392. * @param connectionPoint defines the other connection point
  101393. * @returns a number defining the compatibility state
  101394. */
  101395. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101396. /**
  101397. * Creates a block suitable to be used as an input for this input point.
  101398. * If null is returned, a block based on the point type will be created.
  101399. * @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
  101400. */
  101401. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101402. }
  101403. }
  101404. declare module BABYLON {
  101405. /**
  101406. * Enum defining the type of properties that can be edited in the property pages in the NME
  101407. */
  101408. export enum PropertyTypeForEdition {
  101409. /** property is a boolean */
  101410. Boolean = 0,
  101411. /** property is a float */
  101412. Float = 1,
  101413. /** property is a Vector2 */
  101414. Vector2 = 2,
  101415. /** property is a list of values */
  101416. List = 3
  101417. }
  101418. /**
  101419. * Interface that defines an option in a variable of type list
  101420. */
  101421. export interface IEditablePropertyListOption {
  101422. /** label of the option */
  101423. "label": string;
  101424. /** value of the option */
  101425. "value": number;
  101426. }
  101427. /**
  101428. * Interface that defines the options available for an editable property
  101429. */
  101430. export interface IEditablePropertyOption {
  101431. /** min value */
  101432. "min"?: number;
  101433. /** max value */
  101434. "max"?: number;
  101435. /** notifiers: indicates which actions to take when the property is changed */
  101436. "notifiers"?: {
  101437. /** the material should be rebuilt */
  101438. "rebuild"?: boolean;
  101439. /** the preview should be updated */
  101440. "update"?: boolean;
  101441. };
  101442. /** list of the options for a variable of type list */
  101443. "options"?: IEditablePropertyListOption[];
  101444. }
  101445. /**
  101446. * Interface that describes an editable property
  101447. */
  101448. export interface IPropertyDescriptionForEdition {
  101449. /** name of the property */
  101450. "propertyName": string;
  101451. /** display name of the property */
  101452. "displayName": string;
  101453. /** type of the property */
  101454. "type": PropertyTypeForEdition;
  101455. /** group of the property - all properties with the same group value will be displayed in a specific section */
  101456. "groupName": string;
  101457. /** options for the property */
  101458. "options": IEditablePropertyOption;
  101459. }
  101460. /**
  101461. * Decorator that flags a property in a node material block as being editable
  101462. */
  101463. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  101464. }
  101465. declare module BABYLON {
  101466. /**
  101467. * Block used to implement the refraction part of the sub surface module of the PBR material
  101468. */
  101469. export class RefractionBlock extends NodeMaterialBlock {
  101470. /** @hidden */
  101471. _define3DName: string;
  101472. /** @hidden */
  101473. _refractionMatrixName: string;
  101474. /** @hidden */
  101475. _defineLODRefractionAlpha: string;
  101476. /** @hidden */
  101477. _defineLinearSpecularRefraction: string;
  101478. /** @hidden */
  101479. _defineOppositeZ: string;
  101480. /** @hidden */
  101481. _cubeSamplerName: string;
  101482. /** @hidden */
  101483. _2DSamplerName: string;
  101484. /** @hidden */
  101485. _vRefractionMicrosurfaceInfosName: string;
  101486. /** @hidden */
  101487. _vRefractionInfosName: string;
  101488. private _scene;
  101489. /**
  101490. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101491. * Materials half opaque for instance using refraction could benefit from this control.
  101492. */
  101493. linkRefractionWithTransparency: boolean;
  101494. /**
  101495. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101496. */
  101497. invertRefractionY: boolean;
  101498. /**
  101499. * Gets or sets the texture associated with the node
  101500. */
  101501. texture: Nullable<BaseTexture>;
  101502. /**
  101503. * Create a new RefractionBlock
  101504. * @param name defines the block name
  101505. */
  101506. constructor(name: string);
  101507. /**
  101508. * Gets the current class name
  101509. * @returns the class name
  101510. */
  101511. getClassName(): string;
  101512. /**
  101513. * Gets the intensity input component
  101514. */
  101515. get intensity(): NodeMaterialConnectionPoint;
  101516. /**
  101517. * Gets the index of refraction input component
  101518. */
  101519. get indexOfRefraction(): NodeMaterialConnectionPoint;
  101520. /**
  101521. * Gets the tint at distance input component
  101522. */
  101523. get tintAtDistance(): NodeMaterialConnectionPoint;
  101524. /**
  101525. * Gets the view input component
  101526. */
  101527. get view(): NodeMaterialConnectionPoint;
  101528. /**
  101529. * Gets the refraction object output component
  101530. */
  101531. get refraction(): NodeMaterialConnectionPoint;
  101532. /**
  101533. * Returns true if the block has a texture
  101534. */
  101535. get hasTexture(): boolean;
  101536. protected _getTexture(): Nullable<BaseTexture>;
  101537. autoConfigure(material: NodeMaterial): void;
  101538. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101539. isReady(): boolean;
  101540. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101541. /**
  101542. * Gets the main code of the block (fragment side)
  101543. * @param state current state of the node material building
  101544. * @returns the shader code
  101545. */
  101546. getCode(state: NodeMaterialBuildState): string;
  101547. protected _buildBlock(state: NodeMaterialBuildState): this;
  101548. protected _dumpPropertiesCode(): string;
  101549. serialize(): any;
  101550. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101551. }
  101552. }
  101553. declare module BABYLON {
  101554. /**
  101555. * Base block used as input for post process
  101556. */
  101557. export class CurrentScreenBlock extends NodeMaterialBlock {
  101558. private _samplerName;
  101559. private _linearDefineName;
  101560. private _gammaDefineName;
  101561. private _mainUVName;
  101562. private _tempTextureRead;
  101563. /**
  101564. * Gets or sets the texture associated with the node
  101565. */
  101566. texture: Nullable<BaseTexture>;
  101567. /**
  101568. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101569. */
  101570. convertToGammaSpace: boolean;
  101571. /**
  101572. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101573. */
  101574. convertToLinearSpace: boolean;
  101575. /**
  101576. * Create a new CurrentScreenBlock
  101577. * @param name defines the block name
  101578. */
  101579. constructor(name: string);
  101580. /**
  101581. * Gets the current class name
  101582. * @returns the class name
  101583. */
  101584. getClassName(): string;
  101585. /**
  101586. * Gets the uv input component
  101587. */
  101588. get uv(): NodeMaterialConnectionPoint;
  101589. /**
  101590. * Gets the rgba output component
  101591. */
  101592. get rgba(): NodeMaterialConnectionPoint;
  101593. /**
  101594. * Gets the rgb output component
  101595. */
  101596. get rgb(): NodeMaterialConnectionPoint;
  101597. /**
  101598. * Gets the r output component
  101599. */
  101600. get r(): NodeMaterialConnectionPoint;
  101601. /**
  101602. * Gets the g output component
  101603. */
  101604. get g(): NodeMaterialConnectionPoint;
  101605. /**
  101606. * Gets the b output component
  101607. */
  101608. get b(): NodeMaterialConnectionPoint;
  101609. /**
  101610. * Gets the a output component
  101611. */
  101612. get a(): NodeMaterialConnectionPoint;
  101613. /**
  101614. * Initialize the block and prepare the context for build
  101615. * @param state defines the state that will be used for the build
  101616. */
  101617. initialize(state: NodeMaterialBuildState): void;
  101618. get target(): NodeMaterialBlockTargets;
  101619. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101620. isReady(): boolean;
  101621. private _injectVertexCode;
  101622. private _writeTextureRead;
  101623. private _writeOutput;
  101624. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101625. serialize(): any;
  101626. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101627. }
  101628. }
  101629. declare module BABYLON {
  101630. /**
  101631. * Base block used for the particle texture
  101632. */
  101633. export class ParticleTextureBlock extends NodeMaterialBlock {
  101634. private _samplerName;
  101635. private _linearDefineName;
  101636. private _gammaDefineName;
  101637. private _tempTextureRead;
  101638. /**
  101639. * Gets or sets the texture associated with the node
  101640. */
  101641. texture: Nullable<BaseTexture>;
  101642. /**
  101643. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101644. */
  101645. convertToGammaSpace: boolean;
  101646. /**
  101647. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101648. */
  101649. convertToLinearSpace: boolean;
  101650. /**
  101651. * Create a new ParticleTextureBlock
  101652. * @param name defines the block name
  101653. */
  101654. constructor(name: string);
  101655. /**
  101656. * Gets the current class name
  101657. * @returns the class name
  101658. */
  101659. getClassName(): string;
  101660. /**
  101661. * Gets the uv input component
  101662. */
  101663. get uv(): NodeMaterialConnectionPoint;
  101664. /**
  101665. * Gets the rgba output component
  101666. */
  101667. get rgba(): NodeMaterialConnectionPoint;
  101668. /**
  101669. * Gets the rgb output component
  101670. */
  101671. get rgb(): NodeMaterialConnectionPoint;
  101672. /**
  101673. * Gets the r output component
  101674. */
  101675. get r(): NodeMaterialConnectionPoint;
  101676. /**
  101677. * Gets the g output component
  101678. */
  101679. get g(): NodeMaterialConnectionPoint;
  101680. /**
  101681. * Gets the b output component
  101682. */
  101683. get b(): NodeMaterialConnectionPoint;
  101684. /**
  101685. * Gets the a output component
  101686. */
  101687. get a(): NodeMaterialConnectionPoint;
  101688. /**
  101689. * Initialize the block and prepare the context for build
  101690. * @param state defines the state that will be used for the build
  101691. */
  101692. initialize(state: NodeMaterialBuildState): void;
  101693. autoConfigure(material: NodeMaterial): void;
  101694. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101695. isReady(): boolean;
  101696. private _writeOutput;
  101697. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101698. serialize(): any;
  101699. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101700. }
  101701. }
  101702. declare module BABYLON {
  101703. /**
  101704. * Class used to store shared data between 2 NodeMaterialBuildState
  101705. */
  101706. export class NodeMaterialBuildStateSharedData {
  101707. /**
  101708. * Gets the list of emitted varyings
  101709. */
  101710. temps: string[];
  101711. /**
  101712. * Gets the list of emitted varyings
  101713. */
  101714. varyings: string[];
  101715. /**
  101716. * Gets the varying declaration string
  101717. */
  101718. varyingDeclaration: string;
  101719. /**
  101720. * Input blocks
  101721. */
  101722. inputBlocks: InputBlock[];
  101723. /**
  101724. * Input blocks
  101725. */
  101726. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101727. /**
  101728. * Bindable blocks (Blocks that need to set data to the effect)
  101729. */
  101730. bindableBlocks: NodeMaterialBlock[];
  101731. /**
  101732. * List of blocks that can provide a compilation fallback
  101733. */
  101734. blocksWithFallbacks: NodeMaterialBlock[];
  101735. /**
  101736. * List of blocks that can provide a define update
  101737. */
  101738. blocksWithDefines: NodeMaterialBlock[];
  101739. /**
  101740. * List of blocks that can provide a repeatable content
  101741. */
  101742. repeatableContentBlocks: NodeMaterialBlock[];
  101743. /**
  101744. * List of blocks that can provide a dynamic list of uniforms
  101745. */
  101746. dynamicUniformBlocks: NodeMaterialBlock[];
  101747. /**
  101748. * List of blocks that can block the isReady function for the material
  101749. */
  101750. blockingBlocks: NodeMaterialBlock[];
  101751. /**
  101752. * Gets the list of animated inputs
  101753. */
  101754. animatedInputs: InputBlock[];
  101755. /**
  101756. * Build Id used to avoid multiple recompilations
  101757. */
  101758. buildId: number;
  101759. /** List of emitted variables */
  101760. variableNames: {
  101761. [key: string]: number;
  101762. };
  101763. /** List of emitted defines */
  101764. defineNames: {
  101765. [key: string]: number;
  101766. };
  101767. /** Should emit comments? */
  101768. emitComments: boolean;
  101769. /** Emit build activity */
  101770. verbose: boolean;
  101771. /** Gets or sets the hosting scene */
  101772. scene: Scene;
  101773. /**
  101774. * Gets the compilation hints emitted at compilation time
  101775. */
  101776. hints: {
  101777. needWorldViewMatrix: boolean;
  101778. needWorldViewProjectionMatrix: boolean;
  101779. needAlphaBlending: boolean;
  101780. needAlphaTesting: boolean;
  101781. };
  101782. /**
  101783. * List of compilation checks
  101784. */
  101785. checks: {
  101786. emitVertex: boolean;
  101787. emitFragment: boolean;
  101788. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  101789. };
  101790. /**
  101791. * Is vertex program allowed to be empty?
  101792. */
  101793. allowEmptyVertexProgram: boolean;
  101794. /** Creates a new shared data */
  101795. constructor();
  101796. /**
  101797. * Emits console errors and exceptions if there is a failing check
  101798. */
  101799. emitErrors(): void;
  101800. }
  101801. }
  101802. declare module BABYLON {
  101803. /**
  101804. * Class used to store node based material build state
  101805. */
  101806. export class NodeMaterialBuildState {
  101807. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  101808. supportUniformBuffers: boolean;
  101809. /**
  101810. * Gets the list of emitted attributes
  101811. */
  101812. attributes: string[];
  101813. /**
  101814. * Gets the list of emitted uniforms
  101815. */
  101816. uniforms: string[];
  101817. /**
  101818. * Gets the list of emitted constants
  101819. */
  101820. constants: string[];
  101821. /**
  101822. * Gets the list of emitted samplers
  101823. */
  101824. samplers: string[];
  101825. /**
  101826. * Gets the list of emitted functions
  101827. */
  101828. functions: {
  101829. [key: string]: string;
  101830. };
  101831. /**
  101832. * Gets the list of emitted extensions
  101833. */
  101834. extensions: {
  101835. [key: string]: string;
  101836. };
  101837. /**
  101838. * Gets the target of the compilation state
  101839. */
  101840. target: NodeMaterialBlockTargets;
  101841. /**
  101842. * Gets the list of emitted counters
  101843. */
  101844. counters: {
  101845. [key: string]: number;
  101846. };
  101847. /**
  101848. * Shared data between multiple NodeMaterialBuildState instances
  101849. */
  101850. sharedData: NodeMaterialBuildStateSharedData;
  101851. /** @hidden */
  101852. _vertexState: NodeMaterialBuildState;
  101853. /** @hidden */
  101854. _attributeDeclaration: string;
  101855. /** @hidden */
  101856. _uniformDeclaration: string;
  101857. /** @hidden */
  101858. _constantDeclaration: string;
  101859. /** @hidden */
  101860. _samplerDeclaration: string;
  101861. /** @hidden */
  101862. _varyingTransfer: string;
  101863. /** @hidden */
  101864. _injectAtEnd: string;
  101865. private _repeatableContentAnchorIndex;
  101866. /** @hidden */
  101867. _builtCompilationString: string;
  101868. /**
  101869. * Gets the emitted compilation strings
  101870. */
  101871. compilationString: string;
  101872. /**
  101873. * Finalize the compilation strings
  101874. * @param state defines the current compilation state
  101875. */
  101876. finalize(state: NodeMaterialBuildState): void;
  101877. /** @hidden */
  101878. get _repeatableContentAnchor(): string;
  101879. /** @hidden */
  101880. _getFreeVariableName(prefix: string): string;
  101881. /** @hidden */
  101882. _getFreeDefineName(prefix: string): string;
  101883. /** @hidden */
  101884. _excludeVariableName(name: string): void;
  101885. /** @hidden */
  101886. _emit2DSampler(name: string): void;
  101887. /** @hidden */
  101888. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  101889. /** @hidden */
  101890. _emitExtension(name: string, extension: string, define?: string): void;
  101891. /** @hidden */
  101892. _emitFunction(name: string, code: string, comments: string): void;
  101893. /** @hidden */
  101894. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  101895. replaceStrings?: {
  101896. search: RegExp;
  101897. replace: string;
  101898. }[];
  101899. repeatKey?: string;
  101900. }): string;
  101901. /** @hidden */
  101902. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  101903. repeatKey?: string;
  101904. removeAttributes?: boolean;
  101905. removeUniforms?: boolean;
  101906. removeVaryings?: boolean;
  101907. removeIfDef?: boolean;
  101908. replaceStrings?: {
  101909. search: RegExp;
  101910. replace: string;
  101911. }[];
  101912. }, storeKey?: string): void;
  101913. /** @hidden */
  101914. _registerTempVariable(name: string): boolean;
  101915. /** @hidden */
  101916. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  101917. /** @hidden */
  101918. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  101919. /** @hidden */
  101920. _emitFloat(value: number): string;
  101921. }
  101922. }
  101923. declare module BABYLON {
  101924. /**
  101925. * Helper class used to generate session unique ID
  101926. */
  101927. export class UniqueIdGenerator {
  101928. private static _UniqueIdCounter;
  101929. /**
  101930. * Gets an unique (relatively to the current scene) Id
  101931. */
  101932. static get UniqueId(): number;
  101933. }
  101934. }
  101935. declare module BABYLON {
  101936. /**
  101937. * Defines a block that can be used inside a node based material
  101938. */
  101939. export class NodeMaterialBlock {
  101940. private _buildId;
  101941. private _buildTarget;
  101942. private _target;
  101943. private _isFinalMerger;
  101944. private _isInput;
  101945. private _name;
  101946. protected _isUnique: boolean;
  101947. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  101948. inputsAreExclusive: boolean;
  101949. /** @hidden */
  101950. _codeVariableName: string;
  101951. /** @hidden */
  101952. _inputs: NodeMaterialConnectionPoint[];
  101953. /** @hidden */
  101954. _outputs: NodeMaterialConnectionPoint[];
  101955. /** @hidden */
  101956. _preparationId: number;
  101957. /**
  101958. * Gets the name of the block
  101959. */
  101960. get name(): string;
  101961. /**
  101962. * Sets the name of the block. Will check if the name is valid.
  101963. */
  101964. set name(newName: string);
  101965. /**
  101966. * Gets or sets the unique id of the node
  101967. */
  101968. uniqueId: number;
  101969. /**
  101970. * Gets or sets the comments associated with this block
  101971. */
  101972. comments: string;
  101973. /**
  101974. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  101975. */
  101976. get isUnique(): boolean;
  101977. /**
  101978. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  101979. */
  101980. get isFinalMerger(): boolean;
  101981. /**
  101982. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  101983. */
  101984. get isInput(): boolean;
  101985. /**
  101986. * Gets or sets the build Id
  101987. */
  101988. get buildId(): number;
  101989. set buildId(value: number);
  101990. /**
  101991. * Gets or sets the target of the block
  101992. */
  101993. get target(): NodeMaterialBlockTargets;
  101994. set target(value: NodeMaterialBlockTargets);
  101995. /**
  101996. * Gets the list of input points
  101997. */
  101998. get inputs(): NodeMaterialConnectionPoint[];
  101999. /** Gets the list of output points */
  102000. get outputs(): NodeMaterialConnectionPoint[];
  102001. /**
  102002. * Find an input by its name
  102003. * @param name defines the name of the input to look for
  102004. * @returns the input or null if not found
  102005. */
  102006. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102007. /**
  102008. * Find an output by its name
  102009. * @param name defines the name of the outputto look for
  102010. * @returns the output or null if not found
  102011. */
  102012. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102013. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  102014. visibleInInspector: boolean;
  102015. /**
  102016. * Creates a new NodeMaterialBlock
  102017. * @param name defines the block name
  102018. * @param target defines the target of that block (Vertex by default)
  102019. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  102020. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  102021. */
  102022. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  102023. /**
  102024. * Initialize the block and prepare the context for build
  102025. * @param state defines the state that will be used for the build
  102026. */
  102027. initialize(state: NodeMaterialBuildState): void;
  102028. /**
  102029. * Bind data to effect. Will only be called for blocks with isBindable === true
  102030. * @param effect defines the effect to bind data to
  102031. * @param nodeMaterial defines the hosting NodeMaterial
  102032. * @param mesh defines the mesh that will be rendered
  102033. * @param subMesh defines the submesh that will be rendered
  102034. */
  102035. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102036. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  102037. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  102038. protected _writeFloat(value: number): string;
  102039. /**
  102040. * Gets the current class name e.g. "NodeMaterialBlock"
  102041. * @returns the class name
  102042. */
  102043. getClassName(): string;
  102044. /**
  102045. * Register a new input. Must be called inside a block constructor
  102046. * @param name defines the connection point name
  102047. * @param type defines the connection point type
  102048. * @param isOptional defines a boolean indicating that this input can be omitted
  102049. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102050. * @param point an already created connection point. If not provided, create a new one
  102051. * @returns the current block
  102052. */
  102053. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102054. /**
  102055. * Register a new output. Must be called inside a block constructor
  102056. * @param name defines the connection point name
  102057. * @param type defines the connection point type
  102058. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102059. * @param point an already created connection point. If not provided, create a new one
  102060. * @returns the current block
  102061. */
  102062. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102063. /**
  102064. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  102065. * @param forOutput defines an optional connection point to check compatibility with
  102066. * @returns the first available input or null
  102067. */
  102068. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  102069. /**
  102070. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  102071. * @param forBlock defines an optional block to check compatibility with
  102072. * @returns the first available input or null
  102073. */
  102074. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  102075. /**
  102076. * Gets the sibling of the given output
  102077. * @param current defines the current output
  102078. * @returns the next output in the list or null
  102079. */
  102080. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  102081. /**
  102082. * Connect current block with another block
  102083. * @param other defines the block to connect with
  102084. * @param options define the various options to help pick the right connections
  102085. * @returns the current block
  102086. */
  102087. connectTo(other: NodeMaterialBlock, options?: {
  102088. input?: string;
  102089. output?: string;
  102090. outputSwizzle?: string;
  102091. }): this | undefined;
  102092. protected _buildBlock(state: NodeMaterialBuildState): void;
  102093. /**
  102094. * Add uniforms, samplers and uniform buffers at compilation time
  102095. * @param state defines the state to update
  102096. * @param nodeMaterial defines the node material requesting the update
  102097. * @param defines defines the material defines to update
  102098. * @param uniformBuffers defines the list of uniform buffer names
  102099. */
  102100. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  102101. /**
  102102. * Add potential fallbacks if shader compilation fails
  102103. * @param mesh defines the mesh to be rendered
  102104. * @param fallbacks defines the current prioritized list of fallbacks
  102105. */
  102106. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  102107. /**
  102108. * Initialize defines for shader compilation
  102109. * @param mesh defines the mesh to be rendered
  102110. * @param nodeMaterial defines the node material requesting the update
  102111. * @param defines defines the material defines to update
  102112. * @param useInstances specifies that instances should be used
  102113. */
  102114. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102115. /**
  102116. * Update defines for shader compilation
  102117. * @param mesh defines the mesh to be rendered
  102118. * @param nodeMaterial defines the node material requesting the update
  102119. * @param defines defines the material defines to update
  102120. * @param useInstances specifies that instances should be used
  102121. * @param subMesh defines which submesh to render
  102122. */
  102123. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102124. /**
  102125. * Lets the block try to connect some inputs automatically
  102126. * @param material defines the hosting NodeMaterial
  102127. */
  102128. autoConfigure(material: NodeMaterial): void;
  102129. /**
  102130. * Function called when a block is declared as repeatable content generator
  102131. * @param vertexShaderState defines the current compilation state for the vertex shader
  102132. * @param fragmentShaderState defines the current compilation state for the fragment shader
  102133. * @param mesh defines the mesh to be rendered
  102134. * @param defines defines the material defines to update
  102135. */
  102136. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  102137. /**
  102138. * Checks if the block is ready
  102139. * @param mesh defines the mesh to be rendered
  102140. * @param nodeMaterial defines the node material requesting the update
  102141. * @param defines defines the material defines to update
  102142. * @param useInstances specifies that instances should be used
  102143. * @returns true if the block is ready
  102144. */
  102145. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  102146. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  102147. private _processBuild;
  102148. /**
  102149. * Validates the new name for the block node.
  102150. * @param newName the new name to be given to the node.
  102151. * @returns false if the name is a reserve word, else true.
  102152. */
  102153. validateBlockName(newName: string): boolean;
  102154. /**
  102155. * Compile the current node and generate the shader code
  102156. * @param state defines the current compilation state (uniforms, samplers, current string)
  102157. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  102158. * @returns true if already built
  102159. */
  102160. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  102161. protected _inputRename(name: string): string;
  102162. protected _outputRename(name: string): string;
  102163. protected _dumpPropertiesCode(): string;
  102164. /** @hidden */
  102165. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  102166. /** @hidden */
  102167. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  102168. /**
  102169. * Clone the current block to a new identical block
  102170. * @param scene defines the hosting scene
  102171. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102172. * @returns a copy of the current block
  102173. */
  102174. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  102175. /**
  102176. * Serializes this block in a JSON representation
  102177. * @returns the serialized block object
  102178. */
  102179. serialize(): any;
  102180. /** @hidden */
  102181. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102182. private _deserializePortDisplayNamesAndExposedOnFrame;
  102183. /**
  102184. * Release resources
  102185. */
  102186. dispose(): void;
  102187. }
  102188. }
  102189. declare module BABYLON {
  102190. /**
  102191. * Base class of materials working in push mode in babylon JS
  102192. * @hidden
  102193. */
  102194. export class PushMaterial extends Material {
  102195. protected _activeEffect: Effect;
  102196. protected _normalMatrix: Matrix;
  102197. constructor(name: string, scene: Scene);
  102198. getEffect(): Effect;
  102199. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102200. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102201. /**
  102202. * Binds the given world matrix to the active effect
  102203. *
  102204. * @param world the matrix to bind
  102205. */
  102206. bindOnlyWorldMatrix(world: Matrix): void;
  102207. /**
  102208. * Binds the given normal matrix to the active effect
  102209. *
  102210. * @param normalMatrix the matrix to bind
  102211. */
  102212. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102213. bind(world: Matrix, mesh?: Mesh): void;
  102214. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102215. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102216. }
  102217. }
  102218. declare module BABYLON {
  102219. /**
  102220. * Root class for all node material optimizers
  102221. */
  102222. export class NodeMaterialOptimizer {
  102223. /**
  102224. * Function used to optimize a NodeMaterial graph
  102225. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  102226. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  102227. */
  102228. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  102229. }
  102230. }
  102231. declare module BABYLON {
  102232. /**
  102233. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  102234. */
  102235. export class TransformBlock extends NodeMaterialBlock {
  102236. /**
  102237. * Defines the value to use to complement W value to transform it to a Vector4
  102238. */
  102239. complementW: number;
  102240. /**
  102241. * Defines the value to use to complement z value to transform it to a Vector4
  102242. */
  102243. complementZ: number;
  102244. /**
  102245. * Creates a new TransformBlock
  102246. * @param name defines the block name
  102247. */
  102248. constructor(name: string);
  102249. /**
  102250. * Gets the current class name
  102251. * @returns the class name
  102252. */
  102253. getClassName(): string;
  102254. /**
  102255. * Gets the vector input
  102256. */
  102257. get vector(): NodeMaterialConnectionPoint;
  102258. /**
  102259. * Gets the output component
  102260. */
  102261. get output(): NodeMaterialConnectionPoint;
  102262. /**
  102263. * Gets the xyz output component
  102264. */
  102265. get xyz(): NodeMaterialConnectionPoint;
  102266. /**
  102267. * Gets the matrix transform input
  102268. */
  102269. get transform(): NodeMaterialConnectionPoint;
  102270. protected _buildBlock(state: NodeMaterialBuildState): this;
  102271. /**
  102272. * Update defines for shader compilation
  102273. * @param mesh defines the mesh to be rendered
  102274. * @param nodeMaterial defines the node material requesting the update
  102275. * @param defines defines the material defines to update
  102276. * @param useInstances specifies that instances should be used
  102277. * @param subMesh defines which submesh to render
  102278. */
  102279. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102280. serialize(): any;
  102281. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102282. protected _dumpPropertiesCode(): string;
  102283. }
  102284. }
  102285. declare module BABYLON {
  102286. /**
  102287. * Block used to output the vertex position
  102288. */
  102289. export class VertexOutputBlock extends NodeMaterialBlock {
  102290. /**
  102291. * Creates a new VertexOutputBlock
  102292. * @param name defines the block name
  102293. */
  102294. constructor(name: string);
  102295. /**
  102296. * Gets the current class name
  102297. * @returns the class name
  102298. */
  102299. getClassName(): string;
  102300. /**
  102301. * Gets the vector input component
  102302. */
  102303. get vector(): NodeMaterialConnectionPoint;
  102304. protected _buildBlock(state: NodeMaterialBuildState): this;
  102305. }
  102306. }
  102307. declare module BABYLON {
  102308. /**
  102309. * Block used to output the final color
  102310. */
  102311. export class FragmentOutputBlock extends NodeMaterialBlock {
  102312. /**
  102313. * Create a new FragmentOutputBlock
  102314. * @param name defines the block name
  102315. */
  102316. constructor(name: string);
  102317. /**
  102318. * Gets the current class name
  102319. * @returns the class name
  102320. */
  102321. getClassName(): string;
  102322. /**
  102323. * Gets the rgba input component
  102324. */
  102325. get rgba(): NodeMaterialConnectionPoint;
  102326. /**
  102327. * Gets the rgb input component
  102328. */
  102329. get rgb(): NodeMaterialConnectionPoint;
  102330. /**
  102331. * Gets the a input component
  102332. */
  102333. get a(): NodeMaterialConnectionPoint;
  102334. protected _buildBlock(state: NodeMaterialBuildState): this;
  102335. }
  102336. }
  102337. declare module BABYLON {
  102338. /**
  102339. * Block used for the particle ramp gradient section
  102340. */
  102341. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  102342. /**
  102343. * Create a new ParticleRampGradientBlock
  102344. * @param name defines the block name
  102345. */
  102346. constructor(name: string);
  102347. /**
  102348. * Gets the current class name
  102349. * @returns the class name
  102350. */
  102351. getClassName(): string;
  102352. /**
  102353. * Gets the color input component
  102354. */
  102355. get color(): NodeMaterialConnectionPoint;
  102356. /**
  102357. * Gets the rampColor output component
  102358. */
  102359. get rampColor(): NodeMaterialConnectionPoint;
  102360. /**
  102361. * Initialize the block and prepare the context for build
  102362. * @param state defines the state that will be used for the build
  102363. */
  102364. initialize(state: NodeMaterialBuildState): void;
  102365. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102366. }
  102367. }
  102368. declare module BABYLON {
  102369. /**
  102370. * Block used for the particle blend multiply section
  102371. */
  102372. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  102373. /**
  102374. * Create a new ParticleBlendMultiplyBlock
  102375. * @param name defines the block name
  102376. */
  102377. constructor(name: string);
  102378. /**
  102379. * Gets the current class name
  102380. * @returns the class name
  102381. */
  102382. getClassName(): string;
  102383. /**
  102384. * Gets the color input component
  102385. */
  102386. get color(): NodeMaterialConnectionPoint;
  102387. /**
  102388. * Gets the alphaTexture input component
  102389. */
  102390. get alphaTexture(): NodeMaterialConnectionPoint;
  102391. /**
  102392. * Gets the alphaColor input component
  102393. */
  102394. get alphaColor(): NodeMaterialConnectionPoint;
  102395. /**
  102396. * Gets the blendColor output component
  102397. */
  102398. get blendColor(): NodeMaterialConnectionPoint;
  102399. /**
  102400. * Initialize the block and prepare the context for build
  102401. * @param state defines the state that will be used for the build
  102402. */
  102403. initialize(state: NodeMaterialBuildState): void;
  102404. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102405. }
  102406. }
  102407. declare module BABYLON {
  102408. /**
  102409. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  102410. */
  102411. export class VectorMergerBlock extends NodeMaterialBlock {
  102412. /**
  102413. * Create a new VectorMergerBlock
  102414. * @param name defines the block name
  102415. */
  102416. constructor(name: string);
  102417. /**
  102418. * Gets the current class name
  102419. * @returns the class name
  102420. */
  102421. getClassName(): string;
  102422. /**
  102423. * Gets the xyz component (input)
  102424. */
  102425. get xyzIn(): NodeMaterialConnectionPoint;
  102426. /**
  102427. * Gets the xy component (input)
  102428. */
  102429. get xyIn(): NodeMaterialConnectionPoint;
  102430. /**
  102431. * Gets the x component (input)
  102432. */
  102433. get x(): NodeMaterialConnectionPoint;
  102434. /**
  102435. * Gets the y component (input)
  102436. */
  102437. get y(): NodeMaterialConnectionPoint;
  102438. /**
  102439. * Gets the z component (input)
  102440. */
  102441. get z(): NodeMaterialConnectionPoint;
  102442. /**
  102443. * Gets the w component (input)
  102444. */
  102445. get w(): NodeMaterialConnectionPoint;
  102446. /**
  102447. * Gets the xyzw component (output)
  102448. */
  102449. get xyzw(): NodeMaterialConnectionPoint;
  102450. /**
  102451. * Gets the xyz component (output)
  102452. */
  102453. get xyzOut(): NodeMaterialConnectionPoint;
  102454. /**
  102455. * Gets the xy component (output)
  102456. */
  102457. get xyOut(): NodeMaterialConnectionPoint;
  102458. /**
  102459. * Gets the xy component (output)
  102460. * @deprecated Please use xyOut instead.
  102461. */
  102462. get xy(): NodeMaterialConnectionPoint;
  102463. /**
  102464. * Gets the xyz component (output)
  102465. * @deprecated Please use xyzOut instead.
  102466. */
  102467. get xyz(): NodeMaterialConnectionPoint;
  102468. protected _buildBlock(state: NodeMaterialBuildState): this;
  102469. }
  102470. }
  102471. declare module BABYLON {
  102472. /**
  102473. * Block used to remap a float from a range to a new one
  102474. */
  102475. export class RemapBlock extends NodeMaterialBlock {
  102476. /**
  102477. * Gets or sets the source range
  102478. */
  102479. sourceRange: Vector2;
  102480. /**
  102481. * Gets or sets the target range
  102482. */
  102483. targetRange: Vector2;
  102484. /**
  102485. * Creates a new RemapBlock
  102486. * @param name defines the block name
  102487. */
  102488. constructor(name: string);
  102489. /**
  102490. * Gets the current class name
  102491. * @returns the class name
  102492. */
  102493. getClassName(): string;
  102494. /**
  102495. * Gets the input component
  102496. */
  102497. get input(): NodeMaterialConnectionPoint;
  102498. /**
  102499. * Gets the source min input component
  102500. */
  102501. get sourceMin(): NodeMaterialConnectionPoint;
  102502. /**
  102503. * Gets the source max input component
  102504. */
  102505. get sourceMax(): NodeMaterialConnectionPoint;
  102506. /**
  102507. * Gets the target min input component
  102508. */
  102509. get targetMin(): NodeMaterialConnectionPoint;
  102510. /**
  102511. * Gets the target max input component
  102512. */
  102513. get targetMax(): NodeMaterialConnectionPoint;
  102514. /**
  102515. * Gets the output component
  102516. */
  102517. get output(): NodeMaterialConnectionPoint;
  102518. protected _buildBlock(state: NodeMaterialBuildState): this;
  102519. protected _dumpPropertiesCode(): string;
  102520. serialize(): any;
  102521. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102522. }
  102523. }
  102524. declare module BABYLON {
  102525. /**
  102526. * Block used to multiply 2 values
  102527. */
  102528. export class MultiplyBlock extends NodeMaterialBlock {
  102529. /**
  102530. * Creates a new MultiplyBlock
  102531. * @param name defines the block name
  102532. */
  102533. constructor(name: string);
  102534. /**
  102535. * Gets the current class name
  102536. * @returns the class name
  102537. */
  102538. getClassName(): string;
  102539. /**
  102540. * Gets the left operand input component
  102541. */
  102542. get left(): NodeMaterialConnectionPoint;
  102543. /**
  102544. * Gets the right operand input component
  102545. */
  102546. get right(): NodeMaterialConnectionPoint;
  102547. /**
  102548. * Gets the output component
  102549. */
  102550. get output(): NodeMaterialConnectionPoint;
  102551. protected _buildBlock(state: NodeMaterialBuildState): this;
  102552. }
  102553. }
  102554. declare module BABYLON {
  102555. /**
  102556. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  102557. */
  102558. export class ColorSplitterBlock extends NodeMaterialBlock {
  102559. /**
  102560. * Create a new ColorSplitterBlock
  102561. * @param name defines the block name
  102562. */
  102563. constructor(name: string);
  102564. /**
  102565. * Gets the current class name
  102566. * @returns the class name
  102567. */
  102568. getClassName(): string;
  102569. /**
  102570. * Gets the rgba component (input)
  102571. */
  102572. get rgba(): NodeMaterialConnectionPoint;
  102573. /**
  102574. * Gets the rgb component (input)
  102575. */
  102576. get rgbIn(): NodeMaterialConnectionPoint;
  102577. /**
  102578. * Gets the rgb component (output)
  102579. */
  102580. get rgbOut(): NodeMaterialConnectionPoint;
  102581. /**
  102582. * Gets the r component (output)
  102583. */
  102584. get r(): NodeMaterialConnectionPoint;
  102585. /**
  102586. * Gets the g component (output)
  102587. */
  102588. get g(): NodeMaterialConnectionPoint;
  102589. /**
  102590. * Gets the b component (output)
  102591. */
  102592. get b(): NodeMaterialConnectionPoint;
  102593. /**
  102594. * Gets the a component (output)
  102595. */
  102596. get a(): NodeMaterialConnectionPoint;
  102597. protected _inputRename(name: string): string;
  102598. protected _outputRename(name: string): string;
  102599. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102600. }
  102601. }
  102602. declare module BABYLON {
  102603. /**
  102604. * Operations supported by the Trigonometry block
  102605. */
  102606. export enum TrigonometryBlockOperations {
  102607. /** Cos */
  102608. Cos = 0,
  102609. /** Sin */
  102610. Sin = 1,
  102611. /** Abs */
  102612. Abs = 2,
  102613. /** Exp */
  102614. Exp = 3,
  102615. /** Exp2 */
  102616. Exp2 = 4,
  102617. /** Round */
  102618. Round = 5,
  102619. /** Floor */
  102620. Floor = 6,
  102621. /** Ceiling */
  102622. Ceiling = 7,
  102623. /** Square root */
  102624. Sqrt = 8,
  102625. /** Log */
  102626. Log = 9,
  102627. /** Tangent */
  102628. Tan = 10,
  102629. /** Arc tangent */
  102630. ArcTan = 11,
  102631. /** Arc cosinus */
  102632. ArcCos = 12,
  102633. /** Arc sinus */
  102634. ArcSin = 13,
  102635. /** Fraction */
  102636. Fract = 14,
  102637. /** Sign */
  102638. Sign = 15,
  102639. /** To radians (from degrees) */
  102640. Radians = 16,
  102641. /** To degrees (from radians) */
  102642. Degrees = 17
  102643. }
  102644. /**
  102645. * Block used to apply trigonometry operation to floats
  102646. */
  102647. export class TrigonometryBlock extends NodeMaterialBlock {
  102648. /**
  102649. * Gets or sets the operation applied by the block
  102650. */
  102651. operation: TrigonometryBlockOperations;
  102652. /**
  102653. * Creates a new TrigonometryBlock
  102654. * @param name defines the block name
  102655. */
  102656. constructor(name: string);
  102657. /**
  102658. * Gets the current class name
  102659. * @returns the class name
  102660. */
  102661. getClassName(): string;
  102662. /**
  102663. * Gets the input component
  102664. */
  102665. get input(): NodeMaterialConnectionPoint;
  102666. /**
  102667. * Gets the output component
  102668. */
  102669. get output(): NodeMaterialConnectionPoint;
  102670. protected _buildBlock(state: NodeMaterialBuildState): this;
  102671. serialize(): any;
  102672. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102673. protected _dumpPropertiesCode(): string;
  102674. }
  102675. }
  102676. declare module BABYLON {
  102677. /**
  102678. * Interface used to configure the node material editor
  102679. */
  102680. export interface INodeMaterialEditorOptions {
  102681. /** Define the URl to load node editor script */
  102682. editorURL?: string;
  102683. }
  102684. /** @hidden */
  102685. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102686. NORMAL: boolean;
  102687. TANGENT: boolean;
  102688. UV1: boolean;
  102689. /** BONES */
  102690. NUM_BONE_INFLUENCERS: number;
  102691. BonesPerMesh: number;
  102692. BONETEXTURE: boolean;
  102693. /** MORPH TARGETS */
  102694. MORPHTARGETS: boolean;
  102695. MORPHTARGETS_NORMAL: boolean;
  102696. MORPHTARGETS_TANGENT: boolean;
  102697. MORPHTARGETS_UV: boolean;
  102698. NUM_MORPH_INFLUENCERS: number;
  102699. /** IMAGE PROCESSING */
  102700. IMAGEPROCESSING: boolean;
  102701. VIGNETTE: boolean;
  102702. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102703. VIGNETTEBLENDMODEOPAQUE: boolean;
  102704. TONEMAPPING: boolean;
  102705. TONEMAPPING_ACES: boolean;
  102706. CONTRAST: boolean;
  102707. EXPOSURE: boolean;
  102708. COLORCURVES: boolean;
  102709. COLORGRADING: boolean;
  102710. COLORGRADING3D: boolean;
  102711. SAMPLER3DGREENDEPTH: boolean;
  102712. SAMPLER3DBGRMAP: boolean;
  102713. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102714. /** MISC. */
  102715. BUMPDIRECTUV: number;
  102716. constructor();
  102717. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  102718. }
  102719. /**
  102720. * Class used to configure NodeMaterial
  102721. */
  102722. export interface INodeMaterialOptions {
  102723. /**
  102724. * Defines if blocks should emit comments
  102725. */
  102726. emitComments: boolean;
  102727. }
  102728. /**
  102729. * Class used to create a node based material built by assembling shader blocks
  102730. */
  102731. export class NodeMaterial extends PushMaterial {
  102732. private static _BuildIdGenerator;
  102733. private _options;
  102734. private _vertexCompilationState;
  102735. private _fragmentCompilationState;
  102736. private _sharedData;
  102737. private _buildId;
  102738. private _buildWasSuccessful;
  102739. private _cachedWorldViewMatrix;
  102740. private _cachedWorldViewProjectionMatrix;
  102741. private _optimizers;
  102742. private _animationFrame;
  102743. /** Define the Url to load node editor script */
  102744. static EditorURL: string;
  102745. /** Define the Url to load snippets */
  102746. static SnippetUrl: string;
  102747. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  102748. static IgnoreTexturesAtLoadTime: boolean;
  102749. private BJSNODEMATERIALEDITOR;
  102750. /** Get the inspector from bundle or global */
  102751. private _getGlobalNodeMaterialEditor;
  102752. /**
  102753. * Snippet ID if the material was created from the snippet server
  102754. */
  102755. snippetId: string;
  102756. /**
  102757. * Gets or sets data used by visual editor
  102758. * @see https://nme.babylonjs.com
  102759. */
  102760. editorData: any;
  102761. /**
  102762. * 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)
  102763. */
  102764. ignoreAlpha: boolean;
  102765. /**
  102766. * Defines the maximum number of lights that can be used in the material
  102767. */
  102768. maxSimultaneousLights: number;
  102769. /**
  102770. * Observable raised when the material is built
  102771. */
  102772. onBuildObservable: Observable<NodeMaterial>;
  102773. /**
  102774. * Gets or sets the root nodes of the material vertex shader
  102775. */
  102776. _vertexOutputNodes: NodeMaterialBlock[];
  102777. /**
  102778. * Gets or sets the root nodes of the material fragment (pixel) shader
  102779. */
  102780. _fragmentOutputNodes: NodeMaterialBlock[];
  102781. /** Gets or sets options to control the node material overall behavior */
  102782. get options(): INodeMaterialOptions;
  102783. set options(options: INodeMaterialOptions);
  102784. /**
  102785. * Default configuration related to image processing available in the standard Material.
  102786. */
  102787. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102788. /**
  102789. * Gets the image processing configuration used either in this material.
  102790. */
  102791. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102792. /**
  102793. * Sets the Default image processing configuration used either in the this material.
  102794. *
  102795. * If sets to null, the scene one is in use.
  102796. */
  102797. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102798. /**
  102799. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  102800. */
  102801. attachedBlocks: NodeMaterialBlock[];
  102802. /**
  102803. * Specifies the mode of the node material
  102804. * @hidden
  102805. */
  102806. _mode: NodeMaterialModes;
  102807. /**
  102808. * Gets the mode property
  102809. */
  102810. get mode(): NodeMaterialModes;
  102811. /**
  102812. * Create a new node based material
  102813. * @param name defines the material name
  102814. * @param scene defines the hosting scene
  102815. * @param options defines creation option
  102816. */
  102817. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  102818. /**
  102819. * Gets the current class name of the material e.g. "NodeMaterial"
  102820. * @returns the class name
  102821. */
  102822. getClassName(): string;
  102823. /**
  102824. * Keep track of the image processing observer to allow dispose and replace.
  102825. */
  102826. private _imageProcessingObserver;
  102827. /**
  102828. * Attaches a new image processing configuration to the Standard Material.
  102829. * @param configuration
  102830. */
  102831. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102832. /**
  102833. * Get a block by its name
  102834. * @param name defines the name of the block to retrieve
  102835. * @returns the required block or null if not found
  102836. */
  102837. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  102838. /**
  102839. * Get a block by its name
  102840. * @param predicate defines the predicate used to find the good candidate
  102841. * @returns the required block or null if not found
  102842. */
  102843. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  102844. /**
  102845. * Get an input block by its name
  102846. * @param predicate defines the predicate used to find the good candidate
  102847. * @returns the required input block or null if not found
  102848. */
  102849. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  102850. /**
  102851. * Gets the list of input blocks attached to this material
  102852. * @returns an array of InputBlocks
  102853. */
  102854. getInputBlocks(): InputBlock[];
  102855. /**
  102856. * Adds a new optimizer to the list of optimizers
  102857. * @param optimizer defines the optimizers to add
  102858. * @returns the current material
  102859. */
  102860. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102861. /**
  102862. * Remove an optimizer from the list of optimizers
  102863. * @param optimizer defines the optimizers to remove
  102864. * @returns the current material
  102865. */
  102866. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102867. /**
  102868. * Add a new block to the list of output nodes
  102869. * @param node defines the node to add
  102870. * @returns the current material
  102871. */
  102872. addOutputNode(node: NodeMaterialBlock): this;
  102873. /**
  102874. * Remove a block from the list of root nodes
  102875. * @param node defines the node to remove
  102876. * @returns the current material
  102877. */
  102878. removeOutputNode(node: NodeMaterialBlock): this;
  102879. private _addVertexOutputNode;
  102880. private _removeVertexOutputNode;
  102881. private _addFragmentOutputNode;
  102882. private _removeFragmentOutputNode;
  102883. /**
  102884. * Specifies if the material will require alpha blending
  102885. * @returns a boolean specifying if alpha blending is needed
  102886. */
  102887. needAlphaBlending(): boolean;
  102888. /**
  102889. * Specifies if this material should be rendered in alpha test mode
  102890. * @returns a boolean specifying if an alpha test is needed.
  102891. */
  102892. needAlphaTesting(): boolean;
  102893. private _initializeBlock;
  102894. private _resetDualBlocks;
  102895. /**
  102896. * Remove a block from the current node material
  102897. * @param block defines the block to remove
  102898. */
  102899. removeBlock(block: NodeMaterialBlock): void;
  102900. /**
  102901. * Build the material and generates the inner effect
  102902. * @param verbose defines if the build should log activity
  102903. */
  102904. build(verbose?: boolean): void;
  102905. /**
  102906. * Runs an otpimization phase to try to improve the shader code
  102907. */
  102908. optimize(): void;
  102909. private _prepareDefinesForAttributes;
  102910. /**
  102911. * Create a post process from the material
  102912. * @param camera The camera to apply the render pass to.
  102913. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102914. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102915. * @param engine The engine which the post process will be applied. (default: current engine)
  102916. * @param reusable If the post process can be reused on the same frame. (default: false)
  102917. * @param textureType Type of textures used when performing the post process. (default: 0)
  102918. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102919. * @returns the post process created
  102920. */
  102921. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  102922. /**
  102923. * Create the post process effect from the material
  102924. * @param postProcess The post process to create the effect for
  102925. */
  102926. createEffectForPostProcess(postProcess: PostProcess): void;
  102927. private _createEffectForPostProcess;
  102928. /**
  102929. * Create a new procedural texture based on this node material
  102930. * @param size defines the size of the texture
  102931. * @param scene defines the hosting scene
  102932. * @returns the new procedural texture attached to this node material
  102933. */
  102934. createProceduralTexture(size: number | {
  102935. width: number;
  102936. height: number;
  102937. layers?: number;
  102938. }, scene: Scene): Nullable<ProceduralTexture>;
  102939. private _createEffectForParticles;
  102940. private _checkInternals;
  102941. /**
  102942. * Create the effect to be used as the custom effect for a particle system
  102943. * @param particleSystem Particle system to create the effect for
  102944. * @param onCompiled defines a function to call when the effect creation is successful
  102945. * @param onError defines a function to call when the effect creation has failed
  102946. */
  102947. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102948. private _processDefines;
  102949. /**
  102950. * Get if the submesh is ready to be used and all its information available.
  102951. * Child classes can use it to update shaders
  102952. * @param mesh defines the mesh to check
  102953. * @param subMesh defines which submesh to check
  102954. * @param useInstances specifies that instances should be used
  102955. * @returns a boolean indicating that the submesh is ready or not
  102956. */
  102957. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102958. /**
  102959. * Get a string representing the shaders built by the current node graph
  102960. */
  102961. get compiledShaders(): string;
  102962. /**
  102963. * Binds the world matrix to the material
  102964. * @param world defines the world transformation matrix
  102965. */
  102966. bindOnlyWorldMatrix(world: Matrix): void;
  102967. /**
  102968. * Binds the submesh to this material by preparing the effect and shader to draw
  102969. * @param world defines the world transformation matrix
  102970. * @param mesh defines the mesh containing the submesh
  102971. * @param subMesh defines the submesh to bind the material to
  102972. */
  102973. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102974. /**
  102975. * Gets the active textures from the material
  102976. * @returns an array of textures
  102977. */
  102978. getActiveTextures(): BaseTexture[];
  102979. /**
  102980. * Gets the list of texture blocks
  102981. * @returns an array of texture blocks
  102982. */
  102983. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102984. /**
  102985. * Specifies if the material uses a texture
  102986. * @param texture defines the texture to check against the material
  102987. * @returns a boolean specifying if the material uses the texture
  102988. */
  102989. hasTexture(texture: BaseTexture): boolean;
  102990. /**
  102991. * Disposes the material
  102992. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102993. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102994. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102995. */
  102996. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102997. /** Creates the node editor window. */
  102998. private _createNodeEditor;
  102999. /**
  103000. * Launch the node material editor
  103001. * @param config Define the configuration of the editor
  103002. * @return a promise fulfilled when the node editor is visible
  103003. */
  103004. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  103005. /**
  103006. * Clear the current material
  103007. */
  103008. clear(): void;
  103009. /**
  103010. * Clear the current material and set it to a default state
  103011. */
  103012. setToDefault(): void;
  103013. /**
  103014. * Clear the current material and set it to a default state for post process
  103015. */
  103016. setToDefaultPostProcess(): void;
  103017. /**
  103018. * Clear the current material and set it to a default state for procedural texture
  103019. */
  103020. setToDefaultProceduralTexture(): void;
  103021. /**
  103022. * Clear the current material and set it to a default state for particle
  103023. */
  103024. setToDefaultParticle(): void;
  103025. /**
  103026. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  103027. * @param url defines the url to load from
  103028. * @returns a promise that will fullfil when the material is fully loaded
  103029. */
  103030. loadAsync(url: string): Promise<void>;
  103031. private _gatherBlocks;
  103032. /**
  103033. * Generate a string containing the code declaration required to create an equivalent of this material
  103034. * @returns a string
  103035. */
  103036. generateCode(): string;
  103037. /**
  103038. * Serializes this material in a JSON representation
  103039. * @returns the serialized material object
  103040. */
  103041. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  103042. private _restoreConnections;
  103043. /**
  103044. * Clear the current graph and load a new one from a serialization object
  103045. * @param source defines the JSON representation of the material
  103046. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103047. * @param merge defines whether or not the source must be merged or replace the current content
  103048. */
  103049. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  103050. /**
  103051. * Makes a duplicate of the current material.
  103052. * @param name - name to use for the new material.
  103053. */
  103054. clone(name: string): NodeMaterial;
  103055. /**
  103056. * Creates a node material from parsed material data
  103057. * @param source defines the JSON representation of the material
  103058. * @param scene defines the hosting scene
  103059. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103060. * @returns a new node material
  103061. */
  103062. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  103063. /**
  103064. * Creates a node material from a snippet saved in a remote file
  103065. * @param name defines the name of the material to create
  103066. * @param url defines the url to load from
  103067. * @param scene defines the hosting scene
  103068. * @returns a promise that will resolve to the new node material
  103069. */
  103070. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  103071. /**
  103072. * Creates a node material from a snippet saved by the node material editor
  103073. * @param snippetId defines the snippet to load
  103074. * @param scene defines the hosting scene
  103075. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103076. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  103077. * @returns a promise that will resolve to the new node material
  103078. */
  103079. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103080. /**
  103081. * Creates a new node material set to default basic configuration
  103082. * @param name defines the name of the material
  103083. * @param scene defines the hosting scene
  103084. * @returns a new NodeMaterial
  103085. */
  103086. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103087. }
  103088. }
  103089. declare module BABYLON {
  103090. /**
  103091. * Size options for a post process
  103092. */
  103093. export type PostProcessOptions = {
  103094. width: number;
  103095. height: number;
  103096. };
  103097. /**
  103098. * PostProcess can be used to apply a shader to a texture after it has been rendered
  103099. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103100. */
  103101. export class PostProcess {
  103102. /**
  103103. * Gets or sets the unique id of the post process
  103104. */
  103105. uniqueId: number;
  103106. /** Name of the PostProcess. */
  103107. name: string;
  103108. /**
  103109. * Width of the texture to apply the post process on
  103110. */
  103111. width: number;
  103112. /**
  103113. * Height of the texture to apply the post process on
  103114. */
  103115. height: number;
  103116. /**
  103117. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  103118. */
  103119. nodeMaterialSource: Nullable<NodeMaterial>;
  103120. /**
  103121. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  103122. * @hidden
  103123. */
  103124. _outputTexture: Nullable<InternalTexture>;
  103125. /**
  103126. * Sampling mode used by the shader
  103127. * See https://doc.babylonjs.com/classes/3.1/texture
  103128. */
  103129. renderTargetSamplingMode: number;
  103130. /**
  103131. * Clear color to use when screen clearing
  103132. */
  103133. clearColor: Color4;
  103134. /**
  103135. * If the buffer needs to be cleared before applying the post process. (default: true)
  103136. * Should be set to false if shader will overwrite all previous pixels.
  103137. */
  103138. autoClear: boolean;
  103139. /**
  103140. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  103141. */
  103142. alphaMode: number;
  103143. /**
  103144. * Sets the setAlphaBlendConstants of the babylon engine
  103145. */
  103146. alphaConstants: Color4;
  103147. /**
  103148. * Animations to be used for the post processing
  103149. */
  103150. animations: Animation[];
  103151. /**
  103152. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  103153. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  103154. */
  103155. enablePixelPerfectMode: boolean;
  103156. /**
  103157. * Force the postprocess to be applied without taking in account viewport
  103158. */
  103159. forceFullscreenViewport: boolean;
  103160. /**
  103161. * List of inspectable custom properties (used by the Inspector)
  103162. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103163. */
  103164. inspectableCustomProperties: IInspectable[];
  103165. /**
  103166. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  103167. *
  103168. * | Value | Type | Description |
  103169. * | ----- | ----------------------------------- | ----------- |
  103170. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  103171. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  103172. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  103173. *
  103174. */
  103175. scaleMode: number;
  103176. /**
  103177. * Force textures to be a power of two (default: false)
  103178. */
  103179. alwaysForcePOT: boolean;
  103180. private _samples;
  103181. /**
  103182. * Number of sample textures (default: 1)
  103183. */
  103184. get samples(): number;
  103185. set samples(n: number);
  103186. /**
  103187. * Modify the scale of the post process to be the same as the viewport (default: false)
  103188. */
  103189. adaptScaleToCurrentViewport: boolean;
  103190. private _camera;
  103191. protected _scene: Scene;
  103192. private _engine;
  103193. private _options;
  103194. private _reusable;
  103195. private _textureType;
  103196. private _textureFormat;
  103197. /**
  103198. * Smart array of input and output textures for the post process.
  103199. * @hidden
  103200. */
  103201. _textures: SmartArray<InternalTexture>;
  103202. /**
  103203. * The index in _textures that corresponds to the output texture.
  103204. * @hidden
  103205. */
  103206. _currentRenderTextureInd: number;
  103207. private _effect;
  103208. private _samplers;
  103209. private _fragmentUrl;
  103210. private _vertexUrl;
  103211. private _parameters;
  103212. private _scaleRatio;
  103213. protected _indexParameters: any;
  103214. private _shareOutputWithPostProcess;
  103215. private _texelSize;
  103216. private _forcedOutputTexture;
  103217. /**
  103218. * Returns the fragment url or shader name used in the post process.
  103219. * @returns the fragment url or name in the shader store.
  103220. */
  103221. getEffectName(): string;
  103222. /**
  103223. * An event triggered when the postprocess is activated.
  103224. */
  103225. onActivateObservable: Observable<Camera>;
  103226. private _onActivateObserver;
  103227. /**
  103228. * A function that is added to the onActivateObservable
  103229. */
  103230. set onActivate(callback: Nullable<(camera: Camera) => void>);
  103231. /**
  103232. * An event triggered when the postprocess changes its size.
  103233. */
  103234. onSizeChangedObservable: Observable<PostProcess>;
  103235. private _onSizeChangedObserver;
  103236. /**
  103237. * A function that is added to the onSizeChangedObservable
  103238. */
  103239. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  103240. /**
  103241. * An event triggered when the postprocess applies its effect.
  103242. */
  103243. onApplyObservable: Observable<Effect>;
  103244. private _onApplyObserver;
  103245. /**
  103246. * A function that is added to the onApplyObservable
  103247. */
  103248. set onApply(callback: (effect: Effect) => void);
  103249. /**
  103250. * An event triggered before rendering the postprocess
  103251. */
  103252. onBeforeRenderObservable: Observable<Effect>;
  103253. private _onBeforeRenderObserver;
  103254. /**
  103255. * A function that is added to the onBeforeRenderObservable
  103256. */
  103257. set onBeforeRender(callback: (effect: Effect) => void);
  103258. /**
  103259. * An event triggered after rendering the postprocess
  103260. */
  103261. onAfterRenderObservable: Observable<Effect>;
  103262. private _onAfterRenderObserver;
  103263. /**
  103264. * A function that is added to the onAfterRenderObservable
  103265. */
  103266. set onAfterRender(callback: (efect: Effect) => void);
  103267. /**
  103268. * 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
  103269. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  103270. */
  103271. get inputTexture(): InternalTexture;
  103272. set inputTexture(value: InternalTexture);
  103273. /**
  103274. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  103275. * the only way to unset it is to use this function to restore its internal state
  103276. */
  103277. restoreDefaultInputTexture(): void;
  103278. /**
  103279. * Gets the camera which post process is applied to.
  103280. * @returns The camera the post process is applied to.
  103281. */
  103282. getCamera(): Camera;
  103283. /**
  103284. * Gets the texel size of the postprocess.
  103285. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  103286. */
  103287. get texelSize(): Vector2;
  103288. /**
  103289. * Creates a new instance PostProcess
  103290. * @param name The name of the PostProcess.
  103291. * @param fragmentUrl The url of the fragment shader to be used.
  103292. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  103293. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  103294. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103295. * @param camera The camera to apply the render pass to.
  103296. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103297. * @param engine The engine which the post process will be applied. (default: current engine)
  103298. * @param reusable If the post process can be reused on the same frame. (default: false)
  103299. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  103300. * @param textureType Type of textures used when performing the post process. (default: 0)
  103301. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  103302. * @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
  103303. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  103304. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103305. */
  103306. constructor(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);
  103307. /**
  103308. * Gets a string identifying the name of the class
  103309. * @returns "PostProcess" string
  103310. */
  103311. getClassName(): string;
  103312. /**
  103313. * Gets the engine which this post process belongs to.
  103314. * @returns The engine the post process was enabled with.
  103315. */
  103316. getEngine(): Engine;
  103317. /**
  103318. * The effect that is created when initializing the post process.
  103319. * @returns The created effect corresponding the the postprocess.
  103320. */
  103321. getEffect(): Effect;
  103322. /**
  103323. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  103324. * @param postProcess The post process to share the output with.
  103325. * @returns This post process.
  103326. */
  103327. shareOutputWith(postProcess: PostProcess): PostProcess;
  103328. /**
  103329. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  103330. * This should be called if the post process that shares output with this post process is disabled/disposed.
  103331. */
  103332. useOwnOutput(): void;
  103333. /**
  103334. * Updates the effect with the current post process compile time values and recompiles the shader.
  103335. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  103336. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  103337. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  103338. * @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
  103339. * @param onCompiled Called when the shader has been compiled.
  103340. * @param onError Called if there is an error when compiling a shader.
  103341. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  103342. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  103343. */
  103344. 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;
  103345. /**
  103346. * The post process is reusable if it can be used multiple times within one frame.
  103347. * @returns If the post process is reusable
  103348. */
  103349. isReusable(): boolean;
  103350. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  103351. markTextureDirty(): void;
  103352. /**
  103353. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  103354. * 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.
  103355. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  103356. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  103357. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  103358. * @returns The target texture that was bound to be written to.
  103359. */
  103360. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  103361. /**
  103362. * If the post process is supported.
  103363. */
  103364. get isSupported(): boolean;
  103365. /**
  103366. * The aspect ratio of the output texture.
  103367. */
  103368. get aspectRatio(): number;
  103369. /**
  103370. * Get a value indicating if the post-process is ready to be used
  103371. * @returns true if the post-process is ready (shader is compiled)
  103372. */
  103373. isReady(): boolean;
  103374. /**
  103375. * Binds all textures and uniforms to the shader, this will be run on every pass.
  103376. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  103377. */
  103378. apply(): Nullable<Effect>;
  103379. private _disposeTextures;
  103380. /**
  103381. * Disposes the post process.
  103382. * @param camera The camera to dispose the post process on.
  103383. */
  103384. dispose(camera?: Camera): void;
  103385. /**
  103386. * Serializes the particle system to a JSON object
  103387. * @returns the JSON object
  103388. */
  103389. serialize(): any;
  103390. /**
  103391. * Creates a material from parsed material data
  103392. * @param parsedPostProcess defines parsed post process data
  103393. * @param scene defines the hosting scene
  103394. * @param rootUrl defines the root URL to use to load textures
  103395. * @returns a new post process
  103396. */
  103397. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  103398. }
  103399. }
  103400. declare module BABYLON {
  103401. /** @hidden */
  103402. export var kernelBlurVaryingDeclaration: {
  103403. name: string;
  103404. shader: string;
  103405. };
  103406. }
  103407. declare module BABYLON {
  103408. /** @hidden */
  103409. export var kernelBlurFragment: {
  103410. name: string;
  103411. shader: string;
  103412. };
  103413. }
  103414. declare module BABYLON {
  103415. /** @hidden */
  103416. export var kernelBlurFragment2: {
  103417. name: string;
  103418. shader: string;
  103419. };
  103420. }
  103421. declare module BABYLON {
  103422. /** @hidden */
  103423. export var kernelBlurPixelShader: {
  103424. name: string;
  103425. shader: string;
  103426. };
  103427. }
  103428. declare module BABYLON {
  103429. /** @hidden */
  103430. export var kernelBlurVertex: {
  103431. name: string;
  103432. shader: string;
  103433. };
  103434. }
  103435. declare module BABYLON {
  103436. /** @hidden */
  103437. export var kernelBlurVertexShader: {
  103438. name: string;
  103439. shader: string;
  103440. };
  103441. }
  103442. declare module BABYLON {
  103443. /**
  103444. * The Blur Post Process which blurs an image based on a kernel and direction.
  103445. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  103446. */
  103447. export class BlurPostProcess extends PostProcess {
  103448. private blockCompilation;
  103449. protected _kernel: number;
  103450. protected _idealKernel: number;
  103451. protected _packedFloat: boolean;
  103452. private _staticDefines;
  103453. /** The direction in which to blur the image. */
  103454. direction: Vector2;
  103455. /**
  103456. * Sets the length in pixels of the blur sample region
  103457. */
  103458. set kernel(v: number);
  103459. /**
  103460. * Gets the length in pixels of the blur sample region
  103461. */
  103462. get kernel(): number;
  103463. /**
  103464. * Sets wether or not the blur needs to unpack/repack floats
  103465. */
  103466. set packedFloat(v: boolean);
  103467. /**
  103468. * Gets wether or not the blur is unpacking/repacking floats
  103469. */
  103470. get packedFloat(): boolean;
  103471. /**
  103472. * Gets a string identifying the name of the class
  103473. * @returns "BlurPostProcess" string
  103474. */
  103475. getClassName(): string;
  103476. /**
  103477. * Creates a new instance BlurPostProcess
  103478. * @param name The name of the effect.
  103479. * @param direction The direction in which to blur the image.
  103480. * @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.
  103481. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103482. * @param camera The camera to apply the render pass to.
  103483. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103484. * @param engine The engine which the post process will be applied. (default: current engine)
  103485. * @param reusable If the post process can be reused on the same frame. (default: false)
  103486. * @param textureType Type of textures used when performing the post process. (default: 0)
  103487. * @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)
  103488. */
  103489. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  103490. /**
  103491. * Updates the effect with the current post process compile time values and recompiles the shader.
  103492. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  103493. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  103494. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  103495. * @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
  103496. * @param onCompiled Called when the shader has been compiled.
  103497. * @param onError Called if there is an error when compiling a shader.
  103498. */
  103499. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103500. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103501. /**
  103502. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  103503. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  103504. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  103505. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  103506. * The gaps between physical kernels are compensated for in the weighting of the samples
  103507. * @param idealKernel Ideal blur kernel.
  103508. * @return Nearest best kernel.
  103509. */
  103510. protected _nearestBestKernel(idealKernel: number): number;
  103511. /**
  103512. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  103513. * @param x The point on the Gaussian distribution to sample.
  103514. * @return the value of the Gaussian function at x.
  103515. */
  103516. protected _gaussianWeight(x: number): number;
  103517. /**
  103518. * Generates a string that can be used as a floating point number in GLSL.
  103519. * @param x Value to print.
  103520. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  103521. * @return GLSL float string.
  103522. */
  103523. protected _glslFloat(x: number, decimalFigures?: number): string;
  103524. /** @hidden */
  103525. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  103526. }
  103527. }
  103528. declare module BABYLON {
  103529. /**
  103530. * Mirror texture can be used to simulate the view from a mirror in a scene.
  103531. * It will dynamically be rendered every frame to adapt to the camera point of view.
  103532. * You can then easily use it as a reflectionTexture on a flat surface.
  103533. * In case the surface is not a plane, please consider relying on reflection probes.
  103534. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103535. */
  103536. export class MirrorTexture extends RenderTargetTexture {
  103537. private scene;
  103538. /**
  103539. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  103540. * 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.
  103541. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103542. */
  103543. mirrorPlane: Plane;
  103544. /**
  103545. * Define the blur ratio used to blur the reflection if needed.
  103546. */
  103547. set blurRatio(value: number);
  103548. get blurRatio(): number;
  103549. /**
  103550. * Define the adaptive blur kernel used to blur the reflection if needed.
  103551. * This will autocompute the closest best match for the `blurKernel`
  103552. */
  103553. set adaptiveBlurKernel(value: number);
  103554. /**
  103555. * Define the blur kernel used to blur the reflection if needed.
  103556. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103557. */
  103558. set blurKernel(value: number);
  103559. /**
  103560. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  103561. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103562. */
  103563. set blurKernelX(value: number);
  103564. get blurKernelX(): number;
  103565. /**
  103566. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  103567. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103568. */
  103569. set blurKernelY(value: number);
  103570. get blurKernelY(): number;
  103571. private _autoComputeBlurKernel;
  103572. protected _onRatioRescale(): void;
  103573. private _updateGammaSpace;
  103574. private _imageProcessingConfigChangeObserver;
  103575. private _transformMatrix;
  103576. private _mirrorMatrix;
  103577. private _savedViewMatrix;
  103578. private _blurX;
  103579. private _blurY;
  103580. private _adaptiveBlurKernel;
  103581. private _blurKernelX;
  103582. private _blurKernelY;
  103583. private _blurRatio;
  103584. /**
  103585. * Instantiates a Mirror Texture.
  103586. * Mirror texture can be used to simulate the view from a mirror in a scene.
  103587. * It will dynamically be rendered every frame to adapt to the camera point of view.
  103588. * You can then easily use it as a reflectionTexture on a flat surface.
  103589. * In case the surface is not a plane, please consider relying on reflection probes.
  103590. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103591. * @param name
  103592. * @param size
  103593. * @param scene
  103594. * @param generateMipMaps
  103595. * @param type
  103596. * @param samplingMode
  103597. * @param generateDepthBuffer
  103598. */
  103599. constructor(name: string, size: number | {
  103600. width: number;
  103601. height: number;
  103602. } | {
  103603. ratio: number;
  103604. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  103605. private _preparePostProcesses;
  103606. /**
  103607. * Clone the mirror texture.
  103608. * @returns the cloned texture
  103609. */
  103610. clone(): MirrorTexture;
  103611. /**
  103612. * Serialize the texture to a JSON representation you could use in Parse later on
  103613. * @returns the serialized JSON representation
  103614. */
  103615. serialize(): any;
  103616. /**
  103617. * Dispose the texture and release its associated resources.
  103618. */
  103619. dispose(): void;
  103620. }
  103621. }
  103622. declare module BABYLON {
  103623. /**
  103624. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103625. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103626. */
  103627. export class Texture extends BaseTexture {
  103628. /**
  103629. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  103630. */
  103631. static SerializeBuffers: boolean;
  103632. /** @hidden */
  103633. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  103634. /** @hidden */
  103635. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  103636. /** @hidden */
  103637. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  103638. /** nearest is mag = nearest and min = nearest and mip = linear */
  103639. static readonly NEAREST_SAMPLINGMODE: number;
  103640. /** nearest is mag = nearest and min = nearest and mip = linear */
  103641. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  103642. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103643. static readonly BILINEAR_SAMPLINGMODE: number;
  103644. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103645. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  103646. /** Trilinear is mag = linear and min = linear and mip = linear */
  103647. static readonly TRILINEAR_SAMPLINGMODE: number;
  103648. /** Trilinear is mag = linear and min = linear and mip = linear */
  103649. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  103650. /** mag = nearest and min = nearest and mip = nearest */
  103651. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  103652. /** mag = nearest and min = linear and mip = nearest */
  103653. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  103654. /** mag = nearest and min = linear and mip = linear */
  103655. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  103656. /** mag = nearest and min = linear and mip = none */
  103657. static readonly NEAREST_LINEAR: number;
  103658. /** mag = nearest and min = nearest and mip = none */
  103659. static readonly NEAREST_NEAREST: number;
  103660. /** mag = linear and min = nearest and mip = nearest */
  103661. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  103662. /** mag = linear and min = nearest and mip = linear */
  103663. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  103664. /** mag = linear and min = linear and mip = none */
  103665. static readonly LINEAR_LINEAR: number;
  103666. /** mag = linear and min = nearest and mip = none */
  103667. static readonly LINEAR_NEAREST: number;
  103668. /** Explicit coordinates mode */
  103669. static readonly EXPLICIT_MODE: number;
  103670. /** Spherical coordinates mode */
  103671. static readonly SPHERICAL_MODE: number;
  103672. /** Planar coordinates mode */
  103673. static readonly PLANAR_MODE: number;
  103674. /** Cubic coordinates mode */
  103675. static readonly CUBIC_MODE: number;
  103676. /** Projection coordinates mode */
  103677. static readonly PROJECTION_MODE: number;
  103678. /** Inverse Cubic coordinates mode */
  103679. static readonly SKYBOX_MODE: number;
  103680. /** Inverse Cubic coordinates mode */
  103681. static readonly INVCUBIC_MODE: number;
  103682. /** Equirectangular coordinates mode */
  103683. static readonly EQUIRECTANGULAR_MODE: number;
  103684. /** Equirectangular Fixed coordinates mode */
  103685. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  103686. /** Equirectangular Fixed Mirrored coordinates mode */
  103687. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  103688. /** Texture is not repeating outside of 0..1 UVs */
  103689. static readonly CLAMP_ADDRESSMODE: number;
  103690. /** Texture is repeating outside of 0..1 UVs */
  103691. static readonly WRAP_ADDRESSMODE: number;
  103692. /** Texture is repeating and mirrored */
  103693. static readonly MIRROR_ADDRESSMODE: number;
  103694. /**
  103695. * 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
  103696. */
  103697. static UseSerializedUrlIfAny: boolean;
  103698. /**
  103699. * Define the url of the texture.
  103700. */
  103701. url: Nullable<string>;
  103702. /**
  103703. * Define an offset on the texture to offset the u coordinates of the UVs
  103704. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103705. */
  103706. uOffset: number;
  103707. /**
  103708. * Define an offset on the texture to offset the v coordinates of the UVs
  103709. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103710. */
  103711. vOffset: number;
  103712. /**
  103713. * Define an offset on the texture to scale the u coordinates of the UVs
  103714. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103715. */
  103716. uScale: number;
  103717. /**
  103718. * Define an offset on the texture to scale the v coordinates of the UVs
  103719. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103720. */
  103721. vScale: number;
  103722. /**
  103723. * Define an offset on the texture to rotate around the u coordinates of the UVs
  103724. * @see https://doc.babylonjs.com/how_to/more_materials
  103725. */
  103726. uAng: number;
  103727. /**
  103728. * Define an offset on the texture to rotate around the v coordinates of the UVs
  103729. * @see https://doc.babylonjs.com/how_to/more_materials
  103730. */
  103731. vAng: number;
  103732. /**
  103733. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  103734. * @see https://doc.babylonjs.com/how_to/more_materials
  103735. */
  103736. wAng: number;
  103737. /**
  103738. * Defines the center of rotation (U)
  103739. */
  103740. uRotationCenter: number;
  103741. /**
  103742. * Defines the center of rotation (V)
  103743. */
  103744. vRotationCenter: number;
  103745. /**
  103746. * Defines the center of rotation (W)
  103747. */
  103748. wRotationCenter: number;
  103749. /**
  103750. * Are mip maps generated for this texture or not.
  103751. */
  103752. get noMipmap(): boolean;
  103753. /**
  103754. * List of inspectable custom properties (used by the Inspector)
  103755. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103756. */
  103757. inspectableCustomProperties: Nullable<IInspectable[]>;
  103758. private _noMipmap;
  103759. /** @hidden */
  103760. _invertY: boolean;
  103761. private _rowGenerationMatrix;
  103762. private _cachedTextureMatrix;
  103763. private _projectionModeMatrix;
  103764. private _t0;
  103765. private _t1;
  103766. private _t2;
  103767. private _cachedUOffset;
  103768. private _cachedVOffset;
  103769. private _cachedUScale;
  103770. private _cachedVScale;
  103771. private _cachedUAng;
  103772. private _cachedVAng;
  103773. private _cachedWAng;
  103774. private _cachedProjectionMatrixId;
  103775. private _cachedCoordinatesMode;
  103776. /** @hidden */
  103777. protected _initialSamplingMode: number;
  103778. /** @hidden */
  103779. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  103780. private _deleteBuffer;
  103781. protected _format: Nullable<number>;
  103782. private _delayedOnLoad;
  103783. private _delayedOnError;
  103784. private _mimeType?;
  103785. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  103786. get mimeType(): string | undefined;
  103787. /**
  103788. * Observable triggered once the texture has been loaded.
  103789. */
  103790. onLoadObservable: Observable<Texture>;
  103791. protected _isBlocking: boolean;
  103792. /**
  103793. * Is the texture preventing material to render while loading.
  103794. * If false, a default texture will be used instead of the loading one during the preparation step.
  103795. */
  103796. set isBlocking(value: boolean);
  103797. get isBlocking(): boolean;
  103798. /**
  103799. * Get the current sampling mode associated with the texture.
  103800. */
  103801. get samplingMode(): number;
  103802. /**
  103803. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  103804. */
  103805. get invertY(): boolean;
  103806. /**
  103807. * Instantiates a new texture.
  103808. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103809. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103810. * @param url defines the url of the picture to load as a texture
  103811. * @param sceneOrEngine defines the scene or engine the texture will belong to
  103812. * @param noMipmap defines if the texture will require mip maps or not
  103813. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  103814. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103815. * @param onLoad defines a callback triggered when the texture has been loaded
  103816. * @param onError defines a callback triggered when an error occurred during the loading session
  103817. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  103818. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  103819. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103820. * @param mimeType defines an optional mime type information
  103821. */
  103822. 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);
  103823. /**
  103824. * Update the url (and optional buffer) of this texture if url was null during construction.
  103825. * @param url the url of the texture
  103826. * @param buffer the buffer of the texture (defaults to null)
  103827. * @param onLoad callback called when the texture is loaded (defaults to null)
  103828. */
  103829. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  103830. /**
  103831. * Finish the loading sequence of a texture flagged as delayed load.
  103832. * @hidden
  103833. */
  103834. delayLoad(): void;
  103835. private _prepareRowForTextureGeneration;
  103836. /**
  103837. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  103838. * @returns the transform matrix of the texture.
  103839. */
  103840. getTextureMatrix(uBase?: number): Matrix;
  103841. /**
  103842. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  103843. * @returns The reflection texture transform
  103844. */
  103845. getReflectionTextureMatrix(): Matrix;
  103846. /**
  103847. * Clones the texture.
  103848. * @returns the cloned texture
  103849. */
  103850. clone(): Texture;
  103851. /**
  103852. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103853. * @returns The JSON representation of the texture
  103854. */
  103855. serialize(): any;
  103856. /**
  103857. * Get the current class name of the texture useful for serialization or dynamic coding.
  103858. * @returns "Texture"
  103859. */
  103860. getClassName(): string;
  103861. /**
  103862. * Dispose the texture and release its associated resources.
  103863. */
  103864. dispose(): void;
  103865. /**
  103866. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  103867. * @param parsedTexture Define the JSON representation of the texture
  103868. * @param scene Define the scene the parsed texture should be instantiated in
  103869. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  103870. * @returns The parsed texture if successful
  103871. */
  103872. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  103873. /**
  103874. * Creates a texture from its base 64 representation.
  103875. * @param data Define the base64 payload without the data: prefix
  103876. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103877. * @param scene Define the scene the texture should belong to
  103878. * @param noMipmap Forces the texture to not create mip map information if true
  103879. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103880. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103881. * @param onLoad define a callback triggered when the texture has been loaded
  103882. * @param onError define a callback triggered when an error occurred during the loading session
  103883. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103884. * @returns the created texture
  103885. */
  103886. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  103887. /**
  103888. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  103889. * @param data Define the base64 payload without the data: prefix
  103890. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103891. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  103892. * @param scene Define the scene the texture should belong to
  103893. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  103894. * @param noMipmap Forces the texture to not create mip map information if true
  103895. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103896. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103897. * @param onLoad define a callback triggered when the texture has been loaded
  103898. * @param onError define a callback triggered when an error occurred during the loading session
  103899. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103900. * @returns the created texture
  103901. */
  103902. 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;
  103903. }
  103904. }
  103905. declare module BABYLON {
  103906. /**
  103907. * PostProcessManager is used to manage one or more post processes or post process pipelines
  103908. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103909. */
  103910. export class PostProcessManager {
  103911. private _scene;
  103912. private _indexBuffer;
  103913. private _vertexBuffers;
  103914. /**
  103915. * Creates a new instance PostProcess
  103916. * @param scene The scene that the post process is associated with.
  103917. */
  103918. constructor(scene: Scene);
  103919. private _prepareBuffers;
  103920. private _buildIndexBuffer;
  103921. /**
  103922. * Rebuilds the vertex buffers of the manager.
  103923. * @hidden
  103924. */
  103925. _rebuild(): void;
  103926. /**
  103927. * Prepares a frame to be run through a post process.
  103928. * @param sourceTexture The input texture to the post procesess. (default: null)
  103929. * @param postProcesses An array of post processes to be run. (default: null)
  103930. * @returns True if the post processes were able to be run.
  103931. * @hidden
  103932. */
  103933. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  103934. /**
  103935. * Manually render a set of post processes to a texture.
  103936. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  103937. * @param postProcesses An array of post processes to be run.
  103938. * @param targetTexture The target texture to render to.
  103939. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  103940. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  103941. * @param lodLevel defines which lod of the texture to render to
  103942. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  103943. */
  103944. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  103945. /**
  103946. * Finalize the result of the output of the postprocesses.
  103947. * @param doNotPresent If true the result will not be displayed to the screen.
  103948. * @param targetTexture The target texture to render to.
  103949. * @param faceIndex The index of the face to bind the target texture to.
  103950. * @param postProcesses The array of post processes to render.
  103951. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  103952. * @hidden
  103953. */
  103954. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  103955. /**
  103956. * Disposes of the post process manager.
  103957. */
  103958. dispose(): void;
  103959. }
  103960. }
  103961. declare module BABYLON {
  103962. /**
  103963. * This Helps creating a texture that will be created from a camera in your scene.
  103964. * It is basically a dynamic texture that could be used to create special effects for instance.
  103965. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  103966. */
  103967. export class RenderTargetTexture extends Texture {
  103968. /**
  103969. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  103970. */
  103971. static readonly REFRESHRATE_RENDER_ONCE: number;
  103972. /**
  103973. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  103974. */
  103975. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  103976. /**
  103977. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  103978. * the central point of your effect and can save a lot of performances.
  103979. */
  103980. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  103981. /**
  103982. * Use this predicate to dynamically define the list of mesh you want to render.
  103983. * If set, the renderList property will be overwritten.
  103984. */
  103985. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  103986. private _renderList;
  103987. /**
  103988. * Use this list to define the list of mesh you want to render.
  103989. */
  103990. get renderList(): Nullable<Array<AbstractMesh>>;
  103991. set renderList(value: Nullable<Array<AbstractMesh>>);
  103992. /**
  103993. * Use this function to overload the renderList array at rendering time.
  103994. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  103995. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  103996. * the cube (if the RTT is a cube, else layerOrFace=0).
  103997. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  103998. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  103999. * hold dummy elements!
  104000. */
  104001. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  104002. private _hookArray;
  104003. /**
  104004. * Define if particles should be rendered in your texture.
  104005. */
  104006. renderParticles: boolean;
  104007. /**
  104008. * Define if sprites should be rendered in your texture.
  104009. */
  104010. renderSprites: boolean;
  104011. /**
  104012. * Define the camera used to render the texture.
  104013. */
  104014. activeCamera: Nullable<Camera>;
  104015. /**
  104016. * Override the mesh isReady function with your own one.
  104017. */
  104018. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  104019. /**
  104020. * Override the render function of the texture with your own one.
  104021. */
  104022. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  104023. /**
  104024. * Define if camera post processes should be use while rendering the texture.
  104025. */
  104026. useCameraPostProcesses: boolean;
  104027. /**
  104028. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  104029. */
  104030. ignoreCameraViewport: boolean;
  104031. private _postProcessManager;
  104032. private _postProcesses;
  104033. private _resizeObserver;
  104034. /**
  104035. * An event triggered when the texture is unbind.
  104036. */
  104037. onBeforeBindObservable: Observable<RenderTargetTexture>;
  104038. /**
  104039. * An event triggered when the texture is unbind.
  104040. */
  104041. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  104042. private _onAfterUnbindObserver;
  104043. /**
  104044. * Set a after unbind callback in the texture.
  104045. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  104046. */
  104047. set onAfterUnbind(callback: () => void);
  104048. /**
  104049. * An event triggered before rendering the texture
  104050. */
  104051. onBeforeRenderObservable: Observable<number>;
  104052. private _onBeforeRenderObserver;
  104053. /**
  104054. * Set a before render callback in the texture.
  104055. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  104056. */
  104057. set onBeforeRender(callback: (faceIndex: number) => void);
  104058. /**
  104059. * An event triggered after rendering the texture
  104060. */
  104061. onAfterRenderObservable: Observable<number>;
  104062. private _onAfterRenderObserver;
  104063. /**
  104064. * Set a after render callback in the texture.
  104065. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  104066. */
  104067. set onAfterRender(callback: (faceIndex: number) => void);
  104068. /**
  104069. * An event triggered after the texture clear
  104070. */
  104071. onClearObservable: Observable<Engine>;
  104072. private _onClearObserver;
  104073. /**
  104074. * Set a clear callback in the texture.
  104075. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  104076. */
  104077. set onClear(callback: (Engine: Engine) => void);
  104078. /**
  104079. * An event triggered when the texture is resized.
  104080. */
  104081. onResizeObservable: Observable<RenderTargetTexture>;
  104082. /**
  104083. * Define the clear color of the Render Target if it should be different from the scene.
  104084. */
  104085. clearColor: Color4;
  104086. protected _size: number | {
  104087. width: number;
  104088. height: number;
  104089. layers?: number;
  104090. };
  104091. protected _initialSizeParameter: number | {
  104092. width: number;
  104093. height: number;
  104094. } | {
  104095. ratio: number;
  104096. };
  104097. protected _sizeRatio: Nullable<number>;
  104098. /** @hidden */
  104099. _generateMipMaps: boolean;
  104100. protected _renderingManager: RenderingManager;
  104101. /** @hidden */
  104102. _waitingRenderList?: string[];
  104103. protected _doNotChangeAspectRatio: boolean;
  104104. protected _currentRefreshId: number;
  104105. protected _refreshRate: number;
  104106. protected _textureMatrix: Matrix;
  104107. protected _samples: number;
  104108. protected _renderTargetOptions: RenderTargetCreationOptions;
  104109. /**
  104110. * Gets render target creation options that were used.
  104111. */
  104112. get renderTargetOptions(): RenderTargetCreationOptions;
  104113. protected _onRatioRescale(): void;
  104114. /**
  104115. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  104116. * It must define where the camera used to render the texture is set
  104117. */
  104118. boundingBoxPosition: Vector3;
  104119. private _boundingBoxSize;
  104120. /**
  104121. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  104122. * When defined, the cubemap will switch to local mode
  104123. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  104124. * @example https://www.babylonjs-playground.com/#RNASML
  104125. */
  104126. set boundingBoxSize(value: Vector3);
  104127. get boundingBoxSize(): Vector3;
  104128. /**
  104129. * In case the RTT has been created with a depth texture, get the associated
  104130. * depth texture.
  104131. * Otherwise, return null.
  104132. */
  104133. get depthStencilTexture(): Nullable<InternalTexture>;
  104134. /**
  104135. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  104136. * or used a shadow, depth texture...
  104137. * @param name The friendly name of the texture
  104138. * @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)
  104139. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  104140. * @param generateMipMaps True if mip maps need to be generated after render.
  104141. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  104142. * @param type The type of the buffer in the RTT (int, half float, float...)
  104143. * @param isCube True if a cube texture needs to be created
  104144. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  104145. * @param generateDepthBuffer True to generate a depth buffer
  104146. * @param generateStencilBuffer True to generate a stencil buffer
  104147. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  104148. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  104149. * @param delayAllocation if the texture allocation should be delayed (default: false)
  104150. */
  104151. constructor(name: string, size: number | {
  104152. width: number;
  104153. height: number;
  104154. layers?: number;
  104155. } | {
  104156. ratio: number;
  104157. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  104158. /**
  104159. * Creates a depth stencil texture.
  104160. * This is only available in WebGL 2 or with the depth texture extension available.
  104161. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  104162. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  104163. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  104164. */
  104165. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  104166. private _processSizeParameter;
  104167. /**
  104168. * Define the number of samples to use in case of MSAA.
  104169. * It defaults to one meaning no MSAA has been enabled.
  104170. */
  104171. get samples(): number;
  104172. set samples(value: number);
  104173. /**
  104174. * Resets the refresh counter of the texture and start bak from scratch.
  104175. * Could be useful to regenerate the texture if it is setup to render only once.
  104176. */
  104177. resetRefreshCounter(): void;
  104178. /**
  104179. * Define the refresh rate of the texture or the rendering frequency.
  104180. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  104181. */
  104182. get refreshRate(): number;
  104183. set refreshRate(value: number);
  104184. /**
  104185. * Adds a post process to the render target rendering passes.
  104186. * @param postProcess define the post process to add
  104187. */
  104188. addPostProcess(postProcess: PostProcess): void;
  104189. /**
  104190. * Clear all the post processes attached to the render target
  104191. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  104192. */
  104193. clearPostProcesses(dispose?: boolean): void;
  104194. /**
  104195. * Remove one of the post process from the list of attached post processes to the texture
  104196. * @param postProcess define the post process to remove from the list
  104197. */
  104198. removePostProcess(postProcess: PostProcess): void;
  104199. /** @hidden */
  104200. _shouldRender(): boolean;
  104201. /**
  104202. * Gets the actual render size of the texture.
  104203. * @returns the width of the render size
  104204. */
  104205. getRenderSize(): number;
  104206. /**
  104207. * Gets the actual render width of the texture.
  104208. * @returns the width of the render size
  104209. */
  104210. getRenderWidth(): number;
  104211. /**
  104212. * Gets the actual render height of the texture.
  104213. * @returns the height of the render size
  104214. */
  104215. getRenderHeight(): number;
  104216. /**
  104217. * Gets the actual number of layers of the texture.
  104218. * @returns the number of layers
  104219. */
  104220. getRenderLayers(): number;
  104221. /**
  104222. * Get if the texture can be rescaled or not.
  104223. */
  104224. get canRescale(): boolean;
  104225. /**
  104226. * Resize the texture using a ratio.
  104227. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  104228. */
  104229. scale(ratio: number): void;
  104230. /**
  104231. * Get the texture reflection matrix used to rotate/transform the reflection.
  104232. * @returns the reflection matrix
  104233. */
  104234. getReflectionTextureMatrix(): Matrix;
  104235. /**
  104236. * Resize the texture to a new desired size.
  104237. * Be carrefull as it will recreate all the data in the new texture.
  104238. * @param size Define the new size. It can be:
  104239. * - a number for squared texture,
  104240. * - an object containing { width: number, height: number }
  104241. * - or an object containing a ratio { ratio: number }
  104242. */
  104243. resize(size: number | {
  104244. width: number;
  104245. height: number;
  104246. } | {
  104247. ratio: number;
  104248. }): void;
  104249. private _defaultRenderListPrepared;
  104250. /**
  104251. * Renders all the objects from the render list into the texture.
  104252. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  104253. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  104254. */
  104255. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  104256. private _bestReflectionRenderTargetDimension;
  104257. private _prepareRenderingManager;
  104258. /**
  104259. * @hidden
  104260. * @param faceIndex face index to bind to if this is a cubetexture
  104261. * @param layer defines the index of the texture to bind in the array
  104262. */
  104263. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  104264. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104265. private renderToTarget;
  104266. /**
  104267. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  104268. * This allowed control for front to back rendering or reversly depending of the special needs.
  104269. *
  104270. * @param renderingGroupId The rendering group id corresponding to its index
  104271. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  104272. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  104273. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  104274. */
  104275. 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;
  104276. /**
  104277. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  104278. *
  104279. * @param renderingGroupId The rendering group id corresponding to its index
  104280. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  104281. */
  104282. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  104283. /**
  104284. * Clones the texture.
  104285. * @returns the cloned texture
  104286. */
  104287. clone(): RenderTargetTexture;
  104288. /**
  104289. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  104290. * @returns The JSON representation of the texture
  104291. */
  104292. serialize(): any;
  104293. /**
  104294. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  104295. */
  104296. disposeFramebufferObjects(): void;
  104297. /**
  104298. * Dispose the texture and release its associated resources.
  104299. */
  104300. dispose(): void;
  104301. /** @hidden */
  104302. _rebuild(): void;
  104303. /**
  104304. * Clear the info related to rendering groups preventing retention point in material dispose.
  104305. */
  104306. freeRenderingGroups(): void;
  104307. /**
  104308. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  104309. * @returns the view count
  104310. */
  104311. getViewCount(): number;
  104312. }
  104313. }
  104314. declare module BABYLON {
  104315. /**
  104316. * Class used to manipulate GUIDs
  104317. */
  104318. export class GUID {
  104319. /**
  104320. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104321. * Be aware Math.random() could cause collisions, but:
  104322. * "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"
  104323. * @returns a pseudo random id
  104324. */
  104325. static RandomId(): string;
  104326. }
  104327. }
  104328. declare module BABYLON {
  104329. /**
  104330. * Options to be used when creating a shadow depth material
  104331. */
  104332. export interface IIOptionShadowDepthMaterial {
  104333. /** Variables in the vertex shader code that need to have their names remapped.
  104334. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  104335. * "var_name" should be either: worldPos or vNormalW
  104336. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  104337. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  104338. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  104339. */
  104340. remappedVariables?: string[];
  104341. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  104342. standalone?: boolean;
  104343. }
  104344. /**
  104345. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  104346. */
  104347. export class ShadowDepthWrapper {
  104348. private _scene;
  104349. private _options?;
  104350. private _baseMaterial;
  104351. private _onEffectCreatedObserver;
  104352. private _subMeshToEffect;
  104353. private _subMeshToDepthEffect;
  104354. private _meshes;
  104355. /** @hidden */
  104356. _matriceNames: any;
  104357. /** Gets the standalone status of the wrapper */
  104358. get standalone(): boolean;
  104359. /** Gets the base material the wrapper is built upon */
  104360. get baseMaterial(): Material;
  104361. /**
  104362. * Instantiate a new shadow depth wrapper.
  104363. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  104364. * generate the shadow depth map. For more information, please refer to the documentation:
  104365. * https://doc.babylonjs.com/babylon101/shadows
  104366. * @param baseMaterial Material to wrap
  104367. * @param scene Define the scene the material belongs to
  104368. * @param options Options used to create the wrapper
  104369. */
  104370. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  104371. /**
  104372. * Gets the effect to use to generate the depth map
  104373. * @param subMesh subMesh to get the effect for
  104374. * @param shadowGenerator shadow generator to get the effect for
  104375. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  104376. */
  104377. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  104378. /**
  104379. * Specifies that the submesh is ready to be used for depth rendering
  104380. * @param subMesh submesh to check
  104381. * @param defines the list of defines to take into account when checking the effect
  104382. * @param shadowGenerator combined with subMesh, it defines the effect to check
  104383. * @param useInstances specifies that instances should be used
  104384. * @returns a boolean indicating that the submesh is ready or not
  104385. */
  104386. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  104387. /**
  104388. * Disposes the resources
  104389. */
  104390. dispose(): void;
  104391. private _makeEffect;
  104392. }
  104393. }
  104394. declare module BABYLON {
  104395. interface ThinEngine {
  104396. /**
  104397. * Unbind a list of render target textures from the webGL context
  104398. * This is used only when drawBuffer extension or webGL2 are active
  104399. * @param textures defines the render target textures to unbind
  104400. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104401. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104402. */
  104403. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  104404. /**
  104405. * Create a multi render target texture
  104406. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  104407. * @param size defines the size of the texture
  104408. * @param options defines the creation options
  104409. * @returns the cube texture as an InternalTexture
  104410. */
  104411. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  104412. /**
  104413. * Update the sample count for a given multiple render target texture
  104414. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104415. * @param textures defines the textures to update
  104416. * @param samples defines the sample count to set
  104417. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104418. */
  104419. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  104420. /**
  104421. * Select a subsets of attachments to draw to.
  104422. * @param attachments gl attachments
  104423. */
  104424. bindAttachments(attachments: number[]): void;
  104425. }
  104426. }
  104427. declare module BABYLON {
  104428. /**
  104429. * Creation options of the multi render target texture.
  104430. */
  104431. export interface IMultiRenderTargetOptions {
  104432. /**
  104433. * Define if the texture needs to create mip maps after render.
  104434. */
  104435. generateMipMaps?: boolean;
  104436. /**
  104437. * Define the types of all the draw buffers we want to create
  104438. */
  104439. types?: number[];
  104440. /**
  104441. * Define the sampling modes of all the draw buffers we want to create
  104442. */
  104443. samplingModes?: number[];
  104444. /**
  104445. * Define if a depth buffer is required
  104446. */
  104447. generateDepthBuffer?: boolean;
  104448. /**
  104449. * Define if a stencil buffer is required
  104450. */
  104451. generateStencilBuffer?: boolean;
  104452. /**
  104453. * Define if a depth texture is required instead of a depth buffer
  104454. */
  104455. generateDepthTexture?: boolean;
  104456. /**
  104457. * Define the number of desired draw buffers
  104458. */
  104459. textureCount?: number;
  104460. /**
  104461. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104462. */
  104463. doNotChangeAspectRatio?: boolean;
  104464. /**
  104465. * Define the default type of the buffers we are creating
  104466. */
  104467. defaultType?: number;
  104468. }
  104469. /**
  104470. * A multi render target, like a render target provides the ability to render to a texture.
  104471. * Unlike the render target, it can render to several draw buffers in one draw.
  104472. * This is specially interesting in deferred rendering or for any effects requiring more than
  104473. * just one color from a single pass.
  104474. */
  104475. export class MultiRenderTarget extends RenderTargetTexture {
  104476. private _internalTextures;
  104477. private _textures;
  104478. private _multiRenderTargetOptions;
  104479. private _count;
  104480. /**
  104481. * Get if draw buffers are currently supported by the used hardware and browser.
  104482. */
  104483. get isSupported(): boolean;
  104484. /**
  104485. * Get the list of textures generated by the multi render target.
  104486. */
  104487. get textures(): Texture[];
  104488. /**
  104489. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  104490. */
  104491. get count(): number;
  104492. /**
  104493. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104494. */
  104495. get depthTexture(): Texture;
  104496. /**
  104497. * Set the wrapping mode on U of all the textures we are rendering to.
  104498. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104499. */
  104500. set wrapU(wrap: number);
  104501. /**
  104502. * Set the wrapping mode on V of all the textures we are rendering to.
  104503. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104504. */
  104505. set wrapV(wrap: number);
  104506. /**
  104507. * Instantiate a new multi render target texture.
  104508. * A multi render target, like a render target provides the ability to render to a texture.
  104509. * Unlike the render target, it can render to several draw buffers in one draw.
  104510. * This is specially interesting in deferred rendering or for any effects requiring more than
  104511. * just one color from a single pass.
  104512. * @param name Define the name of the texture
  104513. * @param size Define the size of the buffers to render to
  104514. * @param count Define the number of target we are rendering into
  104515. * @param scene Define the scene the texture belongs to
  104516. * @param options Define the options used to create the multi render target
  104517. */
  104518. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104519. private _initTypes;
  104520. /** @hidden */
  104521. _rebuild(forceFullRebuild?: boolean): void;
  104522. private _createInternalTextures;
  104523. private _createTextures;
  104524. /**
  104525. * Define the number of samples used if MSAA is enabled.
  104526. */
  104527. get samples(): number;
  104528. set samples(value: number);
  104529. /**
  104530. * Resize all the textures in the multi render target.
  104531. * Be careful as it will recreate all the data in the new texture.
  104532. * @param size Define the new size
  104533. */
  104534. resize(size: any): void;
  104535. /**
  104536. * Changes the number of render targets in this MRT
  104537. * Be careful as it will recreate all the data in the new texture.
  104538. * @param count new texture count
  104539. * @param options Specifies texture types and sampling modes for new textures
  104540. */
  104541. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  104542. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104543. /**
  104544. * Dispose the render targets and their associated resources
  104545. */
  104546. dispose(): void;
  104547. /**
  104548. * Release all the underlying texture used as draw buffers.
  104549. */
  104550. releaseInternalTextures(): void;
  104551. }
  104552. }
  104553. declare module BABYLON {
  104554. /** @hidden */
  104555. export var imageProcessingPixelShader: {
  104556. name: string;
  104557. shader: string;
  104558. };
  104559. }
  104560. declare module BABYLON {
  104561. /**
  104562. * ImageProcessingPostProcess
  104563. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  104564. */
  104565. export class ImageProcessingPostProcess extends PostProcess {
  104566. /**
  104567. * Default configuration related to image processing available in the PBR Material.
  104568. */
  104569. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104570. /**
  104571. * Gets the image processing configuration used either in this material.
  104572. */
  104573. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104574. /**
  104575. * Sets the Default image processing configuration used either in the this material.
  104576. *
  104577. * If sets to null, the scene one is in use.
  104578. */
  104579. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104580. /**
  104581. * Keep track of the image processing observer to allow dispose and replace.
  104582. */
  104583. private _imageProcessingObserver;
  104584. /**
  104585. * Attaches a new image processing configuration to the PBR Material.
  104586. * @param configuration
  104587. */
  104588. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104589. /**
  104590. * If the post process is supported.
  104591. */
  104592. get isSupported(): boolean;
  104593. /**
  104594. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104595. */
  104596. get colorCurves(): Nullable<ColorCurves>;
  104597. /**
  104598. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104599. */
  104600. set colorCurves(value: Nullable<ColorCurves>);
  104601. /**
  104602. * Gets wether the color curves effect is enabled.
  104603. */
  104604. get colorCurvesEnabled(): boolean;
  104605. /**
  104606. * Sets wether the color curves effect is enabled.
  104607. */
  104608. set colorCurvesEnabled(value: boolean);
  104609. /**
  104610. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104611. */
  104612. get colorGradingTexture(): Nullable<BaseTexture>;
  104613. /**
  104614. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104615. */
  104616. set colorGradingTexture(value: Nullable<BaseTexture>);
  104617. /**
  104618. * Gets wether the color grading effect is enabled.
  104619. */
  104620. get colorGradingEnabled(): boolean;
  104621. /**
  104622. * Gets wether the color grading effect is enabled.
  104623. */
  104624. set colorGradingEnabled(value: boolean);
  104625. /**
  104626. * Gets exposure used in the effect.
  104627. */
  104628. get exposure(): number;
  104629. /**
  104630. * Sets exposure used in the effect.
  104631. */
  104632. set exposure(value: number);
  104633. /**
  104634. * Gets wether tonemapping is enabled or not.
  104635. */
  104636. get toneMappingEnabled(): boolean;
  104637. /**
  104638. * Sets wether tonemapping is enabled or not
  104639. */
  104640. set toneMappingEnabled(value: boolean);
  104641. /**
  104642. * Gets the type of tone mapping effect.
  104643. */
  104644. get toneMappingType(): number;
  104645. /**
  104646. * Sets the type of tone mapping effect.
  104647. */
  104648. set toneMappingType(value: number);
  104649. /**
  104650. * Gets contrast used in the effect.
  104651. */
  104652. get contrast(): number;
  104653. /**
  104654. * Sets contrast used in the effect.
  104655. */
  104656. set contrast(value: number);
  104657. /**
  104658. * Gets Vignette stretch size.
  104659. */
  104660. get vignetteStretch(): number;
  104661. /**
  104662. * Sets Vignette stretch size.
  104663. */
  104664. set vignetteStretch(value: number);
  104665. /**
  104666. * Gets Vignette centre X Offset.
  104667. */
  104668. get vignetteCentreX(): number;
  104669. /**
  104670. * Sets Vignette centre X Offset.
  104671. */
  104672. set vignetteCentreX(value: number);
  104673. /**
  104674. * Gets Vignette centre Y Offset.
  104675. */
  104676. get vignetteCentreY(): number;
  104677. /**
  104678. * Sets Vignette centre Y Offset.
  104679. */
  104680. set vignetteCentreY(value: number);
  104681. /**
  104682. * Gets Vignette weight or intensity of the vignette effect.
  104683. */
  104684. get vignetteWeight(): number;
  104685. /**
  104686. * Sets Vignette weight or intensity of the vignette effect.
  104687. */
  104688. set vignetteWeight(value: number);
  104689. /**
  104690. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104691. * if vignetteEnabled is set to true.
  104692. */
  104693. get vignetteColor(): Color4;
  104694. /**
  104695. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104696. * if vignetteEnabled is set to true.
  104697. */
  104698. set vignetteColor(value: Color4);
  104699. /**
  104700. * Gets Camera field of view used by the Vignette effect.
  104701. */
  104702. get vignetteCameraFov(): number;
  104703. /**
  104704. * Sets Camera field of view used by the Vignette effect.
  104705. */
  104706. set vignetteCameraFov(value: number);
  104707. /**
  104708. * Gets the vignette blend mode allowing different kind of effect.
  104709. */
  104710. get vignetteBlendMode(): number;
  104711. /**
  104712. * Sets the vignette blend mode allowing different kind of effect.
  104713. */
  104714. set vignetteBlendMode(value: number);
  104715. /**
  104716. * Gets wether the vignette effect is enabled.
  104717. */
  104718. get vignetteEnabled(): boolean;
  104719. /**
  104720. * Sets wether the vignette effect is enabled.
  104721. */
  104722. set vignetteEnabled(value: boolean);
  104723. private _fromLinearSpace;
  104724. /**
  104725. * Gets wether the input of the processing is in Gamma or Linear Space.
  104726. */
  104727. get fromLinearSpace(): boolean;
  104728. /**
  104729. * Sets wether the input of the processing is in Gamma or Linear Space.
  104730. */
  104731. set fromLinearSpace(value: boolean);
  104732. /**
  104733. * Defines cache preventing GC.
  104734. */
  104735. private _defines;
  104736. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104737. /**
  104738. * "ImageProcessingPostProcess"
  104739. * @returns "ImageProcessingPostProcess"
  104740. */
  104741. getClassName(): string;
  104742. /**
  104743. * @hidden
  104744. */
  104745. _updateParameters(): void;
  104746. dispose(camera?: Camera): void;
  104747. }
  104748. }
  104749. declare module BABYLON {
  104750. /**
  104751. * Interface for defining prepass effects in the prepass post-process pipeline
  104752. */
  104753. export interface PrePassEffectConfiguration {
  104754. /**
  104755. * Name of the effect
  104756. */
  104757. name: string;
  104758. /**
  104759. * Post process to attach for this effect
  104760. */
  104761. postProcess?: PostProcess;
  104762. /**
  104763. * Textures required in the MRT
  104764. */
  104765. texturesRequired: number[];
  104766. /**
  104767. * Is the effect enabled
  104768. */
  104769. enabled: boolean;
  104770. /**
  104771. * Disposes the effect configuration
  104772. */
  104773. dispose(): void;
  104774. /**
  104775. * Creates the associated post process
  104776. */
  104777. createPostProcess?: () => PostProcess;
  104778. }
  104779. }
  104780. declare module BABYLON {
  104781. /**
  104782. * Renders a pre pass of the scene
  104783. * This means every mesh in the scene will be rendered to a render target texture
  104784. * And then this texture will be composited to the rendering canvas with post processes
  104785. * It is necessary for effects like subsurface scattering or deferred shading
  104786. */
  104787. export class PrePassRenderer {
  104788. /** @hidden */
  104789. static _SceneComponentInitialization: (scene: Scene) => void;
  104790. private _textureFormats;
  104791. private _textureIndices;
  104792. private _scene;
  104793. private _engine;
  104794. private _isDirty;
  104795. /**
  104796. * Number of textures in the multi render target texture where the scene is directly rendered
  104797. */
  104798. mrtCount: number;
  104799. /**
  104800. * The render target where the scene is directly rendered
  104801. */
  104802. prePassRT: MultiRenderTarget;
  104803. private _multiRenderAttachments;
  104804. private _defaultAttachments;
  104805. private _clearAttachments;
  104806. private _postProcesses;
  104807. private readonly _clearColor;
  104808. /**
  104809. * Image processing post process for composition
  104810. */
  104811. imageProcessingPostProcess: ImageProcessingPostProcess;
  104812. /**
  104813. * Configuration for prepass effects
  104814. */
  104815. private _effectConfigurations;
  104816. /**
  104817. * Should materials render their geometry on the MRT
  104818. */
  104819. materialsShouldRenderGeometry: boolean;
  104820. /**
  104821. * Should materials render the irradiance information on the MRT
  104822. */
  104823. materialsShouldRenderIrradiance: boolean;
  104824. private _mrtFormats;
  104825. private _mrtLayout;
  104826. private _enabled;
  104827. /**
  104828. * Indicates if the prepass is enabled
  104829. */
  104830. get enabled(): boolean;
  104831. /**
  104832. * How many samples are used for MSAA of the scene render target
  104833. */
  104834. get samples(): number;
  104835. set samples(n: number);
  104836. /**
  104837. * Instanciates a prepass renderer
  104838. * @param scene The scene
  104839. */
  104840. constructor(scene: Scene);
  104841. private _initializeAttachments;
  104842. private _createCompositionEffect;
  104843. /**
  104844. * Indicates if rendering a prepass is supported
  104845. */
  104846. get isSupported(): boolean;
  104847. /**
  104848. * Sets the proper output textures to draw in the engine.
  104849. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  104850. */
  104851. bindAttachmentsForEffect(effect: Effect): void;
  104852. /**
  104853. * @hidden
  104854. */
  104855. _beforeCameraDraw(): void;
  104856. /**
  104857. * @hidden
  104858. */
  104859. _afterCameraDraw(): void;
  104860. private _checkRTSize;
  104861. private _bindFrameBuffer;
  104862. /**
  104863. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  104864. */
  104865. clear(): void;
  104866. private _setState;
  104867. private _checkTextureType;
  104868. /**
  104869. * Adds an effect configuration to the prepass.
  104870. * If an effect has already been added, it won't add it twice and will return the configuration
  104871. * already present.
  104872. * @param cfg the effect configuration
  104873. * @return the effect configuration now used by the prepass
  104874. */
  104875. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  104876. /**
  104877. * Returns the index of a texture in the multi render target texture array.
  104878. * @param type Texture type
  104879. * @return The index
  104880. */
  104881. getIndex(type: number): number;
  104882. private _enable;
  104883. private _disable;
  104884. private _resetLayout;
  104885. private _resetPostProcessChain;
  104886. private _bindPostProcessChain;
  104887. /**
  104888. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  104889. */
  104890. markAsDirty(): void;
  104891. /**
  104892. * Enables a texture on the MultiRenderTarget for prepass
  104893. */
  104894. private _enableTextures;
  104895. private _update;
  104896. /**
  104897. * Disposes the prepass renderer.
  104898. */
  104899. dispose(): void;
  104900. }
  104901. }
  104902. declare module BABYLON {
  104903. /**
  104904. * Options for compiling materials.
  104905. */
  104906. export interface IMaterialCompilationOptions {
  104907. /**
  104908. * Defines whether clip planes are enabled.
  104909. */
  104910. clipPlane: boolean;
  104911. /**
  104912. * Defines whether instances are enabled.
  104913. */
  104914. useInstances: boolean;
  104915. }
  104916. /**
  104917. * Options passed when calling customShaderNameResolve
  104918. */
  104919. export interface ICustomShaderNameResolveOptions {
  104920. /**
  104921. * 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
  104922. */
  104923. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  104924. }
  104925. /**
  104926. * Base class for the main features of a material in Babylon.js
  104927. */
  104928. export class Material implements IAnimatable {
  104929. /**
  104930. * Returns the triangle fill mode
  104931. */
  104932. static readonly TriangleFillMode: number;
  104933. /**
  104934. * Returns the wireframe mode
  104935. */
  104936. static readonly WireFrameFillMode: number;
  104937. /**
  104938. * Returns the point fill mode
  104939. */
  104940. static readonly PointFillMode: number;
  104941. /**
  104942. * Returns the point list draw mode
  104943. */
  104944. static readonly PointListDrawMode: number;
  104945. /**
  104946. * Returns the line list draw mode
  104947. */
  104948. static readonly LineListDrawMode: number;
  104949. /**
  104950. * Returns the line loop draw mode
  104951. */
  104952. static readonly LineLoopDrawMode: number;
  104953. /**
  104954. * Returns the line strip draw mode
  104955. */
  104956. static readonly LineStripDrawMode: number;
  104957. /**
  104958. * Returns the triangle strip draw mode
  104959. */
  104960. static readonly TriangleStripDrawMode: number;
  104961. /**
  104962. * Returns the triangle fan draw mode
  104963. */
  104964. static readonly TriangleFanDrawMode: number;
  104965. /**
  104966. * Stores the clock-wise side orientation
  104967. */
  104968. static readonly ClockWiseSideOrientation: number;
  104969. /**
  104970. * Stores the counter clock-wise side orientation
  104971. */
  104972. static readonly CounterClockWiseSideOrientation: number;
  104973. /**
  104974. * The dirty texture flag value
  104975. */
  104976. static readonly TextureDirtyFlag: number;
  104977. /**
  104978. * The dirty light flag value
  104979. */
  104980. static readonly LightDirtyFlag: number;
  104981. /**
  104982. * The dirty fresnel flag value
  104983. */
  104984. static readonly FresnelDirtyFlag: number;
  104985. /**
  104986. * The dirty attribute flag value
  104987. */
  104988. static readonly AttributesDirtyFlag: number;
  104989. /**
  104990. * The dirty misc flag value
  104991. */
  104992. static readonly MiscDirtyFlag: number;
  104993. /**
  104994. * The all dirty flag value
  104995. */
  104996. static readonly AllDirtyFlag: number;
  104997. /**
  104998. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104999. */
  105000. static readonly MATERIAL_OPAQUE: number;
  105001. /**
  105002. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105003. */
  105004. static readonly MATERIAL_ALPHATEST: number;
  105005. /**
  105006. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105007. */
  105008. static readonly MATERIAL_ALPHABLEND: number;
  105009. /**
  105010. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105011. * They are also discarded below the alpha cutoff threshold to improve performances.
  105012. */
  105013. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  105014. /**
  105015. * The Whiteout method is used to blend normals.
  105016. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  105017. */
  105018. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  105019. /**
  105020. * The Reoriented Normal Mapping method is used to blend normals.
  105021. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  105022. */
  105023. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  105024. /**
  105025. * Custom callback helping to override the default shader used in the material.
  105026. */
  105027. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  105028. /**
  105029. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  105030. */
  105031. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  105032. /**
  105033. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  105034. * This means that the material can keep using a previous shader while a new one is being compiled.
  105035. * This is mostly used when shader parallel compilation is supported (true by default)
  105036. */
  105037. allowShaderHotSwapping: boolean;
  105038. /**
  105039. * The ID of the material
  105040. */
  105041. id: string;
  105042. /**
  105043. * Gets or sets the unique id of the material
  105044. */
  105045. uniqueId: number;
  105046. /**
  105047. * The name of the material
  105048. */
  105049. name: string;
  105050. /**
  105051. * Gets or sets user defined metadata
  105052. */
  105053. metadata: any;
  105054. /**
  105055. * For internal use only. Please do not use.
  105056. */
  105057. reservedDataStore: any;
  105058. /**
  105059. * Specifies if the ready state should be checked on each call
  105060. */
  105061. checkReadyOnEveryCall: boolean;
  105062. /**
  105063. * Specifies if the ready state should be checked once
  105064. */
  105065. checkReadyOnlyOnce: boolean;
  105066. /**
  105067. * The state of the material
  105068. */
  105069. state: string;
  105070. /**
  105071. * If the material can be rendered to several textures with MRT extension
  105072. */
  105073. get canRenderToMRT(): boolean;
  105074. /**
  105075. * The alpha value of the material
  105076. */
  105077. protected _alpha: number;
  105078. /**
  105079. * List of inspectable custom properties (used by the Inspector)
  105080. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  105081. */
  105082. inspectableCustomProperties: IInspectable[];
  105083. /**
  105084. * Sets the alpha value of the material
  105085. */
  105086. set alpha(value: number);
  105087. /**
  105088. * Gets the alpha value of the material
  105089. */
  105090. get alpha(): number;
  105091. /**
  105092. * Specifies if back face culling is enabled
  105093. */
  105094. protected _backFaceCulling: boolean;
  105095. /**
  105096. * Sets the back-face culling state
  105097. */
  105098. set backFaceCulling(value: boolean);
  105099. /**
  105100. * Gets the back-face culling state
  105101. */
  105102. get backFaceCulling(): boolean;
  105103. /**
  105104. * Stores the value for side orientation
  105105. */
  105106. sideOrientation: number;
  105107. /**
  105108. * Callback triggered when the material is compiled
  105109. */
  105110. onCompiled: Nullable<(effect: Effect) => void>;
  105111. /**
  105112. * Callback triggered when an error occurs
  105113. */
  105114. onError: Nullable<(effect: Effect, errors: string) => void>;
  105115. /**
  105116. * Callback triggered to get the render target textures
  105117. */
  105118. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  105119. /**
  105120. * Gets a boolean indicating that current material needs to register RTT
  105121. */
  105122. get hasRenderTargetTextures(): boolean;
  105123. /**
  105124. * Specifies if the material should be serialized
  105125. */
  105126. doNotSerialize: boolean;
  105127. /**
  105128. * @hidden
  105129. */
  105130. _storeEffectOnSubMeshes: boolean;
  105131. /**
  105132. * Stores the animations for the material
  105133. */
  105134. animations: Nullable<Array<Animation>>;
  105135. /**
  105136. * An event triggered when the material is disposed
  105137. */
  105138. onDisposeObservable: Observable<Material>;
  105139. /**
  105140. * An observer which watches for dispose events
  105141. */
  105142. private _onDisposeObserver;
  105143. private _onUnBindObservable;
  105144. /**
  105145. * Called during a dispose event
  105146. */
  105147. set onDispose(callback: () => void);
  105148. private _onBindObservable;
  105149. /**
  105150. * An event triggered when the material is bound
  105151. */
  105152. get onBindObservable(): Observable<AbstractMesh>;
  105153. /**
  105154. * An observer which watches for bind events
  105155. */
  105156. private _onBindObserver;
  105157. /**
  105158. * Called during a bind event
  105159. */
  105160. set onBind(callback: (Mesh: AbstractMesh) => void);
  105161. /**
  105162. * An event triggered when the material is unbound
  105163. */
  105164. get onUnBindObservable(): Observable<Material>;
  105165. protected _onEffectCreatedObservable: Nullable<Observable<{
  105166. effect: Effect;
  105167. subMesh: Nullable<SubMesh>;
  105168. }>>;
  105169. /**
  105170. * An event triggered when the effect is (re)created
  105171. */
  105172. get onEffectCreatedObservable(): Observable<{
  105173. effect: Effect;
  105174. subMesh: Nullable<SubMesh>;
  105175. }>;
  105176. /**
  105177. * Stores the value of the alpha mode
  105178. */
  105179. private _alphaMode;
  105180. /**
  105181. * Sets the value of the alpha mode.
  105182. *
  105183. * | Value | Type | Description |
  105184. * | --- | --- | --- |
  105185. * | 0 | ALPHA_DISABLE | |
  105186. * | 1 | ALPHA_ADD | |
  105187. * | 2 | ALPHA_COMBINE | |
  105188. * | 3 | ALPHA_SUBTRACT | |
  105189. * | 4 | ALPHA_MULTIPLY | |
  105190. * | 5 | ALPHA_MAXIMIZED | |
  105191. * | 6 | ALPHA_ONEONE | |
  105192. * | 7 | ALPHA_PREMULTIPLIED | |
  105193. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  105194. * | 9 | ALPHA_INTERPOLATE | |
  105195. * | 10 | ALPHA_SCREENMODE | |
  105196. *
  105197. */
  105198. set alphaMode(value: number);
  105199. /**
  105200. * Gets the value of the alpha mode
  105201. */
  105202. get alphaMode(): number;
  105203. /**
  105204. * Stores the state of the need depth pre-pass value
  105205. */
  105206. private _needDepthPrePass;
  105207. /**
  105208. * Sets the need depth pre-pass value
  105209. */
  105210. set needDepthPrePass(value: boolean);
  105211. /**
  105212. * Gets the depth pre-pass value
  105213. */
  105214. get needDepthPrePass(): boolean;
  105215. /**
  105216. * Specifies if depth writing should be disabled
  105217. */
  105218. disableDepthWrite: boolean;
  105219. /**
  105220. * Specifies if color writing should be disabled
  105221. */
  105222. disableColorWrite: boolean;
  105223. /**
  105224. * Specifies if depth writing should be forced
  105225. */
  105226. forceDepthWrite: boolean;
  105227. /**
  105228. * Specifies the depth function that should be used. 0 means the default engine function
  105229. */
  105230. depthFunction: number;
  105231. /**
  105232. * Specifies if there should be a separate pass for culling
  105233. */
  105234. separateCullingPass: boolean;
  105235. /**
  105236. * Stores the state specifing if fog should be enabled
  105237. */
  105238. private _fogEnabled;
  105239. /**
  105240. * Sets the state for enabling fog
  105241. */
  105242. set fogEnabled(value: boolean);
  105243. /**
  105244. * Gets the value of the fog enabled state
  105245. */
  105246. get fogEnabled(): boolean;
  105247. /**
  105248. * Stores the size of points
  105249. */
  105250. pointSize: number;
  105251. /**
  105252. * Stores the z offset value
  105253. */
  105254. zOffset: number;
  105255. get wireframe(): boolean;
  105256. /**
  105257. * Sets the state of wireframe mode
  105258. */
  105259. set wireframe(value: boolean);
  105260. /**
  105261. * Gets the value specifying if point clouds are enabled
  105262. */
  105263. get pointsCloud(): boolean;
  105264. /**
  105265. * Sets the state of point cloud mode
  105266. */
  105267. set pointsCloud(value: boolean);
  105268. /**
  105269. * Gets the material fill mode
  105270. */
  105271. get fillMode(): number;
  105272. /**
  105273. * Sets the material fill mode
  105274. */
  105275. set fillMode(value: number);
  105276. /**
  105277. * @hidden
  105278. * Stores the effects for the material
  105279. */
  105280. _effect: Nullable<Effect>;
  105281. /**
  105282. * Specifies if uniform buffers should be used
  105283. */
  105284. private _useUBO;
  105285. /**
  105286. * Stores a reference to the scene
  105287. */
  105288. private _scene;
  105289. /**
  105290. * Stores the fill mode state
  105291. */
  105292. private _fillMode;
  105293. /**
  105294. * Specifies if the depth write state should be cached
  105295. */
  105296. private _cachedDepthWriteState;
  105297. /**
  105298. * Specifies if the color write state should be cached
  105299. */
  105300. private _cachedColorWriteState;
  105301. /**
  105302. * Specifies if the depth function state should be cached
  105303. */
  105304. private _cachedDepthFunctionState;
  105305. /**
  105306. * Stores the uniform buffer
  105307. */
  105308. protected _uniformBuffer: UniformBuffer;
  105309. /** @hidden */
  105310. _indexInSceneMaterialArray: number;
  105311. /** @hidden */
  105312. meshMap: Nullable<{
  105313. [id: string]: AbstractMesh | undefined;
  105314. }>;
  105315. /**
  105316. * Creates a material instance
  105317. * @param name defines the name of the material
  105318. * @param scene defines the scene to reference
  105319. * @param doNotAdd specifies if the material should be added to the scene
  105320. */
  105321. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  105322. /**
  105323. * Returns a string representation of the current material
  105324. * @param fullDetails defines a boolean indicating which levels of logging is desired
  105325. * @returns a string with material information
  105326. */
  105327. toString(fullDetails?: boolean): string;
  105328. /**
  105329. * Gets the class name of the material
  105330. * @returns a string with the class name of the material
  105331. */
  105332. getClassName(): string;
  105333. /**
  105334. * Specifies if updates for the material been locked
  105335. */
  105336. get isFrozen(): boolean;
  105337. /**
  105338. * Locks updates for the material
  105339. */
  105340. freeze(): void;
  105341. /**
  105342. * Unlocks updates for the material
  105343. */
  105344. unfreeze(): void;
  105345. /**
  105346. * Specifies if the material is ready to be used
  105347. * @param mesh defines the mesh to check
  105348. * @param useInstances specifies if instances should be used
  105349. * @returns a boolean indicating if the material is ready to be used
  105350. */
  105351. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105352. /**
  105353. * Specifies that the submesh is ready to be used
  105354. * @param mesh defines the mesh to check
  105355. * @param subMesh defines which submesh to check
  105356. * @param useInstances specifies that instances should be used
  105357. * @returns a boolean indicating that the submesh is ready or not
  105358. */
  105359. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105360. /**
  105361. * Returns the material effect
  105362. * @returns the effect associated with the material
  105363. */
  105364. getEffect(): Nullable<Effect>;
  105365. /**
  105366. * Returns the current scene
  105367. * @returns a Scene
  105368. */
  105369. getScene(): Scene;
  105370. /**
  105371. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105372. */
  105373. protected _forceAlphaTest: boolean;
  105374. /**
  105375. * The transparency mode of the material.
  105376. */
  105377. protected _transparencyMode: Nullable<number>;
  105378. /**
  105379. * Gets the current transparency mode.
  105380. */
  105381. get transparencyMode(): Nullable<number>;
  105382. /**
  105383. * Sets the transparency mode of the material.
  105384. *
  105385. * | Value | Type | Description |
  105386. * | ----- | ----------------------------------- | ----------- |
  105387. * | 0 | OPAQUE | |
  105388. * | 1 | ALPHATEST | |
  105389. * | 2 | ALPHABLEND | |
  105390. * | 3 | ALPHATESTANDBLEND | |
  105391. *
  105392. */
  105393. set transparencyMode(value: Nullable<number>);
  105394. /**
  105395. * Returns true if alpha blending should be disabled.
  105396. */
  105397. protected get _disableAlphaBlending(): boolean;
  105398. /**
  105399. * Specifies whether or not this material should be rendered in alpha blend mode.
  105400. * @returns a boolean specifying if alpha blending is needed
  105401. */
  105402. needAlphaBlending(): boolean;
  105403. /**
  105404. * Specifies if the mesh will require alpha blending
  105405. * @param mesh defines the mesh to check
  105406. * @returns a boolean specifying if alpha blending is needed for the mesh
  105407. */
  105408. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105409. /**
  105410. * Specifies whether or not this material should be rendered in alpha test mode.
  105411. * @returns a boolean specifying if an alpha test is needed.
  105412. */
  105413. needAlphaTesting(): boolean;
  105414. /**
  105415. * Specifies if material alpha testing should be turned on for the mesh
  105416. * @param mesh defines the mesh to check
  105417. */
  105418. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  105419. /**
  105420. * Gets the texture used for the alpha test
  105421. * @returns the texture to use for alpha testing
  105422. */
  105423. getAlphaTestTexture(): Nullable<BaseTexture>;
  105424. /**
  105425. * Marks the material to indicate that it needs to be re-calculated
  105426. */
  105427. markDirty(): void;
  105428. /** @hidden */
  105429. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  105430. /**
  105431. * Binds the material to the mesh
  105432. * @param world defines the world transformation matrix
  105433. * @param mesh defines the mesh to bind the material to
  105434. */
  105435. bind(world: Matrix, mesh?: Mesh): void;
  105436. /**
  105437. * Binds the submesh to the material
  105438. * @param world defines the world transformation matrix
  105439. * @param mesh defines the mesh containing the submesh
  105440. * @param subMesh defines the submesh to bind the material to
  105441. */
  105442. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105443. /**
  105444. * Binds the world matrix to the material
  105445. * @param world defines the world transformation matrix
  105446. */
  105447. bindOnlyWorldMatrix(world: Matrix): void;
  105448. /**
  105449. * Binds the scene's uniform buffer to the effect.
  105450. * @param effect defines the effect to bind to the scene uniform buffer
  105451. * @param sceneUbo defines the uniform buffer storing scene data
  105452. */
  105453. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  105454. /**
  105455. * Binds the view matrix to the effect
  105456. * @param effect defines the effect to bind the view matrix to
  105457. */
  105458. bindView(effect: Effect): void;
  105459. /**
  105460. * Binds the view projection matrix to the effect
  105461. * @param effect defines the effect to bind the view projection matrix to
  105462. */
  105463. bindViewProjection(effect: Effect): void;
  105464. /**
  105465. * Processes to execute after binding the material to a mesh
  105466. * @param mesh defines the rendered mesh
  105467. */
  105468. protected _afterBind(mesh?: Mesh): void;
  105469. /**
  105470. * Unbinds the material from the mesh
  105471. */
  105472. unbind(): void;
  105473. /**
  105474. * Gets the active textures from the material
  105475. * @returns an array of textures
  105476. */
  105477. getActiveTextures(): BaseTexture[];
  105478. /**
  105479. * Specifies if the material uses a texture
  105480. * @param texture defines the texture to check against the material
  105481. * @returns a boolean specifying if the material uses the texture
  105482. */
  105483. hasTexture(texture: BaseTexture): boolean;
  105484. /**
  105485. * Makes a duplicate of the material, and gives it a new name
  105486. * @param name defines the new name for the duplicated material
  105487. * @returns the cloned material
  105488. */
  105489. clone(name: string): Nullable<Material>;
  105490. /**
  105491. * Gets the meshes bound to the material
  105492. * @returns an array of meshes bound to the material
  105493. */
  105494. getBindedMeshes(): AbstractMesh[];
  105495. /**
  105496. * Force shader compilation
  105497. * @param mesh defines the mesh associated with this material
  105498. * @param onCompiled defines a function to execute once the material is compiled
  105499. * @param options defines the options to configure the compilation
  105500. * @param onError defines a function to execute if the material fails compiling
  105501. */
  105502. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  105503. /**
  105504. * Force shader compilation
  105505. * @param mesh defines the mesh that will use this material
  105506. * @param options defines additional options for compiling the shaders
  105507. * @returns a promise that resolves when the compilation completes
  105508. */
  105509. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  105510. private static readonly _AllDirtyCallBack;
  105511. private static readonly _ImageProcessingDirtyCallBack;
  105512. private static readonly _TextureDirtyCallBack;
  105513. private static readonly _FresnelDirtyCallBack;
  105514. private static readonly _MiscDirtyCallBack;
  105515. private static readonly _LightsDirtyCallBack;
  105516. private static readonly _AttributeDirtyCallBack;
  105517. private static _FresnelAndMiscDirtyCallBack;
  105518. private static _TextureAndMiscDirtyCallBack;
  105519. private static readonly _DirtyCallbackArray;
  105520. private static readonly _RunDirtyCallBacks;
  105521. /**
  105522. * Marks a define in the material to indicate that it needs to be re-computed
  105523. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  105524. */
  105525. markAsDirty(flag: number): void;
  105526. /**
  105527. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  105528. * @param func defines a function which checks material defines against the submeshes
  105529. */
  105530. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  105531. /**
  105532. * Indicates that the scene should check if the rendering now needs a prepass
  105533. */
  105534. protected _markScenePrePassDirty(): void;
  105535. /**
  105536. * Indicates that we need to re-calculated for all submeshes
  105537. */
  105538. protected _markAllSubMeshesAsAllDirty(): void;
  105539. /**
  105540. * Indicates that image processing needs to be re-calculated for all submeshes
  105541. */
  105542. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  105543. /**
  105544. * Indicates that textures need to be re-calculated for all submeshes
  105545. */
  105546. protected _markAllSubMeshesAsTexturesDirty(): void;
  105547. /**
  105548. * Indicates that fresnel needs to be re-calculated for all submeshes
  105549. */
  105550. protected _markAllSubMeshesAsFresnelDirty(): void;
  105551. /**
  105552. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  105553. */
  105554. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  105555. /**
  105556. * Indicates that lights need to be re-calculated for all submeshes
  105557. */
  105558. protected _markAllSubMeshesAsLightsDirty(): void;
  105559. /**
  105560. * Indicates that attributes need to be re-calculated for all submeshes
  105561. */
  105562. protected _markAllSubMeshesAsAttributesDirty(): void;
  105563. /**
  105564. * Indicates that misc needs to be re-calculated for all submeshes
  105565. */
  105566. protected _markAllSubMeshesAsMiscDirty(): void;
  105567. /**
  105568. * Indicates that textures and misc need to be re-calculated for all submeshes
  105569. */
  105570. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  105571. /**
  105572. * Sets the required values to the prepass renderer.
  105573. * @param prePassRenderer defines the prepass renderer to setup.
  105574. * @returns true if the pre pass is needed.
  105575. */
  105576. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  105577. /**
  105578. * Disposes the material
  105579. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105580. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105581. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  105582. */
  105583. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  105584. /** @hidden */
  105585. private releaseVertexArrayObject;
  105586. /**
  105587. * Serializes this material
  105588. * @returns the serialized material object
  105589. */
  105590. serialize(): any;
  105591. /**
  105592. * Creates a material from parsed material data
  105593. * @param parsedMaterial defines parsed material data
  105594. * @param scene defines the hosting scene
  105595. * @param rootUrl defines the root URL to use to load textures
  105596. * @returns a new material
  105597. */
  105598. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  105599. }
  105600. }
  105601. declare module BABYLON {
  105602. /**
  105603. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105604. * separate meshes. This can be use to improve performances.
  105605. * @see https://doc.babylonjs.com/how_to/multi_materials
  105606. */
  105607. export class MultiMaterial extends Material {
  105608. private _subMaterials;
  105609. /**
  105610. * Gets or Sets the list of Materials used within the multi material.
  105611. * They need to be ordered according to the submeshes order in the associated mesh
  105612. */
  105613. get subMaterials(): Nullable<Material>[];
  105614. set subMaterials(value: Nullable<Material>[]);
  105615. /**
  105616. * Function used to align with Node.getChildren()
  105617. * @returns the list of Materials used within the multi material
  105618. */
  105619. getChildren(): Nullable<Material>[];
  105620. /**
  105621. * Instantiates a new Multi Material
  105622. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105623. * separate meshes. This can be use to improve performances.
  105624. * @see https://doc.babylonjs.com/how_to/multi_materials
  105625. * @param name Define the name in the scene
  105626. * @param scene Define the scene the material belongs to
  105627. */
  105628. constructor(name: string, scene: Scene);
  105629. private _hookArray;
  105630. /**
  105631. * Get one of the submaterial by its index in the submaterials array
  105632. * @param index The index to look the sub material at
  105633. * @returns The Material if the index has been defined
  105634. */
  105635. getSubMaterial(index: number): Nullable<Material>;
  105636. /**
  105637. * Get the list of active textures for the whole sub materials list.
  105638. * @returns All the textures that will be used during the rendering
  105639. */
  105640. getActiveTextures(): BaseTexture[];
  105641. /**
  105642. * Gets the current class name of the material e.g. "MultiMaterial"
  105643. * Mainly use in serialization.
  105644. * @returns the class name
  105645. */
  105646. getClassName(): string;
  105647. /**
  105648. * Checks if the material is ready to render the requested sub mesh
  105649. * @param mesh Define the mesh the submesh belongs to
  105650. * @param subMesh Define the sub mesh to look readyness for
  105651. * @param useInstances Define whether or not the material is used with instances
  105652. * @returns true if ready, otherwise false
  105653. */
  105654. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105655. /**
  105656. * Clones the current material and its related sub materials
  105657. * @param name Define the name of the newly cloned material
  105658. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  105659. * @returns the cloned material
  105660. */
  105661. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  105662. /**
  105663. * Serializes the materials into a JSON representation.
  105664. * @returns the JSON representation
  105665. */
  105666. serialize(): any;
  105667. /**
  105668. * Dispose the material and release its associated resources
  105669. * @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)
  105670. * @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)
  105671. * @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)
  105672. */
  105673. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  105674. /**
  105675. * Creates a MultiMaterial from parsed MultiMaterial data.
  105676. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  105677. * @param scene defines the hosting scene
  105678. * @returns a new MultiMaterial
  105679. */
  105680. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  105681. }
  105682. }
  105683. declare module BABYLON {
  105684. /**
  105685. * Defines a subdivision inside a mesh
  105686. */
  105687. export class SubMesh implements ICullable {
  105688. /** the material index to use */
  105689. materialIndex: number;
  105690. /** vertex index start */
  105691. verticesStart: number;
  105692. /** vertices count */
  105693. verticesCount: number;
  105694. /** index start */
  105695. indexStart: number;
  105696. /** indices count */
  105697. indexCount: number;
  105698. /** @hidden */
  105699. _materialDefines: Nullable<MaterialDefines>;
  105700. /** @hidden */
  105701. _materialEffect: Nullable<Effect>;
  105702. /** @hidden */
  105703. _effectOverride: Nullable<Effect>;
  105704. /**
  105705. * Gets material defines used by the effect associated to the sub mesh
  105706. */
  105707. get materialDefines(): Nullable<MaterialDefines>;
  105708. /**
  105709. * Sets material defines used by the effect associated to the sub mesh
  105710. */
  105711. set materialDefines(defines: Nullable<MaterialDefines>);
  105712. /**
  105713. * Gets associated effect
  105714. */
  105715. get effect(): Nullable<Effect>;
  105716. /**
  105717. * Sets associated effect (effect used to render this submesh)
  105718. * @param effect defines the effect to associate with
  105719. * @param defines defines the set of defines used to compile this effect
  105720. */
  105721. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  105722. /** @hidden */
  105723. _linesIndexCount: number;
  105724. private _mesh;
  105725. private _renderingMesh;
  105726. private _boundingInfo;
  105727. private _linesIndexBuffer;
  105728. /** @hidden */
  105729. _lastColliderWorldVertices: Nullable<Vector3[]>;
  105730. /** @hidden */
  105731. _trianglePlanes: Plane[];
  105732. /** @hidden */
  105733. _lastColliderTransformMatrix: Nullable<Matrix>;
  105734. /** @hidden */
  105735. _renderId: number;
  105736. /** @hidden */
  105737. _alphaIndex: number;
  105738. /** @hidden */
  105739. _distanceToCamera: number;
  105740. /** @hidden */
  105741. _id: number;
  105742. private _currentMaterial;
  105743. /**
  105744. * Add a new submesh to a mesh
  105745. * @param materialIndex defines the material index to use
  105746. * @param verticesStart defines vertex index start
  105747. * @param verticesCount defines vertices count
  105748. * @param indexStart defines index start
  105749. * @param indexCount defines indices count
  105750. * @param mesh defines the parent mesh
  105751. * @param renderingMesh defines an optional rendering mesh
  105752. * @param createBoundingBox defines if bounding box should be created for this submesh
  105753. * @returns the new submesh
  105754. */
  105755. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  105756. /**
  105757. * Creates a new submesh
  105758. * @param materialIndex defines the material index to use
  105759. * @param verticesStart defines vertex index start
  105760. * @param verticesCount defines vertices count
  105761. * @param indexStart defines index start
  105762. * @param indexCount defines indices count
  105763. * @param mesh defines the parent mesh
  105764. * @param renderingMesh defines an optional rendering mesh
  105765. * @param createBoundingBox defines if bounding box should be created for this submesh
  105766. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  105767. */
  105768. constructor(
  105769. /** the material index to use */
  105770. materialIndex: number,
  105771. /** vertex index start */
  105772. verticesStart: number,
  105773. /** vertices count */
  105774. verticesCount: number,
  105775. /** index start */
  105776. indexStart: number,
  105777. /** indices count */
  105778. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  105779. /**
  105780. * Returns true if this submesh covers the entire parent mesh
  105781. * @ignorenaming
  105782. */
  105783. get IsGlobal(): boolean;
  105784. /**
  105785. * Returns the submesh BoudingInfo object
  105786. * @returns current bounding info (or mesh's one if the submesh is global)
  105787. */
  105788. getBoundingInfo(): BoundingInfo;
  105789. /**
  105790. * Sets the submesh BoundingInfo
  105791. * @param boundingInfo defines the new bounding info to use
  105792. * @returns the SubMesh
  105793. */
  105794. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  105795. /**
  105796. * Returns the mesh of the current submesh
  105797. * @return the parent mesh
  105798. */
  105799. getMesh(): AbstractMesh;
  105800. /**
  105801. * Returns the rendering mesh of the submesh
  105802. * @returns the rendering mesh (could be different from parent mesh)
  105803. */
  105804. getRenderingMesh(): Mesh;
  105805. /**
  105806. * Returns the replacement mesh of the submesh
  105807. * @returns the replacement mesh (could be different from parent mesh)
  105808. */
  105809. getReplacementMesh(): Nullable<AbstractMesh>;
  105810. /**
  105811. * Returns the effective mesh of the submesh
  105812. * @returns the effective mesh (could be different from parent mesh)
  105813. */
  105814. getEffectiveMesh(): AbstractMesh;
  105815. /**
  105816. * Returns the submesh material
  105817. * @returns null or the current material
  105818. */
  105819. getMaterial(): Nullable<Material>;
  105820. private _IsMultiMaterial;
  105821. /**
  105822. * Sets a new updated BoundingInfo object to the submesh
  105823. * @param data defines an optional position array to use to determine the bounding info
  105824. * @returns the SubMesh
  105825. */
  105826. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  105827. /** @hidden */
  105828. _checkCollision(collider: Collider): boolean;
  105829. /**
  105830. * Updates the submesh BoundingInfo
  105831. * @param world defines the world matrix to use to update the bounding info
  105832. * @returns the submesh
  105833. */
  105834. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  105835. /**
  105836. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  105837. * @param frustumPlanes defines the frustum planes
  105838. * @returns true if the submesh is intersecting with the frustum
  105839. */
  105840. isInFrustum(frustumPlanes: Plane[]): boolean;
  105841. /**
  105842. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  105843. * @param frustumPlanes defines the frustum planes
  105844. * @returns true if the submesh is inside the frustum
  105845. */
  105846. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  105847. /**
  105848. * Renders the submesh
  105849. * @param enableAlphaMode defines if alpha needs to be used
  105850. * @returns the submesh
  105851. */
  105852. render(enableAlphaMode: boolean): SubMesh;
  105853. /**
  105854. * @hidden
  105855. */
  105856. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  105857. /**
  105858. * Checks if the submesh intersects with a ray
  105859. * @param ray defines the ray to test
  105860. * @returns true is the passed ray intersects the submesh bounding box
  105861. */
  105862. canIntersects(ray: Ray): boolean;
  105863. /**
  105864. * Intersects current submesh with a ray
  105865. * @param ray defines the ray to test
  105866. * @param positions defines mesh's positions array
  105867. * @param indices defines mesh's indices array
  105868. * @param fastCheck defines if the first intersection will be used (and not the closest)
  105869. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105870. * @returns intersection info or null if no intersection
  105871. */
  105872. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  105873. /** @hidden */
  105874. private _intersectLines;
  105875. /** @hidden */
  105876. private _intersectUnIndexedLines;
  105877. /** @hidden */
  105878. private _intersectTriangles;
  105879. /** @hidden */
  105880. private _intersectUnIndexedTriangles;
  105881. /** @hidden */
  105882. _rebuild(): void;
  105883. /**
  105884. * Creates a new submesh from the passed mesh
  105885. * @param newMesh defines the new hosting mesh
  105886. * @param newRenderingMesh defines an optional rendering mesh
  105887. * @returns the new submesh
  105888. */
  105889. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  105890. /**
  105891. * Release associated resources
  105892. */
  105893. dispose(): void;
  105894. /**
  105895. * Gets the class name
  105896. * @returns the string "SubMesh".
  105897. */
  105898. getClassName(): string;
  105899. /**
  105900. * Creates a new submesh from indices data
  105901. * @param materialIndex the index of the main mesh material
  105902. * @param startIndex the index where to start the copy in the mesh indices array
  105903. * @param indexCount the number of indices to copy then from the startIndex
  105904. * @param mesh the main mesh to create the submesh from
  105905. * @param renderingMesh the optional rendering mesh
  105906. * @returns a new submesh
  105907. */
  105908. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  105909. }
  105910. }
  105911. declare module BABYLON {
  105912. /**
  105913. * Class used to represent data loading progression
  105914. */
  105915. export class SceneLoaderFlags {
  105916. private static _ForceFullSceneLoadingForIncremental;
  105917. private static _ShowLoadingScreen;
  105918. private static _CleanBoneMatrixWeights;
  105919. private static _loggingLevel;
  105920. /**
  105921. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105922. */
  105923. static get ForceFullSceneLoadingForIncremental(): boolean;
  105924. static set ForceFullSceneLoadingForIncremental(value: boolean);
  105925. /**
  105926. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105927. */
  105928. static get ShowLoadingScreen(): boolean;
  105929. static set ShowLoadingScreen(value: boolean);
  105930. /**
  105931. * Defines the current logging level (while loading the scene)
  105932. * @ignorenaming
  105933. */
  105934. static get loggingLevel(): number;
  105935. static set loggingLevel(value: number);
  105936. /**
  105937. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105938. */
  105939. static get CleanBoneMatrixWeights(): boolean;
  105940. static set CleanBoneMatrixWeights(value: boolean);
  105941. }
  105942. }
  105943. declare module BABYLON {
  105944. /**
  105945. * Class used to store geometry data (vertex buffers + index buffer)
  105946. */
  105947. export class Geometry implements IGetSetVerticesData {
  105948. /**
  105949. * Gets or sets the ID of the geometry
  105950. */
  105951. id: string;
  105952. /**
  105953. * Gets or sets the unique ID of the geometry
  105954. */
  105955. uniqueId: number;
  105956. /**
  105957. * Gets the delay loading state of the geometry (none by default which means not delayed)
  105958. */
  105959. delayLoadState: number;
  105960. /**
  105961. * Gets the file containing the data to load when running in delay load state
  105962. */
  105963. delayLoadingFile: Nullable<string>;
  105964. /**
  105965. * Callback called when the geometry is updated
  105966. */
  105967. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  105968. private _scene;
  105969. private _engine;
  105970. private _meshes;
  105971. private _totalVertices;
  105972. /** @hidden */
  105973. _indices: IndicesArray;
  105974. /** @hidden */
  105975. _vertexBuffers: {
  105976. [key: string]: VertexBuffer;
  105977. };
  105978. private _isDisposed;
  105979. private _extend;
  105980. private _boundingBias;
  105981. /** @hidden */
  105982. _delayInfo: Array<string>;
  105983. private _indexBuffer;
  105984. private _indexBufferIsUpdatable;
  105985. /** @hidden */
  105986. _boundingInfo: Nullable<BoundingInfo>;
  105987. /** @hidden */
  105988. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  105989. /** @hidden */
  105990. _softwareSkinningFrameId: number;
  105991. private _vertexArrayObjects;
  105992. private _updatable;
  105993. /** @hidden */
  105994. _positions: Nullable<Vector3[]>;
  105995. /**
  105996. * 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
  105997. */
  105998. get boundingBias(): Vector2;
  105999. /**
  106000. * 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
  106001. */
  106002. set boundingBias(value: Vector2);
  106003. /**
  106004. * Static function used to attach a new empty geometry to a mesh
  106005. * @param mesh defines the mesh to attach the geometry to
  106006. * @returns the new Geometry
  106007. */
  106008. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  106009. /** Get the list of meshes using this geometry */
  106010. get meshes(): Mesh[];
  106011. /**
  106012. * 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
  106013. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  106014. */
  106015. useBoundingInfoFromGeometry: boolean;
  106016. /**
  106017. * Creates a new geometry
  106018. * @param id defines the unique ID
  106019. * @param scene defines the hosting scene
  106020. * @param vertexData defines the VertexData used to get geometry data
  106021. * @param updatable defines if geometry must be updatable (false by default)
  106022. * @param mesh defines the mesh that will be associated with the geometry
  106023. */
  106024. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  106025. /**
  106026. * Gets the current extend of the geometry
  106027. */
  106028. get extend(): {
  106029. minimum: Vector3;
  106030. maximum: Vector3;
  106031. };
  106032. /**
  106033. * Gets the hosting scene
  106034. * @returns the hosting Scene
  106035. */
  106036. getScene(): Scene;
  106037. /**
  106038. * Gets the hosting engine
  106039. * @returns the hosting Engine
  106040. */
  106041. getEngine(): Engine;
  106042. /**
  106043. * Defines if the geometry is ready to use
  106044. * @returns true if the geometry is ready to be used
  106045. */
  106046. isReady(): boolean;
  106047. /**
  106048. * Gets a value indicating that the geometry should not be serialized
  106049. */
  106050. get doNotSerialize(): boolean;
  106051. /** @hidden */
  106052. _rebuild(): void;
  106053. /**
  106054. * Affects all geometry data in one call
  106055. * @param vertexData defines the geometry data
  106056. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  106057. */
  106058. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  106059. /**
  106060. * Set specific vertex data
  106061. * @param kind defines the data kind (Position, normal, etc...)
  106062. * @param data defines the vertex data to use
  106063. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  106064. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  106065. */
  106066. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  106067. /**
  106068. * Removes a specific vertex data
  106069. * @param kind defines the data kind (Position, normal, etc...)
  106070. */
  106071. removeVerticesData(kind: string): void;
  106072. /**
  106073. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  106074. * @param buffer defines the vertex buffer to use
  106075. * @param totalVertices defines the total number of vertices for position kind (could be null)
  106076. */
  106077. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  106078. /**
  106079. * Update a specific vertex buffer
  106080. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  106081. * It will do nothing if the buffer is not updatable
  106082. * @param kind defines the data kind (Position, normal, etc...)
  106083. * @param data defines the data to use
  106084. * @param offset defines the offset in the target buffer where to store the data
  106085. * @param useBytes set to true if the offset is in bytes
  106086. */
  106087. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  106088. /**
  106089. * Update a specific vertex buffer
  106090. * This function will create a new buffer if the current one is not updatable
  106091. * @param kind defines the data kind (Position, normal, etc...)
  106092. * @param data defines the data to use
  106093. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  106094. */
  106095. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  106096. private _updateBoundingInfo;
  106097. /** @hidden */
  106098. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  106099. /**
  106100. * Gets total number of vertices
  106101. * @returns the total number of vertices
  106102. */
  106103. getTotalVertices(): number;
  106104. /**
  106105. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  106106. * @param kind defines the data kind (Position, normal, etc...)
  106107. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106108. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106109. * @returns a float array containing vertex data
  106110. */
  106111. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106112. /**
  106113. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  106114. * @param kind defines the data kind (Position, normal, etc...)
  106115. * @returns true if the vertex buffer with the specified kind is updatable
  106116. */
  106117. isVertexBufferUpdatable(kind: string): boolean;
  106118. /**
  106119. * Gets a specific vertex buffer
  106120. * @param kind defines the data kind (Position, normal, etc...)
  106121. * @returns a VertexBuffer
  106122. */
  106123. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  106124. /**
  106125. * Returns all vertex buffers
  106126. * @return an object holding all vertex buffers indexed by kind
  106127. */
  106128. getVertexBuffers(): Nullable<{
  106129. [key: string]: VertexBuffer;
  106130. }>;
  106131. /**
  106132. * Gets a boolean indicating if specific vertex buffer is present
  106133. * @param kind defines the data kind (Position, normal, etc...)
  106134. * @returns true if data is present
  106135. */
  106136. isVerticesDataPresent(kind: string): boolean;
  106137. /**
  106138. * Gets a list of all attached data kinds (Position, normal, etc...)
  106139. * @returns a list of string containing all kinds
  106140. */
  106141. getVerticesDataKinds(): string[];
  106142. /**
  106143. * Update index buffer
  106144. * @param indices defines the indices to store in the index buffer
  106145. * @param offset defines the offset in the target buffer where to store the data
  106146. * @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)
  106147. */
  106148. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  106149. /**
  106150. * Creates a new index buffer
  106151. * @param indices defines the indices to store in the index buffer
  106152. * @param totalVertices defines the total number of vertices (could be null)
  106153. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  106154. */
  106155. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  106156. /**
  106157. * Return the total number of indices
  106158. * @returns the total number of indices
  106159. */
  106160. getTotalIndices(): number;
  106161. /**
  106162. * Gets the index buffer array
  106163. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106164. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106165. * @returns the index buffer array
  106166. */
  106167. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106168. /**
  106169. * Gets the index buffer
  106170. * @return the index buffer
  106171. */
  106172. getIndexBuffer(): Nullable<DataBuffer>;
  106173. /** @hidden */
  106174. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  106175. /**
  106176. * Release the associated resources for a specific mesh
  106177. * @param mesh defines the source mesh
  106178. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  106179. */
  106180. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  106181. /**
  106182. * Apply current geometry to a given mesh
  106183. * @param mesh defines the mesh to apply geometry to
  106184. */
  106185. applyToMesh(mesh: Mesh): void;
  106186. private _updateExtend;
  106187. private _applyToMesh;
  106188. private notifyUpdate;
  106189. /**
  106190. * Load the geometry if it was flagged as delay loaded
  106191. * @param scene defines the hosting scene
  106192. * @param onLoaded defines a callback called when the geometry is loaded
  106193. */
  106194. load(scene: Scene, onLoaded?: () => void): void;
  106195. private _queueLoad;
  106196. /**
  106197. * Invert the geometry to move from a right handed system to a left handed one.
  106198. */
  106199. toLeftHanded(): void;
  106200. /** @hidden */
  106201. _resetPointsArrayCache(): void;
  106202. /** @hidden */
  106203. _generatePointsArray(): boolean;
  106204. /**
  106205. * Gets a value indicating if the geometry is disposed
  106206. * @returns true if the geometry was disposed
  106207. */
  106208. isDisposed(): boolean;
  106209. private _disposeVertexArrayObjects;
  106210. /**
  106211. * Free all associated resources
  106212. */
  106213. dispose(): void;
  106214. /**
  106215. * Clone the current geometry into a new geometry
  106216. * @param id defines the unique ID of the new geometry
  106217. * @returns a new geometry object
  106218. */
  106219. copy(id: string): Geometry;
  106220. /**
  106221. * Serialize the current geometry info (and not the vertices data) into a JSON object
  106222. * @return a JSON representation of the current geometry data (without the vertices data)
  106223. */
  106224. serialize(): any;
  106225. private toNumberArray;
  106226. /**
  106227. * Serialize all vertices data into a JSON oject
  106228. * @returns a JSON representation of the current geometry data
  106229. */
  106230. serializeVerticeData(): any;
  106231. /**
  106232. * Extracts a clone of a mesh geometry
  106233. * @param mesh defines the source mesh
  106234. * @param id defines the unique ID of the new geometry object
  106235. * @returns the new geometry object
  106236. */
  106237. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  106238. /**
  106239. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  106240. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  106241. * Be aware Math.random() could cause collisions, but:
  106242. * "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"
  106243. * @returns a string containing a new GUID
  106244. */
  106245. static RandomId(): string;
  106246. /** @hidden */
  106247. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  106248. private static _CleanMatricesWeights;
  106249. /**
  106250. * Create a new geometry from persisted data (Using .babylon file format)
  106251. * @param parsedVertexData defines the persisted data
  106252. * @param scene defines the hosting scene
  106253. * @param rootUrl defines the root url to use to load assets (like delayed data)
  106254. * @returns the new geometry object
  106255. */
  106256. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  106257. }
  106258. }
  106259. declare module BABYLON {
  106260. /**
  106261. * Define an interface for all classes that will get and set the data on vertices
  106262. */
  106263. export interface IGetSetVerticesData {
  106264. /**
  106265. * Gets a boolean indicating if specific vertex data is present
  106266. * @param kind defines the vertex data kind to use
  106267. * @returns true is data kind is present
  106268. */
  106269. isVerticesDataPresent(kind: string): boolean;
  106270. /**
  106271. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  106272. * @param kind defines the data kind (Position, normal, etc...)
  106273. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106274. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106275. * @returns a float array containing vertex data
  106276. */
  106277. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106278. /**
  106279. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  106280. * @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.
  106281. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106282. * @returns the indices array or an empty array if the mesh has no geometry
  106283. */
  106284. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106285. /**
  106286. * Set specific vertex data
  106287. * @param kind defines the data kind (Position, normal, etc...)
  106288. * @param data defines the vertex data to use
  106289. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  106290. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  106291. */
  106292. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  106293. /**
  106294. * Update a specific associated vertex buffer
  106295. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  106296. * - VertexBuffer.PositionKind
  106297. * - VertexBuffer.UVKind
  106298. * - VertexBuffer.UV2Kind
  106299. * - VertexBuffer.UV3Kind
  106300. * - VertexBuffer.UV4Kind
  106301. * - VertexBuffer.UV5Kind
  106302. * - VertexBuffer.UV6Kind
  106303. * - VertexBuffer.ColorKind
  106304. * - VertexBuffer.MatricesIndicesKind
  106305. * - VertexBuffer.MatricesIndicesExtraKind
  106306. * - VertexBuffer.MatricesWeightsKind
  106307. * - VertexBuffer.MatricesWeightsExtraKind
  106308. * @param data defines the data source
  106309. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  106310. * @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)
  106311. */
  106312. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  106313. /**
  106314. * Creates a new index buffer
  106315. * @param indices defines the indices to store in the index buffer
  106316. * @param totalVertices defines the total number of vertices (could be null)
  106317. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  106318. */
  106319. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  106320. }
  106321. /**
  106322. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  106323. */
  106324. export class VertexData {
  106325. /**
  106326. * Mesh side orientation : usually the external or front surface
  106327. */
  106328. static readonly FRONTSIDE: number;
  106329. /**
  106330. * Mesh side orientation : usually the internal or back surface
  106331. */
  106332. static readonly BACKSIDE: number;
  106333. /**
  106334. * Mesh side orientation : both internal and external or front and back surfaces
  106335. */
  106336. static readonly DOUBLESIDE: number;
  106337. /**
  106338. * Mesh side orientation : by default, `FRONTSIDE`
  106339. */
  106340. static readonly DEFAULTSIDE: number;
  106341. /**
  106342. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  106343. */
  106344. positions: Nullable<FloatArray>;
  106345. /**
  106346. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  106347. */
  106348. normals: Nullable<FloatArray>;
  106349. /**
  106350. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  106351. */
  106352. tangents: Nullable<FloatArray>;
  106353. /**
  106354. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106355. */
  106356. uvs: Nullable<FloatArray>;
  106357. /**
  106358. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106359. */
  106360. uvs2: Nullable<FloatArray>;
  106361. /**
  106362. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106363. */
  106364. uvs3: Nullable<FloatArray>;
  106365. /**
  106366. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106367. */
  106368. uvs4: Nullable<FloatArray>;
  106369. /**
  106370. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106371. */
  106372. uvs5: Nullable<FloatArray>;
  106373. /**
  106374. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106375. */
  106376. uvs6: Nullable<FloatArray>;
  106377. /**
  106378. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  106379. */
  106380. colors: Nullable<FloatArray>;
  106381. /**
  106382. * 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).
  106383. */
  106384. matricesIndices: Nullable<FloatArray>;
  106385. /**
  106386. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  106387. */
  106388. matricesWeights: Nullable<FloatArray>;
  106389. /**
  106390. * An array extending the number of possible indices
  106391. */
  106392. matricesIndicesExtra: Nullable<FloatArray>;
  106393. /**
  106394. * An array extending the number of possible weights when the number of indices is extended
  106395. */
  106396. matricesWeightsExtra: Nullable<FloatArray>;
  106397. /**
  106398. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  106399. */
  106400. indices: Nullable<IndicesArray>;
  106401. /**
  106402. * Uses the passed data array to set the set the values for the specified kind of data
  106403. * @param data a linear array of floating numbers
  106404. * @param kind the type of data that is being set, eg positions, colors etc
  106405. */
  106406. set(data: FloatArray, kind: string): void;
  106407. /**
  106408. * Associates the vertexData to the passed Mesh.
  106409. * Sets it as updatable or not (default `false`)
  106410. * @param mesh the mesh the vertexData is applied to
  106411. * @param updatable when used and having the value true allows new data to update the vertexData
  106412. * @returns the VertexData
  106413. */
  106414. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  106415. /**
  106416. * Associates the vertexData to the passed Geometry.
  106417. * Sets it as updatable or not (default `false`)
  106418. * @param geometry the geometry the vertexData is applied to
  106419. * @param updatable when used and having the value true allows new data to update the vertexData
  106420. * @returns VertexData
  106421. */
  106422. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  106423. /**
  106424. * Updates the associated mesh
  106425. * @param mesh the mesh to be updated
  106426. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106427. * @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
  106428. * @returns VertexData
  106429. */
  106430. updateMesh(mesh: Mesh): VertexData;
  106431. /**
  106432. * Updates the associated geometry
  106433. * @param geometry the geometry to be updated
  106434. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106435. * @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
  106436. * @returns VertexData.
  106437. */
  106438. updateGeometry(geometry: Geometry): VertexData;
  106439. private _applyTo;
  106440. private _update;
  106441. /**
  106442. * Transforms each position and each normal of the vertexData according to the passed Matrix
  106443. * @param matrix the transforming matrix
  106444. * @returns the VertexData
  106445. */
  106446. transform(matrix: Matrix): VertexData;
  106447. /**
  106448. * Merges the passed VertexData into the current one
  106449. * @param other the VertexData to be merged into the current one
  106450. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  106451. * @returns the modified VertexData
  106452. */
  106453. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  106454. private _mergeElement;
  106455. private _validate;
  106456. /**
  106457. * Serializes the VertexData
  106458. * @returns a serialized object
  106459. */
  106460. serialize(): any;
  106461. /**
  106462. * Extracts the vertexData from a mesh
  106463. * @param mesh the mesh from which to extract the VertexData
  106464. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  106465. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106466. * @returns the object VertexData associated to the passed mesh
  106467. */
  106468. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106469. /**
  106470. * Extracts the vertexData from the geometry
  106471. * @param geometry the geometry from which to extract the VertexData
  106472. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  106473. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106474. * @returns the object VertexData associated to the passed mesh
  106475. */
  106476. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106477. private static _ExtractFrom;
  106478. /**
  106479. * Creates the VertexData for a Ribbon
  106480. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  106481. * * pathArray array of paths, each of which an array of successive Vector3
  106482. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  106483. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  106484. * * 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
  106485. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106486. * * 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)
  106487. * * 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)
  106488. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  106489. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  106490. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  106491. * @returns the VertexData of the ribbon
  106492. */
  106493. static CreateRibbon(options: {
  106494. pathArray: Vector3[][];
  106495. closeArray?: boolean;
  106496. closePath?: boolean;
  106497. offset?: number;
  106498. sideOrientation?: number;
  106499. frontUVs?: Vector4;
  106500. backUVs?: Vector4;
  106501. invertUV?: boolean;
  106502. uvs?: Vector2[];
  106503. colors?: Color4[];
  106504. }): VertexData;
  106505. /**
  106506. * Creates the VertexData for a box
  106507. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106508. * * size sets the width, height and depth of the box to the value of size, optional default 1
  106509. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  106510. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  106511. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  106512. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106513. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106514. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106515. * * 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)
  106516. * * 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)
  106517. * @returns the VertexData of the box
  106518. */
  106519. static CreateBox(options: {
  106520. size?: number;
  106521. width?: number;
  106522. height?: number;
  106523. depth?: number;
  106524. faceUV?: Vector4[];
  106525. faceColors?: Color4[];
  106526. sideOrientation?: number;
  106527. frontUVs?: Vector4;
  106528. backUVs?: Vector4;
  106529. }): VertexData;
  106530. /**
  106531. * Creates the VertexData for a tiled box
  106532. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106533. * * faceTiles sets the pattern, tile size and number of tiles for a face
  106534. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106535. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106536. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106537. * @returns the VertexData of the box
  106538. */
  106539. static CreateTiledBox(options: {
  106540. pattern?: number;
  106541. width?: number;
  106542. height?: number;
  106543. depth?: number;
  106544. tileSize?: number;
  106545. tileWidth?: number;
  106546. tileHeight?: number;
  106547. alignHorizontal?: number;
  106548. alignVertical?: number;
  106549. faceUV?: Vector4[];
  106550. faceColors?: Color4[];
  106551. sideOrientation?: number;
  106552. }): VertexData;
  106553. /**
  106554. * Creates the VertexData for a tiled plane
  106555. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106556. * * pattern a limited pattern arrangement depending on the number
  106557. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  106558. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  106559. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  106560. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106561. * * 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)
  106562. * * 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)
  106563. * @returns the VertexData of the tiled plane
  106564. */
  106565. static CreateTiledPlane(options: {
  106566. pattern?: number;
  106567. tileSize?: number;
  106568. tileWidth?: number;
  106569. tileHeight?: number;
  106570. size?: number;
  106571. width?: number;
  106572. height?: number;
  106573. alignHorizontal?: number;
  106574. alignVertical?: number;
  106575. sideOrientation?: number;
  106576. frontUVs?: Vector4;
  106577. backUVs?: Vector4;
  106578. }): VertexData;
  106579. /**
  106580. * Creates the VertexData for an ellipsoid, defaults to a sphere
  106581. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106582. * * segments sets the number of horizontal strips optional, default 32
  106583. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  106584. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  106585. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  106586. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  106587. * * 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
  106588. * * 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
  106589. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106590. * * 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)
  106591. * * 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)
  106592. * @returns the VertexData of the ellipsoid
  106593. */
  106594. static CreateSphere(options: {
  106595. segments?: number;
  106596. diameter?: number;
  106597. diameterX?: number;
  106598. diameterY?: number;
  106599. diameterZ?: number;
  106600. arc?: number;
  106601. slice?: number;
  106602. sideOrientation?: number;
  106603. frontUVs?: Vector4;
  106604. backUVs?: Vector4;
  106605. }): VertexData;
  106606. /**
  106607. * Creates the VertexData for a cylinder, cone or prism
  106608. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106609. * * height sets the height (y direction) of the cylinder, optional, default 2
  106610. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  106611. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  106612. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  106613. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106614. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  106615. * * 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
  106616. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106617. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106618. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  106619. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  106620. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106621. * * 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)
  106622. * * 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)
  106623. * @returns the VertexData of the cylinder, cone or prism
  106624. */
  106625. static CreateCylinder(options: {
  106626. height?: number;
  106627. diameterTop?: number;
  106628. diameterBottom?: number;
  106629. diameter?: number;
  106630. tessellation?: number;
  106631. subdivisions?: number;
  106632. arc?: number;
  106633. faceColors?: Color4[];
  106634. faceUV?: Vector4[];
  106635. hasRings?: boolean;
  106636. enclose?: boolean;
  106637. sideOrientation?: number;
  106638. frontUVs?: Vector4;
  106639. backUVs?: Vector4;
  106640. }): VertexData;
  106641. /**
  106642. * Creates the VertexData for a torus
  106643. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106644. * * diameter the diameter of the torus, optional default 1
  106645. * * thickness the diameter of the tube forming the torus, optional default 0.5
  106646. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106647. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106648. * * 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)
  106649. * * 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)
  106650. * @returns the VertexData of the torus
  106651. */
  106652. static CreateTorus(options: {
  106653. diameter?: number;
  106654. thickness?: number;
  106655. tessellation?: number;
  106656. sideOrientation?: number;
  106657. frontUVs?: Vector4;
  106658. backUVs?: Vector4;
  106659. }): VertexData;
  106660. /**
  106661. * Creates the VertexData of the LineSystem
  106662. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  106663. * - lines an array of lines, each line being an array of successive Vector3
  106664. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  106665. * @returns the VertexData of the LineSystem
  106666. */
  106667. static CreateLineSystem(options: {
  106668. lines: Vector3[][];
  106669. colors?: Nullable<Color4[][]>;
  106670. }): VertexData;
  106671. /**
  106672. * Create the VertexData for a DashedLines
  106673. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  106674. * - points an array successive Vector3
  106675. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  106676. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  106677. * - dashNb the intended total number of dashes, optional, default 200
  106678. * @returns the VertexData for the DashedLines
  106679. */
  106680. static CreateDashedLines(options: {
  106681. points: Vector3[];
  106682. dashSize?: number;
  106683. gapSize?: number;
  106684. dashNb?: number;
  106685. }): VertexData;
  106686. /**
  106687. * Creates the VertexData for a Ground
  106688. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106689. * - width the width (x direction) of the ground, optional, default 1
  106690. * - height the height (z direction) of the ground, optional, default 1
  106691. * - subdivisions the number of subdivisions per side, optional, default 1
  106692. * @returns the VertexData of the Ground
  106693. */
  106694. static CreateGround(options: {
  106695. width?: number;
  106696. height?: number;
  106697. subdivisions?: number;
  106698. subdivisionsX?: number;
  106699. subdivisionsY?: number;
  106700. }): VertexData;
  106701. /**
  106702. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  106703. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106704. * * xmin the ground minimum X coordinate, optional, default -1
  106705. * * zmin the ground minimum Z coordinate, optional, default -1
  106706. * * xmax the ground maximum X coordinate, optional, default 1
  106707. * * zmax the ground maximum Z coordinate, optional, default 1
  106708. * * 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}
  106709. * * 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}
  106710. * @returns the VertexData of the TiledGround
  106711. */
  106712. static CreateTiledGround(options: {
  106713. xmin: number;
  106714. zmin: number;
  106715. xmax: number;
  106716. zmax: number;
  106717. subdivisions?: {
  106718. w: number;
  106719. h: number;
  106720. };
  106721. precision?: {
  106722. w: number;
  106723. h: number;
  106724. };
  106725. }): VertexData;
  106726. /**
  106727. * Creates the VertexData of the Ground designed from a heightmap
  106728. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  106729. * * width the width (x direction) of the ground
  106730. * * height the height (z direction) of the ground
  106731. * * subdivisions the number of subdivisions per side
  106732. * * minHeight the minimum altitude on the ground, optional, default 0
  106733. * * maxHeight the maximum altitude on the ground, optional default 1
  106734. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  106735. * * buffer the array holding the image color data
  106736. * * bufferWidth the width of image
  106737. * * bufferHeight the height of image
  106738. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  106739. * @returns the VertexData of the Ground designed from a heightmap
  106740. */
  106741. static CreateGroundFromHeightMap(options: {
  106742. width: number;
  106743. height: number;
  106744. subdivisions: number;
  106745. minHeight: number;
  106746. maxHeight: number;
  106747. colorFilter: Color3;
  106748. buffer: Uint8Array;
  106749. bufferWidth: number;
  106750. bufferHeight: number;
  106751. alphaFilter: number;
  106752. }): VertexData;
  106753. /**
  106754. * Creates the VertexData for a Plane
  106755. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  106756. * * size sets the width and height of the plane to the value of size, optional default 1
  106757. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  106758. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  106759. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106760. * * 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)
  106761. * * 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)
  106762. * @returns the VertexData of the box
  106763. */
  106764. static CreatePlane(options: {
  106765. size?: number;
  106766. width?: number;
  106767. height?: number;
  106768. sideOrientation?: number;
  106769. frontUVs?: Vector4;
  106770. backUVs?: Vector4;
  106771. }): VertexData;
  106772. /**
  106773. * Creates the VertexData of the Disc or regular Polygon
  106774. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  106775. * * radius the radius of the disc, optional default 0.5
  106776. * * tessellation the number of polygon sides, optional, default 64
  106777. * * 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
  106778. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106779. * * 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)
  106780. * * 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)
  106781. * @returns the VertexData of the box
  106782. */
  106783. static CreateDisc(options: {
  106784. radius?: number;
  106785. tessellation?: number;
  106786. arc?: number;
  106787. sideOrientation?: number;
  106788. frontUVs?: Vector4;
  106789. backUVs?: Vector4;
  106790. }): VertexData;
  106791. /**
  106792. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  106793. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  106794. * @param polygon a mesh built from polygonTriangulation.build()
  106795. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106796. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106797. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106798. * @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)
  106799. * @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)
  106800. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  106801. * @returns the VertexData of the Polygon
  106802. */
  106803. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  106804. /**
  106805. * Creates the VertexData of the IcoSphere
  106806. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  106807. * * radius the radius of the IcoSphere, optional default 1
  106808. * * radiusX allows stretching in the x direction, optional, default radius
  106809. * * radiusY allows stretching in the y direction, optional, default radius
  106810. * * radiusZ allows stretching in the z direction, optional, default radius
  106811. * * flat when true creates a flat shaded mesh, optional, default true
  106812. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106813. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106814. * * 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)
  106815. * * 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)
  106816. * @returns the VertexData of the IcoSphere
  106817. */
  106818. static CreateIcoSphere(options: {
  106819. radius?: number;
  106820. radiusX?: number;
  106821. radiusY?: number;
  106822. radiusZ?: number;
  106823. flat?: boolean;
  106824. subdivisions?: number;
  106825. sideOrientation?: number;
  106826. frontUVs?: Vector4;
  106827. backUVs?: Vector4;
  106828. }): VertexData;
  106829. /**
  106830. * Creates the VertexData for a Polyhedron
  106831. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  106832. * * type provided types are:
  106833. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  106834. * * 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)
  106835. * * size the size of the IcoSphere, optional default 1
  106836. * * sizeX allows stretching in the x direction, optional, default size
  106837. * * sizeY allows stretching in the y direction, optional, default size
  106838. * * sizeZ allows stretching in the z direction, optional, default size
  106839. * * 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
  106840. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106841. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106842. * * flat when true creates a flat shaded mesh, optional, default true
  106843. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106844. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106845. * * 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)
  106846. * * 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)
  106847. * @returns the VertexData of the Polyhedron
  106848. */
  106849. static CreatePolyhedron(options: {
  106850. type?: number;
  106851. size?: number;
  106852. sizeX?: number;
  106853. sizeY?: number;
  106854. sizeZ?: number;
  106855. custom?: any;
  106856. faceUV?: Vector4[];
  106857. faceColors?: Color4[];
  106858. flat?: boolean;
  106859. sideOrientation?: number;
  106860. frontUVs?: Vector4;
  106861. backUVs?: Vector4;
  106862. }): VertexData;
  106863. /**
  106864. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  106865. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  106866. * @returns the VertexData of the Capsule
  106867. */
  106868. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  106869. /**
  106870. * Creates the VertexData for a TorusKnot
  106871. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  106872. * * radius the radius of the torus knot, optional, default 2
  106873. * * tube the thickness of the tube, optional, default 0.5
  106874. * * radialSegments the number of sides on each tube segments, optional, default 32
  106875. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  106876. * * p the number of windings around the z axis, optional, default 2
  106877. * * q the number of windings around the x axis, optional, default 3
  106878. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106879. * * 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)
  106880. * * 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)
  106881. * @returns the VertexData of the Torus Knot
  106882. */
  106883. static CreateTorusKnot(options: {
  106884. radius?: number;
  106885. tube?: number;
  106886. radialSegments?: number;
  106887. tubularSegments?: number;
  106888. p?: number;
  106889. q?: number;
  106890. sideOrientation?: number;
  106891. frontUVs?: Vector4;
  106892. backUVs?: Vector4;
  106893. }): VertexData;
  106894. /**
  106895. * Compute normals for given positions and indices
  106896. * @param positions an array of vertex positions, [...., x, y, z, ......]
  106897. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  106898. * @param normals an array of vertex normals, [...., x, y, z, ......]
  106899. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  106900. * * facetNormals : optional array of facet normals (vector3)
  106901. * * facetPositions : optional array of facet positions (vector3)
  106902. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  106903. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  106904. * * bInfo : optional bounding info, required for facetPartitioning computation
  106905. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  106906. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  106907. * * useRightHandedSystem: optional boolean to for right handed system computation
  106908. * * depthSort : optional boolean to enable the facet depth sort computation
  106909. * * distanceTo : optional Vector3 to compute the facet depth from this location
  106910. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  106911. */
  106912. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  106913. facetNormals?: any;
  106914. facetPositions?: any;
  106915. facetPartitioning?: any;
  106916. ratio?: number;
  106917. bInfo?: any;
  106918. bbSize?: Vector3;
  106919. subDiv?: any;
  106920. useRightHandedSystem?: boolean;
  106921. depthSort?: boolean;
  106922. distanceTo?: Vector3;
  106923. depthSortedFacets?: any;
  106924. }): void;
  106925. /** @hidden */
  106926. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  106927. /**
  106928. * Applies VertexData created from the imported parameters to the geometry
  106929. * @param parsedVertexData the parsed data from an imported file
  106930. * @param geometry the geometry to apply the VertexData to
  106931. */
  106932. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  106933. }
  106934. }
  106935. declare module BABYLON {
  106936. /**
  106937. * Defines a target to use with MorphTargetManager
  106938. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106939. */
  106940. export class MorphTarget implements IAnimatable {
  106941. /** defines the name of the target */
  106942. name: string;
  106943. /**
  106944. * Gets or sets the list of animations
  106945. */
  106946. animations: Animation[];
  106947. private _scene;
  106948. private _positions;
  106949. private _normals;
  106950. private _tangents;
  106951. private _uvs;
  106952. private _influence;
  106953. private _uniqueId;
  106954. /**
  106955. * Observable raised when the influence changes
  106956. */
  106957. onInfluenceChanged: Observable<boolean>;
  106958. /** @hidden */
  106959. _onDataLayoutChanged: Observable<void>;
  106960. /**
  106961. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  106962. */
  106963. get influence(): number;
  106964. set influence(influence: number);
  106965. /**
  106966. * Gets or sets the id of the morph Target
  106967. */
  106968. id: string;
  106969. private _animationPropertiesOverride;
  106970. /**
  106971. * Gets or sets the animation properties override
  106972. */
  106973. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106974. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106975. /**
  106976. * Creates a new MorphTarget
  106977. * @param name defines the name of the target
  106978. * @param influence defines the influence to use
  106979. * @param scene defines the scene the morphtarget belongs to
  106980. */
  106981. constructor(
  106982. /** defines the name of the target */
  106983. name: string, influence?: number, scene?: Nullable<Scene>);
  106984. /**
  106985. * Gets the unique ID of this manager
  106986. */
  106987. get uniqueId(): number;
  106988. /**
  106989. * Gets a boolean defining if the target contains position data
  106990. */
  106991. get hasPositions(): boolean;
  106992. /**
  106993. * Gets a boolean defining if the target contains normal data
  106994. */
  106995. get hasNormals(): boolean;
  106996. /**
  106997. * Gets a boolean defining if the target contains tangent data
  106998. */
  106999. get hasTangents(): boolean;
  107000. /**
  107001. * Gets a boolean defining if the target contains texture coordinates data
  107002. */
  107003. get hasUVs(): boolean;
  107004. /**
  107005. * Affects position data to this target
  107006. * @param data defines the position data to use
  107007. */
  107008. setPositions(data: Nullable<FloatArray>): void;
  107009. /**
  107010. * Gets the position data stored in this target
  107011. * @returns a FloatArray containing the position data (or null if not present)
  107012. */
  107013. getPositions(): Nullable<FloatArray>;
  107014. /**
  107015. * Affects normal data to this target
  107016. * @param data defines the normal data to use
  107017. */
  107018. setNormals(data: Nullable<FloatArray>): void;
  107019. /**
  107020. * Gets the normal data stored in this target
  107021. * @returns a FloatArray containing the normal data (or null if not present)
  107022. */
  107023. getNormals(): Nullable<FloatArray>;
  107024. /**
  107025. * Affects tangent data to this target
  107026. * @param data defines the tangent data to use
  107027. */
  107028. setTangents(data: Nullable<FloatArray>): void;
  107029. /**
  107030. * Gets the tangent data stored in this target
  107031. * @returns a FloatArray containing the tangent data (or null if not present)
  107032. */
  107033. getTangents(): Nullable<FloatArray>;
  107034. /**
  107035. * Affects texture coordinates data to this target
  107036. * @param data defines the texture coordinates data to use
  107037. */
  107038. setUVs(data: Nullable<FloatArray>): void;
  107039. /**
  107040. * Gets the texture coordinates data stored in this target
  107041. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  107042. */
  107043. getUVs(): Nullable<FloatArray>;
  107044. /**
  107045. * Clone the current target
  107046. * @returns a new MorphTarget
  107047. */
  107048. clone(): MorphTarget;
  107049. /**
  107050. * Serializes the current target into a Serialization object
  107051. * @returns the serialized object
  107052. */
  107053. serialize(): any;
  107054. /**
  107055. * Returns the string "MorphTarget"
  107056. * @returns "MorphTarget"
  107057. */
  107058. getClassName(): string;
  107059. /**
  107060. * Creates a new target from serialized data
  107061. * @param serializationObject defines the serialized data to use
  107062. * @returns a new MorphTarget
  107063. */
  107064. static Parse(serializationObject: any): MorphTarget;
  107065. /**
  107066. * Creates a MorphTarget from mesh data
  107067. * @param mesh defines the source mesh
  107068. * @param name defines the name to use for the new target
  107069. * @param influence defines the influence to attach to the target
  107070. * @returns a new MorphTarget
  107071. */
  107072. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  107073. }
  107074. }
  107075. declare module BABYLON {
  107076. /**
  107077. * This class is used to deform meshes using morphing between different targets
  107078. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  107079. */
  107080. export class MorphTargetManager {
  107081. private _targets;
  107082. private _targetInfluenceChangedObservers;
  107083. private _targetDataLayoutChangedObservers;
  107084. private _activeTargets;
  107085. private _scene;
  107086. private _influences;
  107087. private _supportsNormals;
  107088. private _supportsTangents;
  107089. private _supportsUVs;
  107090. private _vertexCount;
  107091. private _uniqueId;
  107092. private _tempInfluences;
  107093. /**
  107094. * Gets or sets a boolean indicating if normals must be morphed
  107095. */
  107096. enableNormalMorphing: boolean;
  107097. /**
  107098. * Gets or sets a boolean indicating if tangents must be morphed
  107099. */
  107100. enableTangentMorphing: boolean;
  107101. /**
  107102. * Gets or sets a boolean indicating if UV must be morphed
  107103. */
  107104. enableUVMorphing: boolean;
  107105. /**
  107106. * Creates a new MorphTargetManager
  107107. * @param scene defines the current scene
  107108. */
  107109. constructor(scene?: Nullable<Scene>);
  107110. /**
  107111. * Gets the unique ID of this manager
  107112. */
  107113. get uniqueId(): number;
  107114. /**
  107115. * Gets the number of vertices handled by this manager
  107116. */
  107117. get vertexCount(): number;
  107118. /**
  107119. * Gets a boolean indicating if this manager supports morphing of normals
  107120. */
  107121. get supportsNormals(): boolean;
  107122. /**
  107123. * Gets a boolean indicating if this manager supports morphing of tangents
  107124. */
  107125. get supportsTangents(): boolean;
  107126. /**
  107127. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  107128. */
  107129. get supportsUVs(): boolean;
  107130. /**
  107131. * Gets the number of targets stored in this manager
  107132. */
  107133. get numTargets(): number;
  107134. /**
  107135. * Gets the number of influencers (ie. the number of targets with influences > 0)
  107136. */
  107137. get numInfluencers(): number;
  107138. /**
  107139. * Gets the list of influences (one per target)
  107140. */
  107141. get influences(): Float32Array;
  107142. /**
  107143. * Gets the active target at specified index. An active target is a target with an influence > 0
  107144. * @param index defines the index to check
  107145. * @returns the requested target
  107146. */
  107147. getActiveTarget(index: number): MorphTarget;
  107148. /**
  107149. * Gets the target at specified index
  107150. * @param index defines the index to check
  107151. * @returns the requested target
  107152. */
  107153. getTarget(index: number): MorphTarget;
  107154. /**
  107155. * Add a new target to this manager
  107156. * @param target defines the target to add
  107157. */
  107158. addTarget(target: MorphTarget): void;
  107159. /**
  107160. * Removes a target from the manager
  107161. * @param target defines the target to remove
  107162. */
  107163. removeTarget(target: MorphTarget): void;
  107164. /**
  107165. * Clone the current manager
  107166. * @returns a new MorphTargetManager
  107167. */
  107168. clone(): MorphTargetManager;
  107169. /**
  107170. * Serializes the current manager into a Serialization object
  107171. * @returns the serialized object
  107172. */
  107173. serialize(): any;
  107174. private _syncActiveTargets;
  107175. /**
  107176. * Syncrhonize the targets with all the meshes using this morph target manager
  107177. */
  107178. synchronize(): void;
  107179. /**
  107180. * Creates a new MorphTargetManager from serialized data
  107181. * @param serializationObject defines the serialized data
  107182. * @param scene defines the hosting scene
  107183. * @returns the new MorphTargetManager
  107184. */
  107185. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  107186. }
  107187. }
  107188. declare module BABYLON {
  107189. /**
  107190. * Class used to represent a specific level of detail of a mesh
  107191. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107192. */
  107193. export class MeshLODLevel {
  107194. /** Defines the distance where this level should start being displayed */
  107195. distance: number;
  107196. /** Defines the mesh to use to render this level */
  107197. mesh: Nullable<Mesh>;
  107198. /**
  107199. * Creates a new LOD level
  107200. * @param distance defines the distance where this level should star being displayed
  107201. * @param mesh defines the mesh to use to render this level
  107202. */
  107203. constructor(
  107204. /** Defines the distance where this level should start being displayed */
  107205. distance: number,
  107206. /** Defines the mesh to use to render this level */
  107207. mesh: Nullable<Mesh>);
  107208. }
  107209. }
  107210. declare module BABYLON {
  107211. /**
  107212. * Helper class used to generate a canvas to manipulate images
  107213. */
  107214. export class CanvasGenerator {
  107215. /**
  107216. * Create a new canvas (or offscreen canvas depending on the context)
  107217. * @param width defines the expected width
  107218. * @param height defines the expected height
  107219. * @return a new canvas or offscreen canvas
  107220. */
  107221. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  107222. }
  107223. }
  107224. declare module BABYLON {
  107225. /**
  107226. * Mesh representing the gorund
  107227. */
  107228. export class GroundMesh extends Mesh {
  107229. /** If octree should be generated */
  107230. generateOctree: boolean;
  107231. private _heightQuads;
  107232. /** @hidden */
  107233. _subdivisionsX: number;
  107234. /** @hidden */
  107235. _subdivisionsY: number;
  107236. /** @hidden */
  107237. _width: number;
  107238. /** @hidden */
  107239. _height: number;
  107240. /** @hidden */
  107241. _minX: number;
  107242. /** @hidden */
  107243. _maxX: number;
  107244. /** @hidden */
  107245. _minZ: number;
  107246. /** @hidden */
  107247. _maxZ: number;
  107248. constructor(name: string, scene: Scene);
  107249. /**
  107250. * "GroundMesh"
  107251. * @returns "GroundMesh"
  107252. */
  107253. getClassName(): string;
  107254. /**
  107255. * The minimum of x and y subdivisions
  107256. */
  107257. get subdivisions(): number;
  107258. /**
  107259. * X subdivisions
  107260. */
  107261. get subdivisionsX(): number;
  107262. /**
  107263. * Y subdivisions
  107264. */
  107265. get subdivisionsY(): number;
  107266. /**
  107267. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  107268. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  107269. * @param chunksCount the number of subdivisions for x and y
  107270. * @param octreeBlocksSize (Default: 32)
  107271. */
  107272. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  107273. /**
  107274. * Returns a height (y) value in the Worl system :
  107275. * the ground altitude at the coordinates (x, z) expressed in the World system.
  107276. * @param x x coordinate
  107277. * @param z z coordinate
  107278. * @returns the ground y position if (x, z) are outside the ground surface.
  107279. */
  107280. getHeightAtCoordinates(x: number, z: number): number;
  107281. /**
  107282. * Returns a normalized vector (Vector3) orthogonal to the ground
  107283. * at the ground coordinates (x, z) expressed in the World system.
  107284. * @param x x coordinate
  107285. * @param z z coordinate
  107286. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  107287. */
  107288. getNormalAtCoordinates(x: number, z: number): Vector3;
  107289. /**
  107290. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  107291. * at the ground coordinates (x, z) expressed in the World system.
  107292. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  107293. * @param x x coordinate
  107294. * @param z z coordinate
  107295. * @param ref vector to store the result
  107296. * @returns the GroundMesh.
  107297. */
  107298. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  107299. /**
  107300. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  107301. * if the ground has been updated.
  107302. * This can be used in the render loop.
  107303. * @returns the GroundMesh.
  107304. */
  107305. updateCoordinateHeights(): GroundMesh;
  107306. private _getFacetAt;
  107307. private _initHeightQuads;
  107308. private _computeHeightQuads;
  107309. /**
  107310. * Serializes this ground mesh
  107311. * @param serializationObject object to write serialization to
  107312. */
  107313. serialize(serializationObject: any): void;
  107314. /**
  107315. * Parses a serialized ground mesh
  107316. * @param parsedMesh the serialized mesh
  107317. * @param scene the scene to create the ground mesh in
  107318. * @returns the created ground mesh
  107319. */
  107320. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  107321. }
  107322. }
  107323. declare module BABYLON {
  107324. /**
  107325. * Interface for Physics-Joint data
  107326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107327. */
  107328. export interface PhysicsJointData {
  107329. /**
  107330. * The main pivot of the joint
  107331. */
  107332. mainPivot?: Vector3;
  107333. /**
  107334. * The connected pivot of the joint
  107335. */
  107336. connectedPivot?: Vector3;
  107337. /**
  107338. * The main axis of the joint
  107339. */
  107340. mainAxis?: Vector3;
  107341. /**
  107342. * The connected axis of the joint
  107343. */
  107344. connectedAxis?: Vector3;
  107345. /**
  107346. * The collision of the joint
  107347. */
  107348. collision?: boolean;
  107349. /**
  107350. * Native Oimo/Cannon/Energy data
  107351. */
  107352. nativeParams?: any;
  107353. }
  107354. /**
  107355. * This is a holder class for the physics joint created by the physics plugin
  107356. * It holds a set of functions to control the underlying joint
  107357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107358. */
  107359. export class PhysicsJoint {
  107360. /**
  107361. * The type of the physics joint
  107362. */
  107363. type: number;
  107364. /**
  107365. * The data for the physics joint
  107366. */
  107367. jointData: PhysicsJointData;
  107368. private _physicsJoint;
  107369. protected _physicsPlugin: IPhysicsEnginePlugin;
  107370. /**
  107371. * Initializes the physics joint
  107372. * @param type The type of the physics joint
  107373. * @param jointData The data for the physics joint
  107374. */
  107375. constructor(
  107376. /**
  107377. * The type of the physics joint
  107378. */
  107379. type: number,
  107380. /**
  107381. * The data for the physics joint
  107382. */
  107383. jointData: PhysicsJointData);
  107384. /**
  107385. * Gets the physics joint
  107386. */
  107387. get physicsJoint(): any;
  107388. /**
  107389. * Sets the physics joint
  107390. */
  107391. set physicsJoint(newJoint: any);
  107392. /**
  107393. * Sets the physics plugin
  107394. */
  107395. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  107396. /**
  107397. * Execute a function that is physics-plugin specific.
  107398. * @param {Function} func the function that will be executed.
  107399. * It accepts two parameters: the physics world and the physics joint
  107400. */
  107401. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  107402. /**
  107403. * Distance-Joint type
  107404. */
  107405. static DistanceJoint: number;
  107406. /**
  107407. * Hinge-Joint type
  107408. */
  107409. static HingeJoint: number;
  107410. /**
  107411. * Ball-and-Socket joint type
  107412. */
  107413. static BallAndSocketJoint: number;
  107414. /**
  107415. * Wheel-Joint type
  107416. */
  107417. static WheelJoint: number;
  107418. /**
  107419. * Slider-Joint type
  107420. */
  107421. static SliderJoint: number;
  107422. /**
  107423. * Prismatic-Joint type
  107424. */
  107425. static PrismaticJoint: number;
  107426. /**
  107427. * Universal-Joint type
  107428. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  107429. */
  107430. static UniversalJoint: number;
  107431. /**
  107432. * Hinge-Joint 2 type
  107433. */
  107434. static Hinge2Joint: number;
  107435. /**
  107436. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  107437. */
  107438. static PointToPointJoint: number;
  107439. /**
  107440. * Spring-Joint type
  107441. */
  107442. static SpringJoint: number;
  107443. /**
  107444. * Lock-Joint type
  107445. */
  107446. static LockJoint: number;
  107447. }
  107448. /**
  107449. * A class representing a physics distance joint
  107450. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107451. */
  107452. export class DistanceJoint extends PhysicsJoint {
  107453. /**
  107454. *
  107455. * @param jointData The data for the Distance-Joint
  107456. */
  107457. constructor(jointData: DistanceJointData);
  107458. /**
  107459. * Update the predefined distance.
  107460. * @param maxDistance The maximum preferred distance
  107461. * @param minDistance The minimum preferred distance
  107462. */
  107463. updateDistance(maxDistance: number, minDistance?: number): void;
  107464. }
  107465. /**
  107466. * Represents a Motor-Enabled Joint
  107467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107468. */
  107469. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  107470. /**
  107471. * Initializes the Motor-Enabled Joint
  107472. * @param type The type of the joint
  107473. * @param jointData The physica joint data for the joint
  107474. */
  107475. constructor(type: number, jointData: PhysicsJointData);
  107476. /**
  107477. * Set the motor values.
  107478. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107479. * @param force the force to apply
  107480. * @param maxForce max force for this motor.
  107481. */
  107482. setMotor(force?: number, maxForce?: number): void;
  107483. /**
  107484. * Set the motor's limits.
  107485. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107486. * @param upperLimit The upper limit of the motor
  107487. * @param lowerLimit The lower limit of the motor
  107488. */
  107489. setLimit(upperLimit: number, lowerLimit?: number): void;
  107490. }
  107491. /**
  107492. * This class represents a single physics Hinge-Joint
  107493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107494. */
  107495. export class HingeJoint extends MotorEnabledJoint {
  107496. /**
  107497. * Initializes the Hinge-Joint
  107498. * @param jointData The joint data for the Hinge-Joint
  107499. */
  107500. constructor(jointData: PhysicsJointData);
  107501. /**
  107502. * Set the motor values.
  107503. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107504. * @param {number} force the force to apply
  107505. * @param {number} maxForce max force for this motor.
  107506. */
  107507. setMotor(force?: number, maxForce?: number): void;
  107508. /**
  107509. * Set the motor's limits.
  107510. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107511. * @param upperLimit The upper limit of the motor
  107512. * @param lowerLimit The lower limit of the motor
  107513. */
  107514. setLimit(upperLimit: number, lowerLimit?: number): void;
  107515. }
  107516. /**
  107517. * This class represents a dual hinge physics joint (same as wheel joint)
  107518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107519. */
  107520. export class Hinge2Joint extends MotorEnabledJoint {
  107521. /**
  107522. * Initializes the Hinge2-Joint
  107523. * @param jointData The joint data for the Hinge2-Joint
  107524. */
  107525. constructor(jointData: PhysicsJointData);
  107526. /**
  107527. * Set the motor values.
  107528. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107529. * @param {number} targetSpeed the speed the motor is to reach
  107530. * @param {number} maxForce max force for this motor.
  107531. * @param {motorIndex} the motor's index, 0 or 1.
  107532. */
  107533. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  107534. /**
  107535. * Set the motor limits.
  107536. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107537. * @param {number} upperLimit the upper limit
  107538. * @param {number} lowerLimit lower limit
  107539. * @param {motorIndex} the motor's index, 0 or 1.
  107540. */
  107541. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107542. }
  107543. /**
  107544. * Interface for a motor enabled joint
  107545. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107546. */
  107547. export interface IMotorEnabledJoint {
  107548. /**
  107549. * Physics joint
  107550. */
  107551. physicsJoint: any;
  107552. /**
  107553. * Sets the motor of the motor-enabled joint
  107554. * @param force The force of the motor
  107555. * @param maxForce The maximum force of the motor
  107556. * @param motorIndex The index of the motor
  107557. */
  107558. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  107559. /**
  107560. * Sets the limit of the motor
  107561. * @param upperLimit The upper limit of the motor
  107562. * @param lowerLimit The lower limit of the motor
  107563. * @param motorIndex The index of the motor
  107564. */
  107565. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107566. }
  107567. /**
  107568. * Joint data for a Distance-Joint
  107569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107570. */
  107571. export interface DistanceJointData extends PhysicsJointData {
  107572. /**
  107573. * Max distance the 2 joint objects can be apart
  107574. */
  107575. maxDistance: number;
  107576. }
  107577. /**
  107578. * Joint data from a spring joint
  107579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107580. */
  107581. export interface SpringJointData extends PhysicsJointData {
  107582. /**
  107583. * Length of the spring
  107584. */
  107585. length: number;
  107586. /**
  107587. * Stiffness of the spring
  107588. */
  107589. stiffness: number;
  107590. /**
  107591. * Damping of the spring
  107592. */
  107593. damping: number;
  107594. /** this callback will be called when applying the force to the impostors. */
  107595. forceApplicationCallback: () => void;
  107596. }
  107597. }
  107598. declare module BABYLON {
  107599. /**
  107600. * Holds the data for the raycast result
  107601. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107602. */
  107603. export class PhysicsRaycastResult {
  107604. private _hasHit;
  107605. private _hitDistance;
  107606. private _hitNormalWorld;
  107607. private _hitPointWorld;
  107608. private _rayFromWorld;
  107609. private _rayToWorld;
  107610. /**
  107611. * Gets if there was a hit
  107612. */
  107613. get hasHit(): boolean;
  107614. /**
  107615. * Gets the distance from the hit
  107616. */
  107617. get hitDistance(): number;
  107618. /**
  107619. * Gets the hit normal/direction in the world
  107620. */
  107621. get hitNormalWorld(): Vector3;
  107622. /**
  107623. * Gets the hit point in the world
  107624. */
  107625. get hitPointWorld(): Vector3;
  107626. /**
  107627. * Gets the ray "start point" of the ray in the world
  107628. */
  107629. get rayFromWorld(): Vector3;
  107630. /**
  107631. * Gets the ray "end point" of the ray in the world
  107632. */
  107633. get rayToWorld(): Vector3;
  107634. /**
  107635. * Sets the hit data (normal & point in world space)
  107636. * @param hitNormalWorld defines the normal in world space
  107637. * @param hitPointWorld defines the point in world space
  107638. */
  107639. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  107640. /**
  107641. * Sets the distance from the start point to the hit point
  107642. * @param distance
  107643. */
  107644. setHitDistance(distance: number): void;
  107645. /**
  107646. * Calculates the distance manually
  107647. */
  107648. calculateHitDistance(): void;
  107649. /**
  107650. * Resets all the values to default
  107651. * @param from The from point on world space
  107652. * @param to The to point on world space
  107653. */
  107654. reset(from?: Vector3, to?: Vector3): void;
  107655. }
  107656. /**
  107657. * Interface for the size containing width and height
  107658. */
  107659. interface IXYZ {
  107660. /**
  107661. * X
  107662. */
  107663. x: number;
  107664. /**
  107665. * Y
  107666. */
  107667. y: number;
  107668. /**
  107669. * Z
  107670. */
  107671. z: number;
  107672. }
  107673. }
  107674. declare module BABYLON {
  107675. /**
  107676. * Interface used to describe a physics joint
  107677. */
  107678. export interface PhysicsImpostorJoint {
  107679. /** Defines the main impostor to which the joint is linked */
  107680. mainImpostor: PhysicsImpostor;
  107681. /** Defines the impostor that is connected to the main impostor using this joint */
  107682. connectedImpostor: PhysicsImpostor;
  107683. /** Defines the joint itself */
  107684. joint: PhysicsJoint;
  107685. }
  107686. /** @hidden */
  107687. export interface IPhysicsEnginePlugin {
  107688. world: any;
  107689. name: string;
  107690. setGravity(gravity: Vector3): void;
  107691. setTimeStep(timeStep: number): void;
  107692. getTimeStep(): number;
  107693. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107694. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107695. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107696. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107697. removePhysicsBody(impostor: PhysicsImpostor): void;
  107698. generateJoint(joint: PhysicsImpostorJoint): void;
  107699. removeJoint(joint: PhysicsImpostorJoint): void;
  107700. isSupported(): boolean;
  107701. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107702. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107703. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107704. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107705. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107706. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107707. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107708. getBodyMass(impostor: PhysicsImpostor): number;
  107709. getBodyFriction(impostor: PhysicsImpostor): number;
  107710. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107711. getBodyRestitution(impostor: PhysicsImpostor): number;
  107712. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107713. getBodyPressure?(impostor: PhysicsImpostor): number;
  107714. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  107715. getBodyStiffness?(impostor: PhysicsImpostor): number;
  107716. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  107717. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  107718. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  107719. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  107720. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  107721. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107722. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107723. sleepBody(impostor: PhysicsImpostor): void;
  107724. wakeUpBody(impostor: PhysicsImpostor): void;
  107725. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107726. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107727. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  107728. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107729. getRadius(impostor: PhysicsImpostor): number;
  107730. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107731. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107732. dispose(): void;
  107733. }
  107734. /**
  107735. * Interface used to define a physics engine
  107736. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107737. */
  107738. export interface IPhysicsEngine {
  107739. /**
  107740. * Gets the gravity vector used by the simulation
  107741. */
  107742. gravity: Vector3;
  107743. /**
  107744. * Sets the gravity vector used by the simulation
  107745. * @param gravity defines the gravity vector to use
  107746. */
  107747. setGravity(gravity: Vector3): void;
  107748. /**
  107749. * Set the time step of the physics engine.
  107750. * Default is 1/60.
  107751. * To slow it down, enter 1/600 for example.
  107752. * To speed it up, 1/30
  107753. * @param newTimeStep the new timestep to apply to this world.
  107754. */
  107755. setTimeStep(newTimeStep: number): void;
  107756. /**
  107757. * Get the time step of the physics engine.
  107758. * @returns the current time step
  107759. */
  107760. getTimeStep(): number;
  107761. /**
  107762. * Set the sub time step of the physics engine.
  107763. * Default is 0 meaning there is no sub steps
  107764. * To increase physics resolution precision, set a small value (like 1 ms)
  107765. * @param subTimeStep defines the new sub timestep used for physics resolution.
  107766. */
  107767. setSubTimeStep(subTimeStep: number): void;
  107768. /**
  107769. * Get the sub time step of the physics engine.
  107770. * @returns the current sub time step
  107771. */
  107772. getSubTimeStep(): number;
  107773. /**
  107774. * Release all resources
  107775. */
  107776. dispose(): void;
  107777. /**
  107778. * Gets the name of the current physics plugin
  107779. * @returns the name of the plugin
  107780. */
  107781. getPhysicsPluginName(): string;
  107782. /**
  107783. * Adding a new impostor for the impostor tracking.
  107784. * This will be done by the impostor itself.
  107785. * @param impostor the impostor to add
  107786. */
  107787. addImpostor(impostor: PhysicsImpostor): void;
  107788. /**
  107789. * Remove an impostor from the engine.
  107790. * This impostor and its mesh will not longer be updated by the physics engine.
  107791. * @param impostor the impostor to remove
  107792. */
  107793. removeImpostor(impostor: PhysicsImpostor): void;
  107794. /**
  107795. * Add a joint to the physics engine
  107796. * @param mainImpostor defines the main impostor to which the joint is added.
  107797. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107798. * @param joint defines the joint that will connect both impostors.
  107799. */
  107800. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107801. /**
  107802. * Removes a joint from the simulation
  107803. * @param mainImpostor defines the impostor used with the joint
  107804. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107805. * @param joint defines the joint to remove
  107806. */
  107807. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107808. /**
  107809. * Gets the current plugin used to run the simulation
  107810. * @returns current plugin
  107811. */
  107812. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107813. /**
  107814. * Gets the list of physic impostors
  107815. * @returns an array of PhysicsImpostor
  107816. */
  107817. getImpostors(): Array<PhysicsImpostor>;
  107818. /**
  107819. * Gets the impostor for a physics enabled object
  107820. * @param object defines the object impersonated by the impostor
  107821. * @returns the PhysicsImpostor or null if not found
  107822. */
  107823. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107824. /**
  107825. * Gets the impostor for a physics body object
  107826. * @param body defines physics body used by the impostor
  107827. * @returns the PhysicsImpostor or null if not found
  107828. */
  107829. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107830. /**
  107831. * Does a raycast in the physics world
  107832. * @param from when should the ray start?
  107833. * @param to when should the ray end?
  107834. * @returns PhysicsRaycastResult
  107835. */
  107836. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107837. /**
  107838. * Called by the scene. No need to call it.
  107839. * @param delta defines the timespam between frames
  107840. */
  107841. _step(delta: number): void;
  107842. }
  107843. }
  107844. declare module BABYLON {
  107845. /**
  107846. * The interface for the physics imposter parameters
  107847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107848. */
  107849. export interface PhysicsImpostorParameters {
  107850. /**
  107851. * The mass of the physics imposter
  107852. */
  107853. mass: number;
  107854. /**
  107855. * The friction of the physics imposter
  107856. */
  107857. friction?: number;
  107858. /**
  107859. * The coefficient of restitution of the physics imposter
  107860. */
  107861. restitution?: number;
  107862. /**
  107863. * The native options of the physics imposter
  107864. */
  107865. nativeOptions?: any;
  107866. /**
  107867. * Specifies if the parent should be ignored
  107868. */
  107869. ignoreParent?: boolean;
  107870. /**
  107871. * Specifies if bi-directional transformations should be disabled
  107872. */
  107873. disableBidirectionalTransformation?: boolean;
  107874. /**
  107875. * The pressure inside the physics imposter, soft object only
  107876. */
  107877. pressure?: number;
  107878. /**
  107879. * The stiffness the physics imposter, soft object only
  107880. */
  107881. stiffness?: number;
  107882. /**
  107883. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  107884. */
  107885. velocityIterations?: number;
  107886. /**
  107887. * The number of iterations used in maintaining consistent vertex positions, soft object only
  107888. */
  107889. positionIterations?: number;
  107890. /**
  107891. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  107892. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  107893. * Add to fix multiple points
  107894. */
  107895. fixedPoints?: number;
  107896. /**
  107897. * The collision margin around a soft object
  107898. */
  107899. margin?: number;
  107900. /**
  107901. * The collision margin around a soft object
  107902. */
  107903. damping?: number;
  107904. /**
  107905. * The path for a rope based on an extrusion
  107906. */
  107907. path?: any;
  107908. /**
  107909. * The shape of an extrusion used for a rope based on an extrusion
  107910. */
  107911. shape?: any;
  107912. }
  107913. /**
  107914. * Interface for a physics-enabled object
  107915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107916. */
  107917. export interface IPhysicsEnabledObject {
  107918. /**
  107919. * The position of the physics-enabled object
  107920. */
  107921. position: Vector3;
  107922. /**
  107923. * The rotation of the physics-enabled object
  107924. */
  107925. rotationQuaternion: Nullable<Quaternion>;
  107926. /**
  107927. * The scale of the physics-enabled object
  107928. */
  107929. scaling: Vector3;
  107930. /**
  107931. * The rotation of the physics-enabled object
  107932. */
  107933. rotation?: Vector3;
  107934. /**
  107935. * The parent of the physics-enabled object
  107936. */
  107937. parent?: any;
  107938. /**
  107939. * The bounding info of the physics-enabled object
  107940. * @returns The bounding info of the physics-enabled object
  107941. */
  107942. getBoundingInfo(): BoundingInfo;
  107943. /**
  107944. * Computes the world matrix
  107945. * @param force Specifies if the world matrix should be computed by force
  107946. * @returns A world matrix
  107947. */
  107948. computeWorldMatrix(force: boolean): Matrix;
  107949. /**
  107950. * Gets the world matrix
  107951. * @returns A world matrix
  107952. */
  107953. getWorldMatrix?(): Matrix;
  107954. /**
  107955. * Gets the child meshes
  107956. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  107957. * @returns An array of abstract meshes
  107958. */
  107959. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  107960. /**
  107961. * Gets the vertex data
  107962. * @param kind The type of vertex data
  107963. * @returns A nullable array of numbers, or a float32 array
  107964. */
  107965. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  107966. /**
  107967. * Gets the indices from the mesh
  107968. * @returns A nullable array of index arrays
  107969. */
  107970. getIndices?(): Nullable<IndicesArray>;
  107971. /**
  107972. * Gets the scene from the mesh
  107973. * @returns the indices array or null
  107974. */
  107975. getScene?(): Scene;
  107976. /**
  107977. * Gets the absolute position from the mesh
  107978. * @returns the absolute position
  107979. */
  107980. getAbsolutePosition(): Vector3;
  107981. /**
  107982. * Gets the absolute pivot point from the mesh
  107983. * @returns the absolute pivot point
  107984. */
  107985. getAbsolutePivotPoint(): Vector3;
  107986. /**
  107987. * Rotates the mesh
  107988. * @param axis The axis of rotation
  107989. * @param amount The amount of rotation
  107990. * @param space The space of the rotation
  107991. * @returns The rotation transform node
  107992. */
  107993. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  107994. /**
  107995. * Translates the mesh
  107996. * @param axis The axis of translation
  107997. * @param distance The distance of translation
  107998. * @param space The space of the translation
  107999. * @returns The transform node
  108000. */
  108001. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  108002. /**
  108003. * Sets the absolute position of the mesh
  108004. * @param absolutePosition The absolute position of the mesh
  108005. * @returns The transform node
  108006. */
  108007. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  108008. /**
  108009. * Gets the class name of the mesh
  108010. * @returns The class name
  108011. */
  108012. getClassName(): string;
  108013. }
  108014. /**
  108015. * Represents a physics imposter
  108016. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108017. */
  108018. export class PhysicsImpostor {
  108019. /**
  108020. * The physics-enabled object used as the physics imposter
  108021. */
  108022. object: IPhysicsEnabledObject;
  108023. /**
  108024. * The type of the physics imposter
  108025. */
  108026. type: number;
  108027. private _options;
  108028. private _scene?;
  108029. /**
  108030. * The default object size of the imposter
  108031. */
  108032. static DEFAULT_OBJECT_SIZE: Vector3;
  108033. /**
  108034. * The identity quaternion of the imposter
  108035. */
  108036. static IDENTITY_QUATERNION: Quaternion;
  108037. /** @hidden */
  108038. _pluginData: any;
  108039. private _physicsEngine;
  108040. private _physicsBody;
  108041. private _bodyUpdateRequired;
  108042. private _onBeforePhysicsStepCallbacks;
  108043. private _onAfterPhysicsStepCallbacks;
  108044. /** @hidden */
  108045. _onPhysicsCollideCallbacks: Array<{
  108046. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  108047. otherImpostors: Array<PhysicsImpostor>;
  108048. }>;
  108049. private _deltaPosition;
  108050. private _deltaRotation;
  108051. private _deltaRotationConjugated;
  108052. /** @hidden */
  108053. _isFromLine: boolean;
  108054. private _parent;
  108055. private _isDisposed;
  108056. private static _tmpVecs;
  108057. private static _tmpQuat;
  108058. /**
  108059. * Specifies if the physics imposter is disposed
  108060. */
  108061. get isDisposed(): boolean;
  108062. /**
  108063. * Gets the mass of the physics imposter
  108064. */
  108065. get mass(): number;
  108066. set mass(value: number);
  108067. /**
  108068. * Gets the coefficient of friction
  108069. */
  108070. get friction(): number;
  108071. /**
  108072. * Sets the coefficient of friction
  108073. */
  108074. set friction(value: number);
  108075. /**
  108076. * Gets the coefficient of restitution
  108077. */
  108078. get restitution(): number;
  108079. /**
  108080. * Sets the coefficient of restitution
  108081. */
  108082. set restitution(value: number);
  108083. /**
  108084. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  108085. */
  108086. get pressure(): number;
  108087. /**
  108088. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  108089. */
  108090. set pressure(value: number);
  108091. /**
  108092. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  108093. */
  108094. get stiffness(): number;
  108095. /**
  108096. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  108097. */
  108098. set stiffness(value: number);
  108099. /**
  108100. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  108101. */
  108102. get velocityIterations(): number;
  108103. /**
  108104. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  108105. */
  108106. set velocityIterations(value: number);
  108107. /**
  108108. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  108109. */
  108110. get positionIterations(): number;
  108111. /**
  108112. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  108113. */
  108114. set positionIterations(value: number);
  108115. /**
  108116. * The unique id of the physics imposter
  108117. * set by the physics engine when adding this impostor to the array
  108118. */
  108119. uniqueId: number;
  108120. /**
  108121. * @hidden
  108122. */
  108123. soft: boolean;
  108124. /**
  108125. * @hidden
  108126. */
  108127. segments: number;
  108128. private _joints;
  108129. /**
  108130. * Initializes the physics imposter
  108131. * @param object The physics-enabled object used as the physics imposter
  108132. * @param type The type of the physics imposter
  108133. * @param _options The options for the physics imposter
  108134. * @param _scene The Babylon scene
  108135. */
  108136. constructor(
  108137. /**
  108138. * The physics-enabled object used as the physics imposter
  108139. */
  108140. object: IPhysicsEnabledObject,
  108141. /**
  108142. * The type of the physics imposter
  108143. */
  108144. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  108145. /**
  108146. * This function will completly initialize this impostor.
  108147. * It will create a new body - but only if this mesh has no parent.
  108148. * If it has, this impostor will not be used other than to define the impostor
  108149. * of the child mesh.
  108150. * @hidden
  108151. */
  108152. _init(): void;
  108153. private _getPhysicsParent;
  108154. /**
  108155. * Should a new body be generated.
  108156. * @returns boolean specifying if body initialization is required
  108157. */
  108158. isBodyInitRequired(): boolean;
  108159. /**
  108160. * Sets the updated scaling
  108161. * @param updated Specifies if the scaling is updated
  108162. */
  108163. setScalingUpdated(): void;
  108164. /**
  108165. * Force a regeneration of this or the parent's impostor's body.
  108166. * Use under cautious - This will remove all joints already implemented.
  108167. */
  108168. forceUpdate(): void;
  108169. /**
  108170. * Gets the body that holds this impostor. Either its own, or its parent.
  108171. */
  108172. get physicsBody(): any;
  108173. /**
  108174. * Get the parent of the physics imposter
  108175. * @returns Physics imposter or null
  108176. */
  108177. get parent(): Nullable<PhysicsImpostor>;
  108178. /**
  108179. * Sets the parent of the physics imposter
  108180. */
  108181. set parent(value: Nullable<PhysicsImpostor>);
  108182. /**
  108183. * Set the physics body. Used mainly by the physics engine/plugin
  108184. */
  108185. set physicsBody(physicsBody: any);
  108186. /**
  108187. * Resets the update flags
  108188. */
  108189. resetUpdateFlags(): void;
  108190. /**
  108191. * Gets the object extend size
  108192. * @returns the object extend size
  108193. */
  108194. getObjectExtendSize(): Vector3;
  108195. /**
  108196. * Gets the object center
  108197. * @returns The object center
  108198. */
  108199. getObjectCenter(): Vector3;
  108200. /**
  108201. * Get a specific parameter from the options parameters
  108202. * @param paramName The object parameter name
  108203. * @returns The object parameter
  108204. */
  108205. getParam(paramName: string): any;
  108206. /**
  108207. * Sets a specific parameter in the options given to the physics plugin
  108208. * @param paramName The parameter name
  108209. * @param value The value of the parameter
  108210. */
  108211. setParam(paramName: string, value: number): void;
  108212. /**
  108213. * Specifically change the body's mass option. Won't recreate the physics body object
  108214. * @param mass The mass of the physics imposter
  108215. */
  108216. setMass(mass: number): void;
  108217. /**
  108218. * Gets the linear velocity
  108219. * @returns linear velocity or null
  108220. */
  108221. getLinearVelocity(): Nullable<Vector3>;
  108222. /**
  108223. * Sets the linear velocity
  108224. * @param velocity linear velocity or null
  108225. */
  108226. setLinearVelocity(velocity: Nullable<Vector3>): void;
  108227. /**
  108228. * Gets the angular velocity
  108229. * @returns angular velocity or null
  108230. */
  108231. getAngularVelocity(): Nullable<Vector3>;
  108232. /**
  108233. * Sets the angular velocity
  108234. * @param velocity The velocity or null
  108235. */
  108236. setAngularVelocity(velocity: Nullable<Vector3>): void;
  108237. /**
  108238. * Execute a function with the physics plugin native code
  108239. * Provide a function the will have two variables - the world object and the physics body object
  108240. * @param func The function to execute with the physics plugin native code
  108241. */
  108242. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  108243. /**
  108244. * Register a function that will be executed before the physics world is stepping forward
  108245. * @param func The function to execute before the physics world is stepped forward
  108246. */
  108247. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108248. /**
  108249. * Unregister a function that will be executed before the physics world is stepping forward
  108250. * @param func The function to execute before the physics world is stepped forward
  108251. */
  108252. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108253. /**
  108254. * Register a function that will be executed after the physics step
  108255. * @param func The function to execute after physics step
  108256. */
  108257. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108258. /**
  108259. * Unregisters a function that will be executed after the physics step
  108260. * @param func The function to execute after physics step
  108261. */
  108262. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108263. /**
  108264. * register a function that will be executed when this impostor collides against a different body
  108265. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  108266. * @param func Callback that is executed on collision
  108267. */
  108268. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  108269. /**
  108270. * Unregisters the physics imposter on contact
  108271. * @param collideAgainst The physics object to collide against
  108272. * @param func Callback to execute on collision
  108273. */
  108274. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  108275. private _tmpQuat;
  108276. private _tmpQuat2;
  108277. /**
  108278. * Get the parent rotation
  108279. * @returns The parent rotation
  108280. */
  108281. getParentsRotation(): Quaternion;
  108282. /**
  108283. * this function is executed by the physics engine.
  108284. */
  108285. beforeStep: () => void;
  108286. /**
  108287. * this function is executed by the physics engine
  108288. */
  108289. afterStep: () => void;
  108290. /**
  108291. * Legacy collision detection event support
  108292. */
  108293. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  108294. /**
  108295. * event and body object due to cannon's event-based architecture.
  108296. */
  108297. onCollide: (e: {
  108298. body: any;
  108299. }) => void;
  108300. /**
  108301. * Apply a force
  108302. * @param force The force to apply
  108303. * @param contactPoint The contact point for the force
  108304. * @returns The physics imposter
  108305. */
  108306. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  108307. /**
  108308. * Apply an impulse
  108309. * @param force The impulse force
  108310. * @param contactPoint The contact point for the impulse force
  108311. * @returns The physics imposter
  108312. */
  108313. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  108314. /**
  108315. * A help function to create a joint
  108316. * @param otherImpostor A physics imposter used to create a joint
  108317. * @param jointType The type of joint
  108318. * @param jointData The data for the joint
  108319. * @returns The physics imposter
  108320. */
  108321. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  108322. /**
  108323. * Add a joint to this impostor with a different impostor
  108324. * @param otherImpostor A physics imposter used to add a joint
  108325. * @param joint The joint to add
  108326. * @returns The physics imposter
  108327. */
  108328. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  108329. /**
  108330. * Add an anchor to a cloth impostor
  108331. * @param otherImpostor rigid impostor to anchor to
  108332. * @param width ratio across width from 0 to 1
  108333. * @param height ratio up height from 0 to 1
  108334. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108335. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  108336. * @returns impostor the soft imposter
  108337. */
  108338. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  108339. /**
  108340. * Add a hook to a rope impostor
  108341. * @param otherImpostor rigid impostor to anchor to
  108342. * @param length ratio across rope from 0 to 1
  108343. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  108344. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108345. * @returns impostor the rope imposter
  108346. */
  108347. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  108348. /**
  108349. * Will keep this body still, in a sleep mode.
  108350. * @returns the physics imposter
  108351. */
  108352. sleep(): PhysicsImpostor;
  108353. /**
  108354. * Wake the body up.
  108355. * @returns The physics imposter
  108356. */
  108357. wakeUp(): PhysicsImpostor;
  108358. /**
  108359. * Clones the physics imposter
  108360. * @param newObject The physics imposter clones to this physics-enabled object
  108361. * @returns A nullable physics imposter
  108362. */
  108363. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108364. /**
  108365. * Disposes the physics imposter
  108366. */
  108367. dispose(): void;
  108368. /**
  108369. * Sets the delta position
  108370. * @param position The delta position amount
  108371. */
  108372. setDeltaPosition(position: Vector3): void;
  108373. /**
  108374. * Sets the delta rotation
  108375. * @param rotation The delta rotation amount
  108376. */
  108377. setDeltaRotation(rotation: Quaternion): void;
  108378. /**
  108379. * Gets the box size of the physics imposter and stores the result in the input parameter
  108380. * @param result Stores the box size
  108381. * @returns The physics imposter
  108382. */
  108383. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  108384. /**
  108385. * Gets the radius of the physics imposter
  108386. * @returns Radius of the physics imposter
  108387. */
  108388. getRadius(): number;
  108389. /**
  108390. * Sync a bone with this impostor
  108391. * @param bone The bone to sync to the impostor.
  108392. * @param boneMesh The mesh that the bone is influencing.
  108393. * @param jointPivot The pivot of the joint / bone in local space.
  108394. * @param distToJoint Optional distance from the impostor to the joint.
  108395. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108396. */
  108397. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  108398. /**
  108399. * Sync impostor to a bone
  108400. * @param bone The bone that the impostor will be synced to.
  108401. * @param boneMesh The mesh that the bone is influencing.
  108402. * @param jointPivot The pivot of the joint / bone in local space.
  108403. * @param distToJoint Optional distance from the impostor to the joint.
  108404. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108405. * @param boneAxis Optional vector3 axis the bone is aligned with
  108406. */
  108407. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  108408. /**
  108409. * No-Imposter type
  108410. */
  108411. static NoImpostor: number;
  108412. /**
  108413. * Sphere-Imposter type
  108414. */
  108415. static SphereImpostor: number;
  108416. /**
  108417. * Box-Imposter type
  108418. */
  108419. static BoxImpostor: number;
  108420. /**
  108421. * Plane-Imposter type
  108422. */
  108423. static PlaneImpostor: number;
  108424. /**
  108425. * Mesh-imposter type
  108426. */
  108427. static MeshImpostor: number;
  108428. /**
  108429. * Capsule-Impostor type (Ammo.js plugin only)
  108430. */
  108431. static CapsuleImpostor: number;
  108432. /**
  108433. * Cylinder-Imposter type
  108434. */
  108435. static CylinderImpostor: number;
  108436. /**
  108437. * Particle-Imposter type
  108438. */
  108439. static ParticleImpostor: number;
  108440. /**
  108441. * Heightmap-Imposter type
  108442. */
  108443. static HeightmapImpostor: number;
  108444. /**
  108445. * ConvexHull-Impostor type (Ammo.js plugin only)
  108446. */
  108447. static ConvexHullImpostor: number;
  108448. /**
  108449. * Custom-Imposter type (Ammo.js plugin only)
  108450. */
  108451. static CustomImpostor: number;
  108452. /**
  108453. * Rope-Imposter type
  108454. */
  108455. static RopeImpostor: number;
  108456. /**
  108457. * Cloth-Imposter type
  108458. */
  108459. static ClothImpostor: number;
  108460. /**
  108461. * Softbody-Imposter type
  108462. */
  108463. static SoftbodyImpostor: number;
  108464. }
  108465. }
  108466. declare module BABYLON {
  108467. /**
  108468. * @hidden
  108469. **/
  108470. export class _CreationDataStorage {
  108471. closePath?: boolean;
  108472. closeArray?: boolean;
  108473. idx: number[];
  108474. dashSize: number;
  108475. gapSize: number;
  108476. path3D: Path3D;
  108477. pathArray: Vector3[][];
  108478. arc: number;
  108479. radius: number;
  108480. cap: number;
  108481. tessellation: number;
  108482. }
  108483. /**
  108484. * @hidden
  108485. **/
  108486. class _InstanceDataStorage {
  108487. visibleInstances: any;
  108488. batchCache: _InstancesBatch;
  108489. instancesBufferSize: number;
  108490. instancesBuffer: Nullable<Buffer>;
  108491. instancesData: Float32Array;
  108492. overridenInstanceCount: number;
  108493. isFrozen: boolean;
  108494. previousBatch: Nullable<_InstancesBatch>;
  108495. hardwareInstancedRendering: boolean;
  108496. sideOrientation: number;
  108497. manualUpdate: boolean;
  108498. previousRenderId: number;
  108499. }
  108500. /**
  108501. * @hidden
  108502. **/
  108503. export class _InstancesBatch {
  108504. mustReturn: boolean;
  108505. visibleInstances: Nullable<InstancedMesh[]>[];
  108506. renderSelf: boolean[];
  108507. hardwareInstancedRendering: boolean[];
  108508. }
  108509. /**
  108510. * @hidden
  108511. **/
  108512. class _ThinInstanceDataStorage {
  108513. instancesCount: number;
  108514. matrixBuffer: Nullable<Buffer>;
  108515. matrixBufferSize: number;
  108516. matrixData: Nullable<Float32Array>;
  108517. boundingVectors: Array<Vector3>;
  108518. worldMatrices: Nullable<Matrix[]>;
  108519. }
  108520. /**
  108521. * Class used to represent renderable models
  108522. */
  108523. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  108524. /**
  108525. * Mesh side orientation : usually the external or front surface
  108526. */
  108527. static readonly FRONTSIDE: number;
  108528. /**
  108529. * Mesh side orientation : usually the internal or back surface
  108530. */
  108531. static readonly BACKSIDE: number;
  108532. /**
  108533. * Mesh side orientation : both internal and external or front and back surfaces
  108534. */
  108535. static readonly DOUBLESIDE: number;
  108536. /**
  108537. * Mesh side orientation : by default, `FRONTSIDE`
  108538. */
  108539. static readonly DEFAULTSIDE: number;
  108540. /**
  108541. * Mesh cap setting : no cap
  108542. */
  108543. static readonly NO_CAP: number;
  108544. /**
  108545. * Mesh cap setting : one cap at the beginning of the mesh
  108546. */
  108547. static readonly CAP_START: number;
  108548. /**
  108549. * Mesh cap setting : one cap at the end of the mesh
  108550. */
  108551. static readonly CAP_END: number;
  108552. /**
  108553. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  108554. */
  108555. static readonly CAP_ALL: number;
  108556. /**
  108557. * Mesh pattern setting : no flip or rotate
  108558. */
  108559. static readonly NO_FLIP: number;
  108560. /**
  108561. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  108562. */
  108563. static readonly FLIP_TILE: number;
  108564. /**
  108565. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  108566. */
  108567. static readonly ROTATE_TILE: number;
  108568. /**
  108569. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  108570. */
  108571. static readonly FLIP_ROW: number;
  108572. /**
  108573. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  108574. */
  108575. static readonly ROTATE_ROW: number;
  108576. /**
  108577. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  108578. */
  108579. static readonly FLIP_N_ROTATE_TILE: number;
  108580. /**
  108581. * Mesh pattern setting : rotate pattern and rotate
  108582. */
  108583. static readonly FLIP_N_ROTATE_ROW: number;
  108584. /**
  108585. * Mesh tile positioning : part tiles same on left/right or top/bottom
  108586. */
  108587. static readonly CENTER: number;
  108588. /**
  108589. * Mesh tile positioning : part tiles on left
  108590. */
  108591. static readonly LEFT: number;
  108592. /**
  108593. * Mesh tile positioning : part tiles on right
  108594. */
  108595. static readonly RIGHT: number;
  108596. /**
  108597. * Mesh tile positioning : part tiles on top
  108598. */
  108599. static readonly TOP: number;
  108600. /**
  108601. * Mesh tile positioning : part tiles on bottom
  108602. */
  108603. static readonly BOTTOM: number;
  108604. /**
  108605. * Gets the default side orientation.
  108606. * @param orientation the orientation to value to attempt to get
  108607. * @returns the default orientation
  108608. * @hidden
  108609. */
  108610. static _GetDefaultSideOrientation(orientation?: number): number;
  108611. private _internalMeshDataInfo;
  108612. get computeBonesUsingShaders(): boolean;
  108613. set computeBonesUsingShaders(value: boolean);
  108614. /**
  108615. * An event triggered before rendering the mesh
  108616. */
  108617. get onBeforeRenderObservable(): Observable<Mesh>;
  108618. /**
  108619. * An event triggered before binding the mesh
  108620. */
  108621. get onBeforeBindObservable(): Observable<Mesh>;
  108622. /**
  108623. * An event triggered after rendering the mesh
  108624. */
  108625. get onAfterRenderObservable(): Observable<Mesh>;
  108626. /**
  108627. * An event triggered before drawing the mesh
  108628. */
  108629. get onBeforeDrawObservable(): Observable<Mesh>;
  108630. private _onBeforeDrawObserver;
  108631. /**
  108632. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  108633. */
  108634. set onBeforeDraw(callback: () => void);
  108635. get hasInstances(): boolean;
  108636. get hasThinInstances(): boolean;
  108637. /**
  108638. * Gets the delay loading state of the mesh (when delay loading is turned on)
  108639. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  108640. */
  108641. delayLoadState: number;
  108642. /**
  108643. * Gets the list of instances created from this mesh
  108644. * it is not supposed to be modified manually.
  108645. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  108646. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108647. */
  108648. instances: InstancedMesh[];
  108649. /**
  108650. * Gets the file containing delay loading data for this mesh
  108651. */
  108652. delayLoadingFile: string;
  108653. /** @hidden */
  108654. _binaryInfo: any;
  108655. /**
  108656. * User defined function used to change how LOD level selection is done
  108657. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108658. */
  108659. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  108660. /**
  108661. * Gets or sets the morph target manager
  108662. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  108663. */
  108664. get morphTargetManager(): Nullable<MorphTargetManager>;
  108665. set morphTargetManager(value: Nullable<MorphTargetManager>);
  108666. /** @hidden */
  108667. _creationDataStorage: Nullable<_CreationDataStorage>;
  108668. /** @hidden */
  108669. _geometry: Nullable<Geometry>;
  108670. /** @hidden */
  108671. _delayInfo: Array<string>;
  108672. /** @hidden */
  108673. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  108674. /** @hidden */
  108675. _instanceDataStorage: _InstanceDataStorage;
  108676. /** @hidden */
  108677. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  108678. private _effectiveMaterial;
  108679. /** @hidden */
  108680. _shouldGenerateFlatShading: boolean;
  108681. /** @hidden */
  108682. _originalBuilderSideOrientation: number;
  108683. /**
  108684. * Use this property to change the original side orientation defined at construction time
  108685. */
  108686. overrideMaterialSideOrientation: Nullable<number>;
  108687. /**
  108688. * Gets the source mesh (the one used to clone this one from)
  108689. */
  108690. get source(): Nullable<Mesh>;
  108691. /**
  108692. * Gets the list of clones of this mesh
  108693. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  108694. * Note that useClonedMeshMap=true is the default setting
  108695. */
  108696. get cloneMeshMap(): Nullable<{
  108697. [id: string]: Mesh | undefined;
  108698. }>;
  108699. /**
  108700. * Gets or sets a boolean indicating that this mesh does not use index buffer
  108701. */
  108702. get isUnIndexed(): boolean;
  108703. set isUnIndexed(value: boolean);
  108704. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  108705. get worldMatrixInstancedBuffer(): Float32Array;
  108706. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  108707. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  108708. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  108709. /**
  108710. * @constructor
  108711. * @param name The value used by scene.getMeshByName() to do a lookup.
  108712. * @param scene The scene to add this mesh to.
  108713. * @param parent The parent of this mesh, if it has one
  108714. * @param source An optional Mesh from which geometry is shared, cloned.
  108715. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  108716. * When false, achieved by calling a clone(), also passing False.
  108717. * This will make creation of children, recursive.
  108718. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  108719. */
  108720. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  108721. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  108722. doNotInstantiate: boolean;
  108723. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  108724. /**
  108725. * Gets the class name
  108726. * @returns the string "Mesh".
  108727. */
  108728. getClassName(): string;
  108729. /** @hidden */
  108730. get _isMesh(): boolean;
  108731. /**
  108732. * Returns a description of this mesh
  108733. * @param fullDetails define if full details about this mesh must be used
  108734. * @returns a descriptive string representing this mesh
  108735. */
  108736. toString(fullDetails?: boolean): string;
  108737. /** @hidden */
  108738. _unBindEffect(): void;
  108739. /**
  108740. * Gets a boolean indicating if this mesh has LOD
  108741. */
  108742. get hasLODLevels(): boolean;
  108743. /**
  108744. * Gets the list of MeshLODLevel associated with the current mesh
  108745. * @returns an array of MeshLODLevel
  108746. */
  108747. getLODLevels(): MeshLODLevel[];
  108748. private _sortLODLevels;
  108749. /**
  108750. * Add a mesh as LOD level triggered at the given distance.
  108751. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108752. * @param distance The distance from the center of the object to show this level
  108753. * @param mesh The mesh to be added as LOD level (can be null)
  108754. * @return This mesh (for chaining)
  108755. */
  108756. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  108757. /**
  108758. * Returns the LOD level mesh at the passed distance or null if not found.
  108759. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108760. * @param distance The distance from the center of the object to show this level
  108761. * @returns a Mesh or `null`
  108762. */
  108763. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  108764. /**
  108765. * Remove a mesh from the LOD array
  108766. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108767. * @param mesh defines the mesh to be removed
  108768. * @return This mesh (for chaining)
  108769. */
  108770. removeLODLevel(mesh: Mesh): Mesh;
  108771. /**
  108772. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  108773. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108774. * @param camera defines the camera to use to compute distance
  108775. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  108776. * @return This mesh (for chaining)
  108777. */
  108778. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  108779. /**
  108780. * Gets the mesh internal Geometry object
  108781. */
  108782. get geometry(): Nullable<Geometry>;
  108783. /**
  108784. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  108785. * @returns the total number of vertices
  108786. */
  108787. getTotalVertices(): number;
  108788. /**
  108789. * Returns the content of an associated vertex buffer
  108790. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108791. * - VertexBuffer.PositionKind
  108792. * - VertexBuffer.UVKind
  108793. * - VertexBuffer.UV2Kind
  108794. * - VertexBuffer.UV3Kind
  108795. * - VertexBuffer.UV4Kind
  108796. * - VertexBuffer.UV5Kind
  108797. * - VertexBuffer.UV6Kind
  108798. * - VertexBuffer.ColorKind
  108799. * - VertexBuffer.MatricesIndicesKind
  108800. * - VertexBuffer.MatricesIndicesExtraKind
  108801. * - VertexBuffer.MatricesWeightsKind
  108802. * - VertexBuffer.MatricesWeightsExtraKind
  108803. * @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
  108804. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  108805. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  108806. */
  108807. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  108808. /**
  108809. * Returns the mesh VertexBuffer object from the requested `kind`
  108810. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108811. * - VertexBuffer.PositionKind
  108812. * - VertexBuffer.NormalKind
  108813. * - VertexBuffer.UVKind
  108814. * - VertexBuffer.UV2Kind
  108815. * - VertexBuffer.UV3Kind
  108816. * - VertexBuffer.UV4Kind
  108817. * - VertexBuffer.UV5Kind
  108818. * - VertexBuffer.UV6Kind
  108819. * - VertexBuffer.ColorKind
  108820. * - VertexBuffer.MatricesIndicesKind
  108821. * - VertexBuffer.MatricesIndicesExtraKind
  108822. * - VertexBuffer.MatricesWeightsKind
  108823. * - VertexBuffer.MatricesWeightsExtraKind
  108824. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  108825. */
  108826. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  108827. /**
  108828. * Tests if a specific vertex buffer is associated with this mesh
  108829. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108830. * - VertexBuffer.PositionKind
  108831. * - VertexBuffer.NormalKind
  108832. * - VertexBuffer.UVKind
  108833. * - VertexBuffer.UV2Kind
  108834. * - VertexBuffer.UV3Kind
  108835. * - VertexBuffer.UV4Kind
  108836. * - VertexBuffer.UV5Kind
  108837. * - VertexBuffer.UV6Kind
  108838. * - VertexBuffer.ColorKind
  108839. * - VertexBuffer.MatricesIndicesKind
  108840. * - VertexBuffer.MatricesIndicesExtraKind
  108841. * - VertexBuffer.MatricesWeightsKind
  108842. * - VertexBuffer.MatricesWeightsExtraKind
  108843. * @returns a boolean
  108844. */
  108845. isVerticesDataPresent(kind: string): boolean;
  108846. /**
  108847. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  108848. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108849. * - VertexBuffer.PositionKind
  108850. * - VertexBuffer.UVKind
  108851. * - VertexBuffer.UV2Kind
  108852. * - VertexBuffer.UV3Kind
  108853. * - VertexBuffer.UV4Kind
  108854. * - VertexBuffer.UV5Kind
  108855. * - VertexBuffer.UV6Kind
  108856. * - VertexBuffer.ColorKind
  108857. * - VertexBuffer.MatricesIndicesKind
  108858. * - VertexBuffer.MatricesIndicesExtraKind
  108859. * - VertexBuffer.MatricesWeightsKind
  108860. * - VertexBuffer.MatricesWeightsExtraKind
  108861. * @returns a boolean
  108862. */
  108863. isVertexBufferUpdatable(kind: string): boolean;
  108864. /**
  108865. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  108866. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108867. * - VertexBuffer.PositionKind
  108868. * - VertexBuffer.NormalKind
  108869. * - VertexBuffer.UVKind
  108870. * - VertexBuffer.UV2Kind
  108871. * - VertexBuffer.UV3Kind
  108872. * - VertexBuffer.UV4Kind
  108873. * - VertexBuffer.UV5Kind
  108874. * - VertexBuffer.UV6Kind
  108875. * - VertexBuffer.ColorKind
  108876. * - VertexBuffer.MatricesIndicesKind
  108877. * - VertexBuffer.MatricesIndicesExtraKind
  108878. * - VertexBuffer.MatricesWeightsKind
  108879. * - VertexBuffer.MatricesWeightsExtraKind
  108880. * @returns an array of strings
  108881. */
  108882. getVerticesDataKinds(): string[];
  108883. /**
  108884. * Returns a positive integer : the total number of indices in this mesh geometry.
  108885. * @returns the numner of indices or zero if the mesh has no geometry.
  108886. */
  108887. getTotalIndices(): number;
  108888. /**
  108889. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  108890. * @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.
  108891. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  108892. * @returns the indices array or an empty array if the mesh has no geometry
  108893. */
  108894. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  108895. get isBlocked(): boolean;
  108896. /**
  108897. * Determine if the current mesh is ready to be rendered
  108898. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  108899. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  108900. * @returns true if all associated assets are ready (material, textures, shaders)
  108901. */
  108902. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  108903. /**
  108904. * 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.
  108905. */
  108906. get areNormalsFrozen(): boolean;
  108907. /**
  108908. * 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.
  108909. * @returns the current mesh
  108910. */
  108911. freezeNormals(): Mesh;
  108912. /**
  108913. * 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
  108914. * @returns the current mesh
  108915. */
  108916. unfreezeNormals(): Mesh;
  108917. /**
  108918. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  108919. */
  108920. set overridenInstanceCount(count: number);
  108921. /** @hidden */
  108922. _preActivate(): Mesh;
  108923. /** @hidden */
  108924. _preActivateForIntermediateRendering(renderId: number): Mesh;
  108925. /** @hidden */
  108926. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  108927. protected _afterComputeWorldMatrix(): void;
  108928. /** @hidden */
  108929. _postActivate(): void;
  108930. /**
  108931. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108932. * This means the mesh underlying bounding box and sphere are recomputed.
  108933. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108934. * @returns the current mesh
  108935. */
  108936. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  108937. /** @hidden */
  108938. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  108939. /**
  108940. * This function will subdivide the mesh into multiple submeshes
  108941. * @param count defines the expected number of submeshes
  108942. */
  108943. subdivide(count: number): void;
  108944. /**
  108945. * Copy a FloatArray into a specific associated vertex buffer
  108946. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108947. * - VertexBuffer.PositionKind
  108948. * - VertexBuffer.UVKind
  108949. * - VertexBuffer.UV2Kind
  108950. * - VertexBuffer.UV3Kind
  108951. * - VertexBuffer.UV4Kind
  108952. * - VertexBuffer.UV5Kind
  108953. * - VertexBuffer.UV6Kind
  108954. * - VertexBuffer.ColorKind
  108955. * - VertexBuffer.MatricesIndicesKind
  108956. * - VertexBuffer.MatricesIndicesExtraKind
  108957. * - VertexBuffer.MatricesWeightsKind
  108958. * - VertexBuffer.MatricesWeightsExtraKind
  108959. * @param data defines the data source
  108960. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108961. * @param stride defines the data stride size (can be null)
  108962. * @returns the current mesh
  108963. */
  108964. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108965. /**
  108966. * Delete a vertex buffer associated with this mesh
  108967. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  108968. * - VertexBuffer.PositionKind
  108969. * - VertexBuffer.UVKind
  108970. * - VertexBuffer.UV2Kind
  108971. * - VertexBuffer.UV3Kind
  108972. * - VertexBuffer.UV4Kind
  108973. * - VertexBuffer.UV5Kind
  108974. * - VertexBuffer.UV6Kind
  108975. * - VertexBuffer.ColorKind
  108976. * - VertexBuffer.MatricesIndicesKind
  108977. * - VertexBuffer.MatricesIndicesExtraKind
  108978. * - VertexBuffer.MatricesWeightsKind
  108979. * - VertexBuffer.MatricesWeightsExtraKind
  108980. */
  108981. removeVerticesData(kind: string): void;
  108982. /**
  108983. * Flags an associated vertex buffer as updatable
  108984. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  108985. * - VertexBuffer.PositionKind
  108986. * - VertexBuffer.UVKind
  108987. * - VertexBuffer.UV2Kind
  108988. * - VertexBuffer.UV3Kind
  108989. * - VertexBuffer.UV4Kind
  108990. * - VertexBuffer.UV5Kind
  108991. * - VertexBuffer.UV6Kind
  108992. * - VertexBuffer.ColorKind
  108993. * - VertexBuffer.MatricesIndicesKind
  108994. * - VertexBuffer.MatricesIndicesExtraKind
  108995. * - VertexBuffer.MatricesWeightsKind
  108996. * - VertexBuffer.MatricesWeightsExtraKind
  108997. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108998. */
  108999. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  109000. /**
  109001. * Sets the mesh global Vertex Buffer
  109002. * @param buffer defines the buffer to use
  109003. * @returns the current mesh
  109004. */
  109005. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  109006. /**
  109007. * Update a specific associated vertex buffer
  109008. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  109009. * - VertexBuffer.PositionKind
  109010. * - VertexBuffer.UVKind
  109011. * - VertexBuffer.UV2Kind
  109012. * - VertexBuffer.UV3Kind
  109013. * - VertexBuffer.UV4Kind
  109014. * - VertexBuffer.UV5Kind
  109015. * - VertexBuffer.UV6Kind
  109016. * - VertexBuffer.ColorKind
  109017. * - VertexBuffer.MatricesIndicesKind
  109018. * - VertexBuffer.MatricesIndicesExtraKind
  109019. * - VertexBuffer.MatricesWeightsKind
  109020. * - VertexBuffer.MatricesWeightsExtraKind
  109021. * @param data defines the data source
  109022. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  109023. * @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)
  109024. * @returns the current mesh
  109025. */
  109026. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  109027. /**
  109028. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  109029. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  109030. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  109031. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  109032. * @returns the current mesh
  109033. */
  109034. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  109035. /**
  109036. * Creates a un-shared specific occurence of the geometry for the mesh.
  109037. * @returns the current mesh
  109038. */
  109039. makeGeometryUnique(): Mesh;
  109040. /**
  109041. * Set the index buffer of this mesh
  109042. * @param indices defines the source data
  109043. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  109044. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  109045. * @returns the current mesh
  109046. */
  109047. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  109048. /**
  109049. * Update the current index buffer
  109050. * @param indices defines the source data
  109051. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  109052. * @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)
  109053. * @returns the current mesh
  109054. */
  109055. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  109056. /**
  109057. * Invert the geometry to move from a right handed system to a left handed one.
  109058. * @returns the current mesh
  109059. */
  109060. toLeftHanded(): Mesh;
  109061. /** @hidden */
  109062. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  109063. /** @hidden */
  109064. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  109065. /**
  109066. * Registers for this mesh a javascript function called just before the rendering process
  109067. * @param func defines the function to call before rendering this mesh
  109068. * @returns the current mesh
  109069. */
  109070. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  109071. /**
  109072. * Disposes a previously registered javascript function called before the rendering
  109073. * @param func defines the function to remove
  109074. * @returns the current mesh
  109075. */
  109076. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  109077. /**
  109078. * Registers for this mesh a javascript function called just after the rendering is complete
  109079. * @param func defines the function to call after rendering this mesh
  109080. * @returns the current mesh
  109081. */
  109082. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  109083. /**
  109084. * Disposes a previously registered javascript function called after the rendering.
  109085. * @param func defines the function to remove
  109086. * @returns the current mesh
  109087. */
  109088. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  109089. /** @hidden */
  109090. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  109091. /** @hidden */
  109092. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  109093. /** @hidden */
  109094. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  109095. /** @hidden */
  109096. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  109097. /** @hidden */
  109098. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  109099. /** @hidden */
  109100. _rebuild(): void;
  109101. /** @hidden */
  109102. _freeze(): void;
  109103. /** @hidden */
  109104. _unFreeze(): void;
  109105. /**
  109106. * 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
  109107. * @param subMesh defines the subMesh to render
  109108. * @param enableAlphaMode defines if alpha mode can be changed
  109109. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  109110. * @returns the current mesh
  109111. */
  109112. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  109113. private _onBeforeDraw;
  109114. /**
  109115. * Renormalize the mesh and patch it up if there are no weights
  109116. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  109117. * However in the case of zero weights then we set just a single influence to 1.
  109118. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  109119. */
  109120. cleanMatrixWeights(): void;
  109121. private normalizeSkinFourWeights;
  109122. private normalizeSkinWeightsAndExtra;
  109123. /**
  109124. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  109125. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  109126. * the user know there was an issue with importing the mesh
  109127. * @returns a validation object with skinned, valid and report string
  109128. */
  109129. validateSkinning(): {
  109130. skinned: boolean;
  109131. valid: boolean;
  109132. report: string;
  109133. };
  109134. /** @hidden */
  109135. _checkDelayState(): Mesh;
  109136. private _queueLoad;
  109137. /**
  109138. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  109139. * A mesh is in the frustum if its bounding box intersects the frustum
  109140. * @param frustumPlanes defines the frustum to test
  109141. * @returns true if the mesh is in the frustum planes
  109142. */
  109143. isInFrustum(frustumPlanes: Plane[]): boolean;
  109144. /**
  109145. * Sets the mesh material by the material or multiMaterial `id` property
  109146. * @param id is a string identifying the material or the multiMaterial
  109147. * @returns the current mesh
  109148. */
  109149. setMaterialByID(id: string): Mesh;
  109150. /**
  109151. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  109152. * @returns an array of IAnimatable
  109153. */
  109154. getAnimatables(): IAnimatable[];
  109155. /**
  109156. * Modifies the mesh geometry according to the passed transformation matrix.
  109157. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  109158. * The mesh normals are modified using the same transformation.
  109159. * Note that, under the hood, this method sets a new VertexBuffer each call.
  109160. * @param transform defines the transform matrix to use
  109161. * @see https://doc.babylonjs.com/resources/baking_transformations
  109162. * @returns the current mesh
  109163. */
  109164. bakeTransformIntoVertices(transform: Matrix): Mesh;
  109165. /**
  109166. * Modifies the mesh geometry according to its own current World Matrix.
  109167. * The mesh World Matrix is then reset.
  109168. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  109169. * Note that, under the hood, this method sets a new VertexBuffer each call.
  109170. * @see https://doc.babylonjs.com/resources/baking_transformations
  109171. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  109172. * @returns the current mesh
  109173. */
  109174. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  109175. /** @hidden */
  109176. get _positions(): Nullable<Vector3[]>;
  109177. /** @hidden */
  109178. _resetPointsArrayCache(): Mesh;
  109179. /** @hidden */
  109180. _generatePointsArray(): boolean;
  109181. /**
  109182. * Returns a new Mesh object generated from the current mesh properties.
  109183. * This method must not get confused with createInstance()
  109184. * @param name is a string, the name given to the new mesh
  109185. * @param newParent can be any Node object (default `null`)
  109186. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  109187. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  109188. * @returns a new mesh
  109189. */
  109190. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  109191. /**
  109192. * Releases resources associated with this mesh.
  109193. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109194. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109195. */
  109196. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109197. /** @hidden */
  109198. _disposeInstanceSpecificData(): void;
  109199. /** @hidden */
  109200. _disposeThinInstanceSpecificData(): void;
  109201. /**
  109202. * Modifies the mesh geometry according to a displacement map.
  109203. * 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.
  109204. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  109205. * @param url is a string, the URL from the image file is to be downloaded.
  109206. * @param minHeight is the lower limit of the displacement.
  109207. * @param maxHeight is the upper limit of the displacement.
  109208. * @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.
  109209. * @param uvOffset is an optional vector2 used to offset UV.
  109210. * @param uvScale is an optional vector2 used to scale UV.
  109211. * @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.
  109212. * @returns the Mesh.
  109213. */
  109214. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  109215. /**
  109216. * Modifies the mesh geometry according to a displacementMap buffer.
  109217. * 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.
  109218. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  109219. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  109220. * @param heightMapWidth is the width of the buffer image.
  109221. * @param heightMapHeight is the height of the buffer image.
  109222. * @param minHeight is the lower limit of the displacement.
  109223. * @param maxHeight is the upper limit of the displacement.
  109224. * @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.
  109225. * @param uvOffset is an optional vector2 used to offset UV.
  109226. * @param uvScale is an optional vector2 used to scale UV.
  109227. * @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.
  109228. * @returns the Mesh.
  109229. */
  109230. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  109231. /**
  109232. * Modify the mesh to get a flat shading rendering.
  109233. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  109234. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  109235. * @returns current mesh
  109236. */
  109237. convertToFlatShadedMesh(): Mesh;
  109238. /**
  109239. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  109240. * In other words, more vertices, no more indices and a single bigger VBO.
  109241. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  109242. * @returns current mesh
  109243. */
  109244. convertToUnIndexedMesh(): Mesh;
  109245. /**
  109246. * Inverses facet orientations.
  109247. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109248. * @param flipNormals will also inverts the normals
  109249. * @returns current mesh
  109250. */
  109251. flipFaces(flipNormals?: boolean): Mesh;
  109252. /**
  109253. * Increase the number of facets and hence vertices in a mesh
  109254. * Vertex normals are interpolated from existing vertex normals
  109255. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109256. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  109257. */
  109258. increaseVertices(numberPerEdge: number): void;
  109259. /**
  109260. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  109261. * This will undo any application of covertToFlatShadedMesh
  109262. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109263. */
  109264. forceSharedVertices(): void;
  109265. /** @hidden */
  109266. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  109267. /** @hidden */
  109268. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  109269. /**
  109270. * Creates a new InstancedMesh object from the mesh model.
  109271. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  109272. * @param name defines the name of the new instance
  109273. * @returns a new InstancedMesh
  109274. */
  109275. createInstance(name: string): InstancedMesh;
  109276. /**
  109277. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  109278. * After this call, all the mesh instances have the same submeshes than the current mesh.
  109279. * @returns the current mesh
  109280. */
  109281. synchronizeInstances(): Mesh;
  109282. /**
  109283. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  109284. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  109285. * This should be used together with the simplification to avoid disappearing triangles.
  109286. * @param successCallback an optional success callback to be called after the optimization finished.
  109287. * @returns the current mesh
  109288. */
  109289. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  109290. /**
  109291. * Serialize current mesh
  109292. * @param serializationObject defines the object which will receive the serialization data
  109293. */
  109294. serialize(serializationObject: any): void;
  109295. /** @hidden */
  109296. _syncGeometryWithMorphTargetManager(): void;
  109297. /** @hidden */
  109298. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  109299. /**
  109300. * Returns a new Mesh object parsed from the source provided.
  109301. * @param parsedMesh is the source
  109302. * @param scene defines the hosting scene
  109303. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  109304. * @returns a new Mesh
  109305. */
  109306. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  109307. /**
  109308. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  109309. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109310. * @param name defines the name of the mesh to create
  109311. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  109312. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  109313. * @param closePath creates a seam between the first and the last points of each path of the path array
  109314. * @param offset is taken in account only if the `pathArray` is containing a single path
  109315. * @param scene defines the hosting scene
  109316. * @param updatable defines if the mesh must be flagged as updatable
  109317. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109318. * @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)
  109319. * @returns a new Mesh
  109320. */
  109321. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109322. /**
  109323. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  109324. * @param name defines the name of the mesh to create
  109325. * @param radius sets the radius size (float) of the polygon (default 0.5)
  109326. * @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
  109327. * @param scene defines the hosting scene
  109328. * @param updatable defines if the mesh must be flagged as updatable
  109329. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109330. * @returns a new Mesh
  109331. */
  109332. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  109333. /**
  109334. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  109335. * @param name defines the name of the mesh to create
  109336. * @param size sets the size (float) of each box side (default 1)
  109337. * @param scene defines the hosting scene
  109338. * @param updatable defines if the mesh must be flagged as updatable
  109339. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109340. * @returns a new Mesh
  109341. */
  109342. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  109343. /**
  109344. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  109345. * @param name defines the name of the mesh to create
  109346. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  109347. * @param diameter sets the diameter size (float) of the sphere (default 1)
  109348. * @param scene defines the hosting scene
  109349. * @param updatable defines if the mesh must be flagged as updatable
  109350. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109351. * @returns a new Mesh
  109352. */
  109353. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109354. /**
  109355. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  109356. * @param name defines the name of the mesh to create
  109357. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  109358. * @param diameter sets the diameter size (float) of the sphere (default 1)
  109359. * @param scene defines the hosting scene
  109360. * @returns a new Mesh
  109361. */
  109362. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  109363. /**
  109364. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  109365. * @param name defines the name of the mesh to create
  109366. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  109367. * @param diameterTop set the top cap diameter (floats, default 1)
  109368. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  109369. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  109370. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  109371. * @param scene defines the hosting scene
  109372. * @param updatable defines if the mesh must be flagged as updatable
  109373. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109374. * @returns a new Mesh
  109375. */
  109376. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  109377. /**
  109378. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  109379. * @param name defines the name of the mesh to create
  109380. * @param diameter sets the diameter size (float) of the torus (default 1)
  109381. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  109382. * @param tessellation sets the number of torus sides (postive integer, default 16)
  109383. * @param scene defines the hosting scene
  109384. * @param updatable defines if the mesh must be flagged as updatable
  109385. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109386. * @returns a new Mesh
  109387. */
  109388. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109389. /**
  109390. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  109391. * @param name defines the name of the mesh to create
  109392. * @param radius sets the global radius size (float) of the torus knot (default 2)
  109393. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  109394. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  109395. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  109396. * @param p the number of windings on X axis (positive integers, default 2)
  109397. * @param q the number of windings on Y axis (positive integers, default 3)
  109398. * @param scene defines the hosting scene
  109399. * @param updatable defines if the mesh must be flagged as updatable
  109400. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109401. * @returns a new Mesh
  109402. */
  109403. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109404. /**
  109405. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  109406. * @param name defines the name of the mesh to create
  109407. * @param points is an array successive Vector3
  109408. * @param scene defines the hosting scene
  109409. * @param updatable defines if the mesh must be flagged as updatable
  109410. * @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).
  109411. * @returns a new Mesh
  109412. */
  109413. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  109414. /**
  109415. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  109416. * @param name defines the name of the mesh to create
  109417. * @param points is an array successive Vector3
  109418. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  109419. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109420. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  109421. * @param scene defines the hosting scene
  109422. * @param updatable defines if the mesh must be flagged as updatable
  109423. * @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)
  109424. * @returns a new Mesh
  109425. */
  109426. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  109427. /**
  109428. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  109429. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  109430. * 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.
  109431. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109432. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109433. * Remember you can only change the shape positions, not their number when updating a polygon.
  109434. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109435. * @param name defines the name of the mesh to create
  109436. * @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
  109437. * @param scene defines the hosting scene
  109438. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109439. * @param updatable defines if the mesh must be flagged as updatable
  109440. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109441. * @param earcutInjection can be used to inject your own earcut reference
  109442. * @returns a new Mesh
  109443. */
  109444. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109445. /**
  109446. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  109447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  109448. * @param name defines the name of the mesh to create
  109449. * @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
  109450. * @param depth defines the height of extrusion
  109451. * @param scene defines the hosting scene
  109452. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109453. * @param updatable defines if the mesh must be flagged as updatable
  109454. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109455. * @param earcutInjection can be used to inject your own earcut reference
  109456. * @returns a new Mesh
  109457. */
  109458. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109459. /**
  109460. * Creates an extruded shape mesh.
  109461. * 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
  109462. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109463. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109464. * @param name defines the name of the mesh to create
  109465. * @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
  109466. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109467. * @param scale is the value to scale the shape
  109468. * @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
  109469. * @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
  109470. * @param scene defines the hosting scene
  109471. * @param updatable defines if the mesh must be flagged as updatable
  109472. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109473. * @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)
  109474. * @returns a new Mesh
  109475. */
  109476. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109477. /**
  109478. * Creates an custom extruded shape mesh.
  109479. * The custom extrusion is a parametric shape.
  109480. * It has no predefined shape. Its final shape will depend on the input parameters.
  109481. * Please consider using the same method from the MeshBuilder class instead
  109482. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109483. * @param name defines the name of the mesh to create
  109484. * @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
  109485. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109486. * @param scaleFunction is a custom Javascript function called on each path point
  109487. * @param rotationFunction is a custom Javascript function called on each path point
  109488. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109489. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  109490. * @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
  109491. * @param scene defines the hosting scene
  109492. * @param updatable defines if the mesh must be flagged as updatable
  109493. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109494. * @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)
  109495. * @returns a new Mesh
  109496. */
  109497. 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;
  109498. /**
  109499. * Creates lathe mesh.
  109500. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  109501. * Please consider using the same method from the MeshBuilder class instead
  109502. * @param name defines the name of the mesh to create
  109503. * @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
  109504. * @param radius is the radius value of the lathe
  109505. * @param tessellation is the side number of the lathe.
  109506. * @param scene defines the hosting scene
  109507. * @param updatable defines if the mesh must be flagged as updatable
  109508. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109509. * @returns a new Mesh
  109510. */
  109511. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109512. /**
  109513. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  109514. * @param name defines the name of the mesh to create
  109515. * @param size sets the size (float) of both sides of the plane at once (default 1)
  109516. * @param scene defines the hosting scene
  109517. * @param updatable defines if the mesh must be flagged as updatable
  109518. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109519. * @returns a new Mesh
  109520. */
  109521. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109522. /**
  109523. * Creates a ground mesh.
  109524. * Please consider using the same method from the MeshBuilder class instead
  109525. * @param name defines the name of the mesh to create
  109526. * @param width set the width of the ground
  109527. * @param height set the height of the ground
  109528. * @param subdivisions sets the number of subdivisions per side
  109529. * @param scene defines the hosting scene
  109530. * @param updatable defines if the mesh must be flagged as updatable
  109531. * @returns a new Mesh
  109532. */
  109533. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  109534. /**
  109535. * Creates a tiled ground mesh.
  109536. * Please consider using the same method from the MeshBuilder class instead
  109537. * @param name defines the name of the mesh to create
  109538. * @param xmin set the ground minimum X coordinate
  109539. * @param zmin set the ground minimum Y coordinate
  109540. * @param xmax set the ground maximum X coordinate
  109541. * @param zmax set the ground maximum Z coordinate
  109542. * @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
  109543. * @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
  109544. * @param scene defines the hosting scene
  109545. * @param updatable defines if the mesh must be flagged as updatable
  109546. * @returns a new Mesh
  109547. */
  109548. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  109549. w: number;
  109550. h: number;
  109551. }, precision: {
  109552. w: number;
  109553. h: number;
  109554. }, scene: Scene, updatable?: boolean): Mesh;
  109555. /**
  109556. * Creates a ground mesh from a height map.
  109557. * Please consider using the same method from the MeshBuilder class instead
  109558. * @see https://doc.babylonjs.com/babylon101/height_map
  109559. * @param name defines the name of the mesh to create
  109560. * @param url sets the URL of the height map image resource
  109561. * @param width set the ground width size
  109562. * @param height set the ground height size
  109563. * @param subdivisions sets the number of subdivision per side
  109564. * @param minHeight is the minimum altitude on the ground
  109565. * @param maxHeight is the maximum altitude on the ground
  109566. * @param scene defines the hosting scene
  109567. * @param updatable defines if the mesh must be flagged as updatable
  109568. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  109569. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109570. * @returns a new Mesh
  109571. */
  109572. 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;
  109573. /**
  109574. * Creates a tube mesh.
  109575. * The tube is a parametric shape.
  109576. * It has no predefined shape. Its final shape will depend on the input parameters.
  109577. * Please consider using the same method from the MeshBuilder class instead
  109578. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109579. * @param name defines the name of the mesh to create
  109580. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  109581. * @param radius sets the tube radius size
  109582. * @param tessellation is the number of sides on the tubular surface
  109583. * @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
  109584. * @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
  109585. * @param scene defines the hosting scene
  109586. * @param updatable defines if the mesh must be flagged as updatable
  109587. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109588. * @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)
  109589. * @returns a new Mesh
  109590. */
  109591. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  109592. (i: number, distance: number): number;
  109593. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109594. /**
  109595. * Creates a polyhedron mesh.
  109596. * Please consider using the same method from the MeshBuilder class instead.
  109597. * * 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
  109598. * * The parameter `size` (positive float, default 1) sets the polygon size
  109599. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109600. * * 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`
  109601. * * 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
  109602. * * 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)`)
  109603. * * 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
  109604. * * 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
  109605. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109608. * @param name defines the name of the mesh to create
  109609. * @param options defines the options used to create the mesh
  109610. * @param scene defines the hosting scene
  109611. * @returns a new Mesh
  109612. */
  109613. static CreatePolyhedron(name: string, options: {
  109614. type?: number;
  109615. size?: number;
  109616. sizeX?: number;
  109617. sizeY?: number;
  109618. sizeZ?: number;
  109619. custom?: any;
  109620. faceUV?: Vector4[];
  109621. faceColors?: Color4[];
  109622. updatable?: boolean;
  109623. sideOrientation?: number;
  109624. }, scene: Scene): Mesh;
  109625. /**
  109626. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109627. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109628. * * 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`)
  109629. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109630. * * 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
  109631. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109634. * @param name defines the name of the mesh
  109635. * @param options defines the options used to create the mesh
  109636. * @param scene defines the hosting scene
  109637. * @returns a new Mesh
  109638. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109639. */
  109640. static CreateIcoSphere(name: string, options: {
  109641. radius?: number;
  109642. flat?: boolean;
  109643. subdivisions?: number;
  109644. sideOrientation?: number;
  109645. updatable?: boolean;
  109646. }, scene: Scene): Mesh;
  109647. /**
  109648. * Creates a decal mesh.
  109649. * Please consider using the same method from the MeshBuilder class instead.
  109650. * A decal is a mesh usually applied as a model onto the surface of another mesh
  109651. * @param name defines the name of the mesh
  109652. * @param sourceMesh defines the mesh receiving the decal
  109653. * @param position sets the position of the decal in world coordinates
  109654. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  109655. * @param size sets the decal scaling
  109656. * @param angle sets the angle to rotate the decal
  109657. * @returns a new Mesh
  109658. */
  109659. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  109660. /** Creates a Capsule Mesh
  109661. * @param name defines the name of the mesh.
  109662. * @param options the constructors options used to shape the mesh.
  109663. * @param scene defines the scene the mesh is scoped to.
  109664. * @returns the capsule mesh
  109665. * @see https://doc.babylonjs.com/how_to/capsule_shape
  109666. */
  109667. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  109668. /**
  109669. * Prepare internal position array for software CPU skinning
  109670. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  109671. */
  109672. setPositionsForCPUSkinning(): Float32Array;
  109673. /**
  109674. * Prepare internal normal array for software CPU skinning
  109675. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  109676. */
  109677. setNormalsForCPUSkinning(): Float32Array;
  109678. /**
  109679. * Updates the vertex buffer by applying transformation from the bones
  109680. * @param skeleton defines the skeleton to apply to current mesh
  109681. * @returns the current mesh
  109682. */
  109683. applySkeleton(skeleton: Skeleton): Mesh;
  109684. /**
  109685. * 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
  109686. * @param meshes defines the list of meshes to scan
  109687. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  109688. */
  109689. static MinMax(meshes: AbstractMesh[]): {
  109690. min: Vector3;
  109691. max: Vector3;
  109692. };
  109693. /**
  109694. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  109695. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  109696. * @returns a vector3
  109697. */
  109698. static Center(meshesOrMinMaxVector: {
  109699. min: Vector3;
  109700. max: Vector3;
  109701. } | AbstractMesh[]): Vector3;
  109702. /**
  109703. * Merge the array of meshes into a single mesh for performance reasons.
  109704. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  109705. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  109706. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  109707. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  109708. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  109709. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  109710. * @returns a new mesh
  109711. */
  109712. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  109713. /** @hidden */
  109714. addInstance(instance: InstancedMesh): void;
  109715. /** @hidden */
  109716. removeInstance(instance: InstancedMesh): void;
  109717. }
  109718. }
  109719. declare module BABYLON {
  109720. /**
  109721. * This is the base class of all the camera used in the application.
  109722. * @see https://doc.babylonjs.com/features/cameras
  109723. */
  109724. export class Camera extends Node {
  109725. /** @hidden */
  109726. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  109727. /**
  109728. * This is the default projection mode used by the cameras.
  109729. * It helps recreating a feeling of perspective and better appreciate depth.
  109730. * This is the best way to simulate real life cameras.
  109731. */
  109732. static readonly PERSPECTIVE_CAMERA: number;
  109733. /**
  109734. * This helps creating camera with an orthographic mode.
  109735. * 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.
  109736. */
  109737. static readonly ORTHOGRAPHIC_CAMERA: number;
  109738. /**
  109739. * This is the default FOV mode for perspective cameras.
  109740. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  109741. */
  109742. static readonly FOVMODE_VERTICAL_FIXED: number;
  109743. /**
  109744. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  109745. */
  109746. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  109747. /**
  109748. * This specifies ther is no need for a camera rig.
  109749. * Basically only one eye is rendered corresponding to the camera.
  109750. */
  109751. static readonly RIG_MODE_NONE: number;
  109752. /**
  109753. * Simulates a camera Rig with one blue eye and one red eye.
  109754. * This can be use with 3d blue and red glasses.
  109755. */
  109756. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  109757. /**
  109758. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  109759. */
  109760. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  109761. /**
  109762. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  109763. */
  109764. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  109765. /**
  109766. * Defines that both eyes of the camera will be rendered over under each other.
  109767. */
  109768. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  109769. /**
  109770. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  109771. */
  109772. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  109773. /**
  109774. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  109775. */
  109776. static readonly RIG_MODE_VR: number;
  109777. /**
  109778. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  109779. */
  109780. static readonly RIG_MODE_WEBVR: number;
  109781. /**
  109782. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  109783. */
  109784. static readonly RIG_MODE_CUSTOM: number;
  109785. /**
  109786. * Defines if by default attaching controls should prevent the default javascript event to continue.
  109787. */
  109788. static ForceAttachControlToAlwaysPreventDefault: boolean;
  109789. /**
  109790. * Define the input manager associated with the camera.
  109791. */
  109792. inputs: CameraInputsManager<Camera>;
  109793. /** @hidden */
  109794. _position: Vector3;
  109795. /**
  109796. * Define the current local position of the camera in the scene
  109797. */
  109798. get position(): Vector3;
  109799. set position(newPosition: Vector3);
  109800. protected _upVector: Vector3;
  109801. /**
  109802. * The vector the camera should consider as up.
  109803. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  109804. */
  109805. set upVector(vec: Vector3);
  109806. get upVector(): Vector3;
  109807. /**
  109808. * Define the current limit on the left side for an orthographic camera
  109809. * In scene unit
  109810. */
  109811. orthoLeft: Nullable<number>;
  109812. /**
  109813. * Define the current limit on the right side for an orthographic camera
  109814. * In scene unit
  109815. */
  109816. orthoRight: Nullable<number>;
  109817. /**
  109818. * Define the current limit on the bottom side for an orthographic camera
  109819. * In scene unit
  109820. */
  109821. orthoBottom: Nullable<number>;
  109822. /**
  109823. * Define the current limit on the top side for an orthographic camera
  109824. * In scene unit
  109825. */
  109826. orthoTop: Nullable<number>;
  109827. /**
  109828. * Field Of View is set in Radians. (default is 0.8)
  109829. */
  109830. fov: number;
  109831. /**
  109832. * Define the minimum distance the camera can see from.
  109833. * This is important to note that the depth buffer are not infinite and the closer it starts
  109834. * the more your scene might encounter depth fighting issue.
  109835. */
  109836. minZ: number;
  109837. /**
  109838. * Define the maximum distance the camera can see to.
  109839. * This is important to note that the depth buffer are not infinite and the further it end
  109840. * the more your scene might encounter depth fighting issue.
  109841. */
  109842. maxZ: number;
  109843. /**
  109844. * Define the default inertia of the camera.
  109845. * This helps giving a smooth feeling to the camera movement.
  109846. */
  109847. inertia: number;
  109848. /**
  109849. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  109850. */
  109851. mode: number;
  109852. /**
  109853. * Define whether the camera is intermediate.
  109854. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  109855. */
  109856. isIntermediate: boolean;
  109857. /**
  109858. * Define the viewport of the camera.
  109859. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  109860. */
  109861. viewport: Viewport;
  109862. /**
  109863. * Restricts the camera to viewing objects with the same layerMask.
  109864. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  109865. */
  109866. layerMask: number;
  109867. /**
  109868. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  109869. */
  109870. fovMode: number;
  109871. /**
  109872. * Rig mode of the camera.
  109873. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  109874. * This is normally controlled byt the camera themselves as internal use.
  109875. */
  109876. cameraRigMode: number;
  109877. /**
  109878. * Defines the distance between both "eyes" in case of a RIG
  109879. */
  109880. interaxialDistance: number;
  109881. /**
  109882. * Defines if stereoscopic rendering is done side by side or over under.
  109883. */
  109884. isStereoscopicSideBySide: boolean;
  109885. /**
  109886. * 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
  109887. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  109888. * else in the scene. (Eg. security camera)
  109889. *
  109890. * 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)
  109891. */
  109892. customRenderTargets: RenderTargetTexture[];
  109893. /**
  109894. * When set, the camera will render to this render target instead of the default canvas
  109895. *
  109896. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  109897. */
  109898. outputRenderTarget: Nullable<RenderTargetTexture>;
  109899. /**
  109900. * Observable triggered when the camera view matrix has changed.
  109901. */
  109902. onViewMatrixChangedObservable: Observable<Camera>;
  109903. /**
  109904. * Observable triggered when the camera Projection matrix has changed.
  109905. */
  109906. onProjectionMatrixChangedObservable: Observable<Camera>;
  109907. /**
  109908. * Observable triggered when the inputs have been processed.
  109909. */
  109910. onAfterCheckInputsObservable: Observable<Camera>;
  109911. /**
  109912. * Observable triggered when reset has been called and applied to the camera.
  109913. */
  109914. onRestoreStateObservable: Observable<Camera>;
  109915. /**
  109916. * Is this camera a part of a rig system?
  109917. */
  109918. isRigCamera: boolean;
  109919. /**
  109920. * If isRigCamera set to true this will be set with the parent camera.
  109921. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  109922. */
  109923. rigParent?: Camera;
  109924. /** @hidden */
  109925. _cameraRigParams: any;
  109926. /** @hidden */
  109927. _rigCameras: Camera[];
  109928. /** @hidden */
  109929. _rigPostProcess: Nullable<PostProcess>;
  109930. protected _webvrViewMatrix: Matrix;
  109931. /** @hidden */
  109932. _skipRendering: boolean;
  109933. /** @hidden */
  109934. _projectionMatrix: Matrix;
  109935. /** @hidden */
  109936. _postProcesses: Nullable<PostProcess>[];
  109937. /** @hidden */
  109938. _activeMeshes: SmartArray<AbstractMesh>;
  109939. protected _globalPosition: Vector3;
  109940. /** @hidden */
  109941. _computedViewMatrix: Matrix;
  109942. private _doNotComputeProjectionMatrix;
  109943. private _transformMatrix;
  109944. private _frustumPlanes;
  109945. private _refreshFrustumPlanes;
  109946. private _storedFov;
  109947. private _stateStored;
  109948. /**
  109949. * Instantiates a new camera object.
  109950. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  109951. * @see https://doc.babylonjs.com/features/cameras
  109952. * @param name Defines the name of the camera in the scene
  109953. * @param position Defines the position of the camera
  109954. * @param scene Defines the scene the camera belongs too
  109955. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  109956. */
  109957. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109958. /**
  109959. * Store current camera state (fov, position, etc..)
  109960. * @returns the camera
  109961. */
  109962. storeState(): Camera;
  109963. /**
  109964. * Restores the camera state values if it has been stored. You must call storeState() first
  109965. */
  109966. protected _restoreStateValues(): boolean;
  109967. /**
  109968. * Restored camera state. You must call storeState() first.
  109969. * @returns true if restored and false otherwise
  109970. */
  109971. restoreState(): boolean;
  109972. /**
  109973. * Gets the class name of the camera.
  109974. * @returns the class name
  109975. */
  109976. getClassName(): string;
  109977. /** @hidden */
  109978. readonly _isCamera: boolean;
  109979. /**
  109980. * Gets a string representation of the camera useful for debug purpose.
  109981. * @param fullDetails Defines that a more verboe level of logging is required
  109982. * @returns the string representation
  109983. */
  109984. toString(fullDetails?: boolean): string;
  109985. /**
  109986. * Gets the current world space position of the camera.
  109987. */
  109988. get globalPosition(): Vector3;
  109989. /**
  109990. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  109991. * @returns the active meshe list
  109992. */
  109993. getActiveMeshes(): SmartArray<AbstractMesh>;
  109994. /**
  109995. * Check whether a mesh is part of the current active mesh list of the camera
  109996. * @param mesh Defines the mesh to check
  109997. * @returns true if active, false otherwise
  109998. */
  109999. isActiveMesh(mesh: Mesh): boolean;
  110000. /**
  110001. * Is this camera ready to be used/rendered
  110002. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  110003. * @return true if the camera is ready
  110004. */
  110005. isReady(completeCheck?: boolean): boolean;
  110006. /** @hidden */
  110007. _initCache(): void;
  110008. /** @hidden */
  110009. _updateCache(ignoreParentClass?: boolean): void;
  110010. /** @hidden */
  110011. _isSynchronized(): boolean;
  110012. /** @hidden */
  110013. _isSynchronizedViewMatrix(): boolean;
  110014. /** @hidden */
  110015. _isSynchronizedProjectionMatrix(): boolean;
  110016. /**
  110017. * Attach the input controls to a specific dom element to get the input from.
  110018. * @param element Defines the element the controls should be listened from
  110019. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110020. */
  110021. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110022. /**
  110023. * Detach the current controls from the specified dom element.
  110024. * @param element Defines the element to stop listening the inputs from
  110025. */
  110026. detachControl(element: HTMLElement): void;
  110027. /**
  110028. * Update the camera state according to the different inputs gathered during the frame.
  110029. */
  110030. update(): void;
  110031. /** @hidden */
  110032. _checkInputs(): void;
  110033. /** @hidden */
  110034. get rigCameras(): Camera[];
  110035. /**
  110036. * Gets the post process used by the rig cameras
  110037. */
  110038. get rigPostProcess(): Nullable<PostProcess>;
  110039. /**
  110040. * Internal, gets the first post proces.
  110041. * @returns the first post process to be run on this camera.
  110042. */
  110043. _getFirstPostProcess(): Nullable<PostProcess>;
  110044. private _cascadePostProcessesToRigCams;
  110045. /**
  110046. * Attach a post process to the camera.
  110047. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  110048. * @param postProcess The post process to attach to the camera
  110049. * @param insertAt The position of the post process in case several of them are in use in the scene
  110050. * @returns the position the post process has been inserted at
  110051. */
  110052. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  110053. /**
  110054. * Detach a post process to the camera.
  110055. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  110056. * @param postProcess The post process to detach from the camera
  110057. */
  110058. detachPostProcess(postProcess: PostProcess): void;
  110059. /**
  110060. * Gets the current world matrix of the camera
  110061. */
  110062. getWorldMatrix(): Matrix;
  110063. /** @hidden */
  110064. _getViewMatrix(): Matrix;
  110065. /**
  110066. * Gets the current view matrix of the camera.
  110067. * @param force forces the camera to recompute the matrix without looking at the cached state
  110068. * @returns the view matrix
  110069. */
  110070. getViewMatrix(force?: boolean): Matrix;
  110071. /**
  110072. * Freeze the projection matrix.
  110073. * It will prevent the cache check of the camera projection compute and can speed up perf
  110074. * if no parameter of the camera are meant to change
  110075. * @param projection Defines manually a projection if necessary
  110076. */
  110077. freezeProjectionMatrix(projection?: Matrix): void;
  110078. /**
  110079. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  110080. */
  110081. unfreezeProjectionMatrix(): void;
  110082. /**
  110083. * Gets the current projection matrix of the camera.
  110084. * @param force forces the camera to recompute the matrix without looking at the cached state
  110085. * @returns the projection matrix
  110086. */
  110087. getProjectionMatrix(force?: boolean): Matrix;
  110088. /**
  110089. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  110090. * @returns a Matrix
  110091. */
  110092. getTransformationMatrix(): Matrix;
  110093. private _updateFrustumPlanes;
  110094. /**
  110095. * Checks if a cullable object (mesh...) is in the camera frustum
  110096. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  110097. * @param target The object to check
  110098. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  110099. * @returns true if the object is in frustum otherwise false
  110100. */
  110101. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  110102. /**
  110103. * Checks if a cullable object (mesh...) is in the camera frustum
  110104. * Unlike isInFrustum this cheks the full bounding box
  110105. * @param target The object to check
  110106. * @returns true if the object is in frustum otherwise false
  110107. */
  110108. isCompletelyInFrustum(target: ICullable): boolean;
  110109. /**
  110110. * Gets a ray in the forward direction from the camera.
  110111. * @param length Defines the length of the ray to create
  110112. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  110113. * @param origin Defines the start point of the ray which defaults to the camera position
  110114. * @returns the forward ray
  110115. */
  110116. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  110117. /**
  110118. * Gets a ray in the forward direction from the camera.
  110119. * @param refRay the ray to (re)use when setting the values
  110120. * @param length Defines the length of the ray to create
  110121. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  110122. * @param origin Defines the start point of the ray which defaults to the camera position
  110123. * @returns the forward ray
  110124. */
  110125. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  110126. /**
  110127. * Releases resources associated with this node.
  110128. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110129. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110130. */
  110131. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110132. /** @hidden */
  110133. _isLeftCamera: boolean;
  110134. /**
  110135. * Gets the left camera of a rig setup in case of Rigged Camera
  110136. */
  110137. get isLeftCamera(): boolean;
  110138. /** @hidden */
  110139. _isRightCamera: boolean;
  110140. /**
  110141. * Gets the right camera of a rig setup in case of Rigged Camera
  110142. */
  110143. get isRightCamera(): boolean;
  110144. /**
  110145. * Gets the left camera of a rig setup in case of Rigged Camera
  110146. */
  110147. get leftCamera(): Nullable<FreeCamera>;
  110148. /**
  110149. * Gets the right camera of a rig setup in case of Rigged Camera
  110150. */
  110151. get rightCamera(): Nullable<FreeCamera>;
  110152. /**
  110153. * Gets the left camera target of a rig setup in case of Rigged Camera
  110154. * @returns the target position
  110155. */
  110156. getLeftTarget(): Nullable<Vector3>;
  110157. /**
  110158. * Gets the right camera target of a rig setup in case of Rigged Camera
  110159. * @returns the target position
  110160. */
  110161. getRightTarget(): Nullable<Vector3>;
  110162. /**
  110163. * @hidden
  110164. */
  110165. setCameraRigMode(mode: number, rigParams: any): void;
  110166. /** @hidden */
  110167. static _setStereoscopicRigMode(camera: Camera): void;
  110168. /** @hidden */
  110169. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  110170. /** @hidden */
  110171. static _setVRRigMode(camera: Camera, rigParams: any): void;
  110172. /** @hidden */
  110173. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  110174. /** @hidden */
  110175. _getVRProjectionMatrix(): Matrix;
  110176. protected _updateCameraRotationMatrix(): void;
  110177. protected _updateWebVRCameraRotationMatrix(): void;
  110178. /**
  110179. * This function MUST be overwritten by the different WebVR cameras available.
  110180. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  110181. * @hidden
  110182. */
  110183. _getWebVRProjectionMatrix(): Matrix;
  110184. /**
  110185. * This function MUST be overwritten by the different WebVR cameras available.
  110186. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  110187. * @hidden
  110188. */
  110189. _getWebVRViewMatrix(): Matrix;
  110190. /** @hidden */
  110191. setCameraRigParameter(name: string, value: any): void;
  110192. /**
  110193. * needs to be overridden by children so sub has required properties to be copied
  110194. * @hidden
  110195. */
  110196. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  110197. /**
  110198. * May need to be overridden by children
  110199. * @hidden
  110200. */
  110201. _updateRigCameras(): void;
  110202. /** @hidden */
  110203. _setupInputs(): void;
  110204. /**
  110205. * Serialiaze the camera setup to a json represention
  110206. * @returns the JSON representation
  110207. */
  110208. serialize(): any;
  110209. /**
  110210. * Clones the current camera.
  110211. * @param name The cloned camera name
  110212. * @returns the cloned camera
  110213. */
  110214. clone(name: string): Camera;
  110215. /**
  110216. * Gets the direction of the camera relative to a given local axis.
  110217. * @param localAxis Defines the reference axis to provide a relative direction.
  110218. * @return the direction
  110219. */
  110220. getDirection(localAxis: Vector3): Vector3;
  110221. /**
  110222. * Returns the current camera absolute rotation
  110223. */
  110224. get absoluteRotation(): Quaternion;
  110225. /**
  110226. * Gets the direction of the camera relative to a given local axis into a passed vector.
  110227. * @param localAxis Defines the reference axis to provide a relative direction.
  110228. * @param result Defines the vector to store the result in
  110229. */
  110230. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  110231. /**
  110232. * Gets a camera constructor for a given camera type
  110233. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  110234. * @param name The name of the camera the result will be able to instantiate
  110235. * @param scene The scene the result will construct the camera in
  110236. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  110237. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  110238. * @returns a factory method to construc the camera
  110239. */
  110240. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  110241. /**
  110242. * Compute the world matrix of the camera.
  110243. * @returns the camera world matrix
  110244. */
  110245. computeWorldMatrix(): Matrix;
  110246. /**
  110247. * Parse a JSON and creates the camera from the parsed information
  110248. * @param parsedCamera The JSON to parse
  110249. * @param scene The scene to instantiate the camera in
  110250. * @returns the newly constructed camera
  110251. */
  110252. static Parse(parsedCamera: any, scene: Scene): Camera;
  110253. }
  110254. }
  110255. declare module BABYLON {
  110256. /**
  110257. * Class containing static functions to help procedurally build meshes
  110258. */
  110259. export class DiscBuilder {
  110260. /**
  110261. * Creates a plane polygonal mesh. By default, this is a disc
  110262. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110263. * * 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
  110264. * * 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
  110265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110266. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110268. * @param name defines the name of the mesh
  110269. * @param options defines the options used to create the mesh
  110270. * @param scene defines the hosting scene
  110271. * @returns the plane polygonal mesh
  110272. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110273. */
  110274. static CreateDisc(name: string, options: {
  110275. radius?: number;
  110276. tessellation?: number;
  110277. arc?: number;
  110278. updatable?: boolean;
  110279. sideOrientation?: number;
  110280. frontUVs?: Vector4;
  110281. backUVs?: Vector4;
  110282. }, scene?: Nullable<Scene>): Mesh;
  110283. }
  110284. }
  110285. declare module BABYLON {
  110286. /**
  110287. * Options to be used when creating a FresnelParameters.
  110288. */
  110289. export type IFresnelParametersCreationOptions = {
  110290. /**
  110291. * Define the color used on edges (grazing angle)
  110292. */
  110293. leftColor?: Color3;
  110294. /**
  110295. * Define the color used on center
  110296. */
  110297. rightColor?: Color3;
  110298. /**
  110299. * Define bias applied to computed fresnel term
  110300. */
  110301. bias?: number;
  110302. /**
  110303. * Defined the power exponent applied to fresnel term
  110304. */
  110305. power?: number;
  110306. /**
  110307. * Define if the fresnel effect is enable or not.
  110308. */
  110309. isEnabled?: boolean;
  110310. };
  110311. /**
  110312. * Serialized format for FresnelParameters.
  110313. */
  110314. export type IFresnelParametersSerialized = {
  110315. /**
  110316. * Define the color used on edges (grazing angle) [as an array]
  110317. */
  110318. leftColor: number[];
  110319. /**
  110320. * Define the color used on center [as an array]
  110321. */
  110322. rightColor: number[];
  110323. /**
  110324. * Define bias applied to computed fresnel term
  110325. */
  110326. bias: number;
  110327. /**
  110328. * Defined the power exponent applied to fresnel term
  110329. */
  110330. power?: number;
  110331. /**
  110332. * Define if the fresnel effect is enable or not.
  110333. */
  110334. isEnabled: boolean;
  110335. };
  110336. /**
  110337. * This represents all the required information to add a fresnel effect on a material:
  110338. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110339. */
  110340. export class FresnelParameters {
  110341. private _isEnabled;
  110342. /**
  110343. * Define if the fresnel effect is enable or not.
  110344. */
  110345. get isEnabled(): boolean;
  110346. set isEnabled(value: boolean);
  110347. /**
  110348. * Define the color used on edges (grazing angle)
  110349. */
  110350. leftColor: Color3;
  110351. /**
  110352. * Define the color used on center
  110353. */
  110354. rightColor: Color3;
  110355. /**
  110356. * Define bias applied to computed fresnel term
  110357. */
  110358. bias: number;
  110359. /**
  110360. * Defined the power exponent applied to fresnel term
  110361. */
  110362. power: number;
  110363. /**
  110364. * Creates a new FresnelParameters object.
  110365. *
  110366. * @param options provide your own settings to optionally to override defaults
  110367. */
  110368. constructor(options?: IFresnelParametersCreationOptions);
  110369. /**
  110370. * Clones the current fresnel and its valuues
  110371. * @returns a clone fresnel configuration
  110372. */
  110373. clone(): FresnelParameters;
  110374. /**
  110375. * Determines equality between FresnelParameters objects
  110376. * @param otherFresnelParameters defines the second operand
  110377. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  110378. */
  110379. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  110380. /**
  110381. * Serializes the current fresnel parameters to a JSON representation.
  110382. * @return the JSON serialization
  110383. */
  110384. serialize(): IFresnelParametersSerialized;
  110385. /**
  110386. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  110387. * @param parsedFresnelParameters Define the JSON representation
  110388. * @returns the parsed parameters
  110389. */
  110390. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  110391. }
  110392. }
  110393. declare module BABYLON {
  110394. /**
  110395. * This groups all the flags used to control the materials channel.
  110396. */
  110397. export class MaterialFlags {
  110398. private static _DiffuseTextureEnabled;
  110399. /**
  110400. * Are diffuse textures enabled in the application.
  110401. */
  110402. static get DiffuseTextureEnabled(): boolean;
  110403. static set DiffuseTextureEnabled(value: boolean);
  110404. private static _DetailTextureEnabled;
  110405. /**
  110406. * Are detail textures enabled in the application.
  110407. */
  110408. static get DetailTextureEnabled(): boolean;
  110409. static set DetailTextureEnabled(value: boolean);
  110410. private static _AmbientTextureEnabled;
  110411. /**
  110412. * Are ambient textures enabled in the application.
  110413. */
  110414. static get AmbientTextureEnabled(): boolean;
  110415. static set AmbientTextureEnabled(value: boolean);
  110416. private static _OpacityTextureEnabled;
  110417. /**
  110418. * Are opacity textures enabled in the application.
  110419. */
  110420. static get OpacityTextureEnabled(): boolean;
  110421. static set OpacityTextureEnabled(value: boolean);
  110422. private static _ReflectionTextureEnabled;
  110423. /**
  110424. * Are reflection textures enabled in the application.
  110425. */
  110426. static get ReflectionTextureEnabled(): boolean;
  110427. static set ReflectionTextureEnabled(value: boolean);
  110428. private static _EmissiveTextureEnabled;
  110429. /**
  110430. * Are emissive textures enabled in the application.
  110431. */
  110432. static get EmissiveTextureEnabled(): boolean;
  110433. static set EmissiveTextureEnabled(value: boolean);
  110434. private static _SpecularTextureEnabled;
  110435. /**
  110436. * Are specular textures enabled in the application.
  110437. */
  110438. static get SpecularTextureEnabled(): boolean;
  110439. static set SpecularTextureEnabled(value: boolean);
  110440. private static _BumpTextureEnabled;
  110441. /**
  110442. * Are bump textures enabled in the application.
  110443. */
  110444. static get BumpTextureEnabled(): boolean;
  110445. static set BumpTextureEnabled(value: boolean);
  110446. private static _LightmapTextureEnabled;
  110447. /**
  110448. * Are lightmap textures enabled in the application.
  110449. */
  110450. static get LightmapTextureEnabled(): boolean;
  110451. static set LightmapTextureEnabled(value: boolean);
  110452. private static _RefractionTextureEnabled;
  110453. /**
  110454. * Are refraction textures enabled in the application.
  110455. */
  110456. static get RefractionTextureEnabled(): boolean;
  110457. static set RefractionTextureEnabled(value: boolean);
  110458. private static _ColorGradingTextureEnabled;
  110459. /**
  110460. * Are color grading textures enabled in the application.
  110461. */
  110462. static get ColorGradingTextureEnabled(): boolean;
  110463. static set ColorGradingTextureEnabled(value: boolean);
  110464. private static _FresnelEnabled;
  110465. /**
  110466. * Are fresnels enabled in the application.
  110467. */
  110468. static get FresnelEnabled(): boolean;
  110469. static set FresnelEnabled(value: boolean);
  110470. private static _ClearCoatTextureEnabled;
  110471. /**
  110472. * Are clear coat textures enabled in the application.
  110473. */
  110474. static get ClearCoatTextureEnabled(): boolean;
  110475. static set ClearCoatTextureEnabled(value: boolean);
  110476. private static _ClearCoatBumpTextureEnabled;
  110477. /**
  110478. * Are clear coat bump textures enabled in the application.
  110479. */
  110480. static get ClearCoatBumpTextureEnabled(): boolean;
  110481. static set ClearCoatBumpTextureEnabled(value: boolean);
  110482. private static _ClearCoatTintTextureEnabled;
  110483. /**
  110484. * Are clear coat tint textures enabled in the application.
  110485. */
  110486. static get ClearCoatTintTextureEnabled(): boolean;
  110487. static set ClearCoatTintTextureEnabled(value: boolean);
  110488. private static _SheenTextureEnabled;
  110489. /**
  110490. * Are sheen textures enabled in the application.
  110491. */
  110492. static get SheenTextureEnabled(): boolean;
  110493. static set SheenTextureEnabled(value: boolean);
  110494. private static _AnisotropicTextureEnabled;
  110495. /**
  110496. * Are anisotropic textures enabled in the application.
  110497. */
  110498. static get AnisotropicTextureEnabled(): boolean;
  110499. static set AnisotropicTextureEnabled(value: boolean);
  110500. private static _ThicknessTextureEnabled;
  110501. /**
  110502. * Are thickness textures enabled in the application.
  110503. */
  110504. static get ThicknessTextureEnabled(): boolean;
  110505. static set ThicknessTextureEnabled(value: boolean);
  110506. }
  110507. }
  110508. declare module BABYLON {
  110509. /** @hidden */
  110510. export var defaultFragmentDeclaration: {
  110511. name: string;
  110512. shader: string;
  110513. };
  110514. }
  110515. declare module BABYLON {
  110516. /** @hidden */
  110517. export var defaultUboDeclaration: {
  110518. name: string;
  110519. shader: string;
  110520. };
  110521. }
  110522. declare module BABYLON {
  110523. /** @hidden */
  110524. export var prePassDeclaration: {
  110525. name: string;
  110526. shader: string;
  110527. };
  110528. }
  110529. declare module BABYLON {
  110530. /** @hidden */
  110531. export var lightFragmentDeclaration: {
  110532. name: string;
  110533. shader: string;
  110534. };
  110535. }
  110536. declare module BABYLON {
  110537. /** @hidden */
  110538. export var lightUboDeclaration: {
  110539. name: string;
  110540. shader: string;
  110541. };
  110542. }
  110543. declare module BABYLON {
  110544. /** @hidden */
  110545. export var lightsFragmentFunctions: {
  110546. name: string;
  110547. shader: string;
  110548. };
  110549. }
  110550. declare module BABYLON {
  110551. /** @hidden */
  110552. export var shadowsFragmentFunctions: {
  110553. name: string;
  110554. shader: string;
  110555. };
  110556. }
  110557. declare module BABYLON {
  110558. /** @hidden */
  110559. export var fresnelFunction: {
  110560. name: string;
  110561. shader: string;
  110562. };
  110563. }
  110564. declare module BABYLON {
  110565. /** @hidden */
  110566. export var bumpFragmentMainFunctions: {
  110567. name: string;
  110568. shader: string;
  110569. };
  110570. }
  110571. declare module BABYLON {
  110572. /** @hidden */
  110573. export var bumpFragmentFunctions: {
  110574. name: string;
  110575. shader: string;
  110576. };
  110577. }
  110578. declare module BABYLON {
  110579. /** @hidden */
  110580. export var logDepthDeclaration: {
  110581. name: string;
  110582. shader: string;
  110583. };
  110584. }
  110585. declare module BABYLON {
  110586. /** @hidden */
  110587. export var bumpFragment: {
  110588. name: string;
  110589. shader: string;
  110590. };
  110591. }
  110592. declare module BABYLON {
  110593. /** @hidden */
  110594. export var depthPrePass: {
  110595. name: string;
  110596. shader: string;
  110597. };
  110598. }
  110599. declare module BABYLON {
  110600. /** @hidden */
  110601. export var lightFragment: {
  110602. name: string;
  110603. shader: string;
  110604. };
  110605. }
  110606. declare module BABYLON {
  110607. /** @hidden */
  110608. export var logDepthFragment: {
  110609. name: string;
  110610. shader: string;
  110611. };
  110612. }
  110613. declare module BABYLON {
  110614. /** @hidden */
  110615. export var defaultPixelShader: {
  110616. name: string;
  110617. shader: string;
  110618. };
  110619. }
  110620. declare module BABYLON {
  110621. /** @hidden */
  110622. export var defaultVertexDeclaration: {
  110623. name: string;
  110624. shader: string;
  110625. };
  110626. }
  110627. declare module BABYLON {
  110628. /** @hidden */
  110629. export var bumpVertexDeclaration: {
  110630. name: string;
  110631. shader: string;
  110632. };
  110633. }
  110634. declare module BABYLON {
  110635. /** @hidden */
  110636. export var bumpVertex: {
  110637. name: string;
  110638. shader: string;
  110639. };
  110640. }
  110641. declare module BABYLON {
  110642. /** @hidden */
  110643. export var fogVertex: {
  110644. name: string;
  110645. shader: string;
  110646. };
  110647. }
  110648. declare module BABYLON {
  110649. /** @hidden */
  110650. export var shadowsVertex: {
  110651. name: string;
  110652. shader: string;
  110653. };
  110654. }
  110655. declare module BABYLON {
  110656. /** @hidden */
  110657. export var pointCloudVertex: {
  110658. name: string;
  110659. shader: string;
  110660. };
  110661. }
  110662. declare module BABYLON {
  110663. /** @hidden */
  110664. export var logDepthVertex: {
  110665. name: string;
  110666. shader: string;
  110667. };
  110668. }
  110669. declare module BABYLON {
  110670. /** @hidden */
  110671. export var defaultVertexShader: {
  110672. name: string;
  110673. shader: string;
  110674. };
  110675. }
  110676. declare module BABYLON {
  110677. /**
  110678. * @hidden
  110679. */
  110680. export interface IMaterialDetailMapDefines {
  110681. DETAIL: boolean;
  110682. DETAILDIRECTUV: number;
  110683. DETAIL_NORMALBLENDMETHOD: number;
  110684. /** @hidden */
  110685. _areTexturesDirty: boolean;
  110686. }
  110687. /**
  110688. * Define the code related to the detail map parameters of a material
  110689. *
  110690. * Inspired from:
  110691. * 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
  110692. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  110693. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  110694. */
  110695. export class DetailMapConfiguration {
  110696. private _texture;
  110697. /**
  110698. * The detail texture of the material.
  110699. */
  110700. texture: Nullable<BaseTexture>;
  110701. /**
  110702. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  110703. * Bigger values mean stronger blending
  110704. */
  110705. diffuseBlendLevel: number;
  110706. /**
  110707. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  110708. * Bigger values mean stronger blending. Only used with PBR materials
  110709. */
  110710. roughnessBlendLevel: number;
  110711. /**
  110712. * Defines how strong the bump effect from the detail map is
  110713. * Bigger values mean stronger effect
  110714. */
  110715. bumpLevel: number;
  110716. private _normalBlendMethod;
  110717. /**
  110718. * The method used to blend the bump and detail normals together
  110719. */
  110720. normalBlendMethod: number;
  110721. private _isEnabled;
  110722. /**
  110723. * Enable or disable the detail map on this material
  110724. */
  110725. isEnabled: boolean;
  110726. /** @hidden */
  110727. private _internalMarkAllSubMeshesAsTexturesDirty;
  110728. /** @hidden */
  110729. _markAllSubMeshesAsTexturesDirty(): void;
  110730. /**
  110731. * Instantiate a new detail map
  110732. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110733. */
  110734. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110735. /**
  110736. * Gets whether the submesh is ready to be used or not.
  110737. * @param defines the list of "defines" to update.
  110738. * @param scene defines the scene the material belongs to.
  110739. * @returns - boolean indicating that the submesh is ready or not.
  110740. */
  110741. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  110742. /**
  110743. * Update the defines for detail map usage
  110744. * @param defines the list of "defines" to update.
  110745. * @param scene defines the scene the material belongs to.
  110746. */
  110747. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  110748. /**
  110749. * Binds the material data.
  110750. * @param uniformBuffer defines the Uniform buffer to fill in.
  110751. * @param scene defines the scene the material belongs to.
  110752. * @param isFrozen defines whether the material is frozen or not.
  110753. */
  110754. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110755. /**
  110756. * Checks to see if a texture is used in the material.
  110757. * @param texture - Base texture to use.
  110758. * @returns - Boolean specifying if a texture is used in the material.
  110759. */
  110760. hasTexture(texture: BaseTexture): boolean;
  110761. /**
  110762. * Returns an array of the actively used textures.
  110763. * @param activeTextures Array of BaseTextures
  110764. */
  110765. getActiveTextures(activeTextures: BaseTexture[]): void;
  110766. /**
  110767. * Returns the animatable textures.
  110768. * @param animatables Array of animatable textures.
  110769. */
  110770. getAnimatables(animatables: IAnimatable[]): void;
  110771. /**
  110772. * Disposes the resources of the material.
  110773. * @param forceDisposeTextures - Forces the disposal of all textures.
  110774. */
  110775. dispose(forceDisposeTextures?: boolean): void;
  110776. /**
  110777. * Get the current class name useful for serialization or dynamic coding.
  110778. * @returns "DetailMap"
  110779. */
  110780. getClassName(): string;
  110781. /**
  110782. * Add the required uniforms to the current list.
  110783. * @param uniforms defines the current uniform list.
  110784. */
  110785. static AddUniforms(uniforms: string[]): void;
  110786. /**
  110787. * Add the required samplers to the current list.
  110788. * @param samplers defines the current sampler list.
  110789. */
  110790. static AddSamplers(samplers: string[]): void;
  110791. /**
  110792. * Add the required uniforms to the current buffer.
  110793. * @param uniformBuffer defines the current uniform buffer.
  110794. */
  110795. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110796. /**
  110797. * Makes a duplicate of the current instance into another one.
  110798. * @param detailMap define the instance where to copy the info
  110799. */
  110800. copyTo(detailMap: DetailMapConfiguration): void;
  110801. /**
  110802. * Serializes this detail map instance
  110803. * @returns - An object with the serialized instance.
  110804. */
  110805. serialize(): any;
  110806. /**
  110807. * Parses a detail map setting from a serialized object.
  110808. * @param source - Serialized object.
  110809. * @param scene Defines the scene we are parsing for
  110810. * @param rootUrl Defines the rootUrl to load from
  110811. */
  110812. parse(source: any, scene: Scene, rootUrl: string): void;
  110813. }
  110814. }
  110815. declare module BABYLON {
  110816. /** @hidden */
  110817. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  110818. MAINUV1: boolean;
  110819. MAINUV2: boolean;
  110820. DIFFUSE: boolean;
  110821. DIFFUSEDIRECTUV: number;
  110822. DETAIL: boolean;
  110823. DETAILDIRECTUV: number;
  110824. DETAIL_NORMALBLENDMETHOD: number;
  110825. AMBIENT: boolean;
  110826. AMBIENTDIRECTUV: number;
  110827. OPACITY: boolean;
  110828. OPACITYDIRECTUV: number;
  110829. OPACITYRGB: boolean;
  110830. REFLECTION: boolean;
  110831. EMISSIVE: boolean;
  110832. EMISSIVEDIRECTUV: number;
  110833. SPECULAR: boolean;
  110834. SPECULARDIRECTUV: number;
  110835. BUMP: boolean;
  110836. BUMPDIRECTUV: number;
  110837. PARALLAX: boolean;
  110838. PARALLAXOCCLUSION: boolean;
  110839. SPECULAROVERALPHA: boolean;
  110840. CLIPPLANE: boolean;
  110841. CLIPPLANE2: boolean;
  110842. CLIPPLANE3: boolean;
  110843. CLIPPLANE4: boolean;
  110844. CLIPPLANE5: boolean;
  110845. CLIPPLANE6: boolean;
  110846. ALPHATEST: boolean;
  110847. DEPTHPREPASS: boolean;
  110848. ALPHAFROMDIFFUSE: boolean;
  110849. POINTSIZE: boolean;
  110850. FOG: boolean;
  110851. SPECULARTERM: boolean;
  110852. DIFFUSEFRESNEL: boolean;
  110853. OPACITYFRESNEL: boolean;
  110854. REFLECTIONFRESNEL: boolean;
  110855. REFRACTIONFRESNEL: boolean;
  110856. EMISSIVEFRESNEL: boolean;
  110857. FRESNEL: boolean;
  110858. NORMAL: boolean;
  110859. UV1: boolean;
  110860. UV2: boolean;
  110861. VERTEXCOLOR: boolean;
  110862. VERTEXALPHA: boolean;
  110863. NUM_BONE_INFLUENCERS: number;
  110864. BonesPerMesh: number;
  110865. BONETEXTURE: boolean;
  110866. INSTANCES: boolean;
  110867. THIN_INSTANCES: boolean;
  110868. GLOSSINESS: boolean;
  110869. ROUGHNESS: boolean;
  110870. EMISSIVEASILLUMINATION: boolean;
  110871. LINKEMISSIVEWITHDIFFUSE: boolean;
  110872. REFLECTIONFRESNELFROMSPECULAR: boolean;
  110873. LIGHTMAP: boolean;
  110874. LIGHTMAPDIRECTUV: number;
  110875. OBJECTSPACE_NORMALMAP: boolean;
  110876. USELIGHTMAPASSHADOWMAP: boolean;
  110877. REFLECTIONMAP_3D: boolean;
  110878. REFLECTIONMAP_SPHERICAL: boolean;
  110879. REFLECTIONMAP_PLANAR: boolean;
  110880. REFLECTIONMAP_CUBIC: boolean;
  110881. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  110882. REFLECTIONMAP_PROJECTION: boolean;
  110883. REFLECTIONMAP_SKYBOX: boolean;
  110884. REFLECTIONMAP_EXPLICIT: boolean;
  110885. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  110886. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  110887. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  110888. INVERTCUBICMAP: boolean;
  110889. LOGARITHMICDEPTH: boolean;
  110890. REFRACTION: boolean;
  110891. REFRACTIONMAP_3D: boolean;
  110892. REFLECTIONOVERALPHA: boolean;
  110893. TWOSIDEDLIGHTING: boolean;
  110894. SHADOWFLOAT: boolean;
  110895. MORPHTARGETS: boolean;
  110896. MORPHTARGETS_NORMAL: boolean;
  110897. MORPHTARGETS_TANGENT: boolean;
  110898. MORPHTARGETS_UV: boolean;
  110899. NUM_MORPH_INFLUENCERS: number;
  110900. NONUNIFORMSCALING: boolean;
  110901. PREMULTIPLYALPHA: boolean;
  110902. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  110903. ALPHABLEND: boolean;
  110904. PREPASS: boolean;
  110905. PREPASS_IRRADIANCE: boolean;
  110906. PREPASS_IRRADIANCE_INDEX: number;
  110907. PREPASS_ALBEDO: boolean;
  110908. PREPASS_ALBEDO_INDEX: number;
  110909. PREPASS_DEPTHNORMAL: boolean;
  110910. PREPASS_DEPTHNORMAL_INDEX: number;
  110911. SCENE_MRT_COUNT: number;
  110912. RGBDLIGHTMAP: boolean;
  110913. RGBDREFLECTION: boolean;
  110914. RGBDREFRACTION: boolean;
  110915. IMAGEPROCESSING: boolean;
  110916. VIGNETTE: boolean;
  110917. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110918. VIGNETTEBLENDMODEOPAQUE: boolean;
  110919. TONEMAPPING: boolean;
  110920. TONEMAPPING_ACES: boolean;
  110921. CONTRAST: boolean;
  110922. COLORCURVES: boolean;
  110923. COLORGRADING: boolean;
  110924. COLORGRADING3D: boolean;
  110925. SAMPLER3DGREENDEPTH: boolean;
  110926. SAMPLER3DBGRMAP: boolean;
  110927. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110928. MULTIVIEW: boolean;
  110929. /**
  110930. * If the reflection texture on this material is in linear color space
  110931. * @hidden
  110932. */
  110933. IS_REFLECTION_LINEAR: boolean;
  110934. /**
  110935. * If the refraction texture on this material is in linear color space
  110936. * @hidden
  110937. */
  110938. IS_REFRACTION_LINEAR: boolean;
  110939. EXPOSURE: boolean;
  110940. constructor();
  110941. setReflectionMode(modeToEnable: string): void;
  110942. }
  110943. /**
  110944. * This is the default material used in Babylon. It is the best trade off between quality
  110945. * and performances.
  110946. * @see https://doc.babylonjs.com/babylon101/materials
  110947. */
  110948. export class StandardMaterial extends PushMaterial {
  110949. private _diffuseTexture;
  110950. /**
  110951. * The basic texture of the material as viewed under a light.
  110952. */
  110953. diffuseTexture: Nullable<BaseTexture>;
  110954. private _ambientTexture;
  110955. /**
  110956. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  110957. */
  110958. ambientTexture: Nullable<BaseTexture>;
  110959. private _opacityTexture;
  110960. /**
  110961. * Define the transparency of the material from a texture.
  110962. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  110963. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  110964. */
  110965. opacityTexture: Nullable<BaseTexture>;
  110966. private _reflectionTexture;
  110967. /**
  110968. * Define the texture used to display the reflection.
  110969. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110970. */
  110971. reflectionTexture: Nullable<BaseTexture>;
  110972. private _emissiveTexture;
  110973. /**
  110974. * Define texture of the material as if self lit.
  110975. * This will be mixed in the final result even in the absence of light.
  110976. */
  110977. emissiveTexture: Nullable<BaseTexture>;
  110978. private _specularTexture;
  110979. /**
  110980. * Define how the color and intensity of the highlight given by the light in the material.
  110981. */
  110982. specularTexture: Nullable<BaseTexture>;
  110983. private _bumpTexture;
  110984. /**
  110985. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  110986. * 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.
  110987. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  110988. */
  110989. bumpTexture: Nullable<BaseTexture>;
  110990. private _lightmapTexture;
  110991. /**
  110992. * Complex lighting can be computationally expensive to compute at runtime.
  110993. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  110994. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  110995. */
  110996. lightmapTexture: Nullable<BaseTexture>;
  110997. private _refractionTexture;
  110998. /**
  110999. * Define the texture used to display the refraction.
  111000. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111001. */
  111002. refractionTexture: Nullable<BaseTexture>;
  111003. /**
  111004. * The color of the material lit by the environmental background lighting.
  111005. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  111006. */
  111007. ambientColor: Color3;
  111008. /**
  111009. * The basic color of the material as viewed under a light.
  111010. */
  111011. diffuseColor: Color3;
  111012. /**
  111013. * Define how the color and intensity of the highlight given by the light in the material.
  111014. */
  111015. specularColor: Color3;
  111016. /**
  111017. * Define the color of the material as if self lit.
  111018. * This will be mixed in the final result even in the absence of light.
  111019. */
  111020. emissiveColor: Color3;
  111021. /**
  111022. * Defines how sharp are the highlights in the material.
  111023. * The bigger the value the sharper giving a more glossy feeling to the result.
  111024. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  111025. */
  111026. specularPower: number;
  111027. private _useAlphaFromDiffuseTexture;
  111028. /**
  111029. * Does the transparency come from the diffuse texture alpha channel.
  111030. */
  111031. useAlphaFromDiffuseTexture: boolean;
  111032. private _useEmissiveAsIllumination;
  111033. /**
  111034. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  111035. */
  111036. useEmissiveAsIllumination: boolean;
  111037. private _linkEmissiveWithDiffuse;
  111038. /**
  111039. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  111040. * the emissive level when the final color is close to one.
  111041. */
  111042. linkEmissiveWithDiffuse: boolean;
  111043. private _useSpecularOverAlpha;
  111044. /**
  111045. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  111046. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  111047. */
  111048. useSpecularOverAlpha: boolean;
  111049. private _useReflectionOverAlpha;
  111050. /**
  111051. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111052. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111053. */
  111054. useReflectionOverAlpha: boolean;
  111055. private _disableLighting;
  111056. /**
  111057. * Does lights from the scene impacts this material.
  111058. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  111059. */
  111060. disableLighting: boolean;
  111061. private _useObjectSpaceNormalMap;
  111062. /**
  111063. * Allows using an object space normal map (instead of tangent space).
  111064. */
  111065. useObjectSpaceNormalMap: boolean;
  111066. private _useParallax;
  111067. /**
  111068. * Is parallax enabled or not.
  111069. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  111070. */
  111071. useParallax: boolean;
  111072. private _useParallaxOcclusion;
  111073. /**
  111074. * Is parallax occlusion enabled or not.
  111075. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  111076. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  111077. */
  111078. useParallaxOcclusion: boolean;
  111079. /**
  111080. * 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.
  111081. */
  111082. parallaxScaleBias: number;
  111083. private _roughness;
  111084. /**
  111085. * Helps to define how blurry the reflections should appears in the material.
  111086. */
  111087. roughness: number;
  111088. /**
  111089. * In case of refraction, define the value of the index of refraction.
  111090. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111091. */
  111092. indexOfRefraction: number;
  111093. /**
  111094. * Invert the refraction texture alongside the y axis.
  111095. * It can be useful with procedural textures or probe for instance.
  111096. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111097. */
  111098. invertRefractionY: boolean;
  111099. /**
  111100. * Defines the alpha limits in alpha test mode.
  111101. */
  111102. alphaCutOff: number;
  111103. private _useLightmapAsShadowmap;
  111104. /**
  111105. * In case of light mapping, define whether the map contains light or shadow informations.
  111106. */
  111107. useLightmapAsShadowmap: boolean;
  111108. private _diffuseFresnelParameters;
  111109. /**
  111110. * Define the diffuse fresnel parameters of the material.
  111111. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111112. */
  111113. diffuseFresnelParameters: FresnelParameters;
  111114. private _opacityFresnelParameters;
  111115. /**
  111116. * Define the opacity fresnel parameters of the material.
  111117. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111118. */
  111119. opacityFresnelParameters: FresnelParameters;
  111120. private _reflectionFresnelParameters;
  111121. /**
  111122. * Define the reflection fresnel parameters of the material.
  111123. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111124. */
  111125. reflectionFresnelParameters: FresnelParameters;
  111126. private _refractionFresnelParameters;
  111127. /**
  111128. * Define the refraction fresnel parameters of the material.
  111129. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111130. */
  111131. refractionFresnelParameters: FresnelParameters;
  111132. private _emissiveFresnelParameters;
  111133. /**
  111134. * Define the emissive fresnel parameters of the material.
  111135. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111136. */
  111137. emissiveFresnelParameters: FresnelParameters;
  111138. private _useReflectionFresnelFromSpecular;
  111139. /**
  111140. * If true automatically deducts the fresnels values from the material specularity.
  111141. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111142. */
  111143. useReflectionFresnelFromSpecular: boolean;
  111144. private _useGlossinessFromSpecularMapAlpha;
  111145. /**
  111146. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  111147. */
  111148. useGlossinessFromSpecularMapAlpha: boolean;
  111149. private _maxSimultaneousLights;
  111150. /**
  111151. * Defines the maximum number of lights that can be used in the material
  111152. */
  111153. maxSimultaneousLights: number;
  111154. private _invertNormalMapX;
  111155. /**
  111156. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  111157. */
  111158. invertNormalMapX: boolean;
  111159. private _invertNormalMapY;
  111160. /**
  111161. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  111162. */
  111163. invertNormalMapY: boolean;
  111164. private _twoSidedLighting;
  111165. /**
  111166. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111167. */
  111168. twoSidedLighting: boolean;
  111169. /**
  111170. * Default configuration related to image processing available in the standard Material.
  111171. */
  111172. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111173. /**
  111174. * Gets the image processing configuration used either in this material.
  111175. */
  111176. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  111177. /**
  111178. * Sets the Default image processing configuration used either in the this material.
  111179. *
  111180. * If sets to null, the scene one is in use.
  111181. */
  111182. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  111183. /**
  111184. * Keep track of the image processing observer to allow dispose and replace.
  111185. */
  111186. private _imageProcessingObserver;
  111187. /**
  111188. * Attaches a new image processing configuration to the Standard Material.
  111189. * @param configuration
  111190. */
  111191. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111192. /**
  111193. * Gets wether the color curves effect is enabled.
  111194. */
  111195. get cameraColorCurvesEnabled(): boolean;
  111196. /**
  111197. * Sets wether the color curves effect is enabled.
  111198. */
  111199. set cameraColorCurvesEnabled(value: boolean);
  111200. /**
  111201. * Gets wether the color grading effect is enabled.
  111202. */
  111203. get cameraColorGradingEnabled(): boolean;
  111204. /**
  111205. * Gets wether the color grading effect is enabled.
  111206. */
  111207. set cameraColorGradingEnabled(value: boolean);
  111208. /**
  111209. * Gets wether tonemapping is enabled or not.
  111210. */
  111211. get cameraToneMappingEnabled(): boolean;
  111212. /**
  111213. * Sets wether tonemapping is enabled or not
  111214. */
  111215. set cameraToneMappingEnabled(value: boolean);
  111216. /**
  111217. * The camera exposure used on this material.
  111218. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111219. * This corresponds to a photographic exposure.
  111220. */
  111221. get cameraExposure(): number;
  111222. /**
  111223. * The camera exposure used on this material.
  111224. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111225. * This corresponds to a photographic exposure.
  111226. */
  111227. set cameraExposure(value: number);
  111228. /**
  111229. * Gets The camera contrast used on this material.
  111230. */
  111231. get cameraContrast(): number;
  111232. /**
  111233. * Sets The camera contrast used on this material.
  111234. */
  111235. set cameraContrast(value: number);
  111236. /**
  111237. * Gets the Color Grading 2D Lookup Texture.
  111238. */
  111239. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  111240. /**
  111241. * Sets the Color Grading 2D Lookup Texture.
  111242. */
  111243. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  111244. /**
  111245. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111246. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111247. * 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;
  111248. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111249. */
  111250. get cameraColorCurves(): Nullable<ColorCurves>;
  111251. /**
  111252. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111253. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111254. * 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;
  111255. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111256. */
  111257. set cameraColorCurves(value: Nullable<ColorCurves>);
  111258. /**
  111259. * Can this material render to several textures at once
  111260. */
  111261. get canRenderToMRT(): boolean;
  111262. /**
  111263. * Defines the detail map parameters for the material.
  111264. */
  111265. readonly detailMap: DetailMapConfiguration;
  111266. protected _renderTargets: SmartArray<RenderTargetTexture>;
  111267. protected _worldViewProjectionMatrix: Matrix;
  111268. protected _globalAmbientColor: Color3;
  111269. protected _useLogarithmicDepth: boolean;
  111270. protected _rebuildInParallel: boolean;
  111271. /**
  111272. * Instantiates a new standard material.
  111273. * This is the default material used in Babylon. It is the best trade off between quality
  111274. * and performances.
  111275. * @see https://doc.babylonjs.com/babylon101/materials
  111276. * @param name Define the name of the material in the scene
  111277. * @param scene Define the scene the material belong to
  111278. */
  111279. constructor(name: string, scene: Scene);
  111280. /**
  111281. * Gets a boolean indicating that current material needs to register RTT
  111282. */
  111283. get hasRenderTargetTextures(): boolean;
  111284. /**
  111285. * Gets the current class name of the material e.g. "StandardMaterial"
  111286. * Mainly use in serialization.
  111287. * @returns the class name
  111288. */
  111289. getClassName(): string;
  111290. /**
  111291. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  111292. * You can try switching to logarithmic depth.
  111293. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  111294. */
  111295. get useLogarithmicDepth(): boolean;
  111296. set useLogarithmicDepth(value: boolean);
  111297. /**
  111298. * Specifies if the material will require alpha blending
  111299. * @returns a boolean specifying if alpha blending is needed
  111300. */
  111301. needAlphaBlending(): boolean;
  111302. /**
  111303. * Specifies if this material should be rendered in alpha test mode
  111304. * @returns a boolean specifying if an alpha test is needed.
  111305. */
  111306. needAlphaTesting(): boolean;
  111307. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  111308. /**
  111309. * Get the texture used for alpha test purpose.
  111310. * @returns the diffuse texture in case of the standard material.
  111311. */
  111312. getAlphaTestTexture(): Nullable<BaseTexture>;
  111313. /**
  111314. * Get if the submesh is ready to be used and all its information available.
  111315. * Child classes can use it to update shaders
  111316. * @param mesh defines the mesh to check
  111317. * @param subMesh defines which submesh to check
  111318. * @param useInstances specifies that instances should be used
  111319. * @returns a boolean indicating that the submesh is ready or not
  111320. */
  111321. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111322. /**
  111323. * Builds the material UBO layouts.
  111324. * Used internally during the effect preparation.
  111325. */
  111326. buildUniformLayout(): void;
  111327. /**
  111328. * Unbinds the material from the mesh
  111329. */
  111330. unbind(): void;
  111331. /**
  111332. * Binds the submesh to this material by preparing the effect and shader to draw
  111333. * @param world defines the world transformation matrix
  111334. * @param mesh defines the mesh containing the submesh
  111335. * @param subMesh defines the submesh to bind the material to
  111336. */
  111337. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111338. /**
  111339. * Get the list of animatables in the material.
  111340. * @returns the list of animatables object used in the material
  111341. */
  111342. getAnimatables(): IAnimatable[];
  111343. /**
  111344. * Gets the active textures from the material
  111345. * @returns an array of textures
  111346. */
  111347. getActiveTextures(): BaseTexture[];
  111348. /**
  111349. * Specifies if the material uses a texture
  111350. * @param texture defines the texture to check against the material
  111351. * @returns a boolean specifying if the material uses the texture
  111352. */
  111353. hasTexture(texture: BaseTexture): boolean;
  111354. /**
  111355. * Disposes the material
  111356. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  111357. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  111358. */
  111359. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111360. /**
  111361. * Makes a duplicate of the material, and gives it a new name
  111362. * @param name defines the new name for the duplicated material
  111363. * @returns the cloned material
  111364. */
  111365. clone(name: string): StandardMaterial;
  111366. /**
  111367. * Serializes this material in a JSON representation
  111368. * @returns the serialized material object
  111369. */
  111370. serialize(): any;
  111371. /**
  111372. * Creates a standard material from parsed material data
  111373. * @param source defines the JSON representation of the material
  111374. * @param scene defines the hosting scene
  111375. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  111376. * @returns a new standard material
  111377. */
  111378. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  111379. /**
  111380. * Are diffuse textures enabled in the application.
  111381. */
  111382. static get DiffuseTextureEnabled(): boolean;
  111383. static set DiffuseTextureEnabled(value: boolean);
  111384. /**
  111385. * Are detail textures enabled in the application.
  111386. */
  111387. static get DetailTextureEnabled(): boolean;
  111388. static set DetailTextureEnabled(value: boolean);
  111389. /**
  111390. * Are ambient textures enabled in the application.
  111391. */
  111392. static get AmbientTextureEnabled(): boolean;
  111393. static set AmbientTextureEnabled(value: boolean);
  111394. /**
  111395. * Are opacity textures enabled in the application.
  111396. */
  111397. static get OpacityTextureEnabled(): boolean;
  111398. static set OpacityTextureEnabled(value: boolean);
  111399. /**
  111400. * Are reflection textures enabled in the application.
  111401. */
  111402. static get ReflectionTextureEnabled(): boolean;
  111403. static set ReflectionTextureEnabled(value: boolean);
  111404. /**
  111405. * Are emissive textures enabled in the application.
  111406. */
  111407. static get EmissiveTextureEnabled(): boolean;
  111408. static set EmissiveTextureEnabled(value: boolean);
  111409. /**
  111410. * Are specular textures enabled in the application.
  111411. */
  111412. static get SpecularTextureEnabled(): boolean;
  111413. static set SpecularTextureEnabled(value: boolean);
  111414. /**
  111415. * Are bump textures enabled in the application.
  111416. */
  111417. static get BumpTextureEnabled(): boolean;
  111418. static set BumpTextureEnabled(value: boolean);
  111419. /**
  111420. * Are lightmap textures enabled in the application.
  111421. */
  111422. static get LightmapTextureEnabled(): boolean;
  111423. static set LightmapTextureEnabled(value: boolean);
  111424. /**
  111425. * Are refraction textures enabled in the application.
  111426. */
  111427. static get RefractionTextureEnabled(): boolean;
  111428. static set RefractionTextureEnabled(value: boolean);
  111429. /**
  111430. * Are color grading textures enabled in the application.
  111431. */
  111432. static get ColorGradingTextureEnabled(): boolean;
  111433. static set ColorGradingTextureEnabled(value: boolean);
  111434. /**
  111435. * Are fresnels enabled in the application.
  111436. */
  111437. static get FresnelEnabled(): boolean;
  111438. static set FresnelEnabled(value: boolean);
  111439. }
  111440. }
  111441. declare module BABYLON {
  111442. /**
  111443. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  111444. *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.
  111445. * The SPS is also a particle system. It provides some methods to manage the particles.
  111446. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  111447. *
  111448. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  111449. */
  111450. export class SolidParticleSystem implements IDisposable {
  111451. /**
  111452. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  111453. * Example : var p = SPS.particles[i];
  111454. */
  111455. particles: SolidParticle[];
  111456. /**
  111457. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  111458. */
  111459. nbParticles: number;
  111460. /**
  111461. * If the particles must ever face the camera (default false). Useful for planar particles.
  111462. */
  111463. billboard: boolean;
  111464. /**
  111465. * Recompute normals when adding a shape
  111466. */
  111467. recomputeNormals: boolean;
  111468. /**
  111469. * This a counter ofr your own usage. It's not set by any SPS functions.
  111470. */
  111471. counter: number;
  111472. /**
  111473. * The SPS name. This name is also given to the underlying mesh.
  111474. */
  111475. name: string;
  111476. /**
  111477. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  111478. */
  111479. mesh: Mesh;
  111480. /**
  111481. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  111482. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  111483. */
  111484. vars: any;
  111485. /**
  111486. * This array is populated when the SPS is set as 'pickable'.
  111487. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  111488. * Each element of this array is an object `{idx: int, faceId: int}`.
  111489. * `idx` is the picked particle index in the `SPS.particles` array
  111490. * `faceId` is the picked face index counted within this particle.
  111491. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  111492. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  111493. * Use the method SPS.pickedParticle(pickingInfo) instead.
  111494. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111495. */
  111496. pickedParticles: {
  111497. idx: number;
  111498. faceId: number;
  111499. }[];
  111500. /**
  111501. * This array is populated when the SPS is set as 'pickable'
  111502. * Each key of this array is a submesh index.
  111503. * Each element of this array is a second array defined like this :
  111504. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  111505. * Each element of this second array is an object `{idx: int, faceId: int}`.
  111506. * `idx` is the picked particle index in the `SPS.particles` array
  111507. * `faceId` is the picked face index counted within this particle.
  111508. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  111509. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111510. */
  111511. pickedBySubMesh: {
  111512. idx: number;
  111513. faceId: number;
  111514. }[][];
  111515. /**
  111516. * This array is populated when `enableDepthSort` is set to true.
  111517. * Each element of this array is an instance of the class DepthSortedParticle.
  111518. */
  111519. depthSortedParticles: DepthSortedParticle[];
  111520. /**
  111521. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  111522. * @hidden
  111523. */
  111524. _bSphereOnly: boolean;
  111525. /**
  111526. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  111527. * @hidden
  111528. */
  111529. _bSphereRadiusFactor: number;
  111530. private _scene;
  111531. private _positions;
  111532. private _indices;
  111533. private _normals;
  111534. private _colors;
  111535. private _uvs;
  111536. private _indices32;
  111537. private _positions32;
  111538. private _normals32;
  111539. private _fixedNormal32;
  111540. private _colors32;
  111541. private _uvs32;
  111542. private _index;
  111543. private _updatable;
  111544. private _pickable;
  111545. private _isVisibilityBoxLocked;
  111546. private _alwaysVisible;
  111547. private _depthSort;
  111548. private _expandable;
  111549. private _shapeCounter;
  111550. private _copy;
  111551. private _color;
  111552. private _computeParticleColor;
  111553. private _computeParticleTexture;
  111554. private _computeParticleRotation;
  111555. private _computeParticleVertex;
  111556. private _computeBoundingBox;
  111557. private _depthSortParticles;
  111558. private _camera;
  111559. private _mustUnrotateFixedNormals;
  111560. private _particlesIntersect;
  111561. private _needs32Bits;
  111562. private _isNotBuilt;
  111563. private _lastParticleId;
  111564. private _idxOfId;
  111565. private _multimaterialEnabled;
  111566. private _useModelMaterial;
  111567. private _indicesByMaterial;
  111568. private _materialIndexes;
  111569. private _depthSortFunction;
  111570. private _materialSortFunction;
  111571. private _materials;
  111572. private _multimaterial;
  111573. private _materialIndexesById;
  111574. private _defaultMaterial;
  111575. private _autoUpdateSubMeshes;
  111576. private _tmpVertex;
  111577. /**
  111578. * Creates a SPS (Solid Particle System) object.
  111579. * @param name (String) is the SPS name, this will be the underlying mesh name.
  111580. * @param scene (Scene) is the scene in which the SPS is added.
  111581. * @param options defines the options of the sps e.g.
  111582. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  111583. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  111584. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  111585. * * 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.
  111586. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  111587. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  111588. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  111589. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  111590. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  111591. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  111592. */
  111593. constructor(name: string, scene: Scene, options?: {
  111594. updatable?: boolean;
  111595. isPickable?: boolean;
  111596. enableDepthSort?: boolean;
  111597. particleIntersection?: boolean;
  111598. boundingSphereOnly?: boolean;
  111599. bSphereRadiusFactor?: number;
  111600. expandable?: boolean;
  111601. useModelMaterial?: boolean;
  111602. enableMultiMaterial?: boolean;
  111603. });
  111604. /**
  111605. * Builds the SPS underlying mesh. Returns a standard Mesh.
  111606. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  111607. * @returns the created mesh
  111608. */
  111609. buildMesh(): Mesh;
  111610. /**
  111611. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  111612. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  111613. * Thus the particles generated from `digest()` have their property `position` set yet.
  111614. * @param mesh ( Mesh ) is the mesh to be digested
  111615. * @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
  111616. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  111617. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  111618. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111619. * @returns the current SPS
  111620. */
  111621. digest(mesh: Mesh, options?: {
  111622. facetNb?: number;
  111623. number?: number;
  111624. delta?: number;
  111625. storage?: [];
  111626. }): SolidParticleSystem;
  111627. /**
  111628. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  111629. * @hidden
  111630. */
  111631. private _unrotateFixedNormals;
  111632. /**
  111633. * Resets the temporary working copy particle
  111634. * @hidden
  111635. */
  111636. private _resetCopy;
  111637. /**
  111638. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  111639. * @param p the current index in the positions array to be updated
  111640. * @param ind the current index in the indices array
  111641. * @param shape a Vector3 array, the shape geometry
  111642. * @param positions the positions array to be updated
  111643. * @param meshInd the shape indices array
  111644. * @param indices the indices array to be updated
  111645. * @param meshUV the shape uv array
  111646. * @param uvs the uv array to be updated
  111647. * @param meshCol the shape color array
  111648. * @param colors the color array to be updated
  111649. * @param meshNor the shape normals array
  111650. * @param normals the normals array to be updated
  111651. * @param idx the particle index
  111652. * @param idxInShape the particle index in its shape
  111653. * @param options the addShape() method passed options
  111654. * @model the particle model
  111655. * @hidden
  111656. */
  111657. private _meshBuilder;
  111658. /**
  111659. * Returns a shape Vector3 array from positions float array
  111660. * @param positions float array
  111661. * @returns a vector3 array
  111662. * @hidden
  111663. */
  111664. private _posToShape;
  111665. /**
  111666. * Returns a shapeUV array from a float uvs (array deep copy)
  111667. * @param uvs as a float array
  111668. * @returns a shapeUV array
  111669. * @hidden
  111670. */
  111671. private _uvsToShapeUV;
  111672. /**
  111673. * Adds a new particle object in the particles array
  111674. * @param idx particle index in particles array
  111675. * @param id particle id
  111676. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  111677. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  111678. * @param model particle ModelShape object
  111679. * @param shapeId model shape identifier
  111680. * @param idxInShape index of the particle in the current model
  111681. * @param bInfo model bounding info object
  111682. * @param storage target storage array, if any
  111683. * @hidden
  111684. */
  111685. private _addParticle;
  111686. /**
  111687. * Adds some particles to the SPS from the model shape. Returns the shape id.
  111688. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  111689. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  111690. * @param nb (positive integer) the number of particles to be created from this model
  111691. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  111692. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  111693. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111694. * @returns the number of shapes in the system
  111695. */
  111696. addShape(mesh: Mesh, nb: number, options?: {
  111697. positionFunction?: any;
  111698. vertexFunction?: any;
  111699. storage?: [];
  111700. }): number;
  111701. /**
  111702. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  111703. * @hidden
  111704. */
  111705. private _rebuildParticle;
  111706. /**
  111707. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  111708. * @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.
  111709. * @returns the SPS.
  111710. */
  111711. rebuildMesh(reset?: boolean): SolidParticleSystem;
  111712. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  111713. * Returns an array with the removed particles.
  111714. * 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.
  111715. * The SPS can't be empty so at least one particle needs to remain in place.
  111716. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  111717. * @param start index of the first particle to remove
  111718. * @param end index of the last particle to remove (included)
  111719. * @returns an array populated with the removed particles
  111720. */
  111721. removeParticles(start: number, end: number): SolidParticle[];
  111722. /**
  111723. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  111724. * @param solidParticleArray an array populated with Solid Particles objects
  111725. * @returns the SPS
  111726. */
  111727. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  111728. /**
  111729. * Creates a new particle and modifies the SPS mesh geometry :
  111730. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  111731. * - calls _addParticle() to populate the particle array
  111732. * factorized code from addShape() and insertParticlesFromArray()
  111733. * @param idx particle index in the particles array
  111734. * @param i particle index in its shape
  111735. * @param modelShape particle ModelShape object
  111736. * @param shape shape vertex array
  111737. * @param meshInd shape indices array
  111738. * @param meshUV shape uv array
  111739. * @param meshCol shape color array
  111740. * @param meshNor shape normals array
  111741. * @param bbInfo shape bounding info
  111742. * @param storage target particle storage
  111743. * @options addShape() passed options
  111744. * @hidden
  111745. */
  111746. private _insertNewParticle;
  111747. /**
  111748. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  111749. * This method calls `updateParticle()` for each particle of the SPS.
  111750. * For an animated SPS, it is usually called within the render loop.
  111751. * 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.
  111752. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  111753. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  111754. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  111755. * @returns the SPS.
  111756. */
  111757. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  111758. /**
  111759. * Disposes the SPS.
  111760. */
  111761. dispose(): void;
  111762. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  111763. * idx is the particle index in the SPS
  111764. * faceId is the picked face index counted within this particle.
  111765. * Returns null if the pickInfo can't identify a picked particle.
  111766. * @param pickingInfo (PickingInfo object)
  111767. * @returns {idx: number, faceId: number} or null
  111768. */
  111769. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  111770. idx: number;
  111771. faceId: number;
  111772. }>;
  111773. /**
  111774. * Returns a SolidParticle object from its identifier : particle.id
  111775. * @param id (integer) the particle Id
  111776. * @returns the searched particle or null if not found in the SPS.
  111777. */
  111778. getParticleById(id: number): Nullable<SolidParticle>;
  111779. /**
  111780. * Returns a new array populated with the particles having the passed shapeId.
  111781. * @param shapeId (integer) the shape identifier
  111782. * @returns a new solid particle array
  111783. */
  111784. getParticlesByShapeId(shapeId: number): SolidParticle[];
  111785. /**
  111786. * Populates the passed array "ref" with the particles having the passed shapeId.
  111787. * @param shapeId the shape identifier
  111788. * @returns the SPS
  111789. * @param ref
  111790. */
  111791. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  111792. /**
  111793. * Computes the required SubMeshes according the materials assigned to the particles.
  111794. * @returns the solid particle system.
  111795. * Does nothing if called before the SPS mesh is built.
  111796. */
  111797. computeSubMeshes(): SolidParticleSystem;
  111798. /**
  111799. * Sorts the solid particles by material when MultiMaterial is enabled.
  111800. * Updates the indices32 array.
  111801. * Updates the indicesByMaterial array.
  111802. * Updates the mesh indices array.
  111803. * @returns the SPS
  111804. * @hidden
  111805. */
  111806. private _sortParticlesByMaterial;
  111807. /**
  111808. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  111809. * @hidden
  111810. */
  111811. private _setMaterialIndexesById;
  111812. /**
  111813. * Returns an array with unique values of Materials from the passed array
  111814. * @param array the material array to be checked and filtered
  111815. * @hidden
  111816. */
  111817. private _filterUniqueMaterialId;
  111818. /**
  111819. * Sets a new Standard Material as _defaultMaterial if not already set.
  111820. * @hidden
  111821. */
  111822. private _setDefaultMaterial;
  111823. /**
  111824. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  111825. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111826. * @returns the SPS.
  111827. */
  111828. refreshVisibleSize(): SolidParticleSystem;
  111829. /**
  111830. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  111831. * @param size the size (float) of the visibility box
  111832. * note : this doesn't lock the SPS mesh bounding box.
  111833. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111834. */
  111835. setVisibilityBox(size: number): void;
  111836. /**
  111837. * Gets whether the SPS as always visible or not
  111838. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111839. */
  111840. get isAlwaysVisible(): boolean;
  111841. /**
  111842. * Sets the SPS as always visible or not
  111843. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111844. */
  111845. set isAlwaysVisible(val: boolean);
  111846. /**
  111847. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111848. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111849. */
  111850. set isVisibilityBoxLocked(val: boolean);
  111851. /**
  111852. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111853. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111854. */
  111855. get isVisibilityBoxLocked(): boolean;
  111856. /**
  111857. * Tells to `setParticles()` to compute the particle rotations or not.
  111858. * Default value : true. The SPS is faster when it's set to false.
  111859. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111860. */
  111861. set computeParticleRotation(val: boolean);
  111862. /**
  111863. * Tells to `setParticles()` to compute the particle colors or not.
  111864. * Default value : true. The SPS is faster when it's set to false.
  111865. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111866. */
  111867. set computeParticleColor(val: boolean);
  111868. set computeParticleTexture(val: boolean);
  111869. /**
  111870. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  111871. * Default value : false. The SPS is faster when it's set to false.
  111872. * Note : the particle custom vertex positions aren't stored values.
  111873. */
  111874. set computeParticleVertex(val: boolean);
  111875. /**
  111876. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  111877. */
  111878. set computeBoundingBox(val: boolean);
  111879. /**
  111880. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  111881. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111882. * Default : `true`
  111883. */
  111884. set depthSortParticles(val: boolean);
  111885. /**
  111886. * Gets if `setParticles()` computes the particle rotations or not.
  111887. * Default value : true. The SPS is faster when it's set to false.
  111888. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111889. */
  111890. get computeParticleRotation(): boolean;
  111891. /**
  111892. * Gets if `setParticles()` computes the particle colors or not.
  111893. * Default value : true. The SPS is faster when it's set to false.
  111894. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111895. */
  111896. get computeParticleColor(): boolean;
  111897. /**
  111898. * Gets if `setParticles()` computes the particle textures or not.
  111899. * Default value : true. The SPS is faster when it's set to false.
  111900. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  111901. */
  111902. get computeParticleTexture(): boolean;
  111903. /**
  111904. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  111905. * Default value : false. The SPS is faster when it's set to false.
  111906. * Note : the particle custom vertex positions aren't stored values.
  111907. */
  111908. get computeParticleVertex(): boolean;
  111909. /**
  111910. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  111911. */
  111912. get computeBoundingBox(): boolean;
  111913. /**
  111914. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  111915. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111916. * Default : `true`
  111917. */
  111918. get depthSortParticles(): boolean;
  111919. /**
  111920. * Gets if the SPS is created as expandable at construction time.
  111921. * Default : `false`
  111922. */
  111923. get expandable(): boolean;
  111924. /**
  111925. * Gets if the SPS supports the Multi Materials
  111926. */
  111927. get multimaterialEnabled(): boolean;
  111928. /**
  111929. * Gets if the SPS uses the model materials for its own multimaterial.
  111930. */
  111931. get useModelMaterial(): boolean;
  111932. /**
  111933. * The SPS used material array.
  111934. */
  111935. get materials(): Material[];
  111936. /**
  111937. * Sets the SPS MultiMaterial from the passed materials.
  111938. * Note : the passed array is internally copied and not used then by reference.
  111939. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  111940. */
  111941. setMultiMaterial(materials: Material[]): void;
  111942. /**
  111943. * The SPS computed multimaterial object
  111944. */
  111945. get multimaterial(): MultiMaterial;
  111946. set multimaterial(mm: MultiMaterial);
  111947. /**
  111948. * If the subMeshes must be updated on the next call to setParticles()
  111949. */
  111950. get autoUpdateSubMeshes(): boolean;
  111951. set autoUpdateSubMeshes(val: boolean);
  111952. /**
  111953. * This function does nothing. It may be overwritten to set all the particle first values.
  111954. * The SPS doesn't call this function, you may have to call it by your own.
  111955. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111956. */
  111957. initParticles(): void;
  111958. /**
  111959. * This function does nothing. It may be overwritten to recycle a particle.
  111960. * The SPS doesn't call this function, you may have to call it by your own.
  111961. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111962. * @param particle The particle to recycle
  111963. * @returns the recycled particle
  111964. */
  111965. recycleParticle(particle: SolidParticle): SolidParticle;
  111966. /**
  111967. * Updates a particle : this function should be overwritten by the user.
  111968. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  111969. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111970. * @example : just set a particle position or velocity and recycle conditions
  111971. * @param particle The particle to update
  111972. * @returns the updated particle
  111973. */
  111974. updateParticle(particle: SolidParticle): SolidParticle;
  111975. /**
  111976. * Updates a vertex of a particle : it can be overwritten by the user.
  111977. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  111978. * @param particle the current particle
  111979. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  111980. * @param pt the index of the current vertex in the particle shape
  111981. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  111982. * @example : just set a vertex particle position or color
  111983. * @returns the sps
  111984. */
  111985. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  111986. /**
  111987. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  111988. * This does nothing and may be overwritten by the user.
  111989. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111990. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111991. * @param update the boolean update value actually passed to setParticles()
  111992. */
  111993. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111994. /**
  111995. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  111996. * This will be passed three parameters.
  111997. * This does nothing and may be overwritten by the user.
  111998. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111999. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112000. * @param update the boolean update value actually passed to setParticles()
  112001. */
  112002. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  112003. }
  112004. }
  112005. declare module BABYLON {
  112006. /**
  112007. * Represents one particle of a solid particle system.
  112008. */
  112009. export class SolidParticle {
  112010. /**
  112011. * particle global index
  112012. */
  112013. idx: number;
  112014. /**
  112015. * particle identifier
  112016. */
  112017. id: number;
  112018. /**
  112019. * The color of the particle
  112020. */
  112021. color: Nullable<Color4>;
  112022. /**
  112023. * The world space position of the particle.
  112024. */
  112025. position: Vector3;
  112026. /**
  112027. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  112028. */
  112029. rotation: Vector3;
  112030. /**
  112031. * The world space rotation quaternion of the particle.
  112032. */
  112033. rotationQuaternion: Nullable<Quaternion>;
  112034. /**
  112035. * The scaling of the particle.
  112036. */
  112037. scaling: Vector3;
  112038. /**
  112039. * The uvs of the particle.
  112040. */
  112041. uvs: Vector4;
  112042. /**
  112043. * The current speed of the particle.
  112044. */
  112045. velocity: Vector3;
  112046. /**
  112047. * The pivot point in the particle local space.
  112048. */
  112049. pivot: Vector3;
  112050. /**
  112051. * Must the particle be translated from its pivot point in its local space ?
  112052. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  112053. * Default : false
  112054. */
  112055. translateFromPivot: boolean;
  112056. /**
  112057. * Is the particle active or not ?
  112058. */
  112059. alive: boolean;
  112060. /**
  112061. * Is the particle visible or not ?
  112062. */
  112063. isVisible: boolean;
  112064. /**
  112065. * Index of this particle in the global "positions" array (Internal use)
  112066. * @hidden
  112067. */
  112068. _pos: number;
  112069. /**
  112070. * @hidden Index of this particle in the global "indices" array (Internal use)
  112071. */
  112072. _ind: number;
  112073. /**
  112074. * @hidden ModelShape of this particle (Internal use)
  112075. */
  112076. _model: ModelShape;
  112077. /**
  112078. * ModelShape id of this particle
  112079. */
  112080. shapeId: number;
  112081. /**
  112082. * Index of the particle in its shape id
  112083. */
  112084. idxInShape: number;
  112085. /**
  112086. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  112087. */
  112088. _modelBoundingInfo: BoundingInfo;
  112089. /**
  112090. * @hidden Particle BoundingInfo object (Internal use)
  112091. */
  112092. _boundingInfo: BoundingInfo;
  112093. /**
  112094. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  112095. */
  112096. _sps: SolidParticleSystem;
  112097. /**
  112098. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  112099. */
  112100. _stillInvisible: boolean;
  112101. /**
  112102. * @hidden Last computed particle rotation matrix
  112103. */
  112104. _rotationMatrix: number[];
  112105. /**
  112106. * Parent particle Id, if any.
  112107. * Default null.
  112108. */
  112109. parentId: Nullable<number>;
  112110. /**
  112111. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  112112. */
  112113. materialIndex: Nullable<number>;
  112114. /**
  112115. * Custom object or properties.
  112116. */
  112117. props: Nullable<any>;
  112118. /**
  112119. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  112120. * The possible values are :
  112121. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112122. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112123. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112124. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112125. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112126. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  112127. * */
  112128. cullingStrategy: number;
  112129. /**
  112130. * @hidden Internal global position in the SPS.
  112131. */
  112132. _globalPosition: Vector3;
  112133. /**
  112134. * Creates a Solid Particle object.
  112135. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  112136. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  112137. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  112138. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  112139. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  112140. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  112141. * @param shapeId (integer) is the model shape identifier in the SPS.
  112142. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  112143. * @param sps defines the sps it is associated to
  112144. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  112145. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  112146. */
  112147. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  112148. /**
  112149. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  112150. * @param target the particle target
  112151. * @returns the current particle
  112152. */
  112153. copyToRef(target: SolidParticle): SolidParticle;
  112154. /**
  112155. * Legacy support, changed scale to scaling
  112156. */
  112157. get scale(): Vector3;
  112158. /**
  112159. * Legacy support, changed scale to scaling
  112160. */
  112161. set scale(scale: Vector3);
  112162. /**
  112163. * Legacy support, changed quaternion to rotationQuaternion
  112164. */
  112165. get quaternion(): Nullable<Quaternion>;
  112166. /**
  112167. * Legacy support, changed quaternion to rotationQuaternion
  112168. */
  112169. set quaternion(q: Nullable<Quaternion>);
  112170. /**
  112171. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  112172. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  112173. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  112174. * @returns true if it intersects
  112175. */
  112176. intersectsMesh(target: Mesh | SolidParticle): boolean;
  112177. /**
  112178. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  112179. * A particle is in the frustum if its bounding box intersects the frustum
  112180. * @param frustumPlanes defines the frustum to test
  112181. * @returns true if the particle is in the frustum planes
  112182. */
  112183. isInFrustum(frustumPlanes: Plane[]): boolean;
  112184. /**
  112185. * get the rotation matrix of the particle
  112186. * @hidden
  112187. */
  112188. getRotationMatrix(m: Matrix): void;
  112189. }
  112190. /**
  112191. * Represents the shape of the model used by one particle of a solid particle system.
  112192. * SPS internal tool, don't use it manually.
  112193. */
  112194. export class ModelShape {
  112195. /**
  112196. * The shape id
  112197. * @hidden
  112198. */
  112199. shapeID: number;
  112200. /**
  112201. * flat array of model positions (internal use)
  112202. * @hidden
  112203. */
  112204. _shape: Vector3[];
  112205. /**
  112206. * flat array of model UVs (internal use)
  112207. * @hidden
  112208. */
  112209. _shapeUV: number[];
  112210. /**
  112211. * color array of the model
  112212. * @hidden
  112213. */
  112214. _shapeColors: number[];
  112215. /**
  112216. * indices array of the model
  112217. * @hidden
  112218. */
  112219. _indices: number[];
  112220. /**
  112221. * normals array of the model
  112222. * @hidden
  112223. */
  112224. _normals: number[];
  112225. /**
  112226. * length of the shape in the model indices array (internal use)
  112227. * @hidden
  112228. */
  112229. _indicesLength: number;
  112230. /**
  112231. * Custom position function (internal use)
  112232. * @hidden
  112233. */
  112234. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  112235. /**
  112236. * Custom vertex function (internal use)
  112237. * @hidden
  112238. */
  112239. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  112240. /**
  112241. * Model material (internal use)
  112242. * @hidden
  112243. */
  112244. _material: Nullable<Material>;
  112245. /**
  112246. * 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.
  112247. * SPS internal tool, don't use it manually.
  112248. * @hidden
  112249. */
  112250. 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>);
  112251. }
  112252. /**
  112253. * Represents a Depth Sorted Particle in the solid particle system.
  112254. * @hidden
  112255. */
  112256. export class DepthSortedParticle {
  112257. /**
  112258. * Particle index
  112259. */
  112260. idx: number;
  112261. /**
  112262. * Index of the particle in the "indices" array
  112263. */
  112264. ind: number;
  112265. /**
  112266. * Length of the particle shape in the "indices" array
  112267. */
  112268. indicesLength: number;
  112269. /**
  112270. * Squared distance from the particle to the camera
  112271. */
  112272. sqDistance: number;
  112273. /**
  112274. * Material index when used with MultiMaterials
  112275. */
  112276. materialIndex: number;
  112277. /**
  112278. * Creates a new sorted particle
  112279. * @param materialIndex
  112280. */
  112281. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  112282. }
  112283. /**
  112284. * Represents a solid particle vertex
  112285. */
  112286. export class SolidParticleVertex {
  112287. /**
  112288. * Vertex position
  112289. */
  112290. position: Vector3;
  112291. /**
  112292. * Vertex color
  112293. */
  112294. color: Color4;
  112295. /**
  112296. * Vertex UV
  112297. */
  112298. uv: Vector2;
  112299. /**
  112300. * Creates a new solid particle vertex
  112301. */
  112302. constructor();
  112303. /** Vertex x coordinate */
  112304. get x(): number;
  112305. set x(val: number);
  112306. /** Vertex y coordinate */
  112307. get y(): number;
  112308. set y(val: number);
  112309. /** Vertex z coordinate */
  112310. get z(): number;
  112311. set z(val: number);
  112312. }
  112313. }
  112314. declare module BABYLON {
  112315. /**
  112316. * @hidden
  112317. */
  112318. export class _MeshCollisionData {
  112319. _checkCollisions: boolean;
  112320. _collisionMask: number;
  112321. _collisionGroup: number;
  112322. _surroundingMeshes: Nullable<AbstractMesh[]>;
  112323. _collider: Nullable<Collider>;
  112324. _oldPositionForCollisions: Vector3;
  112325. _diffPositionForCollisions: Vector3;
  112326. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  112327. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  112328. _collisionResponse: boolean;
  112329. }
  112330. }
  112331. declare module BABYLON {
  112332. /** @hidden */
  112333. class _FacetDataStorage {
  112334. facetPositions: Vector3[];
  112335. facetNormals: Vector3[];
  112336. facetPartitioning: number[][];
  112337. facetNb: number;
  112338. partitioningSubdivisions: number;
  112339. partitioningBBoxRatio: number;
  112340. facetDataEnabled: boolean;
  112341. facetParameters: any;
  112342. bbSize: Vector3;
  112343. subDiv: {
  112344. max: number;
  112345. X: number;
  112346. Y: number;
  112347. Z: number;
  112348. };
  112349. facetDepthSort: boolean;
  112350. facetDepthSortEnabled: boolean;
  112351. depthSortedIndices: IndicesArray;
  112352. depthSortedFacets: {
  112353. ind: number;
  112354. sqDistance: number;
  112355. }[];
  112356. facetDepthSortFunction: (f1: {
  112357. ind: number;
  112358. sqDistance: number;
  112359. }, f2: {
  112360. ind: number;
  112361. sqDistance: number;
  112362. }) => number;
  112363. facetDepthSortFrom: Vector3;
  112364. facetDepthSortOrigin: Vector3;
  112365. invertedMatrix: Matrix;
  112366. }
  112367. /**
  112368. * @hidden
  112369. **/
  112370. class _InternalAbstractMeshDataInfo {
  112371. _hasVertexAlpha: boolean;
  112372. _useVertexColors: boolean;
  112373. _numBoneInfluencers: number;
  112374. _applyFog: boolean;
  112375. _receiveShadows: boolean;
  112376. _facetData: _FacetDataStorage;
  112377. _visibility: number;
  112378. _skeleton: Nullable<Skeleton>;
  112379. _layerMask: number;
  112380. _computeBonesUsingShaders: boolean;
  112381. _isActive: boolean;
  112382. _onlyForInstances: boolean;
  112383. _isActiveIntermediate: boolean;
  112384. _onlyForInstancesIntermediate: boolean;
  112385. _actAsRegularMesh: boolean;
  112386. }
  112387. /**
  112388. * Class used to store all common mesh properties
  112389. */
  112390. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  112391. /** No occlusion */
  112392. static OCCLUSION_TYPE_NONE: number;
  112393. /** Occlusion set to optimisitic */
  112394. static OCCLUSION_TYPE_OPTIMISTIC: number;
  112395. /** Occlusion set to strict */
  112396. static OCCLUSION_TYPE_STRICT: number;
  112397. /** Use an accurante occlusion algorithm */
  112398. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  112399. /** Use a conservative occlusion algorithm */
  112400. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  112401. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  112402. * Test order :
  112403. * Is the bounding sphere outside the frustum ?
  112404. * If not, are the bounding box vertices outside the frustum ?
  112405. * It not, then the cullable object is in the frustum.
  112406. */
  112407. static readonly CULLINGSTRATEGY_STANDARD: number;
  112408. /** Culling strategy : Bounding Sphere Only.
  112409. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  112410. * It's also less accurate than the standard because some not visible objects can still be selected.
  112411. * Test : is the bounding sphere outside the frustum ?
  112412. * If not, then the cullable object is in the frustum.
  112413. */
  112414. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  112415. /** Culling strategy : Optimistic Inclusion.
  112416. * This in an inclusion test first, then the standard exclusion test.
  112417. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  112418. * 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.
  112419. * Anyway, it's as accurate as the standard strategy.
  112420. * Test :
  112421. * Is the cullable object bounding sphere center in the frustum ?
  112422. * If not, apply the default culling strategy.
  112423. */
  112424. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  112425. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  112426. * This in an inclusion test first, then the bounding sphere only exclusion test.
  112427. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  112428. * 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.
  112429. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  112430. * Test :
  112431. * Is the cullable object bounding sphere center in the frustum ?
  112432. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  112433. */
  112434. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  112435. /**
  112436. * No billboard
  112437. */
  112438. static get BILLBOARDMODE_NONE(): number;
  112439. /** Billboard on X axis */
  112440. static get BILLBOARDMODE_X(): number;
  112441. /** Billboard on Y axis */
  112442. static get BILLBOARDMODE_Y(): number;
  112443. /** Billboard on Z axis */
  112444. static get BILLBOARDMODE_Z(): number;
  112445. /** Billboard on all axes */
  112446. static get BILLBOARDMODE_ALL(): number;
  112447. /** Billboard on using position instead of orientation */
  112448. static get BILLBOARDMODE_USE_POSITION(): number;
  112449. /** @hidden */
  112450. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  112451. /**
  112452. * The culling strategy to use to check whether the mesh must be rendered or not.
  112453. * This value can be changed at any time and will be used on the next render mesh selection.
  112454. * The possible values are :
  112455. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112456. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112457. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112458. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112459. * Please read each static variable documentation to get details about the culling process.
  112460. * */
  112461. cullingStrategy: number;
  112462. /**
  112463. * Gets the number of facets in the mesh
  112464. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112465. */
  112466. get facetNb(): number;
  112467. /**
  112468. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  112469. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112470. */
  112471. get partitioningSubdivisions(): number;
  112472. set partitioningSubdivisions(nb: number);
  112473. /**
  112474. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  112475. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  112476. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112477. */
  112478. get partitioningBBoxRatio(): number;
  112479. set partitioningBBoxRatio(ratio: number);
  112480. /**
  112481. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  112482. * Works only for updatable meshes.
  112483. * Doesn't work with multi-materials
  112484. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112485. */
  112486. get mustDepthSortFacets(): boolean;
  112487. set mustDepthSortFacets(sort: boolean);
  112488. /**
  112489. * The location (Vector3) where the facet depth sort must be computed from.
  112490. * By default, the active camera position.
  112491. * Used only when facet depth sort is enabled
  112492. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112493. */
  112494. get facetDepthSortFrom(): Vector3;
  112495. set facetDepthSortFrom(location: Vector3);
  112496. /**
  112497. * gets a boolean indicating if facetData is enabled
  112498. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112499. */
  112500. get isFacetDataEnabled(): boolean;
  112501. /** @hidden */
  112502. _updateNonUniformScalingState(value: boolean): boolean;
  112503. /**
  112504. * An event triggered when this mesh collides with another one
  112505. */
  112506. onCollideObservable: Observable<AbstractMesh>;
  112507. /** Set a function to call when this mesh collides with another one */
  112508. set onCollide(callback: () => void);
  112509. /**
  112510. * An event triggered when the collision's position changes
  112511. */
  112512. onCollisionPositionChangeObservable: Observable<Vector3>;
  112513. /** Set a function to call when the collision's position changes */
  112514. set onCollisionPositionChange(callback: () => void);
  112515. /**
  112516. * An event triggered when material is changed
  112517. */
  112518. onMaterialChangedObservable: Observable<AbstractMesh>;
  112519. /**
  112520. * Gets or sets the orientation for POV movement & rotation
  112521. */
  112522. definedFacingForward: boolean;
  112523. /** @hidden */
  112524. _occlusionQuery: Nullable<WebGLQuery>;
  112525. /** @hidden */
  112526. _renderingGroup: Nullable<RenderingGroup>;
  112527. /**
  112528. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112529. */
  112530. get visibility(): number;
  112531. /**
  112532. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112533. */
  112534. set visibility(value: number);
  112535. /** Gets or sets the alpha index used to sort transparent meshes
  112536. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  112537. */
  112538. alphaIndex: number;
  112539. /**
  112540. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  112541. */
  112542. isVisible: boolean;
  112543. /**
  112544. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  112545. */
  112546. isPickable: boolean;
  112547. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  112548. showSubMeshesBoundingBox: boolean;
  112549. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  112550. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112551. */
  112552. isBlocker: boolean;
  112553. /**
  112554. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  112555. */
  112556. enablePointerMoveEvents: boolean;
  112557. private _renderingGroupId;
  112558. /**
  112559. * Specifies the rendering group id for this mesh (0 by default)
  112560. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  112561. */
  112562. get renderingGroupId(): number;
  112563. set renderingGroupId(value: number);
  112564. private _material;
  112565. /** Gets or sets current material */
  112566. get material(): Nullable<Material>;
  112567. set material(value: Nullable<Material>);
  112568. /**
  112569. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  112570. * @see https://doc.babylonjs.com/babylon101/shadows
  112571. */
  112572. get receiveShadows(): boolean;
  112573. set receiveShadows(value: boolean);
  112574. /** Defines color to use when rendering outline */
  112575. outlineColor: Color3;
  112576. /** Define width to use when rendering outline */
  112577. outlineWidth: number;
  112578. /** Defines color to use when rendering overlay */
  112579. overlayColor: Color3;
  112580. /** Defines alpha to use when rendering overlay */
  112581. overlayAlpha: number;
  112582. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  112583. get hasVertexAlpha(): boolean;
  112584. set hasVertexAlpha(value: boolean);
  112585. /** 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) */
  112586. get useVertexColors(): boolean;
  112587. set useVertexColors(value: boolean);
  112588. /**
  112589. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  112590. */
  112591. get computeBonesUsingShaders(): boolean;
  112592. set computeBonesUsingShaders(value: boolean);
  112593. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  112594. get numBoneInfluencers(): number;
  112595. set numBoneInfluencers(value: number);
  112596. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  112597. get applyFog(): boolean;
  112598. set applyFog(value: boolean);
  112599. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  112600. useOctreeForRenderingSelection: boolean;
  112601. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  112602. useOctreeForPicking: boolean;
  112603. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  112604. useOctreeForCollisions: boolean;
  112605. /**
  112606. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  112607. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  112608. */
  112609. get layerMask(): number;
  112610. set layerMask(value: number);
  112611. /**
  112612. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  112613. */
  112614. alwaysSelectAsActiveMesh: boolean;
  112615. /**
  112616. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  112617. */
  112618. doNotSyncBoundingInfo: boolean;
  112619. /**
  112620. * Gets or sets the current action manager
  112621. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112622. */
  112623. actionManager: Nullable<AbstractActionManager>;
  112624. private _meshCollisionData;
  112625. /**
  112626. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  112627. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112628. */
  112629. ellipsoid: Vector3;
  112630. /**
  112631. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  112632. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112633. */
  112634. ellipsoidOffset: Vector3;
  112635. /**
  112636. * Gets or sets a collision mask used to mask collisions (default is -1).
  112637. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112638. */
  112639. get collisionMask(): number;
  112640. set collisionMask(mask: number);
  112641. /**
  112642. * Gets or sets a collision response flag (default is true).
  112643. * when collisionResponse is false, events are still triggered but colliding entity has no response
  112644. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  112645. * to respond to the collision.
  112646. */
  112647. get collisionResponse(): boolean;
  112648. set collisionResponse(response: boolean);
  112649. /**
  112650. * Gets or sets the current collision group mask (-1 by default).
  112651. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112652. */
  112653. get collisionGroup(): number;
  112654. set collisionGroup(mask: number);
  112655. /**
  112656. * Gets or sets current surrounding meshes (null by default).
  112657. *
  112658. * By default collision detection is tested against every mesh in the scene.
  112659. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  112660. * meshes will be tested for the collision.
  112661. *
  112662. * Note: if set to an empty array no collision will happen when this mesh is moved.
  112663. */
  112664. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  112665. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  112666. /**
  112667. * Defines edge width used when edgesRenderer is enabled
  112668. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112669. */
  112670. edgesWidth: number;
  112671. /**
  112672. * Defines edge color used when edgesRenderer is enabled
  112673. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112674. */
  112675. edgesColor: Color4;
  112676. /** @hidden */
  112677. _edgesRenderer: Nullable<IEdgesRenderer>;
  112678. /** @hidden */
  112679. _masterMesh: Nullable<AbstractMesh>;
  112680. /** @hidden */
  112681. _boundingInfo: Nullable<BoundingInfo>;
  112682. /** @hidden */
  112683. _renderId: number;
  112684. /**
  112685. * Gets or sets the list of subMeshes
  112686. * @see https://doc.babylonjs.com/how_to/multi_materials
  112687. */
  112688. subMeshes: SubMesh[];
  112689. /** @hidden */
  112690. _intersectionsInProgress: AbstractMesh[];
  112691. /** @hidden */
  112692. _unIndexed: boolean;
  112693. /** @hidden */
  112694. _lightSources: Light[];
  112695. /** Gets the list of lights affecting that mesh */
  112696. get lightSources(): Light[];
  112697. /** @hidden */
  112698. get _positions(): Nullable<Vector3[]>;
  112699. /** @hidden */
  112700. _waitingData: {
  112701. lods: Nullable<any>;
  112702. actions: Nullable<any>;
  112703. freezeWorldMatrix: Nullable<boolean>;
  112704. };
  112705. /** @hidden */
  112706. _bonesTransformMatrices: Nullable<Float32Array>;
  112707. /** @hidden */
  112708. _transformMatrixTexture: Nullable<RawTexture>;
  112709. /**
  112710. * Gets or sets a skeleton to apply skining transformations
  112711. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  112712. */
  112713. set skeleton(value: Nullable<Skeleton>);
  112714. get skeleton(): Nullable<Skeleton>;
  112715. /**
  112716. * An event triggered when the mesh is rebuilt.
  112717. */
  112718. onRebuildObservable: Observable<AbstractMesh>;
  112719. /**
  112720. * Creates a new AbstractMesh
  112721. * @param name defines the name of the mesh
  112722. * @param scene defines the hosting scene
  112723. */
  112724. constructor(name: string, scene?: Nullable<Scene>);
  112725. /**
  112726. * Returns the string "AbstractMesh"
  112727. * @returns "AbstractMesh"
  112728. */
  112729. getClassName(): string;
  112730. /**
  112731. * Gets a string representation of the current mesh
  112732. * @param fullDetails defines a boolean indicating if full details must be included
  112733. * @returns a string representation of the current mesh
  112734. */
  112735. toString(fullDetails?: boolean): string;
  112736. /**
  112737. * @hidden
  112738. */
  112739. protected _getEffectiveParent(): Nullable<Node>;
  112740. /** @hidden */
  112741. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112742. /** @hidden */
  112743. _rebuild(): void;
  112744. /** @hidden */
  112745. _resyncLightSources(): void;
  112746. /** @hidden */
  112747. _resyncLightSource(light: Light): void;
  112748. /** @hidden */
  112749. _unBindEffect(): void;
  112750. /** @hidden */
  112751. _removeLightSource(light: Light, dispose: boolean): void;
  112752. private _markSubMeshesAsDirty;
  112753. /** @hidden */
  112754. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  112755. /** @hidden */
  112756. _markSubMeshesAsAttributesDirty(): void;
  112757. /** @hidden */
  112758. _markSubMeshesAsMiscDirty(): void;
  112759. /**
  112760. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  112761. */
  112762. get scaling(): Vector3;
  112763. set scaling(newScaling: Vector3);
  112764. /**
  112765. * Returns true if the mesh is blocked. Implemented by child classes
  112766. */
  112767. get isBlocked(): boolean;
  112768. /**
  112769. * Returns the mesh itself by default. Implemented by child classes
  112770. * @param camera defines the camera to use to pick the right LOD level
  112771. * @returns the currentAbstractMesh
  112772. */
  112773. getLOD(camera: Camera): Nullable<AbstractMesh>;
  112774. /**
  112775. * Returns 0 by default. Implemented by child classes
  112776. * @returns an integer
  112777. */
  112778. getTotalVertices(): number;
  112779. /**
  112780. * Returns a positive integer : the total number of indices in this mesh geometry.
  112781. * @returns the numner of indices or zero if the mesh has no geometry.
  112782. */
  112783. getTotalIndices(): number;
  112784. /**
  112785. * Returns null by default. Implemented by child classes
  112786. * @returns null
  112787. */
  112788. getIndices(): Nullable<IndicesArray>;
  112789. /**
  112790. * Returns the array of the requested vertex data kind. Implemented by child classes
  112791. * @param kind defines the vertex data kind to use
  112792. * @returns null
  112793. */
  112794. getVerticesData(kind: string): Nullable<FloatArray>;
  112795. /**
  112796. * Sets the vertex data of the mesh geometry for the requested `kind`.
  112797. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  112798. * Note that a new underlying VertexBuffer object is created each call.
  112799. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  112800. * @param kind defines vertex data kind:
  112801. * * VertexBuffer.PositionKind
  112802. * * VertexBuffer.UVKind
  112803. * * VertexBuffer.UV2Kind
  112804. * * VertexBuffer.UV3Kind
  112805. * * VertexBuffer.UV4Kind
  112806. * * VertexBuffer.UV5Kind
  112807. * * VertexBuffer.UV6Kind
  112808. * * VertexBuffer.ColorKind
  112809. * * VertexBuffer.MatricesIndicesKind
  112810. * * VertexBuffer.MatricesIndicesExtraKind
  112811. * * VertexBuffer.MatricesWeightsKind
  112812. * * VertexBuffer.MatricesWeightsExtraKind
  112813. * @param data defines the data source
  112814. * @param updatable defines if the data must be flagged as updatable (or static)
  112815. * @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
  112816. * @returns the current mesh
  112817. */
  112818. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  112819. /**
  112820. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  112821. * If the mesh has no geometry, it is simply returned as it is.
  112822. * @param kind defines vertex data kind:
  112823. * * VertexBuffer.PositionKind
  112824. * * VertexBuffer.UVKind
  112825. * * VertexBuffer.UV2Kind
  112826. * * VertexBuffer.UV3Kind
  112827. * * VertexBuffer.UV4Kind
  112828. * * VertexBuffer.UV5Kind
  112829. * * VertexBuffer.UV6Kind
  112830. * * VertexBuffer.ColorKind
  112831. * * VertexBuffer.MatricesIndicesKind
  112832. * * VertexBuffer.MatricesIndicesExtraKind
  112833. * * VertexBuffer.MatricesWeightsKind
  112834. * * VertexBuffer.MatricesWeightsExtraKind
  112835. * @param data defines the data source
  112836. * @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
  112837. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  112838. * @returns the current mesh
  112839. */
  112840. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  112841. /**
  112842. * Sets the mesh indices,
  112843. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  112844. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  112845. * @param totalVertices Defines the total number of vertices
  112846. * @returns the current mesh
  112847. */
  112848. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  112849. /**
  112850. * Gets a boolean indicating if specific vertex data is present
  112851. * @param kind defines the vertex data kind to use
  112852. * @returns true is data kind is present
  112853. */
  112854. isVerticesDataPresent(kind: string): boolean;
  112855. /**
  112856. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  112857. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  112858. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  112859. * @returns a BoundingInfo
  112860. */
  112861. getBoundingInfo(): BoundingInfo;
  112862. /**
  112863. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  112864. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  112865. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  112866. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  112867. * @returns the current mesh
  112868. */
  112869. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  112870. /**
  112871. * Overwrite the current bounding info
  112872. * @param boundingInfo defines the new bounding info
  112873. * @returns the current mesh
  112874. */
  112875. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  112876. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  112877. get useBones(): boolean;
  112878. /** @hidden */
  112879. _preActivate(): void;
  112880. /** @hidden */
  112881. _preActivateForIntermediateRendering(renderId: number): void;
  112882. /** @hidden */
  112883. _activate(renderId: number, intermediateRendering: boolean): boolean;
  112884. /** @hidden */
  112885. _postActivate(): void;
  112886. /** @hidden */
  112887. _freeze(): void;
  112888. /** @hidden */
  112889. _unFreeze(): void;
  112890. /**
  112891. * Gets the current world matrix
  112892. * @returns a Matrix
  112893. */
  112894. getWorldMatrix(): Matrix;
  112895. /** @hidden */
  112896. _getWorldMatrixDeterminant(): number;
  112897. /**
  112898. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  112899. */
  112900. get isAnInstance(): boolean;
  112901. /**
  112902. * Gets a boolean indicating if this mesh has instances
  112903. */
  112904. get hasInstances(): boolean;
  112905. /**
  112906. * Gets a boolean indicating if this mesh has thin instances
  112907. */
  112908. get hasThinInstances(): boolean;
  112909. /**
  112910. * Perform relative position change from the point of view of behind the front of the mesh.
  112911. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112912. * Supports definition of mesh facing forward or backward
  112913. * @param amountRight defines the distance on the right axis
  112914. * @param amountUp defines the distance on the up axis
  112915. * @param amountForward defines the distance on the forward axis
  112916. * @returns the current mesh
  112917. */
  112918. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  112919. /**
  112920. * Calculate relative position change from the point of view of behind the front of the mesh.
  112921. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112922. * Supports definition of mesh facing forward or backward
  112923. * @param amountRight defines the distance on the right axis
  112924. * @param amountUp defines the distance on the up axis
  112925. * @param amountForward defines the distance on the forward axis
  112926. * @returns the new displacement vector
  112927. */
  112928. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  112929. /**
  112930. * Perform relative rotation change from the point of view of behind the front of the mesh.
  112931. * Supports definition of mesh facing forward or backward
  112932. * @param flipBack defines the flip
  112933. * @param twirlClockwise defines the twirl
  112934. * @param tiltRight defines the tilt
  112935. * @returns the current mesh
  112936. */
  112937. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  112938. /**
  112939. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  112940. * Supports definition of mesh facing forward or backward.
  112941. * @param flipBack defines the flip
  112942. * @param twirlClockwise defines the twirl
  112943. * @param tiltRight defines the tilt
  112944. * @returns the new rotation vector
  112945. */
  112946. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  112947. /**
  112948. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  112949. * This means the mesh underlying bounding box and sphere are recomputed.
  112950. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  112951. * @returns the current mesh
  112952. */
  112953. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  112954. /** @hidden */
  112955. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  112956. /** @hidden */
  112957. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  112958. /** @hidden */
  112959. _updateBoundingInfo(): AbstractMesh;
  112960. /** @hidden */
  112961. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  112962. /** @hidden */
  112963. protected _afterComputeWorldMatrix(): void;
  112964. /** @hidden */
  112965. get _effectiveMesh(): AbstractMesh;
  112966. /**
  112967. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  112968. * A mesh is in the frustum if its bounding box intersects the frustum
  112969. * @param frustumPlanes defines the frustum to test
  112970. * @returns true if the mesh is in the frustum planes
  112971. */
  112972. isInFrustum(frustumPlanes: Plane[]): boolean;
  112973. /**
  112974. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  112975. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  112976. * @param frustumPlanes defines the frustum to test
  112977. * @returns true if the mesh is completely in the frustum planes
  112978. */
  112979. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  112980. /**
  112981. * True if the mesh intersects another mesh or a SolidParticle object
  112982. * @param mesh defines a target mesh or SolidParticle to test
  112983. * @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)
  112984. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  112985. * @returns true if there is an intersection
  112986. */
  112987. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  112988. /**
  112989. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  112990. * @param point defines the point to test
  112991. * @returns true if there is an intersection
  112992. */
  112993. intersectsPoint(point: Vector3): boolean;
  112994. /**
  112995. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  112996. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112997. */
  112998. get checkCollisions(): boolean;
  112999. set checkCollisions(collisionEnabled: boolean);
  113000. /**
  113001. * Gets Collider object used to compute collisions (not physics)
  113002. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  113003. */
  113004. get collider(): Nullable<Collider>;
  113005. /**
  113006. * Move the mesh using collision engine
  113007. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  113008. * @param displacement defines the requested displacement vector
  113009. * @returns the current mesh
  113010. */
  113011. moveWithCollisions(displacement: Vector3): AbstractMesh;
  113012. private _onCollisionPositionChange;
  113013. /** @hidden */
  113014. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  113015. /** @hidden */
  113016. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  113017. /** @hidden */
  113018. _checkCollision(collider: Collider): AbstractMesh;
  113019. /** @hidden */
  113020. _generatePointsArray(): boolean;
  113021. /**
  113022. * Checks if the passed Ray intersects with the mesh
  113023. * @param ray defines the ray to use
  113024. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  113025. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113026. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  113027. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  113028. * @returns the picking info
  113029. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  113030. */
  113031. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  113032. /**
  113033. * Clones the current mesh
  113034. * @param name defines the mesh name
  113035. * @param newParent defines the new mesh parent
  113036. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  113037. * @returns the new mesh
  113038. */
  113039. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  113040. /**
  113041. * Disposes all the submeshes of the current meshnp
  113042. * @returns the current mesh
  113043. */
  113044. releaseSubMeshes(): AbstractMesh;
  113045. /**
  113046. * Releases resources associated with this abstract mesh.
  113047. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113048. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113049. */
  113050. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113051. /**
  113052. * Adds the passed mesh as a child to the current mesh
  113053. * @param mesh defines the child mesh
  113054. * @returns the current mesh
  113055. */
  113056. addChild(mesh: AbstractMesh): AbstractMesh;
  113057. /**
  113058. * Removes the passed mesh from the current mesh children list
  113059. * @param mesh defines the child mesh
  113060. * @returns the current mesh
  113061. */
  113062. removeChild(mesh: AbstractMesh): AbstractMesh;
  113063. /** @hidden */
  113064. private _initFacetData;
  113065. /**
  113066. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  113067. * This method can be called within the render loop.
  113068. * 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
  113069. * @returns the current mesh
  113070. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113071. */
  113072. updateFacetData(): AbstractMesh;
  113073. /**
  113074. * Returns the facetLocalNormals array.
  113075. * The normals are expressed in the mesh local spac
  113076. * @returns an array of Vector3
  113077. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113078. */
  113079. getFacetLocalNormals(): Vector3[];
  113080. /**
  113081. * Returns the facetLocalPositions array.
  113082. * The facet positions are expressed in the mesh local space
  113083. * @returns an array of Vector3
  113084. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113085. */
  113086. getFacetLocalPositions(): Vector3[];
  113087. /**
  113088. * Returns the facetLocalPartioning array
  113089. * @returns an array of array of numbers
  113090. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113091. */
  113092. getFacetLocalPartitioning(): number[][];
  113093. /**
  113094. * Returns the i-th facet position in the world system.
  113095. * This method allocates a new Vector3 per call
  113096. * @param i defines the facet index
  113097. * @returns a new Vector3
  113098. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113099. */
  113100. getFacetPosition(i: number): Vector3;
  113101. /**
  113102. * Sets the reference Vector3 with the i-th facet position in the world system
  113103. * @param i defines the facet index
  113104. * @param ref defines the target vector
  113105. * @returns the current mesh
  113106. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113107. */
  113108. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  113109. /**
  113110. * Returns the i-th facet normal in the world system.
  113111. * This method allocates a new Vector3 per call
  113112. * @param i defines the facet index
  113113. * @returns a new Vector3
  113114. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113115. */
  113116. getFacetNormal(i: number): Vector3;
  113117. /**
  113118. * Sets the reference Vector3 with the i-th facet normal in the world system
  113119. * @param i defines the facet index
  113120. * @param ref defines the target vector
  113121. * @returns the current mesh
  113122. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113123. */
  113124. getFacetNormalToRef(i: number, ref: Vector3): this;
  113125. /**
  113126. * 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)
  113127. * @param x defines x coordinate
  113128. * @param y defines y coordinate
  113129. * @param z defines z coordinate
  113130. * @returns the array of facet indexes
  113131. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113132. */
  113133. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  113134. /**
  113135. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  113136. * @param projected sets as the (x,y,z) world projection on the facet
  113137. * @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
  113138. * @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
  113139. * @param x defines x coordinate
  113140. * @param y defines y coordinate
  113141. * @param z defines z coordinate
  113142. * @returns the face index if found (or null instead)
  113143. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113144. */
  113145. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  113146. /**
  113147. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  113148. * @param projected sets as the (x,y,z) local projection on the facet
  113149. * @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
  113150. * @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
  113151. * @param x defines x coordinate
  113152. * @param y defines y coordinate
  113153. * @param z defines z coordinate
  113154. * @returns the face index if found (or null instead)
  113155. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113156. */
  113157. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  113158. /**
  113159. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  113160. * @returns the parameters
  113161. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113162. */
  113163. getFacetDataParameters(): any;
  113164. /**
  113165. * Disables the feature FacetData and frees the related memory
  113166. * @returns the current mesh
  113167. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113168. */
  113169. disableFacetData(): AbstractMesh;
  113170. /**
  113171. * Updates the AbstractMesh indices array
  113172. * @param indices defines the data source
  113173. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  113174. * @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)
  113175. * @returns the current mesh
  113176. */
  113177. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  113178. /**
  113179. * Creates new normals data for the mesh
  113180. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  113181. * @returns the current mesh
  113182. */
  113183. createNormals(updatable: boolean): AbstractMesh;
  113184. /**
  113185. * Align the mesh with a normal
  113186. * @param normal defines the normal to use
  113187. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  113188. * @returns the current mesh
  113189. */
  113190. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  113191. /** @hidden */
  113192. _checkOcclusionQuery(): boolean;
  113193. /**
  113194. * Disables the mesh edge rendering mode
  113195. * @returns the currentAbstractMesh
  113196. */
  113197. disableEdgesRendering(): AbstractMesh;
  113198. /**
  113199. * Enables the edge rendering mode on the mesh.
  113200. * This mode makes the mesh edges visible
  113201. * @param epsilon defines the maximal distance between two angles to detect a face
  113202. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  113203. * @returns the currentAbstractMesh
  113204. * @see https://www.babylonjs-playground.com/#19O9TU#0
  113205. */
  113206. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  113207. /**
  113208. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  113209. * @returns an array of particle systems in the scene that use the mesh as an emitter
  113210. */
  113211. getConnectedParticleSystems(): IParticleSystem[];
  113212. }
  113213. }
  113214. declare module BABYLON {
  113215. /**
  113216. * Interface used to define ActionEvent
  113217. */
  113218. export interface IActionEvent {
  113219. /** The mesh or sprite that triggered the action */
  113220. source: any;
  113221. /** The X mouse cursor position at the time of the event */
  113222. pointerX: number;
  113223. /** The Y mouse cursor position at the time of the event */
  113224. pointerY: number;
  113225. /** The mesh that is currently pointed at (can be null) */
  113226. meshUnderPointer: Nullable<AbstractMesh>;
  113227. /** the original (browser) event that triggered the ActionEvent */
  113228. sourceEvent?: any;
  113229. /** additional data for the event */
  113230. additionalData?: any;
  113231. }
  113232. /**
  113233. * ActionEvent is the event being sent when an action is triggered.
  113234. */
  113235. export class ActionEvent implements IActionEvent {
  113236. /** The mesh or sprite that triggered the action */
  113237. source: any;
  113238. /** The X mouse cursor position at the time of the event */
  113239. pointerX: number;
  113240. /** The Y mouse cursor position at the time of the event */
  113241. pointerY: number;
  113242. /** The mesh that is currently pointed at (can be null) */
  113243. meshUnderPointer: Nullable<AbstractMesh>;
  113244. /** the original (browser) event that triggered the ActionEvent */
  113245. sourceEvent?: any;
  113246. /** additional data for the event */
  113247. additionalData?: any;
  113248. /**
  113249. * Creates a new ActionEvent
  113250. * @param source The mesh or sprite that triggered the action
  113251. * @param pointerX The X mouse cursor position at the time of the event
  113252. * @param pointerY The Y mouse cursor position at the time of the event
  113253. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  113254. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  113255. * @param additionalData additional data for the event
  113256. */
  113257. constructor(
  113258. /** The mesh or sprite that triggered the action */
  113259. source: any,
  113260. /** The X mouse cursor position at the time of the event */
  113261. pointerX: number,
  113262. /** The Y mouse cursor position at the time of the event */
  113263. pointerY: number,
  113264. /** The mesh that is currently pointed at (can be null) */
  113265. meshUnderPointer: Nullable<AbstractMesh>,
  113266. /** the original (browser) event that triggered the ActionEvent */
  113267. sourceEvent?: any,
  113268. /** additional data for the event */
  113269. additionalData?: any);
  113270. /**
  113271. * Helper function to auto-create an ActionEvent from a source mesh.
  113272. * @param source The source mesh that triggered the event
  113273. * @param evt The original (browser) event
  113274. * @param additionalData additional data for the event
  113275. * @returns the new ActionEvent
  113276. */
  113277. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  113278. /**
  113279. * Helper function to auto-create an ActionEvent from a source sprite
  113280. * @param source The source sprite that triggered the event
  113281. * @param scene Scene associated with the sprite
  113282. * @param evt The original (browser) event
  113283. * @param additionalData additional data for the event
  113284. * @returns the new ActionEvent
  113285. */
  113286. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  113287. /**
  113288. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  113289. * @param scene the scene where the event occurred
  113290. * @param evt The original (browser) event
  113291. * @returns the new ActionEvent
  113292. */
  113293. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  113294. /**
  113295. * Helper function to auto-create an ActionEvent from a primitive
  113296. * @param prim defines the target primitive
  113297. * @param pointerPos defines the pointer position
  113298. * @param evt The original (browser) event
  113299. * @param additionalData additional data for the event
  113300. * @returns the new ActionEvent
  113301. */
  113302. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  113303. }
  113304. }
  113305. declare module BABYLON {
  113306. /**
  113307. * Abstract class used to decouple action Manager from scene and meshes.
  113308. * Do not instantiate.
  113309. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  113310. */
  113311. export abstract class AbstractActionManager implements IDisposable {
  113312. /** Gets the list of active triggers */
  113313. static Triggers: {
  113314. [key: string]: number;
  113315. };
  113316. /** Gets the cursor to use when hovering items */
  113317. hoverCursor: string;
  113318. /** Gets the list of actions */
  113319. actions: IAction[];
  113320. /**
  113321. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  113322. */
  113323. isRecursive: boolean;
  113324. /**
  113325. * Releases all associated resources
  113326. */
  113327. abstract dispose(): void;
  113328. /**
  113329. * Does this action manager has pointer triggers
  113330. */
  113331. abstract get hasPointerTriggers(): boolean;
  113332. /**
  113333. * Does this action manager has pick triggers
  113334. */
  113335. abstract get hasPickTriggers(): boolean;
  113336. /**
  113337. * Process a specific trigger
  113338. * @param trigger defines the trigger to process
  113339. * @param evt defines the event details to be processed
  113340. */
  113341. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  113342. /**
  113343. * Does this action manager handles actions of any of the given triggers
  113344. * @param triggers defines the triggers to be tested
  113345. * @return a boolean indicating whether one (or more) of the triggers is handled
  113346. */
  113347. abstract hasSpecificTriggers(triggers: number[]): boolean;
  113348. /**
  113349. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  113350. * speed.
  113351. * @param triggerA defines the trigger to be tested
  113352. * @param triggerB defines the trigger to be tested
  113353. * @return a boolean indicating whether one (or more) of the triggers is handled
  113354. */
  113355. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  113356. /**
  113357. * Does this action manager handles actions of a given trigger
  113358. * @param trigger defines the trigger to be tested
  113359. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  113360. * @return whether the trigger is handled
  113361. */
  113362. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  113363. /**
  113364. * Serialize this manager to a JSON object
  113365. * @param name defines the property name to store this manager
  113366. * @returns a JSON representation of this manager
  113367. */
  113368. abstract serialize(name: string): any;
  113369. /**
  113370. * Registers an action to this action manager
  113371. * @param action defines the action to be registered
  113372. * @return the action amended (prepared) after registration
  113373. */
  113374. abstract registerAction(action: IAction): Nullable<IAction>;
  113375. /**
  113376. * Unregisters an action to this action manager
  113377. * @param action defines the action to be unregistered
  113378. * @return a boolean indicating whether the action has been unregistered
  113379. */
  113380. abstract unregisterAction(action: IAction): Boolean;
  113381. /**
  113382. * Does exist one action manager with at least one trigger
  113383. **/
  113384. static get HasTriggers(): boolean;
  113385. /**
  113386. * Does exist one action manager with at least one pick trigger
  113387. **/
  113388. static get HasPickTriggers(): boolean;
  113389. /**
  113390. * Does exist one action manager that handles actions of a given trigger
  113391. * @param trigger defines the trigger to be tested
  113392. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  113393. **/
  113394. static HasSpecificTrigger(trigger: number): boolean;
  113395. }
  113396. }
  113397. declare module BABYLON {
  113398. /**
  113399. * Defines how a node can be built from a string name.
  113400. */
  113401. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  113402. /**
  113403. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  113404. */
  113405. export class Node implements IBehaviorAware<Node> {
  113406. /** @hidden */
  113407. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  113408. private static _NodeConstructors;
  113409. /**
  113410. * Add a new node constructor
  113411. * @param type defines the type name of the node to construct
  113412. * @param constructorFunc defines the constructor function
  113413. */
  113414. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  113415. /**
  113416. * Returns a node constructor based on type name
  113417. * @param type defines the type name
  113418. * @param name defines the new node name
  113419. * @param scene defines the hosting scene
  113420. * @param options defines optional options to transmit to constructors
  113421. * @returns the new constructor or null
  113422. */
  113423. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  113424. /**
  113425. * Gets or sets the name of the node
  113426. */
  113427. name: string;
  113428. /**
  113429. * Gets or sets the id of the node
  113430. */
  113431. id: string;
  113432. /**
  113433. * Gets or sets the unique id of the node
  113434. */
  113435. uniqueId: number;
  113436. /**
  113437. * Gets or sets a string used to store user defined state for the node
  113438. */
  113439. state: string;
  113440. /**
  113441. * Gets or sets an object used to store user defined information for the node
  113442. */
  113443. metadata: any;
  113444. /**
  113445. * For internal use only. Please do not use.
  113446. */
  113447. reservedDataStore: any;
  113448. /**
  113449. * List of inspectable custom properties (used by the Inspector)
  113450. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113451. */
  113452. inspectableCustomProperties: IInspectable[];
  113453. private _doNotSerialize;
  113454. /**
  113455. * Gets or sets a boolean used to define if the node must be serialized
  113456. */
  113457. get doNotSerialize(): boolean;
  113458. set doNotSerialize(value: boolean);
  113459. /** @hidden */
  113460. _isDisposed: boolean;
  113461. /**
  113462. * Gets a list of Animations associated with the node
  113463. */
  113464. animations: Animation[];
  113465. protected _ranges: {
  113466. [name: string]: Nullable<AnimationRange>;
  113467. };
  113468. /**
  113469. * Callback raised when the node is ready to be used
  113470. */
  113471. onReady: Nullable<(node: Node) => void>;
  113472. private _isEnabled;
  113473. private _isParentEnabled;
  113474. private _isReady;
  113475. /** @hidden */
  113476. _currentRenderId: number;
  113477. private _parentUpdateId;
  113478. /** @hidden */
  113479. _childUpdateId: number;
  113480. /** @hidden */
  113481. _waitingParentId: Nullable<string>;
  113482. /** @hidden */
  113483. _scene: Scene;
  113484. /** @hidden */
  113485. _cache: any;
  113486. private _parentNode;
  113487. private _children;
  113488. /** @hidden */
  113489. _worldMatrix: Matrix;
  113490. /** @hidden */
  113491. _worldMatrixDeterminant: number;
  113492. /** @hidden */
  113493. _worldMatrixDeterminantIsDirty: boolean;
  113494. /** @hidden */
  113495. private _sceneRootNodesIndex;
  113496. /**
  113497. * Gets a boolean indicating if the node has been disposed
  113498. * @returns true if the node was disposed
  113499. */
  113500. isDisposed(): boolean;
  113501. /**
  113502. * Gets or sets the parent of the node (without keeping the current position in the scene)
  113503. * @see https://doc.babylonjs.com/how_to/parenting
  113504. */
  113505. set parent(parent: Nullable<Node>);
  113506. get parent(): Nullable<Node>;
  113507. /** @hidden */
  113508. _addToSceneRootNodes(): void;
  113509. /** @hidden */
  113510. _removeFromSceneRootNodes(): void;
  113511. private _animationPropertiesOverride;
  113512. /**
  113513. * Gets or sets the animation properties override
  113514. */
  113515. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  113516. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  113517. /**
  113518. * Gets a string identifying the name of the class
  113519. * @returns "Node" string
  113520. */
  113521. getClassName(): string;
  113522. /** @hidden */
  113523. readonly _isNode: boolean;
  113524. /**
  113525. * An event triggered when the mesh is disposed
  113526. */
  113527. onDisposeObservable: Observable<Node>;
  113528. private _onDisposeObserver;
  113529. /**
  113530. * Sets a callback that will be raised when the node will be disposed
  113531. */
  113532. set onDispose(callback: () => void);
  113533. /**
  113534. * Creates a new Node
  113535. * @param name the name and id to be given to this node
  113536. * @param scene the scene this node will be added to
  113537. */
  113538. constructor(name: string, scene?: Nullable<Scene>);
  113539. /**
  113540. * Gets the scene of the node
  113541. * @returns a scene
  113542. */
  113543. getScene(): Scene;
  113544. /**
  113545. * Gets the engine of the node
  113546. * @returns a Engine
  113547. */
  113548. getEngine(): Engine;
  113549. private _behaviors;
  113550. /**
  113551. * Attach a behavior to the node
  113552. * @see https://doc.babylonjs.com/features/behaviour
  113553. * @param behavior defines the behavior to attach
  113554. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  113555. * @returns the current Node
  113556. */
  113557. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  113558. /**
  113559. * Remove an attached behavior
  113560. * @see https://doc.babylonjs.com/features/behaviour
  113561. * @param behavior defines the behavior to attach
  113562. * @returns the current Node
  113563. */
  113564. removeBehavior(behavior: Behavior<Node>): Node;
  113565. /**
  113566. * Gets the list of attached behaviors
  113567. * @see https://doc.babylonjs.com/features/behaviour
  113568. */
  113569. get behaviors(): Behavior<Node>[];
  113570. /**
  113571. * Gets an attached behavior by name
  113572. * @param name defines the name of the behavior to look for
  113573. * @see https://doc.babylonjs.com/features/behaviour
  113574. * @returns null if behavior was not found else the requested behavior
  113575. */
  113576. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  113577. /**
  113578. * Returns the latest update of the World matrix
  113579. * @returns a Matrix
  113580. */
  113581. getWorldMatrix(): Matrix;
  113582. /** @hidden */
  113583. _getWorldMatrixDeterminant(): number;
  113584. /**
  113585. * Returns directly the latest state of the mesh World matrix.
  113586. * A Matrix is returned.
  113587. */
  113588. get worldMatrixFromCache(): Matrix;
  113589. /** @hidden */
  113590. _initCache(): void;
  113591. /** @hidden */
  113592. updateCache(force?: boolean): void;
  113593. /** @hidden */
  113594. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  113595. /** @hidden */
  113596. _updateCache(ignoreParentClass?: boolean): void;
  113597. /** @hidden */
  113598. _isSynchronized(): boolean;
  113599. /** @hidden */
  113600. _markSyncedWithParent(): void;
  113601. /** @hidden */
  113602. isSynchronizedWithParent(): boolean;
  113603. /** @hidden */
  113604. isSynchronized(): boolean;
  113605. /**
  113606. * Is this node ready to be used/rendered
  113607. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113608. * @return true if the node is ready
  113609. */
  113610. isReady(completeCheck?: boolean): boolean;
  113611. /**
  113612. * Is this node enabled?
  113613. * 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
  113614. * @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
  113615. * @return whether this node (and its parent) is enabled
  113616. */
  113617. isEnabled(checkAncestors?: boolean): boolean;
  113618. /** @hidden */
  113619. protected _syncParentEnabledState(): void;
  113620. /**
  113621. * Set the enabled state of this node
  113622. * @param value defines the new enabled state
  113623. */
  113624. setEnabled(value: boolean): void;
  113625. /**
  113626. * Is this node a descendant of the given node?
  113627. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  113628. * @param ancestor defines the parent node to inspect
  113629. * @returns a boolean indicating if this node is a descendant of the given node
  113630. */
  113631. isDescendantOf(ancestor: Node): boolean;
  113632. /** @hidden */
  113633. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  113634. /**
  113635. * Will return all nodes that have this node as ascendant
  113636. * @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
  113637. * @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
  113638. * @return all children nodes of all types
  113639. */
  113640. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  113641. /**
  113642. * Get all child-meshes of this node
  113643. * @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)
  113644. * @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
  113645. * @returns an array of AbstractMesh
  113646. */
  113647. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  113648. /**
  113649. * Get all direct children of this node
  113650. * @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
  113651. * @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)
  113652. * @returns an array of Node
  113653. */
  113654. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  113655. /** @hidden */
  113656. _setReady(state: boolean): void;
  113657. /**
  113658. * Get an animation by name
  113659. * @param name defines the name of the animation to look for
  113660. * @returns null if not found else the requested animation
  113661. */
  113662. getAnimationByName(name: string): Nullable<Animation>;
  113663. /**
  113664. * Creates an animation range for this node
  113665. * @param name defines the name of the range
  113666. * @param from defines the starting key
  113667. * @param to defines the end key
  113668. */
  113669. createAnimationRange(name: string, from: number, to: number): void;
  113670. /**
  113671. * Delete a specific animation range
  113672. * @param name defines the name of the range to delete
  113673. * @param deleteFrames defines if animation frames from the range must be deleted as well
  113674. */
  113675. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  113676. /**
  113677. * Get an animation range by name
  113678. * @param name defines the name of the animation range to look for
  113679. * @returns null if not found else the requested animation range
  113680. */
  113681. getAnimationRange(name: string): Nullable<AnimationRange>;
  113682. /**
  113683. * Gets the list of all animation ranges defined on this node
  113684. * @returns an array
  113685. */
  113686. getAnimationRanges(): Nullable<AnimationRange>[];
  113687. /**
  113688. * Will start the animation sequence
  113689. * @param name defines the range frames for animation sequence
  113690. * @param loop defines if the animation should loop (false by default)
  113691. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  113692. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  113693. * @returns the object created for this animation. If range does not exist, it will return null
  113694. */
  113695. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  113696. /**
  113697. * Serialize animation ranges into a JSON compatible object
  113698. * @returns serialization object
  113699. */
  113700. serializeAnimationRanges(): any;
  113701. /**
  113702. * Computes the world matrix of the node
  113703. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  113704. * @returns the world matrix
  113705. */
  113706. computeWorldMatrix(force?: boolean): Matrix;
  113707. /**
  113708. * Releases resources associated with this node.
  113709. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113710. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113711. */
  113712. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113713. /**
  113714. * Parse animation range data from a serialization object and store them into a given node
  113715. * @param node defines where to store the animation ranges
  113716. * @param parsedNode defines the serialization object to read data from
  113717. * @param scene defines the hosting scene
  113718. */
  113719. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  113720. /**
  113721. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  113722. * @param includeDescendants Include bounding info from descendants as well (true by default)
  113723. * @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
  113724. * @returns the new bounding vectors
  113725. */
  113726. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  113727. min: Vector3;
  113728. max: Vector3;
  113729. };
  113730. }
  113731. }
  113732. declare module BABYLON {
  113733. /**
  113734. * @hidden
  113735. */
  113736. export class _IAnimationState {
  113737. key: number;
  113738. repeatCount: number;
  113739. workValue?: any;
  113740. loopMode?: number;
  113741. offsetValue?: any;
  113742. highLimitValue?: any;
  113743. }
  113744. /**
  113745. * Class used to store any kind of animation
  113746. */
  113747. export class Animation {
  113748. /**Name of the animation */
  113749. name: string;
  113750. /**Property to animate */
  113751. targetProperty: string;
  113752. /**The frames per second of the animation */
  113753. framePerSecond: number;
  113754. /**The data type of the animation */
  113755. dataType: number;
  113756. /**The loop mode of the animation */
  113757. loopMode?: number | undefined;
  113758. /**Specifies if blending should be enabled */
  113759. enableBlending?: boolean | undefined;
  113760. /**
  113761. * Use matrix interpolation instead of using direct key value when animating matrices
  113762. */
  113763. static AllowMatricesInterpolation: boolean;
  113764. /**
  113765. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  113766. */
  113767. static AllowMatrixDecomposeForInterpolation: boolean;
  113768. /** Define the Url to load snippets */
  113769. static SnippetUrl: string;
  113770. /** Snippet ID if the animation was created from the snippet server */
  113771. snippetId: string;
  113772. /**
  113773. * Stores the key frames of the animation
  113774. */
  113775. private _keys;
  113776. /**
  113777. * Stores the easing function of the animation
  113778. */
  113779. private _easingFunction;
  113780. /**
  113781. * @hidden Internal use only
  113782. */
  113783. _runtimeAnimations: RuntimeAnimation[];
  113784. /**
  113785. * The set of event that will be linked to this animation
  113786. */
  113787. private _events;
  113788. /**
  113789. * Stores an array of target property paths
  113790. */
  113791. targetPropertyPath: string[];
  113792. /**
  113793. * Stores the blending speed of the animation
  113794. */
  113795. blendingSpeed: number;
  113796. /**
  113797. * Stores the animation ranges for the animation
  113798. */
  113799. private _ranges;
  113800. /**
  113801. * @hidden Internal use
  113802. */
  113803. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  113804. /**
  113805. * Sets up an animation
  113806. * @param property The property to animate
  113807. * @param animationType The animation type to apply
  113808. * @param framePerSecond The frames per second of the animation
  113809. * @param easingFunction The easing function used in the animation
  113810. * @returns The created animation
  113811. */
  113812. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  113813. /**
  113814. * Create and start an animation on a node
  113815. * @param name defines the name of the global animation that will be run on all nodes
  113816. * @param node defines the root node where the animation will take place
  113817. * @param targetProperty defines property to animate
  113818. * @param framePerSecond defines the number of frame per second yo use
  113819. * @param totalFrame defines the number of frames in total
  113820. * @param from defines the initial value
  113821. * @param to defines the final value
  113822. * @param loopMode defines which loop mode you want to use (off by default)
  113823. * @param easingFunction defines the easing function to use (linear by default)
  113824. * @param onAnimationEnd defines the callback to call when animation end
  113825. * @returns the animatable created for this animation
  113826. */
  113827. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113828. /**
  113829. * Create and start an animation on a node and its descendants
  113830. * @param name defines the name of the global animation that will be run on all nodes
  113831. * @param node defines the root node where the animation will take place
  113832. * @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
  113833. * @param targetProperty defines property to animate
  113834. * @param framePerSecond defines the number of frame per second to use
  113835. * @param totalFrame defines the number of frames in total
  113836. * @param from defines the initial value
  113837. * @param to defines the final value
  113838. * @param loopMode defines which loop mode you want to use (off by default)
  113839. * @param easingFunction defines the easing function to use (linear by default)
  113840. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  113841. * @returns the list of animatables created for all nodes
  113842. * @example https://www.babylonjs-playground.com/#MH0VLI
  113843. */
  113844. 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[]>;
  113845. /**
  113846. * Creates a new animation, merges it with the existing animations and starts it
  113847. * @param name Name of the animation
  113848. * @param node Node which contains the scene that begins the animations
  113849. * @param targetProperty Specifies which property to animate
  113850. * @param framePerSecond The frames per second of the animation
  113851. * @param totalFrame The total number of frames
  113852. * @param from The frame at the beginning of the animation
  113853. * @param to The frame at the end of the animation
  113854. * @param loopMode Specifies the loop mode of the animation
  113855. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  113856. * @param onAnimationEnd Callback to run once the animation is complete
  113857. * @returns Nullable animation
  113858. */
  113859. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113860. /**
  113861. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  113862. * @param sourceAnimation defines the Animation containing keyframes to convert
  113863. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  113864. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  113865. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  113866. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  113867. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  113868. */
  113869. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  113870. /**
  113871. * Transition property of an host to the target Value
  113872. * @param property The property to transition
  113873. * @param targetValue The target Value of the property
  113874. * @param host The object where the property to animate belongs
  113875. * @param scene Scene used to run the animation
  113876. * @param frameRate Framerate (in frame/s) to use
  113877. * @param transition The transition type we want to use
  113878. * @param duration The duration of the animation, in milliseconds
  113879. * @param onAnimationEnd Callback trigger at the end of the animation
  113880. * @returns Nullable animation
  113881. */
  113882. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  113883. /**
  113884. * Return the array of runtime animations currently using this animation
  113885. */
  113886. get runtimeAnimations(): RuntimeAnimation[];
  113887. /**
  113888. * Specifies if any of the runtime animations are currently running
  113889. */
  113890. get hasRunningRuntimeAnimations(): boolean;
  113891. /**
  113892. * Initializes the animation
  113893. * @param name Name of the animation
  113894. * @param targetProperty Property to animate
  113895. * @param framePerSecond The frames per second of the animation
  113896. * @param dataType The data type of the animation
  113897. * @param loopMode The loop mode of the animation
  113898. * @param enableBlending Specifies if blending should be enabled
  113899. */
  113900. constructor(
  113901. /**Name of the animation */
  113902. name: string,
  113903. /**Property to animate */
  113904. targetProperty: string,
  113905. /**The frames per second of the animation */
  113906. framePerSecond: number,
  113907. /**The data type of the animation */
  113908. dataType: number,
  113909. /**The loop mode of the animation */
  113910. loopMode?: number | undefined,
  113911. /**Specifies if blending should be enabled */
  113912. enableBlending?: boolean | undefined);
  113913. /**
  113914. * Converts the animation to a string
  113915. * @param fullDetails support for multiple levels of logging within scene loading
  113916. * @returns String form of the animation
  113917. */
  113918. toString(fullDetails?: boolean): string;
  113919. /**
  113920. * Add an event to this animation
  113921. * @param event Event to add
  113922. */
  113923. addEvent(event: AnimationEvent): void;
  113924. /**
  113925. * Remove all events found at the given frame
  113926. * @param frame The frame to remove events from
  113927. */
  113928. removeEvents(frame: number): void;
  113929. /**
  113930. * Retrieves all the events from the animation
  113931. * @returns Events from the animation
  113932. */
  113933. getEvents(): AnimationEvent[];
  113934. /**
  113935. * Creates an animation range
  113936. * @param name Name of the animation range
  113937. * @param from Starting frame of the animation range
  113938. * @param to Ending frame of the animation
  113939. */
  113940. createRange(name: string, from: number, to: number): void;
  113941. /**
  113942. * Deletes an animation range by name
  113943. * @param name Name of the animation range to delete
  113944. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  113945. */
  113946. deleteRange(name: string, deleteFrames?: boolean): void;
  113947. /**
  113948. * Gets the animation range by name, or null if not defined
  113949. * @param name Name of the animation range
  113950. * @returns Nullable animation range
  113951. */
  113952. getRange(name: string): Nullable<AnimationRange>;
  113953. /**
  113954. * Gets the key frames from the animation
  113955. * @returns The key frames of the animation
  113956. */
  113957. getKeys(): Array<IAnimationKey>;
  113958. /**
  113959. * Gets the highest frame rate of the animation
  113960. * @returns Highest frame rate of the animation
  113961. */
  113962. getHighestFrame(): number;
  113963. /**
  113964. * Gets the easing function of the animation
  113965. * @returns Easing function of the animation
  113966. */
  113967. getEasingFunction(): IEasingFunction;
  113968. /**
  113969. * Sets the easing function of the animation
  113970. * @param easingFunction A custom mathematical formula for animation
  113971. */
  113972. setEasingFunction(easingFunction: EasingFunction): void;
  113973. /**
  113974. * Interpolates a scalar linearly
  113975. * @param startValue Start value of the animation curve
  113976. * @param endValue End value of the animation curve
  113977. * @param gradient Scalar amount to interpolate
  113978. * @returns Interpolated scalar value
  113979. */
  113980. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  113981. /**
  113982. * Interpolates a scalar cubically
  113983. * @param startValue Start value of the animation curve
  113984. * @param outTangent End tangent of the animation
  113985. * @param endValue End value of the animation curve
  113986. * @param inTangent Start tangent of the animation curve
  113987. * @param gradient Scalar amount to interpolate
  113988. * @returns Interpolated scalar value
  113989. */
  113990. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  113991. /**
  113992. * Interpolates a quaternion using a spherical linear interpolation
  113993. * @param startValue Start value of the animation curve
  113994. * @param endValue End value of the animation curve
  113995. * @param gradient Scalar amount to interpolate
  113996. * @returns Interpolated quaternion value
  113997. */
  113998. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  113999. /**
  114000. * Interpolates a quaternion cubically
  114001. * @param startValue Start value of the animation curve
  114002. * @param outTangent End tangent of the animation curve
  114003. * @param endValue End value of the animation curve
  114004. * @param inTangent Start tangent of the animation curve
  114005. * @param gradient Scalar amount to interpolate
  114006. * @returns Interpolated quaternion value
  114007. */
  114008. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  114009. /**
  114010. * Interpolates a Vector3 linearl
  114011. * @param startValue Start value of the animation curve
  114012. * @param endValue End value of the animation curve
  114013. * @param gradient Scalar amount to interpolate
  114014. * @returns Interpolated scalar value
  114015. */
  114016. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  114017. /**
  114018. * Interpolates a Vector3 cubically
  114019. * @param startValue Start value of the animation curve
  114020. * @param outTangent End tangent of the animation
  114021. * @param endValue End value of the animation curve
  114022. * @param inTangent Start tangent of the animation curve
  114023. * @param gradient Scalar amount to interpolate
  114024. * @returns InterpolatedVector3 value
  114025. */
  114026. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  114027. /**
  114028. * Interpolates a Vector2 linearly
  114029. * @param startValue Start value of the animation curve
  114030. * @param endValue End value of the animation curve
  114031. * @param gradient Scalar amount to interpolate
  114032. * @returns Interpolated Vector2 value
  114033. */
  114034. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  114035. /**
  114036. * Interpolates a Vector2 cubically
  114037. * @param startValue Start value of the animation curve
  114038. * @param outTangent End tangent of the animation
  114039. * @param endValue End value of the animation curve
  114040. * @param inTangent Start tangent of the animation curve
  114041. * @param gradient Scalar amount to interpolate
  114042. * @returns Interpolated Vector2 value
  114043. */
  114044. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  114045. /**
  114046. * Interpolates a size linearly
  114047. * @param startValue Start value of the animation curve
  114048. * @param endValue End value of the animation curve
  114049. * @param gradient Scalar amount to interpolate
  114050. * @returns Interpolated Size value
  114051. */
  114052. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  114053. /**
  114054. * Interpolates a Color3 linearly
  114055. * @param startValue Start value of the animation curve
  114056. * @param endValue End value of the animation curve
  114057. * @param gradient Scalar amount to interpolate
  114058. * @returns Interpolated Color3 value
  114059. */
  114060. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  114061. /**
  114062. * Interpolates a Color4 linearly
  114063. * @param startValue Start value of the animation curve
  114064. * @param endValue End value of the animation curve
  114065. * @param gradient Scalar amount to interpolate
  114066. * @returns Interpolated Color3 value
  114067. */
  114068. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  114069. /**
  114070. * @hidden Internal use only
  114071. */
  114072. _getKeyValue(value: any): any;
  114073. /**
  114074. * @hidden Internal use only
  114075. */
  114076. _interpolate(currentFrame: number, state: _IAnimationState): any;
  114077. /**
  114078. * Defines the function to use to interpolate matrices
  114079. * @param startValue defines the start matrix
  114080. * @param endValue defines the end matrix
  114081. * @param gradient defines the gradient between both matrices
  114082. * @param result defines an optional target matrix where to store the interpolation
  114083. * @returns the interpolated matrix
  114084. */
  114085. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  114086. /**
  114087. * Makes a copy of the animation
  114088. * @returns Cloned animation
  114089. */
  114090. clone(): Animation;
  114091. /**
  114092. * Sets the key frames of the animation
  114093. * @param values The animation key frames to set
  114094. */
  114095. setKeys(values: Array<IAnimationKey>): void;
  114096. /**
  114097. * Serializes the animation to an object
  114098. * @returns Serialized object
  114099. */
  114100. serialize(): any;
  114101. /**
  114102. * Float animation type
  114103. */
  114104. static readonly ANIMATIONTYPE_FLOAT: number;
  114105. /**
  114106. * Vector3 animation type
  114107. */
  114108. static readonly ANIMATIONTYPE_VECTOR3: number;
  114109. /**
  114110. * Quaternion animation type
  114111. */
  114112. static readonly ANIMATIONTYPE_QUATERNION: number;
  114113. /**
  114114. * Matrix animation type
  114115. */
  114116. static readonly ANIMATIONTYPE_MATRIX: number;
  114117. /**
  114118. * Color3 animation type
  114119. */
  114120. static readonly ANIMATIONTYPE_COLOR3: number;
  114121. /**
  114122. * Color3 animation type
  114123. */
  114124. static readonly ANIMATIONTYPE_COLOR4: number;
  114125. /**
  114126. * Vector2 animation type
  114127. */
  114128. static readonly ANIMATIONTYPE_VECTOR2: number;
  114129. /**
  114130. * Size animation type
  114131. */
  114132. static readonly ANIMATIONTYPE_SIZE: number;
  114133. /**
  114134. * Relative Loop Mode
  114135. */
  114136. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  114137. /**
  114138. * Cycle Loop Mode
  114139. */
  114140. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  114141. /**
  114142. * Constant Loop Mode
  114143. */
  114144. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  114145. /** @hidden */
  114146. static _UniversalLerp(left: any, right: any, amount: number): any;
  114147. /**
  114148. * Parses an animation object and creates an animation
  114149. * @param parsedAnimation Parsed animation object
  114150. * @returns Animation object
  114151. */
  114152. static Parse(parsedAnimation: any): Animation;
  114153. /**
  114154. * Appends the serialized animations from the source animations
  114155. * @param source Source containing the animations
  114156. * @param destination Target to store the animations
  114157. */
  114158. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  114159. /**
  114160. * Creates a new animation or an array of animations from a snippet saved in a remote file
  114161. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  114162. * @param url defines the url to load from
  114163. * @returns a promise that will resolve to the new animation or an array of animations
  114164. */
  114165. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  114166. /**
  114167. * Creates an animation or an array of animations from a snippet saved by the Inspector
  114168. * @param snippetId defines the snippet to load
  114169. * @returns a promise that will resolve to the new animation or a new array of animations
  114170. */
  114171. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  114172. }
  114173. }
  114174. declare module BABYLON {
  114175. /**
  114176. * Interface containing an array of animations
  114177. */
  114178. export interface IAnimatable {
  114179. /**
  114180. * Array of animations
  114181. */
  114182. animations: Nullable<Array<Animation>>;
  114183. }
  114184. }
  114185. declare module BABYLON {
  114186. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  114187. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114188. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114189. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114190. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114191. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114192. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114193. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114194. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114195. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114196. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114197. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114198. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114199. /**
  114200. * Decorator used to define property that can be serialized as reference to a camera
  114201. * @param sourceName defines the name of the property to decorate
  114202. */
  114203. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114204. /**
  114205. * Class used to help serialization objects
  114206. */
  114207. export class SerializationHelper {
  114208. /** @hidden */
  114209. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  114210. /** @hidden */
  114211. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  114212. /** @hidden */
  114213. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  114214. /** @hidden */
  114215. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  114216. /**
  114217. * Appends the serialized animations from the source animations
  114218. * @param source Source containing the animations
  114219. * @param destination Target to store the animations
  114220. */
  114221. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  114222. /**
  114223. * Static function used to serialized a specific entity
  114224. * @param entity defines the entity to serialize
  114225. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  114226. * @returns a JSON compatible object representing the serialization of the entity
  114227. */
  114228. static Serialize<T>(entity: T, serializationObject?: any): any;
  114229. /**
  114230. * Creates a new entity from a serialization data object
  114231. * @param creationFunction defines a function used to instanciated the new entity
  114232. * @param source defines the source serialization data
  114233. * @param scene defines the hosting scene
  114234. * @param rootUrl defines the root url for resources
  114235. * @returns a new entity
  114236. */
  114237. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  114238. /**
  114239. * Clones an object
  114240. * @param creationFunction defines the function used to instanciate the new object
  114241. * @param source defines the source object
  114242. * @returns the cloned object
  114243. */
  114244. static Clone<T>(creationFunction: () => T, source: T): T;
  114245. /**
  114246. * Instanciates a new object based on a source one (some data will be shared between both object)
  114247. * @param creationFunction defines the function used to instanciate the new object
  114248. * @param source defines the source object
  114249. * @returns the new object
  114250. */
  114251. static Instanciate<T>(creationFunction: () => T, source: T): T;
  114252. }
  114253. }
  114254. declare module BABYLON {
  114255. /**
  114256. * Base class of all the textures in babylon.
  114257. * It groups all the common properties the materials, post process, lights... might need
  114258. * in order to make a correct use of the texture.
  114259. */
  114260. export class BaseTexture implements IAnimatable {
  114261. /**
  114262. * Default anisotropic filtering level for the application.
  114263. * It is set to 4 as a good tradeoff between perf and quality.
  114264. */
  114265. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  114266. /**
  114267. * Gets or sets the unique id of the texture
  114268. */
  114269. uniqueId: number;
  114270. /**
  114271. * Define the name of the texture.
  114272. */
  114273. name: string;
  114274. /**
  114275. * Gets or sets an object used to store user defined information.
  114276. */
  114277. metadata: any;
  114278. /**
  114279. * For internal use only. Please do not use.
  114280. */
  114281. reservedDataStore: any;
  114282. private _hasAlpha;
  114283. /**
  114284. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  114285. */
  114286. set hasAlpha(value: boolean);
  114287. get hasAlpha(): boolean;
  114288. /**
  114289. * Defines if the alpha value should be determined via the rgb values.
  114290. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  114291. */
  114292. getAlphaFromRGB: boolean;
  114293. /**
  114294. * Intensity or strength of the texture.
  114295. * It is commonly used by materials to fine tune the intensity of the texture
  114296. */
  114297. level: number;
  114298. /**
  114299. * Define the UV chanel to use starting from 0 and defaulting to 0.
  114300. * This is part of the texture as textures usually maps to one uv set.
  114301. */
  114302. coordinatesIndex: number;
  114303. protected _coordinatesMode: number;
  114304. /**
  114305. * How a texture is mapped.
  114306. *
  114307. * | Value | Type | Description |
  114308. * | ----- | ----------------------------------- | ----------- |
  114309. * | 0 | EXPLICIT_MODE | |
  114310. * | 1 | SPHERICAL_MODE | |
  114311. * | 2 | PLANAR_MODE | |
  114312. * | 3 | CUBIC_MODE | |
  114313. * | 4 | PROJECTION_MODE | |
  114314. * | 5 | SKYBOX_MODE | |
  114315. * | 6 | INVCUBIC_MODE | |
  114316. * | 7 | EQUIRECTANGULAR_MODE | |
  114317. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  114318. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  114319. */
  114320. set coordinatesMode(value: number);
  114321. get coordinatesMode(): number;
  114322. private _wrapU;
  114323. /**
  114324. * | Value | Type | Description |
  114325. * | ----- | ------------------ | ----------- |
  114326. * | 0 | CLAMP_ADDRESSMODE | |
  114327. * | 1 | WRAP_ADDRESSMODE | |
  114328. * | 2 | MIRROR_ADDRESSMODE | |
  114329. */
  114330. get wrapU(): number;
  114331. set wrapU(value: number);
  114332. private _wrapV;
  114333. /**
  114334. * | Value | Type | Description |
  114335. * | ----- | ------------------ | ----------- |
  114336. * | 0 | CLAMP_ADDRESSMODE | |
  114337. * | 1 | WRAP_ADDRESSMODE | |
  114338. * | 2 | MIRROR_ADDRESSMODE | |
  114339. */
  114340. get wrapV(): number;
  114341. set wrapV(value: number);
  114342. /**
  114343. * | Value | Type | Description |
  114344. * | ----- | ------------------ | ----------- |
  114345. * | 0 | CLAMP_ADDRESSMODE | |
  114346. * | 1 | WRAP_ADDRESSMODE | |
  114347. * | 2 | MIRROR_ADDRESSMODE | |
  114348. */
  114349. wrapR: number;
  114350. /**
  114351. * With compliant hardware and browser (supporting anisotropic filtering)
  114352. * this defines the level of anisotropic filtering in the texture.
  114353. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  114354. */
  114355. anisotropicFilteringLevel: number;
  114356. /**
  114357. * Define if the texture is a cube texture or if false a 2d texture.
  114358. */
  114359. get isCube(): boolean;
  114360. set isCube(value: boolean);
  114361. /**
  114362. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  114363. */
  114364. get is3D(): boolean;
  114365. set is3D(value: boolean);
  114366. /**
  114367. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  114368. */
  114369. get is2DArray(): boolean;
  114370. set is2DArray(value: boolean);
  114371. private _gammaSpace;
  114372. /**
  114373. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  114374. * HDR texture are usually stored in linear space.
  114375. * This only impacts the PBR and Background materials
  114376. */
  114377. get gammaSpace(): boolean;
  114378. set gammaSpace(gamma: boolean);
  114379. /**
  114380. * Gets or sets whether or not the texture contains RGBD data.
  114381. */
  114382. get isRGBD(): boolean;
  114383. set isRGBD(value: boolean);
  114384. /**
  114385. * Is Z inverted in the texture (useful in a cube texture).
  114386. */
  114387. invertZ: boolean;
  114388. /**
  114389. * Are mip maps generated for this texture or not.
  114390. */
  114391. get noMipmap(): boolean;
  114392. /**
  114393. * @hidden
  114394. */
  114395. lodLevelInAlpha: boolean;
  114396. /**
  114397. * With prefiltered texture, defined the offset used during the prefiltering steps.
  114398. */
  114399. get lodGenerationOffset(): number;
  114400. set lodGenerationOffset(value: number);
  114401. /**
  114402. * With prefiltered texture, defined the scale used during the prefiltering steps.
  114403. */
  114404. get lodGenerationScale(): number;
  114405. set lodGenerationScale(value: number);
  114406. /**
  114407. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  114408. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  114409. * average roughness values.
  114410. */
  114411. get linearSpecularLOD(): boolean;
  114412. set linearSpecularLOD(value: boolean);
  114413. /**
  114414. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  114415. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  114416. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  114417. */
  114418. get irradianceTexture(): Nullable<BaseTexture>;
  114419. set irradianceTexture(value: Nullable<BaseTexture>);
  114420. /**
  114421. * Define if the texture is a render target.
  114422. */
  114423. isRenderTarget: boolean;
  114424. /**
  114425. * Define the unique id of the texture in the scene.
  114426. */
  114427. get uid(): string;
  114428. /** @hidden */
  114429. _prefiltered: boolean;
  114430. /**
  114431. * Return a string representation of the texture.
  114432. * @returns the texture as a string
  114433. */
  114434. toString(): string;
  114435. /**
  114436. * Get the class name of the texture.
  114437. * @returns "BaseTexture"
  114438. */
  114439. getClassName(): string;
  114440. /**
  114441. * Define the list of animation attached to the texture.
  114442. */
  114443. animations: Animation[];
  114444. /**
  114445. * An event triggered when the texture is disposed.
  114446. */
  114447. onDisposeObservable: Observable<BaseTexture>;
  114448. private _onDisposeObserver;
  114449. /**
  114450. * Callback triggered when the texture has been disposed.
  114451. * Kept for back compatibility, you can use the onDisposeObservable instead.
  114452. */
  114453. set onDispose(callback: () => void);
  114454. /**
  114455. * Define the current state of the loading sequence when in delayed load mode.
  114456. */
  114457. delayLoadState: number;
  114458. protected _scene: Nullable<Scene>;
  114459. protected _engine: Nullable<ThinEngine>;
  114460. /** @hidden */
  114461. _texture: Nullable<InternalTexture>;
  114462. private _uid;
  114463. /**
  114464. * Define if the texture is preventinga material to render or not.
  114465. * If not and the texture is not ready, the engine will use a default black texture instead.
  114466. */
  114467. get isBlocking(): boolean;
  114468. /**
  114469. * Instantiates a new BaseTexture.
  114470. * Base class of all the textures in babylon.
  114471. * It groups all the common properties the materials, post process, lights... might need
  114472. * in order to make a correct use of the texture.
  114473. * @param sceneOrEngine Define the scene or engine the texture blongs to
  114474. */
  114475. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  114476. /**
  114477. * Get the scene the texture belongs to.
  114478. * @returns the scene or null if undefined
  114479. */
  114480. getScene(): Nullable<Scene>;
  114481. /** @hidden */
  114482. protected _getEngine(): Nullable<ThinEngine>;
  114483. /**
  114484. * Get the texture transform matrix used to offset tile the texture for istance.
  114485. * @returns the transformation matrix
  114486. */
  114487. getTextureMatrix(): Matrix;
  114488. /**
  114489. * Get the texture reflection matrix used to rotate/transform the reflection.
  114490. * @returns the reflection matrix
  114491. */
  114492. getReflectionTextureMatrix(): Matrix;
  114493. /**
  114494. * Get the underlying lower level texture from Babylon.
  114495. * @returns the insternal texture
  114496. */
  114497. getInternalTexture(): Nullable<InternalTexture>;
  114498. /**
  114499. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  114500. * @returns true if ready or not blocking
  114501. */
  114502. isReadyOrNotBlocking(): boolean;
  114503. /**
  114504. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  114505. * @returns true if fully ready
  114506. */
  114507. isReady(): boolean;
  114508. private _cachedSize;
  114509. /**
  114510. * Get the size of the texture.
  114511. * @returns the texture size.
  114512. */
  114513. getSize(): ISize;
  114514. /**
  114515. * Get the base size of the texture.
  114516. * It can be different from the size if the texture has been resized for POT for instance
  114517. * @returns the base size
  114518. */
  114519. getBaseSize(): ISize;
  114520. /**
  114521. * Update the sampling mode of the texture.
  114522. * Default is Trilinear mode.
  114523. *
  114524. * | Value | Type | Description |
  114525. * | ----- | ------------------ | ----------- |
  114526. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  114527. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  114528. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  114529. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  114530. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  114531. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  114532. * | 7 | NEAREST_LINEAR | |
  114533. * | 8 | NEAREST_NEAREST | |
  114534. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  114535. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  114536. * | 11 | LINEAR_LINEAR | |
  114537. * | 12 | LINEAR_NEAREST | |
  114538. *
  114539. * > _mag_: magnification filter (close to the viewer)
  114540. * > _min_: minification filter (far from the viewer)
  114541. * > _mip_: filter used between mip map levels
  114542. *@param samplingMode Define the new sampling mode of the texture
  114543. */
  114544. updateSamplingMode(samplingMode: number): void;
  114545. /**
  114546. * Scales the texture if is `canRescale()`
  114547. * @param ratio the resize factor we want to use to rescale
  114548. */
  114549. scale(ratio: number): void;
  114550. /**
  114551. * Get if the texture can rescale.
  114552. */
  114553. get canRescale(): boolean;
  114554. /** @hidden */
  114555. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  114556. /** @hidden */
  114557. _rebuild(): void;
  114558. /**
  114559. * Triggers the load sequence in delayed load mode.
  114560. */
  114561. delayLoad(): void;
  114562. /**
  114563. * Clones the texture.
  114564. * @returns the cloned texture
  114565. */
  114566. clone(): Nullable<BaseTexture>;
  114567. /**
  114568. * Get the texture underlying type (INT, FLOAT...)
  114569. */
  114570. get textureType(): number;
  114571. /**
  114572. * Get the texture underlying format (RGB, RGBA...)
  114573. */
  114574. get textureFormat(): number;
  114575. /**
  114576. * Indicates that textures need to be re-calculated for all materials
  114577. */
  114578. protected _markAllSubMeshesAsTexturesDirty(): void;
  114579. /**
  114580. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  114581. * This will returns an RGBA array buffer containing either in values (0-255) or
  114582. * float values (0-1) depending of the underlying buffer type.
  114583. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  114584. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  114585. * @param buffer defines a user defined buffer to fill with data (can be null)
  114586. * @returns The Array buffer containing the pixels data.
  114587. */
  114588. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  114589. /**
  114590. * Release and destroy the underlying lower level texture aka internalTexture.
  114591. */
  114592. releaseInternalTexture(): void;
  114593. /** @hidden */
  114594. get _lodTextureHigh(): Nullable<BaseTexture>;
  114595. /** @hidden */
  114596. get _lodTextureMid(): Nullable<BaseTexture>;
  114597. /** @hidden */
  114598. get _lodTextureLow(): Nullable<BaseTexture>;
  114599. /**
  114600. * Dispose the texture and release its associated resources.
  114601. */
  114602. dispose(): void;
  114603. /**
  114604. * Serialize the texture into a JSON representation that can be parsed later on.
  114605. * @returns the JSON representation of the texture
  114606. */
  114607. serialize(): any;
  114608. /**
  114609. * Helper function to be called back once a list of texture contains only ready textures.
  114610. * @param textures Define the list of textures to wait for
  114611. * @param callback Define the callback triggered once the entire list will be ready
  114612. */
  114613. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  114614. private static _isScene;
  114615. }
  114616. }
  114617. declare module BABYLON {
  114618. /**
  114619. * Options to be used when creating an effect.
  114620. */
  114621. export interface IEffectCreationOptions {
  114622. /**
  114623. * Atrributes that will be used in the shader.
  114624. */
  114625. attributes: string[];
  114626. /**
  114627. * Uniform varible names that will be set in the shader.
  114628. */
  114629. uniformsNames: string[];
  114630. /**
  114631. * Uniform buffer variable names that will be set in the shader.
  114632. */
  114633. uniformBuffersNames: string[];
  114634. /**
  114635. * Sampler texture variable names that will be set in the shader.
  114636. */
  114637. samplers: string[];
  114638. /**
  114639. * Define statements that will be set in the shader.
  114640. */
  114641. defines: any;
  114642. /**
  114643. * Possible fallbacks for this effect to improve performance when needed.
  114644. */
  114645. fallbacks: Nullable<IEffectFallbacks>;
  114646. /**
  114647. * Callback that will be called when the shader is compiled.
  114648. */
  114649. onCompiled: Nullable<(effect: Effect) => void>;
  114650. /**
  114651. * Callback that will be called if an error occurs during shader compilation.
  114652. */
  114653. onError: Nullable<(effect: Effect, errors: string) => void>;
  114654. /**
  114655. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114656. */
  114657. indexParameters?: any;
  114658. /**
  114659. * Max number of lights that can be used in the shader.
  114660. */
  114661. maxSimultaneousLights?: number;
  114662. /**
  114663. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  114664. */
  114665. transformFeedbackVaryings?: Nullable<string[]>;
  114666. /**
  114667. * 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
  114668. */
  114669. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  114670. /**
  114671. * Is this effect rendering to several color attachments ?
  114672. */
  114673. multiTarget?: boolean;
  114674. }
  114675. /**
  114676. * Effect containing vertex and fragment shader that can be executed on an object.
  114677. */
  114678. export class Effect implements IDisposable {
  114679. /**
  114680. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114681. */
  114682. static ShadersRepository: string;
  114683. /**
  114684. * Enable logging of the shader code when a compilation error occurs
  114685. */
  114686. static LogShaderCodeOnCompilationError: boolean;
  114687. /**
  114688. * Name of the effect.
  114689. */
  114690. name: any;
  114691. /**
  114692. * String container all the define statements that should be set on the shader.
  114693. */
  114694. defines: string;
  114695. /**
  114696. * Callback that will be called when the shader is compiled.
  114697. */
  114698. onCompiled: Nullable<(effect: Effect) => void>;
  114699. /**
  114700. * Callback that will be called if an error occurs during shader compilation.
  114701. */
  114702. onError: Nullable<(effect: Effect, errors: string) => void>;
  114703. /**
  114704. * Callback that will be called when effect is bound.
  114705. */
  114706. onBind: Nullable<(effect: Effect) => void>;
  114707. /**
  114708. * Unique ID of the effect.
  114709. */
  114710. uniqueId: number;
  114711. /**
  114712. * Observable that will be called when the shader is compiled.
  114713. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  114714. */
  114715. onCompileObservable: Observable<Effect>;
  114716. /**
  114717. * Observable that will be called if an error occurs during shader compilation.
  114718. */
  114719. onErrorObservable: Observable<Effect>;
  114720. /** @hidden */
  114721. _onBindObservable: Nullable<Observable<Effect>>;
  114722. /**
  114723. * @hidden
  114724. * Specifies if the effect was previously ready
  114725. */
  114726. _wasPreviouslyReady: boolean;
  114727. /**
  114728. * Observable that will be called when effect is bound.
  114729. */
  114730. get onBindObservable(): Observable<Effect>;
  114731. /** @hidden */
  114732. _bonesComputationForcedToCPU: boolean;
  114733. /** @hidden */
  114734. _multiTarget: boolean;
  114735. private static _uniqueIdSeed;
  114736. private _engine;
  114737. private _uniformBuffersNames;
  114738. private _uniformBuffersNamesList;
  114739. private _uniformsNames;
  114740. private _samplerList;
  114741. private _samplers;
  114742. private _isReady;
  114743. private _compilationError;
  114744. private _allFallbacksProcessed;
  114745. private _attributesNames;
  114746. private _attributes;
  114747. private _attributeLocationByName;
  114748. private _uniforms;
  114749. /**
  114750. * Key for the effect.
  114751. * @hidden
  114752. */
  114753. _key: string;
  114754. private _indexParameters;
  114755. private _fallbacks;
  114756. private _vertexSourceCode;
  114757. private _fragmentSourceCode;
  114758. private _vertexSourceCodeOverride;
  114759. private _fragmentSourceCodeOverride;
  114760. private _transformFeedbackVaryings;
  114761. /**
  114762. * Compiled shader to webGL program.
  114763. * @hidden
  114764. */
  114765. _pipelineContext: Nullable<IPipelineContext>;
  114766. private _valueCache;
  114767. private static _baseCache;
  114768. /**
  114769. * Instantiates an effect.
  114770. * An effect can be used to create/manage/execute vertex and fragment shaders.
  114771. * @param baseName Name of the effect.
  114772. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  114773. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  114774. * @param samplers List of sampler variables that will be passed to the shader.
  114775. * @param engine Engine to be used to render the effect
  114776. * @param defines Define statements to be added to the shader.
  114777. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  114778. * @param onCompiled Callback that will be called when the shader is compiled.
  114779. * @param onError Callback that will be called if an error occurs during shader compilation.
  114780. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114781. */
  114782. 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);
  114783. private _useFinalCode;
  114784. /**
  114785. * Unique key for this effect
  114786. */
  114787. get key(): string;
  114788. /**
  114789. * If the effect has been compiled and prepared.
  114790. * @returns if the effect is compiled and prepared.
  114791. */
  114792. isReady(): boolean;
  114793. private _isReadyInternal;
  114794. /**
  114795. * The engine the effect was initialized with.
  114796. * @returns the engine.
  114797. */
  114798. getEngine(): Engine;
  114799. /**
  114800. * The pipeline context for this effect
  114801. * @returns the associated pipeline context
  114802. */
  114803. getPipelineContext(): Nullable<IPipelineContext>;
  114804. /**
  114805. * The set of names of attribute variables for the shader.
  114806. * @returns An array of attribute names.
  114807. */
  114808. getAttributesNames(): string[];
  114809. /**
  114810. * Returns the attribute at the given index.
  114811. * @param index The index of the attribute.
  114812. * @returns The location of the attribute.
  114813. */
  114814. getAttributeLocation(index: number): number;
  114815. /**
  114816. * Returns the attribute based on the name of the variable.
  114817. * @param name of the attribute to look up.
  114818. * @returns the attribute location.
  114819. */
  114820. getAttributeLocationByName(name: string): number;
  114821. /**
  114822. * The number of attributes.
  114823. * @returns the numnber of attributes.
  114824. */
  114825. getAttributesCount(): number;
  114826. /**
  114827. * Gets the index of a uniform variable.
  114828. * @param uniformName of the uniform to look up.
  114829. * @returns the index.
  114830. */
  114831. getUniformIndex(uniformName: string): number;
  114832. /**
  114833. * Returns the attribute based on the name of the variable.
  114834. * @param uniformName of the uniform to look up.
  114835. * @returns the location of the uniform.
  114836. */
  114837. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  114838. /**
  114839. * Returns an array of sampler variable names
  114840. * @returns The array of sampler variable names.
  114841. */
  114842. getSamplers(): string[];
  114843. /**
  114844. * Returns an array of uniform variable names
  114845. * @returns The array of uniform variable names.
  114846. */
  114847. getUniformNames(): string[];
  114848. /**
  114849. * Returns an array of uniform buffer variable names
  114850. * @returns The array of uniform buffer variable names.
  114851. */
  114852. getUniformBuffersNames(): string[];
  114853. /**
  114854. * Returns the index parameters used to create the effect
  114855. * @returns The index parameters object
  114856. */
  114857. getIndexParameters(): any;
  114858. /**
  114859. * The error from the last compilation.
  114860. * @returns the error string.
  114861. */
  114862. getCompilationError(): string;
  114863. /**
  114864. * Gets a boolean indicating that all fallbacks were used during compilation
  114865. * @returns true if all fallbacks were used
  114866. */
  114867. allFallbacksProcessed(): boolean;
  114868. /**
  114869. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  114870. * @param func The callback to be used.
  114871. */
  114872. executeWhenCompiled(func: (effect: Effect) => void): void;
  114873. private _checkIsReady;
  114874. private _loadShader;
  114875. /**
  114876. * Gets the vertex shader source code of this effect
  114877. */
  114878. get vertexSourceCode(): string;
  114879. /**
  114880. * Gets the fragment shader source code of this effect
  114881. */
  114882. get fragmentSourceCode(): string;
  114883. /**
  114884. * Recompiles the webGL program
  114885. * @param vertexSourceCode The source code for the vertex shader.
  114886. * @param fragmentSourceCode The source code for the fragment shader.
  114887. * @param onCompiled Callback called when completed.
  114888. * @param onError Callback called on error.
  114889. * @hidden
  114890. */
  114891. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  114892. /**
  114893. * Prepares the effect
  114894. * @hidden
  114895. */
  114896. _prepareEffect(): void;
  114897. private _getShaderCodeAndErrorLine;
  114898. private _processCompilationErrors;
  114899. /**
  114900. * Checks if the effect is supported. (Must be called after compilation)
  114901. */
  114902. get isSupported(): boolean;
  114903. /**
  114904. * Binds a texture to the engine to be used as output of the shader.
  114905. * @param channel Name of the output variable.
  114906. * @param texture Texture to bind.
  114907. * @hidden
  114908. */
  114909. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  114910. /**
  114911. * Sets a texture on the engine to be used in the shader.
  114912. * @param channel Name of the sampler variable.
  114913. * @param texture Texture to set.
  114914. */
  114915. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  114916. /**
  114917. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  114918. * @param channel Name of the sampler variable.
  114919. * @param texture Texture to set.
  114920. */
  114921. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  114922. /**
  114923. * Sets an array of textures on the engine to be used in the shader.
  114924. * @param channel Name of the variable.
  114925. * @param textures Textures to set.
  114926. */
  114927. setTextureArray(channel: string, textures: BaseTexture[]): void;
  114928. /**
  114929. * 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)
  114930. * @param channel Name of the sampler variable.
  114931. * @param postProcess Post process to get the input texture from.
  114932. */
  114933. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  114934. /**
  114935. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  114936. * 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)
  114937. * @param channel Name of the sampler variable.
  114938. * @param postProcess Post process to get the output texture from.
  114939. */
  114940. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  114941. /** @hidden */
  114942. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  114943. /** @hidden */
  114944. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  114945. /** @hidden */
  114946. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  114947. /** @hidden */
  114948. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  114949. /**
  114950. * Binds a buffer to a uniform.
  114951. * @param buffer Buffer to bind.
  114952. * @param name Name of the uniform variable to bind to.
  114953. */
  114954. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  114955. /**
  114956. * Binds block to a uniform.
  114957. * @param blockName Name of the block to bind.
  114958. * @param index Index to bind.
  114959. */
  114960. bindUniformBlock(blockName: string, index: number): void;
  114961. /**
  114962. * Sets an interger value on a uniform variable.
  114963. * @param uniformName Name of the variable.
  114964. * @param value Value to be set.
  114965. * @returns this effect.
  114966. */
  114967. setInt(uniformName: string, value: number): Effect;
  114968. /**
  114969. * Sets an int array on a uniform variable.
  114970. * @param uniformName Name of the variable.
  114971. * @param array array to be set.
  114972. * @returns this effect.
  114973. */
  114974. setIntArray(uniformName: string, array: Int32Array): Effect;
  114975. /**
  114976. * 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)
  114977. * @param uniformName Name of the variable.
  114978. * @param array array to be set.
  114979. * @returns this effect.
  114980. */
  114981. setIntArray2(uniformName: string, array: Int32Array): Effect;
  114982. /**
  114983. * 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)
  114984. * @param uniformName Name of the variable.
  114985. * @param array array to be set.
  114986. * @returns this effect.
  114987. */
  114988. setIntArray3(uniformName: string, array: Int32Array): Effect;
  114989. /**
  114990. * 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)
  114991. * @param uniformName Name of the variable.
  114992. * @param array array to be set.
  114993. * @returns this effect.
  114994. */
  114995. setIntArray4(uniformName: string, array: Int32Array): Effect;
  114996. /**
  114997. * Sets an float array on a uniform variable.
  114998. * @param uniformName Name of the variable.
  114999. * @param array array to be set.
  115000. * @returns this effect.
  115001. */
  115002. setFloatArray(uniformName: string, array: Float32Array): Effect;
  115003. /**
  115004. * 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)
  115005. * @param uniformName Name of the variable.
  115006. * @param array array to be set.
  115007. * @returns this effect.
  115008. */
  115009. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  115010. /**
  115011. * 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)
  115012. * @param uniformName Name of the variable.
  115013. * @param array array to be set.
  115014. * @returns this effect.
  115015. */
  115016. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  115017. /**
  115018. * 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)
  115019. * @param uniformName Name of the variable.
  115020. * @param array array to be set.
  115021. * @returns this effect.
  115022. */
  115023. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  115024. /**
  115025. * Sets an array on a uniform variable.
  115026. * @param uniformName Name of the variable.
  115027. * @param array array to be set.
  115028. * @returns this effect.
  115029. */
  115030. setArray(uniformName: string, array: number[]): Effect;
  115031. /**
  115032. * 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)
  115033. * @param uniformName Name of the variable.
  115034. * @param array array to be set.
  115035. * @returns this effect.
  115036. */
  115037. setArray2(uniformName: string, array: number[]): Effect;
  115038. /**
  115039. * 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)
  115040. * @param uniformName Name of the variable.
  115041. * @param array array to be set.
  115042. * @returns this effect.
  115043. */
  115044. setArray3(uniformName: string, array: number[]): Effect;
  115045. /**
  115046. * 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)
  115047. * @param uniformName Name of the variable.
  115048. * @param array array to be set.
  115049. * @returns this effect.
  115050. */
  115051. setArray4(uniformName: string, array: number[]): Effect;
  115052. /**
  115053. * Sets matrices on a uniform variable.
  115054. * @param uniformName Name of the variable.
  115055. * @param matrices matrices to be set.
  115056. * @returns this effect.
  115057. */
  115058. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  115059. /**
  115060. * Sets matrix on a uniform variable.
  115061. * @param uniformName Name of the variable.
  115062. * @param matrix matrix to be set.
  115063. * @returns this effect.
  115064. */
  115065. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  115066. /**
  115067. * 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)
  115068. * @param uniformName Name of the variable.
  115069. * @param matrix matrix to be set.
  115070. * @returns this effect.
  115071. */
  115072. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  115073. /**
  115074. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  115075. * @param uniformName Name of the variable.
  115076. * @param matrix matrix to be set.
  115077. * @returns this effect.
  115078. */
  115079. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  115080. /**
  115081. * Sets a float on a uniform variable.
  115082. * @param uniformName Name of the variable.
  115083. * @param value value to be set.
  115084. * @returns this effect.
  115085. */
  115086. setFloat(uniformName: string, value: number): Effect;
  115087. /**
  115088. * Sets a boolean on a uniform variable.
  115089. * @param uniformName Name of the variable.
  115090. * @param bool value to be set.
  115091. * @returns this effect.
  115092. */
  115093. setBool(uniformName: string, bool: boolean): Effect;
  115094. /**
  115095. * Sets a Vector2 on a uniform variable.
  115096. * @param uniformName Name of the variable.
  115097. * @param vector2 vector2 to be set.
  115098. * @returns this effect.
  115099. */
  115100. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  115101. /**
  115102. * Sets a float2 on a uniform variable.
  115103. * @param uniformName Name of the variable.
  115104. * @param x First float in float2.
  115105. * @param y Second float in float2.
  115106. * @returns this effect.
  115107. */
  115108. setFloat2(uniformName: string, x: number, y: number): Effect;
  115109. /**
  115110. * Sets a Vector3 on a uniform variable.
  115111. * @param uniformName Name of the variable.
  115112. * @param vector3 Value to be set.
  115113. * @returns this effect.
  115114. */
  115115. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  115116. /**
  115117. * Sets a float3 on a uniform variable.
  115118. * @param uniformName Name of the variable.
  115119. * @param x First float in float3.
  115120. * @param y Second float in float3.
  115121. * @param z Third float in float3.
  115122. * @returns this effect.
  115123. */
  115124. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  115125. /**
  115126. * Sets a Vector4 on a uniform variable.
  115127. * @param uniformName Name of the variable.
  115128. * @param vector4 Value to be set.
  115129. * @returns this effect.
  115130. */
  115131. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  115132. /**
  115133. * Sets a float4 on a uniform variable.
  115134. * @param uniformName Name of the variable.
  115135. * @param x First float in float4.
  115136. * @param y Second float in float4.
  115137. * @param z Third float in float4.
  115138. * @param w Fourth float in float4.
  115139. * @returns this effect.
  115140. */
  115141. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  115142. /**
  115143. * Sets a Color3 on a uniform variable.
  115144. * @param uniformName Name of the variable.
  115145. * @param color3 Value to be set.
  115146. * @returns this effect.
  115147. */
  115148. setColor3(uniformName: string, color3: IColor3Like): Effect;
  115149. /**
  115150. * Sets a Color4 on a uniform variable.
  115151. * @param uniformName Name of the variable.
  115152. * @param color3 Value to be set.
  115153. * @param alpha Alpha value to be set.
  115154. * @returns this effect.
  115155. */
  115156. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  115157. /**
  115158. * Sets a Color4 on a uniform variable
  115159. * @param uniformName defines the name of the variable
  115160. * @param color4 defines the value to be set
  115161. * @returns this effect.
  115162. */
  115163. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  115164. /** Release all associated resources */
  115165. dispose(): void;
  115166. /**
  115167. * This function will add a new shader to the shader store
  115168. * @param name the name of the shader
  115169. * @param pixelShader optional pixel shader content
  115170. * @param vertexShader optional vertex shader content
  115171. */
  115172. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  115173. /**
  115174. * Store of each shader (The can be looked up using effect.key)
  115175. */
  115176. static ShadersStore: {
  115177. [key: string]: string;
  115178. };
  115179. /**
  115180. * Store of each included file for a shader (The can be looked up using effect.key)
  115181. */
  115182. static IncludesShadersStore: {
  115183. [key: string]: string;
  115184. };
  115185. /**
  115186. * Resets the cache of effects.
  115187. */
  115188. static ResetCache(): void;
  115189. }
  115190. }
  115191. declare module BABYLON {
  115192. /**
  115193. * Interface used to describe the capabilities of the engine relatively to the current browser
  115194. */
  115195. export interface EngineCapabilities {
  115196. /** Maximum textures units per fragment shader */
  115197. maxTexturesImageUnits: number;
  115198. /** Maximum texture units per vertex shader */
  115199. maxVertexTextureImageUnits: number;
  115200. /** Maximum textures units in the entire pipeline */
  115201. maxCombinedTexturesImageUnits: number;
  115202. /** Maximum texture size */
  115203. maxTextureSize: number;
  115204. /** Maximum texture samples */
  115205. maxSamples?: number;
  115206. /** Maximum cube texture size */
  115207. maxCubemapTextureSize: number;
  115208. /** Maximum render texture size */
  115209. maxRenderTextureSize: number;
  115210. /** Maximum number of vertex attributes */
  115211. maxVertexAttribs: number;
  115212. /** Maximum number of varyings */
  115213. maxVaryingVectors: number;
  115214. /** Maximum number of uniforms per vertex shader */
  115215. maxVertexUniformVectors: number;
  115216. /** Maximum number of uniforms per fragment shader */
  115217. maxFragmentUniformVectors: number;
  115218. /** Defines if standard derivates (dx/dy) are supported */
  115219. standardDerivatives: boolean;
  115220. /** Defines if s3tc texture compression is supported */
  115221. s3tc?: WEBGL_compressed_texture_s3tc;
  115222. /** Defines if pvrtc texture compression is supported */
  115223. pvrtc: any;
  115224. /** Defines if etc1 texture compression is supported */
  115225. etc1: any;
  115226. /** Defines if etc2 texture compression is supported */
  115227. etc2: any;
  115228. /** Defines if astc texture compression is supported */
  115229. astc: any;
  115230. /** Defines if bptc texture compression is supported */
  115231. bptc: any;
  115232. /** Defines if float textures are supported */
  115233. textureFloat: boolean;
  115234. /** Defines if vertex array objects are supported */
  115235. vertexArrayObject: boolean;
  115236. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  115237. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  115238. /** Gets the maximum level of anisotropy supported */
  115239. maxAnisotropy: number;
  115240. /** Defines if instancing is supported */
  115241. instancedArrays: boolean;
  115242. /** Defines if 32 bits indices are supported */
  115243. uintIndices: boolean;
  115244. /** Defines if high precision shaders are supported */
  115245. highPrecisionShaderSupported: boolean;
  115246. /** Defines if depth reading in the fragment shader is supported */
  115247. fragmentDepthSupported: boolean;
  115248. /** Defines if float texture linear filtering is supported*/
  115249. textureFloatLinearFiltering: boolean;
  115250. /** Defines if rendering to float textures is supported */
  115251. textureFloatRender: boolean;
  115252. /** Defines if half float textures are supported*/
  115253. textureHalfFloat: boolean;
  115254. /** Defines if half float texture linear filtering is supported*/
  115255. textureHalfFloatLinearFiltering: boolean;
  115256. /** Defines if rendering to half float textures is supported */
  115257. textureHalfFloatRender: boolean;
  115258. /** Defines if textureLOD shader command is supported */
  115259. textureLOD: boolean;
  115260. /** Defines if draw buffers extension is supported */
  115261. drawBuffersExtension: boolean;
  115262. /** Defines if depth textures are supported */
  115263. depthTextureExtension: boolean;
  115264. /** Defines if float color buffer are supported */
  115265. colorBufferFloat: boolean;
  115266. /** Gets disjoint timer query extension (null if not supported) */
  115267. timerQuery?: EXT_disjoint_timer_query;
  115268. /** Defines if timestamp can be used with timer query */
  115269. canUseTimestampForTimerQuery: boolean;
  115270. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  115271. multiview?: any;
  115272. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  115273. oculusMultiview?: any;
  115274. /** Function used to let the system compiles shaders in background */
  115275. parallelShaderCompile?: {
  115276. COMPLETION_STATUS_KHR: number;
  115277. };
  115278. /** Max number of texture samples for MSAA */
  115279. maxMSAASamples: number;
  115280. /** Defines if the blend min max extension is supported */
  115281. blendMinMax: boolean;
  115282. }
  115283. }
  115284. declare module BABYLON {
  115285. /**
  115286. * @hidden
  115287. **/
  115288. export class DepthCullingState {
  115289. private _isDepthTestDirty;
  115290. private _isDepthMaskDirty;
  115291. private _isDepthFuncDirty;
  115292. private _isCullFaceDirty;
  115293. private _isCullDirty;
  115294. private _isZOffsetDirty;
  115295. private _isFrontFaceDirty;
  115296. private _depthTest;
  115297. private _depthMask;
  115298. private _depthFunc;
  115299. private _cull;
  115300. private _cullFace;
  115301. private _zOffset;
  115302. private _frontFace;
  115303. /**
  115304. * Initializes the state.
  115305. */
  115306. constructor();
  115307. get isDirty(): boolean;
  115308. get zOffset(): number;
  115309. set zOffset(value: number);
  115310. get cullFace(): Nullable<number>;
  115311. set cullFace(value: Nullable<number>);
  115312. get cull(): Nullable<boolean>;
  115313. set cull(value: Nullable<boolean>);
  115314. get depthFunc(): Nullable<number>;
  115315. set depthFunc(value: Nullable<number>);
  115316. get depthMask(): boolean;
  115317. set depthMask(value: boolean);
  115318. get depthTest(): boolean;
  115319. set depthTest(value: boolean);
  115320. get frontFace(): Nullable<number>;
  115321. set frontFace(value: Nullable<number>);
  115322. reset(): void;
  115323. apply(gl: WebGLRenderingContext): void;
  115324. }
  115325. }
  115326. declare module BABYLON {
  115327. /**
  115328. * @hidden
  115329. **/
  115330. export class StencilState {
  115331. /** 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 */
  115332. static readonly ALWAYS: number;
  115333. /** Passed to stencilOperation to specify that stencil value must be kept */
  115334. static readonly KEEP: number;
  115335. /** Passed to stencilOperation to specify that stencil value must be replaced */
  115336. static readonly REPLACE: number;
  115337. private _isStencilTestDirty;
  115338. private _isStencilMaskDirty;
  115339. private _isStencilFuncDirty;
  115340. private _isStencilOpDirty;
  115341. private _stencilTest;
  115342. private _stencilMask;
  115343. private _stencilFunc;
  115344. private _stencilFuncRef;
  115345. private _stencilFuncMask;
  115346. private _stencilOpStencilFail;
  115347. private _stencilOpDepthFail;
  115348. private _stencilOpStencilDepthPass;
  115349. get isDirty(): boolean;
  115350. get stencilFunc(): number;
  115351. set stencilFunc(value: number);
  115352. get stencilFuncRef(): number;
  115353. set stencilFuncRef(value: number);
  115354. get stencilFuncMask(): number;
  115355. set stencilFuncMask(value: number);
  115356. get stencilOpStencilFail(): number;
  115357. set stencilOpStencilFail(value: number);
  115358. get stencilOpDepthFail(): number;
  115359. set stencilOpDepthFail(value: number);
  115360. get stencilOpStencilDepthPass(): number;
  115361. set stencilOpStencilDepthPass(value: number);
  115362. get stencilMask(): number;
  115363. set stencilMask(value: number);
  115364. get stencilTest(): boolean;
  115365. set stencilTest(value: boolean);
  115366. constructor();
  115367. reset(): void;
  115368. apply(gl: WebGLRenderingContext): void;
  115369. }
  115370. }
  115371. declare module BABYLON {
  115372. /**
  115373. * @hidden
  115374. **/
  115375. export class AlphaState {
  115376. private _isAlphaBlendDirty;
  115377. private _isBlendFunctionParametersDirty;
  115378. private _isBlendEquationParametersDirty;
  115379. private _isBlendConstantsDirty;
  115380. private _alphaBlend;
  115381. private _blendFunctionParameters;
  115382. private _blendEquationParameters;
  115383. private _blendConstants;
  115384. /**
  115385. * Initializes the state.
  115386. */
  115387. constructor();
  115388. get isDirty(): boolean;
  115389. get alphaBlend(): boolean;
  115390. set alphaBlend(value: boolean);
  115391. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  115392. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  115393. setAlphaEquationParameters(rgb: number, alpha: number): void;
  115394. reset(): void;
  115395. apply(gl: WebGLRenderingContext): void;
  115396. }
  115397. }
  115398. declare module BABYLON {
  115399. /** @hidden */
  115400. export class WebGL2ShaderProcessor implements IShaderProcessor {
  115401. attributeProcessor(attribute: string): string;
  115402. varyingProcessor(varying: string, isFragment: boolean): string;
  115403. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  115404. }
  115405. }
  115406. declare module BABYLON {
  115407. /**
  115408. * Interface for attribute information associated with buffer instanciation
  115409. */
  115410. export interface InstancingAttributeInfo {
  115411. /**
  115412. * Name of the GLSL attribute
  115413. * if attribute index is not specified, this is used to retrieve the index from the effect
  115414. */
  115415. attributeName: string;
  115416. /**
  115417. * Index/offset of the attribute in the vertex shader
  115418. * if not specified, this will be computes from the name.
  115419. */
  115420. index?: number;
  115421. /**
  115422. * size of the attribute, 1, 2, 3 or 4
  115423. */
  115424. attributeSize: number;
  115425. /**
  115426. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  115427. */
  115428. offset: number;
  115429. /**
  115430. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  115431. * default to 1
  115432. */
  115433. divisor?: number;
  115434. /**
  115435. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  115436. * default is FLOAT
  115437. */
  115438. attributeType?: number;
  115439. /**
  115440. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  115441. */
  115442. normalized?: boolean;
  115443. }
  115444. }
  115445. declare module BABYLON {
  115446. interface ThinEngine {
  115447. /**
  115448. * Update a video texture
  115449. * @param texture defines the texture to update
  115450. * @param video defines the video element to use
  115451. * @param invertY defines if data must be stored with Y axis inverted
  115452. */
  115453. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  115454. }
  115455. }
  115456. declare module BABYLON {
  115457. interface ThinEngine {
  115458. /**
  115459. * Creates a dynamic texture
  115460. * @param width defines the width of the texture
  115461. * @param height defines the height of the texture
  115462. * @param generateMipMaps defines if the engine should generate the mip levels
  115463. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  115464. * @returns the dynamic texture inside an InternalTexture
  115465. */
  115466. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  115467. /**
  115468. * Update the content of a dynamic texture
  115469. * @param texture defines the texture to update
  115470. * @param canvas defines the canvas containing the source
  115471. * @param invertY defines if data must be stored with Y axis inverted
  115472. * @param premulAlpha defines if alpha is stored as premultiplied
  115473. * @param format defines the format of the data
  115474. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  115475. */
  115476. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  115477. }
  115478. }
  115479. declare module BABYLON {
  115480. /**
  115481. * Settings for finer control over video usage
  115482. */
  115483. export interface VideoTextureSettings {
  115484. /**
  115485. * Applies `autoplay` to video, if specified
  115486. */
  115487. autoPlay?: boolean;
  115488. /**
  115489. * Applies `loop` to video, if specified
  115490. */
  115491. loop?: boolean;
  115492. /**
  115493. * Automatically updates internal texture from video at every frame in the render loop
  115494. */
  115495. autoUpdateTexture: boolean;
  115496. /**
  115497. * Image src displayed during the video loading or until the user interacts with the video.
  115498. */
  115499. poster?: string;
  115500. }
  115501. /**
  115502. * If you want to display a video in your scene, this is the special texture for that.
  115503. * This special texture works similar to other textures, with the exception of a few parameters.
  115504. * @see https://doc.babylonjs.com/how_to/video_texture
  115505. */
  115506. export class VideoTexture extends Texture {
  115507. /**
  115508. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  115509. */
  115510. readonly autoUpdateTexture: boolean;
  115511. /**
  115512. * The video instance used by the texture internally
  115513. */
  115514. readonly video: HTMLVideoElement;
  115515. private _onUserActionRequestedObservable;
  115516. /**
  115517. * Event triggerd when a dom action is required by the user to play the video.
  115518. * This happens due to recent changes in browser policies preventing video to auto start.
  115519. */
  115520. get onUserActionRequestedObservable(): Observable<Texture>;
  115521. private _generateMipMaps;
  115522. private _stillImageCaptured;
  115523. private _displayingPosterTexture;
  115524. private _settings;
  115525. private _createInternalTextureOnEvent;
  115526. private _frameId;
  115527. private _currentSrc;
  115528. /**
  115529. * Creates a video texture.
  115530. * If you want to display a video in your scene, this is the special texture for that.
  115531. * This special texture works similar to other textures, with the exception of a few parameters.
  115532. * @see https://doc.babylonjs.com/how_to/video_texture
  115533. * @param name optional name, will detect from video source, if not defined
  115534. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  115535. * @param scene is obviously the current scene.
  115536. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  115537. * @param invertY is false by default but can be used to invert video on Y axis
  115538. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  115539. * @param settings allows finer control over video usage
  115540. */
  115541. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  115542. private _getName;
  115543. private _getVideo;
  115544. private _createInternalTexture;
  115545. private reset;
  115546. /**
  115547. * @hidden Internal method to initiate `update`.
  115548. */
  115549. _rebuild(): void;
  115550. /**
  115551. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  115552. */
  115553. update(): void;
  115554. /**
  115555. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  115556. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  115557. */
  115558. updateTexture(isVisible: boolean): void;
  115559. protected _updateInternalTexture: () => void;
  115560. /**
  115561. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  115562. * @param url New url.
  115563. */
  115564. updateURL(url: string): void;
  115565. /**
  115566. * Clones the texture.
  115567. * @returns the cloned texture
  115568. */
  115569. clone(): VideoTexture;
  115570. /**
  115571. * Dispose the texture and release its associated resources.
  115572. */
  115573. dispose(): void;
  115574. /**
  115575. * Creates a video texture straight from a stream.
  115576. * @param scene Define the scene the texture should be created in
  115577. * @param stream Define the stream the texture should be created from
  115578. * @returns The created video texture as a promise
  115579. */
  115580. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  115581. /**
  115582. * Creates a video texture straight from your WebCam video feed.
  115583. * @param scene Define the scene the texture should be created in
  115584. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115585. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115586. * @returns The created video texture as a promise
  115587. */
  115588. static CreateFromWebCamAsync(scene: Scene, constraints: {
  115589. minWidth: number;
  115590. maxWidth: number;
  115591. minHeight: number;
  115592. maxHeight: number;
  115593. deviceId: string;
  115594. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  115595. /**
  115596. * Creates a video texture straight from your WebCam video feed.
  115597. * @param scene Define the scene the texture should be created in
  115598. * @param onReady Define a callback to triggered once the texture will be ready
  115599. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115600. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115601. */
  115602. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  115603. minWidth: number;
  115604. maxWidth: number;
  115605. minHeight: number;
  115606. maxHeight: number;
  115607. deviceId: string;
  115608. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  115609. }
  115610. }
  115611. declare module BABYLON {
  115612. /**
  115613. * Defines the interface used by objects working like Scene
  115614. * @hidden
  115615. */
  115616. export interface ISceneLike {
  115617. _addPendingData(data: any): void;
  115618. _removePendingData(data: any): void;
  115619. offlineProvider: IOfflineProvider;
  115620. }
  115621. /**
  115622. * Information about the current host
  115623. */
  115624. export interface HostInformation {
  115625. /**
  115626. * Defines if the current host is a mobile
  115627. */
  115628. isMobile: boolean;
  115629. }
  115630. /** Interface defining initialization parameters for Engine class */
  115631. export interface EngineOptions extends WebGLContextAttributes {
  115632. /**
  115633. * Defines if the engine should no exceed a specified device ratio
  115634. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  115635. */
  115636. limitDeviceRatio?: number;
  115637. /**
  115638. * Defines if webvr should be enabled automatically
  115639. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115640. */
  115641. autoEnableWebVR?: boolean;
  115642. /**
  115643. * Defines if webgl2 should be turned off even if supported
  115644. * @see https://doc.babylonjs.com/features/webgl2
  115645. */
  115646. disableWebGL2Support?: boolean;
  115647. /**
  115648. * Defines if webaudio should be initialized as well
  115649. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115650. */
  115651. audioEngine?: boolean;
  115652. /**
  115653. * Defines if animations should run using a deterministic lock step
  115654. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115655. */
  115656. deterministicLockstep?: boolean;
  115657. /** Defines the maximum steps to use with deterministic lock step mode */
  115658. lockstepMaxSteps?: number;
  115659. /** Defines the seconds between each deterministic lock step */
  115660. timeStep?: number;
  115661. /**
  115662. * Defines that engine should ignore context lost events
  115663. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  115664. */
  115665. doNotHandleContextLost?: boolean;
  115666. /**
  115667. * Defines that engine should ignore modifying touch action attribute and style
  115668. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  115669. */
  115670. doNotHandleTouchAction?: boolean;
  115671. /**
  115672. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  115673. */
  115674. useHighPrecisionFloats?: boolean;
  115675. /**
  115676. * Make the canvas XR Compatible for XR sessions
  115677. */
  115678. xrCompatible?: boolean;
  115679. /**
  115680. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  115681. */
  115682. useHighPrecisionMatrix?: boolean;
  115683. /**
  115684. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  115685. */
  115686. failIfMajorPerformanceCaveat?: boolean;
  115687. }
  115688. /**
  115689. * The base engine class (root of all engines)
  115690. */
  115691. export class ThinEngine {
  115692. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  115693. static ExceptionList: ({
  115694. key: string;
  115695. capture: string;
  115696. captureConstraint: number;
  115697. targets: string[];
  115698. } | {
  115699. key: string;
  115700. capture: null;
  115701. captureConstraint: null;
  115702. targets: string[];
  115703. })[];
  115704. /** @hidden */
  115705. static _TextureLoaders: IInternalTextureLoader[];
  115706. /**
  115707. * Returns the current npm package of the sdk
  115708. */
  115709. static get NpmPackage(): string;
  115710. /**
  115711. * Returns the current version of the framework
  115712. */
  115713. static get Version(): string;
  115714. /**
  115715. * Returns a string describing the current engine
  115716. */
  115717. get description(): string;
  115718. /**
  115719. * Gets or sets the epsilon value used by collision engine
  115720. */
  115721. static CollisionsEpsilon: number;
  115722. /**
  115723. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  115724. */
  115725. static get ShadersRepository(): string;
  115726. static set ShadersRepository(value: string);
  115727. /** @hidden */
  115728. _shaderProcessor: IShaderProcessor;
  115729. /**
  115730. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  115731. */
  115732. forcePOTTextures: boolean;
  115733. /**
  115734. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  115735. */
  115736. isFullscreen: boolean;
  115737. /**
  115738. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  115739. */
  115740. cullBackFaces: boolean;
  115741. /**
  115742. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  115743. */
  115744. renderEvenInBackground: boolean;
  115745. /**
  115746. * Gets or sets a boolean indicating that cache can be kept between frames
  115747. */
  115748. preventCacheWipeBetweenFrames: boolean;
  115749. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  115750. validateShaderPrograms: boolean;
  115751. /**
  115752. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  115753. * This can provide greater z depth for distant objects.
  115754. */
  115755. useReverseDepthBuffer: boolean;
  115756. /**
  115757. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  115758. */
  115759. disableUniformBuffers: boolean;
  115760. /** @hidden */
  115761. _uniformBuffers: UniformBuffer[];
  115762. /**
  115763. * Gets a boolean indicating that the engine supports uniform buffers
  115764. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  115765. */
  115766. get supportsUniformBuffers(): boolean;
  115767. /** @hidden */
  115768. _gl: WebGLRenderingContext;
  115769. /** @hidden */
  115770. _webGLVersion: number;
  115771. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  115772. protected _windowIsBackground: boolean;
  115773. protected _creationOptions: EngineOptions;
  115774. protected _highPrecisionShadersAllowed: boolean;
  115775. /** @hidden */
  115776. get _shouldUseHighPrecisionShader(): boolean;
  115777. /**
  115778. * Gets a boolean indicating that only power of 2 textures are supported
  115779. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  115780. */
  115781. get needPOTTextures(): boolean;
  115782. /** @hidden */
  115783. _badOS: boolean;
  115784. /** @hidden */
  115785. _badDesktopOS: boolean;
  115786. private _hardwareScalingLevel;
  115787. /** @hidden */
  115788. _caps: EngineCapabilities;
  115789. private _isStencilEnable;
  115790. private _glVersion;
  115791. private _glRenderer;
  115792. private _glVendor;
  115793. /** @hidden */
  115794. _videoTextureSupported: boolean;
  115795. protected _renderingQueueLaunched: boolean;
  115796. protected _activeRenderLoops: (() => void)[];
  115797. /**
  115798. * Observable signaled when a context lost event is raised
  115799. */
  115800. onContextLostObservable: Observable<ThinEngine>;
  115801. /**
  115802. * Observable signaled when a context restored event is raised
  115803. */
  115804. onContextRestoredObservable: Observable<ThinEngine>;
  115805. private _onContextLost;
  115806. private _onContextRestored;
  115807. protected _contextWasLost: boolean;
  115808. /** @hidden */
  115809. _doNotHandleContextLost: boolean;
  115810. /**
  115811. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  115812. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  115813. */
  115814. get doNotHandleContextLost(): boolean;
  115815. set doNotHandleContextLost(value: boolean);
  115816. /**
  115817. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  115818. */
  115819. disableVertexArrayObjects: boolean;
  115820. /** @hidden */
  115821. protected _colorWrite: boolean;
  115822. /** @hidden */
  115823. protected _colorWriteChanged: boolean;
  115824. /** @hidden */
  115825. protected _depthCullingState: DepthCullingState;
  115826. /** @hidden */
  115827. protected _stencilState: StencilState;
  115828. /** @hidden */
  115829. _alphaState: AlphaState;
  115830. /** @hidden */
  115831. _alphaMode: number;
  115832. /** @hidden */
  115833. _alphaEquation: number;
  115834. /** @hidden */
  115835. _internalTexturesCache: InternalTexture[];
  115836. /** @hidden */
  115837. protected _activeChannel: number;
  115838. private _currentTextureChannel;
  115839. /** @hidden */
  115840. protected _boundTexturesCache: {
  115841. [key: string]: Nullable<InternalTexture>;
  115842. };
  115843. /** @hidden */
  115844. protected _currentEffect: Nullable<Effect>;
  115845. /** @hidden */
  115846. protected _currentProgram: Nullable<WebGLProgram>;
  115847. private _compiledEffects;
  115848. private _vertexAttribArraysEnabled;
  115849. /** @hidden */
  115850. protected _cachedViewport: Nullable<IViewportLike>;
  115851. private _cachedVertexArrayObject;
  115852. /** @hidden */
  115853. protected _cachedVertexBuffers: any;
  115854. /** @hidden */
  115855. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  115856. /** @hidden */
  115857. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  115858. /** @hidden */
  115859. _currentRenderTarget: Nullable<InternalTexture>;
  115860. private _uintIndicesCurrentlySet;
  115861. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  115862. /** @hidden */
  115863. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  115864. /** @hidden */
  115865. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  115866. private _currentBufferPointers;
  115867. private _currentInstanceLocations;
  115868. private _currentInstanceBuffers;
  115869. private _textureUnits;
  115870. /** @hidden */
  115871. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115872. /** @hidden */
  115873. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115874. /** @hidden */
  115875. _boundRenderFunction: any;
  115876. private _vaoRecordInProgress;
  115877. private _mustWipeVertexAttributes;
  115878. private _emptyTexture;
  115879. private _emptyCubeTexture;
  115880. private _emptyTexture3D;
  115881. private _emptyTexture2DArray;
  115882. /** @hidden */
  115883. _frameHandler: number;
  115884. private _nextFreeTextureSlots;
  115885. private _maxSimultaneousTextures;
  115886. private _activeRequests;
  115887. /** @hidden */
  115888. _transformTextureUrl: Nullable<(url: string) => string>;
  115889. /**
  115890. * Gets information about the current host
  115891. */
  115892. hostInformation: HostInformation;
  115893. protected get _supportsHardwareTextureRescaling(): boolean;
  115894. private _framebufferDimensionsObject;
  115895. /**
  115896. * sets the object from which width and height will be taken from when getting render width and height
  115897. * Will fallback to the gl object
  115898. * @param dimensions the framebuffer width and height that will be used.
  115899. */
  115900. set framebufferDimensionsObject(dimensions: Nullable<{
  115901. framebufferWidth: number;
  115902. framebufferHeight: number;
  115903. }>);
  115904. /**
  115905. * Gets the current viewport
  115906. */
  115907. get currentViewport(): Nullable<IViewportLike>;
  115908. /**
  115909. * Gets the default empty texture
  115910. */
  115911. get emptyTexture(): InternalTexture;
  115912. /**
  115913. * Gets the default empty 3D texture
  115914. */
  115915. get emptyTexture3D(): InternalTexture;
  115916. /**
  115917. * Gets the default empty 2D array texture
  115918. */
  115919. get emptyTexture2DArray(): InternalTexture;
  115920. /**
  115921. * Gets the default empty cube texture
  115922. */
  115923. get emptyCubeTexture(): InternalTexture;
  115924. /**
  115925. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  115926. */
  115927. readonly premultipliedAlpha: boolean;
  115928. /**
  115929. * Observable event triggered before each texture is initialized
  115930. */
  115931. onBeforeTextureInitObservable: Observable<Texture>;
  115932. /**
  115933. * Creates a new engine
  115934. * @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
  115935. * @param antialias defines enable antialiasing (default: false)
  115936. * @param options defines further options to be sent to the getContext() function
  115937. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  115938. */
  115939. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  115940. private _rebuildInternalTextures;
  115941. private _rebuildEffects;
  115942. /**
  115943. * Gets a boolean indicating if all created effects are ready
  115944. * @returns true if all effects are ready
  115945. */
  115946. areAllEffectsReady(): boolean;
  115947. protected _rebuildBuffers(): void;
  115948. protected _initGLContext(): void;
  115949. /**
  115950. * Gets version of the current webGL context
  115951. */
  115952. get webGLVersion(): number;
  115953. /**
  115954. * Gets a string identifying the name of the class
  115955. * @returns "Engine" string
  115956. */
  115957. getClassName(): string;
  115958. /**
  115959. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  115960. */
  115961. get isStencilEnable(): boolean;
  115962. /** @hidden */
  115963. _prepareWorkingCanvas(): void;
  115964. /**
  115965. * Reset the texture cache to empty state
  115966. */
  115967. resetTextureCache(): void;
  115968. /**
  115969. * Gets an object containing information about the current webGL context
  115970. * @returns an object containing the vender, the renderer and the version of the current webGL context
  115971. */
  115972. getGlInfo(): {
  115973. vendor: string;
  115974. renderer: string;
  115975. version: string;
  115976. };
  115977. /**
  115978. * Defines the hardware scaling level.
  115979. * By default the hardware scaling level is computed from the window device ratio.
  115980. * 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.
  115981. * @param level defines the level to use
  115982. */
  115983. setHardwareScalingLevel(level: number): void;
  115984. /**
  115985. * Gets the current hardware scaling level.
  115986. * By default the hardware scaling level is computed from the window device ratio.
  115987. * 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.
  115988. * @returns a number indicating the current hardware scaling level
  115989. */
  115990. getHardwareScalingLevel(): number;
  115991. /**
  115992. * Gets the list of loaded textures
  115993. * @returns an array containing all loaded textures
  115994. */
  115995. getLoadedTexturesCache(): InternalTexture[];
  115996. /**
  115997. * Gets the object containing all engine capabilities
  115998. * @returns the EngineCapabilities object
  115999. */
  116000. getCaps(): EngineCapabilities;
  116001. /**
  116002. * stop executing a render loop function and remove it from the execution array
  116003. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  116004. */
  116005. stopRenderLoop(renderFunction?: () => void): void;
  116006. /** @hidden */
  116007. _renderLoop(): void;
  116008. /**
  116009. * Gets the HTML canvas attached with the current webGL context
  116010. * @returns a HTML canvas
  116011. */
  116012. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  116013. /**
  116014. * Gets host window
  116015. * @returns the host window object
  116016. */
  116017. getHostWindow(): Nullable<Window>;
  116018. /**
  116019. * Gets the current render width
  116020. * @param useScreen defines if screen size must be used (or the current render target if any)
  116021. * @returns a number defining the current render width
  116022. */
  116023. getRenderWidth(useScreen?: boolean): number;
  116024. /**
  116025. * Gets the current render height
  116026. * @param useScreen defines if screen size must be used (or the current render target if any)
  116027. * @returns a number defining the current render height
  116028. */
  116029. getRenderHeight(useScreen?: boolean): number;
  116030. /**
  116031. * Can be used to override the current requestAnimationFrame requester.
  116032. * @hidden
  116033. */
  116034. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  116035. /**
  116036. * Register and execute a render loop. The engine can have more than one render function
  116037. * @param renderFunction defines the function to continuously execute
  116038. */
  116039. runRenderLoop(renderFunction: () => void): void;
  116040. /**
  116041. * Clear the current render buffer or the current render target (if any is set up)
  116042. * @param color defines the color to use
  116043. * @param backBuffer defines if the back buffer must be cleared
  116044. * @param depth defines if the depth buffer must be cleared
  116045. * @param stencil defines if the stencil buffer must be cleared
  116046. */
  116047. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  116048. private _viewportCached;
  116049. /** @hidden */
  116050. _viewport(x: number, y: number, width: number, height: number): void;
  116051. /**
  116052. * Set the WebGL's viewport
  116053. * @param viewport defines the viewport element to be used
  116054. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  116055. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  116056. */
  116057. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  116058. /**
  116059. * Begin a new frame
  116060. */
  116061. beginFrame(): void;
  116062. /**
  116063. * Enf the current frame
  116064. */
  116065. endFrame(): void;
  116066. /**
  116067. * Resize the view according to the canvas' size
  116068. */
  116069. resize(): void;
  116070. /**
  116071. * Force a specific size of the canvas
  116072. * @param width defines the new canvas' width
  116073. * @param height defines the new canvas' height
  116074. * @returns true if the size was changed
  116075. */
  116076. setSize(width: number, height: number): boolean;
  116077. /**
  116078. * Binds the frame buffer to the specified texture.
  116079. * @param texture The texture to render to or null for the default canvas
  116080. * @param faceIndex The face of the texture to render to in case of cube texture
  116081. * @param requiredWidth The width of the target to render to
  116082. * @param requiredHeight The height of the target to render to
  116083. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  116084. * @param lodLevel defines the lod level to bind to the frame buffer
  116085. * @param layer defines the 2d array index to bind to frame buffer to
  116086. */
  116087. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  116088. /** @hidden */
  116089. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  116090. /**
  116091. * Unbind the current render target texture from the webGL context
  116092. * @param texture defines the render target texture to unbind
  116093. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  116094. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  116095. */
  116096. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  116097. /**
  116098. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  116099. */
  116100. flushFramebuffer(): void;
  116101. /**
  116102. * Unbind the current render target and bind the default framebuffer
  116103. */
  116104. restoreDefaultFramebuffer(): void;
  116105. /** @hidden */
  116106. protected _resetVertexBufferBinding(): void;
  116107. /**
  116108. * Creates a vertex buffer
  116109. * @param data the data for the vertex buffer
  116110. * @returns the new WebGL static buffer
  116111. */
  116112. createVertexBuffer(data: DataArray): DataBuffer;
  116113. private _createVertexBuffer;
  116114. /**
  116115. * Creates a dynamic vertex buffer
  116116. * @param data the data for the dynamic vertex buffer
  116117. * @returns the new WebGL dynamic buffer
  116118. */
  116119. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  116120. protected _resetIndexBufferBinding(): void;
  116121. /**
  116122. * Creates a new index buffer
  116123. * @param indices defines the content of the index buffer
  116124. * @param updatable defines if the index buffer must be updatable
  116125. * @returns a new webGL buffer
  116126. */
  116127. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  116128. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  116129. /**
  116130. * Bind a webGL buffer to the webGL context
  116131. * @param buffer defines the buffer to bind
  116132. */
  116133. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  116134. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  116135. private bindBuffer;
  116136. /**
  116137. * update the bound buffer with the given data
  116138. * @param data defines the data to update
  116139. */
  116140. updateArrayBuffer(data: Float32Array): void;
  116141. private _vertexAttribPointer;
  116142. /** @hidden */
  116143. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  116144. private _bindVertexBuffersAttributes;
  116145. /**
  116146. * Records a vertex array object
  116147. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  116148. * @param vertexBuffers defines the list of vertex buffers to store
  116149. * @param indexBuffer defines the index buffer to store
  116150. * @param effect defines the effect to store
  116151. * @returns the new vertex array object
  116152. */
  116153. recordVertexArrayObject(vertexBuffers: {
  116154. [key: string]: VertexBuffer;
  116155. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  116156. /**
  116157. * Bind a specific vertex array object
  116158. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  116159. * @param vertexArrayObject defines the vertex array object to bind
  116160. * @param indexBuffer defines the index buffer to bind
  116161. */
  116162. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  116163. /**
  116164. * Bind webGl buffers directly to the webGL context
  116165. * @param vertexBuffer defines the vertex buffer to bind
  116166. * @param indexBuffer defines the index buffer to bind
  116167. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  116168. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  116169. * @param effect defines the effect associated with the vertex buffer
  116170. */
  116171. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  116172. private _unbindVertexArrayObject;
  116173. /**
  116174. * Bind a list of vertex buffers to the webGL context
  116175. * @param vertexBuffers defines the list of vertex buffers to bind
  116176. * @param indexBuffer defines the index buffer to bind
  116177. * @param effect defines the effect associated with the vertex buffers
  116178. */
  116179. bindBuffers(vertexBuffers: {
  116180. [key: string]: Nullable<VertexBuffer>;
  116181. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  116182. /**
  116183. * Unbind all instance attributes
  116184. */
  116185. unbindInstanceAttributes(): void;
  116186. /**
  116187. * Release and free the memory of a vertex array object
  116188. * @param vao defines the vertex array object to delete
  116189. */
  116190. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  116191. /** @hidden */
  116192. _releaseBuffer(buffer: DataBuffer): boolean;
  116193. protected _deleteBuffer(buffer: DataBuffer): void;
  116194. /**
  116195. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  116196. * @param instancesBuffer defines the webGL buffer to update and bind
  116197. * @param data defines the data to store in the buffer
  116198. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  116199. */
  116200. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  116201. /**
  116202. * Bind the content of a webGL buffer used with instantiation
  116203. * @param instancesBuffer defines the webGL buffer to bind
  116204. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  116205. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  116206. */
  116207. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  116208. /**
  116209. * Disable the instance attribute corresponding to the name in parameter
  116210. * @param name defines the name of the attribute to disable
  116211. */
  116212. disableInstanceAttributeByName(name: string): void;
  116213. /**
  116214. * Disable the instance attribute corresponding to the location in parameter
  116215. * @param attributeLocation defines the attribute location of the attribute to disable
  116216. */
  116217. disableInstanceAttribute(attributeLocation: number): void;
  116218. /**
  116219. * Disable the attribute corresponding to the location in parameter
  116220. * @param attributeLocation defines the attribute location of the attribute to disable
  116221. */
  116222. disableAttributeByIndex(attributeLocation: number): void;
  116223. /**
  116224. * Send a draw order
  116225. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116226. * @param indexStart defines the starting index
  116227. * @param indexCount defines the number of index to draw
  116228. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116229. */
  116230. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  116231. /**
  116232. * Draw a list of points
  116233. * @param verticesStart defines the index of first vertex to draw
  116234. * @param verticesCount defines the count of vertices to draw
  116235. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116236. */
  116237. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116238. /**
  116239. * Draw a list of unindexed primitives
  116240. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116241. * @param verticesStart defines the index of first vertex to draw
  116242. * @param verticesCount defines the count of vertices to draw
  116243. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116244. */
  116245. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116246. /**
  116247. * Draw a list of indexed primitives
  116248. * @param fillMode defines the primitive to use
  116249. * @param indexStart defines the starting index
  116250. * @param indexCount defines the number of index to draw
  116251. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116252. */
  116253. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  116254. /**
  116255. * Draw a list of unindexed primitives
  116256. * @param fillMode defines the primitive to use
  116257. * @param verticesStart defines the index of first vertex to draw
  116258. * @param verticesCount defines the count of vertices to draw
  116259. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116260. */
  116261. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116262. private _drawMode;
  116263. /** @hidden */
  116264. protected _reportDrawCall(): void;
  116265. /** @hidden */
  116266. _releaseEffect(effect: Effect): void;
  116267. /** @hidden */
  116268. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  116269. /**
  116270. * Create a new effect (used to store vertex/fragment shaders)
  116271. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  116272. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  116273. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  116274. * @param samplers defines an array of string used to represent textures
  116275. * @param defines defines the string containing the defines to use to compile the shaders
  116276. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  116277. * @param onCompiled defines a function to call when the effect creation is successful
  116278. * @param onError defines a function to call when the effect creation has failed
  116279. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  116280. * @returns the new Effect
  116281. */
  116282. 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;
  116283. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  116284. private _compileShader;
  116285. private _compileRawShader;
  116286. /** @hidden */
  116287. _getShaderSource(shader: WebGLShader): Nullable<string>;
  116288. /**
  116289. * Directly creates a webGL program
  116290. * @param pipelineContext defines the pipeline context to attach to
  116291. * @param vertexCode defines the vertex shader code to use
  116292. * @param fragmentCode defines the fragment shader code to use
  116293. * @param context defines the webGL context to use (if not set, the current one will be used)
  116294. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  116295. * @returns the new webGL program
  116296. */
  116297. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116298. /**
  116299. * Creates a webGL program
  116300. * @param pipelineContext defines the pipeline context to attach to
  116301. * @param vertexCode defines the vertex shader code to use
  116302. * @param fragmentCode defines the fragment shader code to use
  116303. * @param defines defines the string containing the defines to use to compile the shaders
  116304. * @param context defines the webGL context to use (if not set, the current one will be used)
  116305. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  116306. * @returns the new webGL program
  116307. */
  116308. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116309. /**
  116310. * Creates a new pipeline context
  116311. * @returns the new pipeline
  116312. */
  116313. createPipelineContext(): IPipelineContext;
  116314. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116315. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  116316. /** @hidden */
  116317. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  116318. /** @hidden */
  116319. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  116320. /** @hidden */
  116321. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  116322. /**
  116323. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  116324. * @param pipelineContext defines the pipeline context to use
  116325. * @param uniformsNames defines the list of uniform names
  116326. * @returns an array of webGL uniform locations
  116327. */
  116328. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  116329. /**
  116330. * Gets the lsit of active attributes for a given webGL program
  116331. * @param pipelineContext defines the pipeline context to use
  116332. * @param attributesNames defines the list of attribute names to get
  116333. * @returns an array of indices indicating the offset of each attribute
  116334. */
  116335. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  116336. /**
  116337. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  116338. * @param effect defines the effect to activate
  116339. */
  116340. enableEffect(effect: Nullable<Effect>): void;
  116341. /**
  116342. * Set the value of an uniform to a number (int)
  116343. * @param uniform defines the webGL uniform location where to store the value
  116344. * @param value defines the int number to store
  116345. * @returns true if the value was set
  116346. */
  116347. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  116348. /**
  116349. * Set the value of an uniform to an array of int32
  116350. * @param uniform defines the webGL uniform location where to store the value
  116351. * @param array defines the array of int32 to store
  116352. * @returns true if the value was set
  116353. */
  116354. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116355. /**
  116356. * Set the value of an uniform to an array of int32 (stored as vec2)
  116357. * @param uniform defines the webGL uniform location where to store the value
  116358. * @param array defines the array of int32 to store
  116359. * @returns true if the value was set
  116360. */
  116361. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116362. /**
  116363. * Set the value of an uniform to an array of int32 (stored as vec3)
  116364. * @param uniform defines the webGL uniform location where to store the value
  116365. * @param array defines the array of int32 to store
  116366. * @returns true if the value was set
  116367. */
  116368. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116369. /**
  116370. * Set the value of an uniform to an array of int32 (stored as vec4)
  116371. * @param uniform defines the webGL uniform location where to store the value
  116372. * @param array defines the array of int32 to store
  116373. * @returns true if the value was set
  116374. */
  116375. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116376. /**
  116377. * Set the value of an uniform to an array of number
  116378. * @param uniform defines the webGL uniform location where to store the value
  116379. * @param array defines the array of number to store
  116380. * @returns true if the value was set
  116381. */
  116382. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116383. /**
  116384. * Set the value of an uniform to an array of number (stored as vec2)
  116385. * @param uniform defines the webGL uniform location where to store the value
  116386. * @param array defines the array of number to store
  116387. * @returns true if the value was set
  116388. */
  116389. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116390. /**
  116391. * Set the value of an uniform to an array of number (stored as vec3)
  116392. * @param uniform defines the webGL uniform location where to store the value
  116393. * @param array defines the array of number to store
  116394. * @returns true if the value was set
  116395. */
  116396. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116397. /**
  116398. * Set the value of an uniform to an array of number (stored as vec4)
  116399. * @param uniform defines the webGL uniform location where to store the value
  116400. * @param array defines the array of number to store
  116401. * @returns true if the value was set
  116402. */
  116403. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116404. /**
  116405. * Set the value of an uniform to an array of float32 (stored as matrices)
  116406. * @param uniform defines the webGL uniform location where to store the value
  116407. * @param matrices defines the array of float32 to store
  116408. * @returns true if the value was set
  116409. */
  116410. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  116411. /**
  116412. * Set the value of an uniform to a matrix (3x3)
  116413. * @param uniform defines the webGL uniform location where to store the value
  116414. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  116415. * @returns true if the value was set
  116416. */
  116417. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  116418. /**
  116419. * Set the value of an uniform to a matrix (2x2)
  116420. * @param uniform defines the webGL uniform location where to store the value
  116421. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  116422. * @returns true if the value was set
  116423. */
  116424. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  116425. /**
  116426. * Set the value of an uniform to a number (float)
  116427. * @param uniform defines the webGL uniform location where to store the value
  116428. * @param value defines the float number to store
  116429. * @returns true if the value was transfered
  116430. */
  116431. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  116432. /**
  116433. * Set the value of an uniform to a vec2
  116434. * @param uniform defines the webGL uniform location where to store the value
  116435. * @param x defines the 1st component of the value
  116436. * @param y defines the 2nd component of the value
  116437. * @returns true if the value was set
  116438. */
  116439. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  116440. /**
  116441. * Set the value of an uniform to a vec3
  116442. * @param uniform defines the webGL uniform location where to store the value
  116443. * @param x defines the 1st component of the value
  116444. * @param y defines the 2nd component of the value
  116445. * @param z defines the 3rd component of the value
  116446. * @returns true if the value was set
  116447. */
  116448. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  116449. /**
  116450. * Set the value of an uniform to a vec4
  116451. * @param uniform defines the webGL uniform location where to store the value
  116452. * @param x defines the 1st component of the value
  116453. * @param y defines the 2nd component of the value
  116454. * @param z defines the 3rd component of the value
  116455. * @param w defines the 4th component of the value
  116456. * @returns true if the value was set
  116457. */
  116458. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  116459. /**
  116460. * Apply all cached states (depth, culling, stencil and alpha)
  116461. */
  116462. applyStates(): void;
  116463. /**
  116464. * Enable or disable color writing
  116465. * @param enable defines the state to set
  116466. */
  116467. setColorWrite(enable: boolean): void;
  116468. /**
  116469. * Gets a boolean indicating if color writing is enabled
  116470. * @returns the current color writing state
  116471. */
  116472. getColorWrite(): boolean;
  116473. /**
  116474. * Gets the depth culling state manager
  116475. */
  116476. get depthCullingState(): DepthCullingState;
  116477. /**
  116478. * Gets the alpha state manager
  116479. */
  116480. get alphaState(): AlphaState;
  116481. /**
  116482. * Gets the stencil state manager
  116483. */
  116484. get stencilState(): StencilState;
  116485. /**
  116486. * Clears the list of texture accessible through engine.
  116487. * This can help preventing texture load conflict due to name collision.
  116488. */
  116489. clearInternalTexturesCache(): void;
  116490. /**
  116491. * Force the entire cache to be cleared
  116492. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  116493. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  116494. */
  116495. wipeCaches(bruteForce?: boolean): void;
  116496. /** @hidden */
  116497. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  116498. min: number;
  116499. mag: number;
  116500. };
  116501. /** @hidden */
  116502. _createTexture(): WebGLTexture;
  116503. /**
  116504. * Usually called from Texture.ts.
  116505. * Passed information to create a WebGLTexture
  116506. * @param url defines a value which contains one of the following:
  116507. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116508. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116509. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116510. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116511. * @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)
  116512. * @param scene needed for loading to the correct scene
  116513. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  116514. * @param onLoad optional callback to be called upon successful completion
  116515. * @param onError optional callback to be called upon failure
  116516. * @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
  116517. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116518. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116519. * @param forcedExtension defines the extension to use to pick the right loader
  116520. * @param mimeType defines an optional mime type
  116521. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116522. */
  116523. 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;
  116524. /**
  116525. * Loads an image as an HTMLImageElement.
  116526. * @param input url string, ArrayBuffer, or Blob to load
  116527. * @param onLoad callback called when the image successfully loads
  116528. * @param onError callback called when the image fails to load
  116529. * @param offlineProvider offline provider for caching
  116530. * @param mimeType optional mime type
  116531. * @returns the HTMLImageElement of the loaded image
  116532. * @hidden
  116533. */
  116534. 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>;
  116535. /**
  116536. * @hidden
  116537. */
  116538. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116539. private _unpackFlipYCached;
  116540. /**
  116541. * In case you are sharing the context with other applications, it might
  116542. * be interested to not cache the unpack flip y state to ensure a consistent
  116543. * value would be set.
  116544. */
  116545. enableUnpackFlipYCached: boolean;
  116546. /** @hidden */
  116547. _unpackFlipY(value: boolean): void;
  116548. /** @hidden */
  116549. _getUnpackAlignement(): number;
  116550. private _getTextureTarget;
  116551. /**
  116552. * Update the sampling mode of a given texture
  116553. * @param samplingMode defines the required sampling mode
  116554. * @param texture defines the texture to update
  116555. * @param generateMipMaps defines whether to generate mipmaps for the texture
  116556. */
  116557. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  116558. /**
  116559. * Update the sampling mode of a given texture
  116560. * @param texture defines the texture to update
  116561. * @param wrapU defines the texture wrap mode of the u coordinates
  116562. * @param wrapV defines the texture wrap mode of the v coordinates
  116563. * @param wrapR defines the texture wrap mode of the r coordinates
  116564. */
  116565. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  116566. /** @hidden */
  116567. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  116568. width: number;
  116569. height: number;
  116570. layers?: number;
  116571. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  116572. /** @hidden */
  116573. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116574. /** @hidden */
  116575. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  116576. /**
  116577. * Update a portion of an internal texture
  116578. * @param texture defines the texture to update
  116579. * @param imageData defines the data to store into the texture
  116580. * @param xOffset defines the x coordinates of the update rectangle
  116581. * @param yOffset defines the y coordinates of the update rectangle
  116582. * @param width defines the width of the update rectangle
  116583. * @param height defines the height of the update rectangle
  116584. * @param faceIndex defines the face index if texture is a cube (0 by default)
  116585. * @param lod defines the lod level to update (0 by default)
  116586. */
  116587. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  116588. /** @hidden */
  116589. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116590. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  116591. private _prepareWebGLTexture;
  116592. /** @hidden */
  116593. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  116594. private _getDepthStencilBuffer;
  116595. /** @hidden */
  116596. _releaseFramebufferObjects(texture: InternalTexture): void;
  116597. /** @hidden */
  116598. _releaseTexture(texture: InternalTexture): void;
  116599. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  116600. protected _setProgram(program: WebGLProgram): void;
  116601. protected _boundUniforms: {
  116602. [key: number]: WebGLUniformLocation;
  116603. };
  116604. /**
  116605. * Binds an effect to the webGL context
  116606. * @param effect defines the effect to bind
  116607. */
  116608. bindSamplers(effect: Effect): void;
  116609. private _activateCurrentTexture;
  116610. /** @hidden */
  116611. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  116612. /** @hidden */
  116613. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  116614. /**
  116615. * Unbind all textures from the webGL context
  116616. */
  116617. unbindAllTextures(): void;
  116618. /**
  116619. * Sets a texture to the according uniform.
  116620. * @param channel The texture channel
  116621. * @param uniform The uniform to set
  116622. * @param texture The texture to apply
  116623. */
  116624. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  116625. private _bindSamplerUniformToChannel;
  116626. private _getTextureWrapMode;
  116627. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  116628. /**
  116629. * Sets an array of texture to the webGL context
  116630. * @param channel defines the channel where the texture array must be set
  116631. * @param uniform defines the associated uniform location
  116632. * @param textures defines the array of textures to bind
  116633. */
  116634. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  116635. /** @hidden */
  116636. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  116637. private _setTextureParameterFloat;
  116638. private _setTextureParameterInteger;
  116639. /**
  116640. * Unbind all vertex attributes from the webGL context
  116641. */
  116642. unbindAllAttributes(): void;
  116643. /**
  116644. * 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
  116645. */
  116646. releaseEffects(): void;
  116647. /**
  116648. * Dispose and release all associated resources
  116649. */
  116650. dispose(): void;
  116651. /**
  116652. * Attach a new callback raised when context lost event is fired
  116653. * @param callback defines the callback to call
  116654. */
  116655. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116656. /**
  116657. * Attach a new callback raised when context restored event is fired
  116658. * @param callback defines the callback to call
  116659. */
  116660. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116661. /**
  116662. * Get the current error code of the webGL context
  116663. * @returns the error code
  116664. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116665. */
  116666. getError(): number;
  116667. private _canRenderToFloatFramebuffer;
  116668. private _canRenderToHalfFloatFramebuffer;
  116669. private _canRenderToFramebuffer;
  116670. /** @hidden */
  116671. _getWebGLTextureType(type: number): number;
  116672. /** @hidden */
  116673. _getInternalFormat(format: number): number;
  116674. /** @hidden */
  116675. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  116676. /** @hidden */
  116677. _getRGBAMultiSampleBufferFormat(type: number): number;
  116678. /** @hidden */
  116679. _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;
  116680. /**
  116681. * Loads a file from a url
  116682. * @param url url to load
  116683. * @param onSuccess callback called when the file successfully loads
  116684. * @param onProgress callback called while file is loading (if the server supports this mode)
  116685. * @param offlineProvider defines the offline provider for caching
  116686. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116687. * @param onError callback called when the file fails to load
  116688. * @returns a file request object
  116689. * @hidden
  116690. */
  116691. 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;
  116692. /**
  116693. * Reads pixels from the current frame buffer. Please note that this function can be slow
  116694. * @param x defines the x coordinate of the rectangle where pixels must be read
  116695. * @param y defines the y coordinate of the rectangle where pixels must be read
  116696. * @param width defines the width of the rectangle where pixels must be read
  116697. * @param height defines the height of the rectangle where pixels must be read
  116698. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  116699. * @returns a Uint8Array containing RGBA colors
  116700. */
  116701. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  116702. private static _IsSupported;
  116703. private static _HasMajorPerformanceCaveat;
  116704. /**
  116705. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  116706. */
  116707. static get IsSupported(): boolean;
  116708. /**
  116709. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  116710. * @returns true if the engine can be created
  116711. * @ignorenaming
  116712. */
  116713. static isSupported(): boolean;
  116714. /**
  116715. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  116716. */
  116717. static get HasMajorPerformanceCaveat(): boolean;
  116718. /**
  116719. * Find the next highest power of two.
  116720. * @param x Number to start search from.
  116721. * @return Next highest power of two.
  116722. */
  116723. static CeilingPOT(x: number): number;
  116724. /**
  116725. * Find the next lowest power of two.
  116726. * @param x Number to start search from.
  116727. * @return Next lowest power of two.
  116728. */
  116729. static FloorPOT(x: number): number;
  116730. /**
  116731. * Find the nearest power of two.
  116732. * @param x Number to start search from.
  116733. * @return Next nearest power of two.
  116734. */
  116735. static NearestPOT(x: number): number;
  116736. /**
  116737. * Get the closest exponent of two
  116738. * @param value defines the value to approximate
  116739. * @param max defines the maximum value to return
  116740. * @param mode defines how to define the closest value
  116741. * @returns closest exponent of two of the given value
  116742. */
  116743. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  116744. /**
  116745. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  116746. * @param func - the function to be called
  116747. * @param requester - the object that will request the next frame. Falls back to window.
  116748. * @returns frame number
  116749. */
  116750. static QueueNewFrame(func: () => void, requester?: any): number;
  116751. /**
  116752. * Gets host document
  116753. * @returns the host document object
  116754. */
  116755. getHostDocument(): Nullable<Document>;
  116756. }
  116757. }
  116758. declare module BABYLON {
  116759. /**
  116760. * Class representing spherical harmonics coefficients to the 3rd degree
  116761. */
  116762. export class SphericalHarmonics {
  116763. /**
  116764. * Defines whether or not the harmonics have been prescaled for rendering.
  116765. */
  116766. preScaled: boolean;
  116767. /**
  116768. * The l0,0 coefficients of the spherical harmonics
  116769. */
  116770. l00: Vector3;
  116771. /**
  116772. * The l1,-1 coefficients of the spherical harmonics
  116773. */
  116774. l1_1: Vector3;
  116775. /**
  116776. * The l1,0 coefficients of the spherical harmonics
  116777. */
  116778. l10: Vector3;
  116779. /**
  116780. * The l1,1 coefficients of the spherical harmonics
  116781. */
  116782. l11: Vector3;
  116783. /**
  116784. * The l2,-2 coefficients of the spherical harmonics
  116785. */
  116786. l2_2: Vector3;
  116787. /**
  116788. * The l2,-1 coefficients of the spherical harmonics
  116789. */
  116790. l2_1: Vector3;
  116791. /**
  116792. * The l2,0 coefficients of the spherical harmonics
  116793. */
  116794. l20: Vector3;
  116795. /**
  116796. * The l2,1 coefficients of the spherical harmonics
  116797. */
  116798. l21: Vector3;
  116799. /**
  116800. * The l2,2 coefficients of the spherical harmonics
  116801. */
  116802. l22: Vector3;
  116803. /**
  116804. * Adds a light to the spherical harmonics
  116805. * @param direction the direction of the light
  116806. * @param color the color of the light
  116807. * @param deltaSolidAngle the delta solid angle of the light
  116808. */
  116809. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  116810. /**
  116811. * Scales the spherical harmonics by the given amount
  116812. * @param scale the amount to scale
  116813. */
  116814. scaleInPlace(scale: number): void;
  116815. /**
  116816. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  116817. *
  116818. * ```
  116819. * E_lm = A_l * L_lm
  116820. * ```
  116821. *
  116822. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  116823. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  116824. * the scaling factors are given in equation 9.
  116825. */
  116826. convertIncidentRadianceToIrradiance(): void;
  116827. /**
  116828. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  116829. *
  116830. * ```
  116831. * L = (1/pi) * E * rho
  116832. * ```
  116833. *
  116834. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  116835. */
  116836. convertIrradianceToLambertianRadiance(): void;
  116837. /**
  116838. * Integrates the reconstruction coefficients directly in to the SH preventing further
  116839. * required operations at run time.
  116840. *
  116841. * This is simply done by scaling back the SH with Ylm constants parameter.
  116842. * The trigonometric part being applied by the shader at run time.
  116843. */
  116844. preScaleForRendering(): void;
  116845. /**
  116846. * Constructs a spherical harmonics from an array.
  116847. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  116848. * @returns the spherical harmonics
  116849. */
  116850. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  116851. /**
  116852. * Gets the spherical harmonics from polynomial
  116853. * @param polynomial the spherical polynomial
  116854. * @returns the spherical harmonics
  116855. */
  116856. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  116857. }
  116858. /**
  116859. * Class representing spherical polynomial coefficients to the 3rd degree
  116860. */
  116861. export class SphericalPolynomial {
  116862. private _harmonics;
  116863. /**
  116864. * The spherical harmonics used to create the polynomials.
  116865. */
  116866. get preScaledHarmonics(): SphericalHarmonics;
  116867. /**
  116868. * The x coefficients of the spherical polynomial
  116869. */
  116870. x: Vector3;
  116871. /**
  116872. * The y coefficients of the spherical polynomial
  116873. */
  116874. y: Vector3;
  116875. /**
  116876. * The z coefficients of the spherical polynomial
  116877. */
  116878. z: Vector3;
  116879. /**
  116880. * The xx coefficients of the spherical polynomial
  116881. */
  116882. xx: Vector3;
  116883. /**
  116884. * The yy coefficients of the spherical polynomial
  116885. */
  116886. yy: Vector3;
  116887. /**
  116888. * The zz coefficients of the spherical polynomial
  116889. */
  116890. zz: Vector3;
  116891. /**
  116892. * The xy coefficients of the spherical polynomial
  116893. */
  116894. xy: Vector3;
  116895. /**
  116896. * The yz coefficients of the spherical polynomial
  116897. */
  116898. yz: Vector3;
  116899. /**
  116900. * The zx coefficients of the spherical polynomial
  116901. */
  116902. zx: Vector3;
  116903. /**
  116904. * Adds an ambient color to the spherical polynomial
  116905. * @param color the color to add
  116906. */
  116907. addAmbient(color: Color3): void;
  116908. /**
  116909. * Scales the spherical polynomial by the given amount
  116910. * @param scale the amount to scale
  116911. */
  116912. scaleInPlace(scale: number): void;
  116913. /**
  116914. * Gets the spherical polynomial from harmonics
  116915. * @param harmonics the spherical harmonics
  116916. * @returns the spherical polynomial
  116917. */
  116918. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  116919. /**
  116920. * Constructs a spherical polynomial from an array.
  116921. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  116922. * @returns the spherical polynomial
  116923. */
  116924. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  116925. }
  116926. }
  116927. declare module BABYLON {
  116928. /**
  116929. * Defines the source of the internal texture
  116930. */
  116931. export enum InternalTextureSource {
  116932. /**
  116933. * The source of the texture data is unknown
  116934. */
  116935. Unknown = 0,
  116936. /**
  116937. * Texture data comes from an URL
  116938. */
  116939. Url = 1,
  116940. /**
  116941. * Texture data is only used for temporary storage
  116942. */
  116943. Temp = 2,
  116944. /**
  116945. * Texture data comes from raw data (ArrayBuffer)
  116946. */
  116947. Raw = 3,
  116948. /**
  116949. * Texture content is dynamic (video or dynamic texture)
  116950. */
  116951. Dynamic = 4,
  116952. /**
  116953. * Texture content is generated by rendering to it
  116954. */
  116955. RenderTarget = 5,
  116956. /**
  116957. * Texture content is part of a multi render target process
  116958. */
  116959. MultiRenderTarget = 6,
  116960. /**
  116961. * Texture data comes from a cube data file
  116962. */
  116963. Cube = 7,
  116964. /**
  116965. * Texture data comes from a raw cube data
  116966. */
  116967. CubeRaw = 8,
  116968. /**
  116969. * Texture data come from a prefiltered cube data file
  116970. */
  116971. CubePrefiltered = 9,
  116972. /**
  116973. * Texture content is raw 3D data
  116974. */
  116975. Raw3D = 10,
  116976. /**
  116977. * Texture content is raw 2D array data
  116978. */
  116979. Raw2DArray = 11,
  116980. /**
  116981. * Texture content is a depth texture
  116982. */
  116983. Depth = 12,
  116984. /**
  116985. * Texture data comes from a raw cube data encoded with RGBD
  116986. */
  116987. CubeRawRGBD = 13
  116988. }
  116989. /**
  116990. * Class used to store data associated with WebGL texture data for the engine
  116991. * This class should not be used directly
  116992. */
  116993. export class InternalTexture {
  116994. /** @hidden */
  116995. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  116996. /**
  116997. * Defines if the texture is ready
  116998. */
  116999. isReady: boolean;
  117000. /**
  117001. * Defines if the texture is a cube texture
  117002. */
  117003. isCube: boolean;
  117004. /**
  117005. * Defines if the texture contains 3D data
  117006. */
  117007. is3D: boolean;
  117008. /**
  117009. * Defines if the texture contains 2D array data
  117010. */
  117011. is2DArray: boolean;
  117012. /**
  117013. * Defines if the texture contains multiview data
  117014. */
  117015. isMultiview: boolean;
  117016. /**
  117017. * Gets the URL used to load this texture
  117018. */
  117019. url: string;
  117020. /**
  117021. * Gets the sampling mode of the texture
  117022. */
  117023. samplingMode: number;
  117024. /**
  117025. * Gets a boolean indicating if the texture needs mipmaps generation
  117026. */
  117027. generateMipMaps: boolean;
  117028. /**
  117029. * Gets the number of samples used by the texture (WebGL2+ only)
  117030. */
  117031. samples: number;
  117032. /**
  117033. * Gets the type of the texture (int, float...)
  117034. */
  117035. type: number;
  117036. /**
  117037. * Gets the format of the texture (RGB, RGBA...)
  117038. */
  117039. format: number;
  117040. /**
  117041. * Observable called when the texture is loaded
  117042. */
  117043. onLoadedObservable: Observable<InternalTexture>;
  117044. /**
  117045. * Gets the width of the texture
  117046. */
  117047. width: number;
  117048. /**
  117049. * Gets the height of the texture
  117050. */
  117051. height: number;
  117052. /**
  117053. * Gets the depth of the texture
  117054. */
  117055. depth: number;
  117056. /**
  117057. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  117058. */
  117059. baseWidth: number;
  117060. /**
  117061. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  117062. */
  117063. baseHeight: number;
  117064. /**
  117065. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  117066. */
  117067. baseDepth: number;
  117068. /**
  117069. * Gets a boolean indicating if the texture is inverted on Y axis
  117070. */
  117071. invertY: boolean;
  117072. /** @hidden */
  117073. _invertVScale: boolean;
  117074. /** @hidden */
  117075. _associatedChannel: number;
  117076. /** @hidden */
  117077. _source: InternalTextureSource;
  117078. /** @hidden */
  117079. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  117080. /** @hidden */
  117081. _bufferView: Nullable<ArrayBufferView>;
  117082. /** @hidden */
  117083. _bufferViewArray: Nullable<ArrayBufferView[]>;
  117084. /** @hidden */
  117085. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  117086. /** @hidden */
  117087. _size: number;
  117088. /** @hidden */
  117089. _extension: string;
  117090. /** @hidden */
  117091. _files: Nullable<string[]>;
  117092. /** @hidden */
  117093. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  117094. /** @hidden */
  117095. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  117096. /** @hidden */
  117097. _framebuffer: Nullable<WebGLFramebuffer>;
  117098. /** @hidden */
  117099. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  117100. /** @hidden */
  117101. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  117102. /** @hidden */
  117103. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  117104. /** @hidden */
  117105. _attachments: Nullable<number[]>;
  117106. /** @hidden */
  117107. _textureArray: Nullable<InternalTexture[]>;
  117108. /** @hidden */
  117109. _cachedCoordinatesMode: Nullable<number>;
  117110. /** @hidden */
  117111. _cachedWrapU: Nullable<number>;
  117112. /** @hidden */
  117113. _cachedWrapV: Nullable<number>;
  117114. /** @hidden */
  117115. _cachedWrapR: Nullable<number>;
  117116. /** @hidden */
  117117. _cachedAnisotropicFilteringLevel: Nullable<number>;
  117118. /** @hidden */
  117119. _isDisabled: boolean;
  117120. /** @hidden */
  117121. _compression: Nullable<string>;
  117122. /** @hidden */
  117123. _generateStencilBuffer: boolean;
  117124. /** @hidden */
  117125. _generateDepthBuffer: boolean;
  117126. /** @hidden */
  117127. _comparisonFunction: number;
  117128. /** @hidden */
  117129. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  117130. /** @hidden */
  117131. _lodGenerationScale: number;
  117132. /** @hidden */
  117133. _lodGenerationOffset: number;
  117134. /** @hidden */
  117135. _depthStencilTexture: Nullable<InternalTexture>;
  117136. /** @hidden */
  117137. _colorTextureArray: Nullable<WebGLTexture>;
  117138. /** @hidden */
  117139. _depthStencilTextureArray: Nullable<WebGLTexture>;
  117140. /** @hidden */
  117141. _lodTextureHigh: Nullable<BaseTexture>;
  117142. /** @hidden */
  117143. _lodTextureMid: Nullable<BaseTexture>;
  117144. /** @hidden */
  117145. _lodTextureLow: Nullable<BaseTexture>;
  117146. /** @hidden */
  117147. _isRGBD: boolean;
  117148. /** @hidden */
  117149. _linearSpecularLOD: boolean;
  117150. /** @hidden */
  117151. _irradianceTexture: Nullable<BaseTexture>;
  117152. /** @hidden */
  117153. _webGLTexture: Nullable<WebGLTexture>;
  117154. /** @hidden */
  117155. _references: number;
  117156. /** @hidden */
  117157. _gammaSpace: Nullable<boolean>;
  117158. private _engine;
  117159. /**
  117160. * Gets the Engine the texture belongs to.
  117161. * @returns The babylon engine
  117162. */
  117163. getEngine(): ThinEngine;
  117164. /**
  117165. * Gets the data source type of the texture
  117166. */
  117167. get source(): InternalTextureSource;
  117168. /**
  117169. * Creates a new InternalTexture
  117170. * @param engine defines the engine to use
  117171. * @param source defines the type of data that will be used
  117172. * @param delayAllocation if the texture allocation should be delayed (default: false)
  117173. */
  117174. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  117175. /**
  117176. * Increments the number of references (ie. the number of Texture that point to it)
  117177. */
  117178. incrementReferences(): void;
  117179. /**
  117180. * Change the size of the texture (not the size of the content)
  117181. * @param width defines the new width
  117182. * @param height defines the new height
  117183. * @param depth defines the new depth (1 by default)
  117184. */
  117185. updateSize(width: int, height: int, depth?: int): void;
  117186. /** @hidden */
  117187. _rebuild(): void;
  117188. /** @hidden */
  117189. _swapAndDie(target: InternalTexture): void;
  117190. /**
  117191. * Dispose the current allocated resources
  117192. */
  117193. dispose(): void;
  117194. }
  117195. }
  117196. declare module BABYLON {
  117197. /**
  117198. * Class used to work with sound analyzer using fast fourier transform (FFT)
  117199. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117200. */
  117201. export class Analyser {
  117202. /**
  117203. * Gets or sets the smoothing
  117204. * @ignorenaming
  117205. */
  117206. SMOOTHING: number;
  117207. /**
  117208. * Gets or sets the FFT table size
  117209. * @ignorenaming
  117210. */
  117211. FFT_SIZE: number;
  117212. /**
  117213. * Gets or sets the bar graph amplitude
  117214. * @ignorenaming
  117215. */
  117216. BARGRAPHAMPLITUDE: number;
  117217. /**
  117218. * Gets or sets the position of the debug canvas
  117219. * @ignorenaming
  117220. */
  117221. DEBUGCANVASPOS: {
  117222. x: number;
  117223. y: number;
  117224. };
  117225. /**
  117226. * Gets or sets the debug canvas size
  117227. * @ignorenaming
  117228. */
  117229. DEBUGCANVASSIZE: {
  117230. width: number;
  117231. height: number;
  117232. };
  117233. private _byteFreqs;
  117234. private _byteTime;
  117235. private _floatFreqs;
  117236. private _webAudioAnalyser;
  117237. private _debugCanvas;
  117238. private _debugCanvasContext;
  117239. private _scene;
  117240. private _registerFunc;
  117241. private _audioEngine;
  117242. /**
  117243. * Creates a new analyser
  117244. * @param scene defines hosting scene
  117245. */
  117246. constructor(scene: Scene);
  117247. /**
  117248. * Get the number of data values you will have to play with for the visualization
  117249. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  117250. * @returns a number
  117251. */
  117252. getFrequencyBinCount(): number;
  117253. /**
  117254. * Gets the current frequency data as a byte array
  117255. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  117256. * @returns a Uint8Array
  117257. */
  117258. getByteFrequencyData(): Uint8Array;
  117259. /**
  117260. * Gets the current waveform as a byte array
  117261. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  117262. * @returns a Uint8Array
  117263. */
  117264. getByteTimeDomainData(): Uint8Array;
  117265. /**
  117266. * Gets the current frequency data as a float array
  117267. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  117268. * @returns a Float32Array
  117269. */
  117270. getFloatFrequencyData(): Float32Array;
  117271. /**
  117272. * Renders the debug canvas
  117273. */
  117274. drawDebugCanvas(): void;
  117275. /**
  117276. * Stops rendering the debug canvas and removes it
  117277. */
  117278. stopDebugCanvas(): void;
  117279. /**
  117280. * Connects two audio nodes
  117281. * @param inputAudioNode defines first node to connect
  117282. * @param outputAudioNode defines second node to connect
  117283. */
  117284. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  117285. /**
  117286. * Releases all associated resources
  117287. */
  117288. dispose(): void;
  117289. }
  117290. }
  117291. declare module BABYLON {
  117292. /**
  117293. * This represents an audio engine and it is responsible
  117294. * to play, synchronize and analyse sounds throughout the application.
  117295. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117296. */
  117297. export interface IAudioEngine extends IDisposable {
  117298. /**
  117299. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  117300. */
  117301. readonly canUseWebAudio: boolean;
  117302. /**
  117303. * Gets the current AudioContext if available.
  117304. */
  117305. readonly audioContext: Nullable<AudioContext>;
  117306. /**
  117307. * The master gain node defines the global audio volume of your audio engine.
  117308. */
  117309. readonly masterGain: GainNode;
  117310. /**
  117311. * Gets whether or not mp3 are supported by your browser.
  117312. */
  117313. readonly isMP3supported: boolean;
  117314. /**
  117315. * Gets whether or not ogg are supported by your browser.
  117316. */
  117317. readonly isOGGsupported: boolean;
  117318. /**
  117319. * Defines if Babylon should emit a warning if WebAudio is not supported.
  117320. * @ignoreNaming
  117321. */
  117322. WarnedWebAudioUnsupported: boolean;
  117323. /**
  117324. * Defines if the audio engine relies on a custom unlocked button.
  117325. * In this case, the embedded button will not be displayed.
  117326. */
  117327. useCustomUnlockedButton: boolean;
  117328. /**
  117329. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  117330. */
  117331. readonly unlocked: boolean;
  117332. /**
  117333. * Event raised when audio has been unlocked on the browser.
  117334. */
  117335. onAudioUnlockedObservable: Observable<AudioEngine>;
  117336. /**
  117337. * Event raised when audio has been locked on the browser.
  117338. */
  117339. onAudioLockedObservable: Observable<AudioEngine>;
  117340. /**
  117341. * Flags the audio engine in Locked state.
  117342. * This happens due to new browser policies preventing audio to autoplay.
  117343. */
  117344. lock(): void;
  117345. /**
  117346. * Unlocks the audio engine once a user action has been done on the dom.
  117347. * This is helpful to resume play once browser policies have been satisfied.
  117348. */
  117349. unlock(): void;
  117350. /**
  117351. * Gets the global volume sets on the master gain.
  117352. * @returns the global volume if set or -1 otherwise
  117353. */
  117354. getGlobalVolume(): number;
  117355. /**
  117356. * Sets the global volume of your experience (sets on the master gain).
  117357. * @param newVolume Defines the new global volume of the application
  117358. */
  117359. setGlobalVolume(newVolume: number): void;
  117360. /**
  117361. * Connect the audio engine to an audio analyser allowing some amazing
  117362. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117363. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117364. * @param analyser The analyser to connect to the engine
  117365. */
  117366. connectToAnalyser(analyser: Analyser): void;
  117367. }
  117368. /**
  117369. * This represents the default audio engine used in babylon.
  117370. * It is responsible to play, synchronize and analyse sounds throughout the application.
  117371. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117372. */
  117373. export class AudioEngine implements IAudioEngine {
  117374. private _audioContext;
  117375. private _audioContextInitialized;
  117376. private _muteButton;
  117377. private _hostElement;
  117378. /**
  117379. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  117380. */
  117381. canUseWebAudio: boolean;
  117382. /**
  117383. * The master gain node defines the global audio volume of your audio engine.
  117384. */
  117385. masterGain: GainNode;
  117386. /**
  117387. * Defines if Babylon should emit a warning if WebAudio is not supported.
  117388. * @ignoreNaming
  117389. */
  117390. WarnedWebAudioUnsupported: boolean;
  117391. /**
  117392. * Gets whether or not mp3 are supported by your browser.
  117393. */
  117394. isMP3supported: boolean;
  117395. /**
  117396. * Gets whether or not ogg are supported by your browser.
  117397. */
  117398. isOGGsupported: boolean;
  117399. /**
  117400. * Gets whether audio has been unlocked on the device.
  117401. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  117402. * a user interaction has happened.
  117403. */
  117404. unlocked: boolean;
  117405. /**
  117406. * Defines if the audio engine relies on a custom unlocked button.
  117407. * In this case, the embedded button will not be displayed.
  117408. */
  117409. useCustomUnlockedButton: boolean;
  117410. /**
  117411. * Event raised when audio has been unlocked on the browser.
  117412. */
  117413. onAudioUnlockedObservable: Observable<AudioEngine>;
  117414. /**
  117415. * Event raised when audio has been locked on the browser.
  117416. */
  117417. onAudioLockedObservable: Observable<AudioEngine>;
  117418. /**
  117419. * Gets the current AudioContext if available.
  117420. */
  117421. get audioContext(): Nullable<AudioContext>;
  117422. private _connectedAnalyser;
  117423. /**
  117424. * Instantiates a new audio engine.
  117425. *
  117426. * There should be only one per page as some browsers restrict the number
  117427. * of audio contexts you can create.
  117428. * @param hostElement defines the host element where to display the mute icon if necessary
  117429. */
  117430. constructor(hostElement?: Nullable<HTMLElement>);
  117431. /**
  117432. * Flags the audio engine in Locked state.
  117433. * This happens due to new browser policies preventing audio to autoplay.
  117434. */
  117435. lock(): void;
  117436. /**
  117437. * Unlocks the audio engine once a user action has been done on the dom.
  117438. * This is helpful to resume play once browser policies have been satisfied.
  117439. */
  117440. unlock(): void;
  117441. private _resumeAudioContext;
  117442. private _initializeAudioContext;
  117443. private _tryToRun;
  117444. private _triggerRunningState;
  117445. private _triggerSuspendedState;
  117446. private _displayMuteButton;
  117447. private _moveButtonToTopLeft;
  117448. private _onResize;
  117449. private _hideMuteButton;
  117450. /**
  117451. * Destroy and release the resources associated with the audio ccontext.
  117452. */
  117453. dispose(): void;
  117454. /**
  117455. * Gets the global volume sets on the master gain.
  117456. * @returns the global volume if set or -1 otherwise
  117457. */
  117458. getGlobalVolume(): number;
  117459. /**
  117460. * Sets the global volume of your experience (sets on the master gain).
  117461. * @param newVolume Defines the new global volume of the application
  117462. */
  117463. setGlobalVolume(newVolume: number): void;
  117464. /**
  117465. * Connect the audio engine to an audio analyser allowing some amazing
  117466. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117467. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117468. * @param analyser The analyser to connect to the engine
  117469. */
  117470. connectToAnalyser(analyser: Analyser): void;
  117471. }
  117472. }
  117473. declare module BABYLON {
  117474. /**
  117475. * Interface used to present a loading screen while loading a scene
  117476. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117477. */
  117478. export interface ILoadingScreen {
  117479. /**
  117480. * Function called to display the loading screen
  117481. */
  117482. displayLoadingUI: () => void;
  117483. /**
  117484. * Function called to hide the loading screen
  117485. */
  117486. hideLoadingUI: () => void;
  117487. /**
  117488. * Gets or sets the color to use for the background
  117489. */
  117490. loadingUIBackgroundColor: string;
  117491. /**
  117492. * Gets or sets the text to display while loading
  117493. */
  117494. loadingUIText: string;
  117495. }
  117496. /**
  117497. * Class used for the default loading screen
  117498. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117499. */
  117500. export class DefaultLoadingScreen implements ILoadingScreen {
  117501. private _renderingCanvas;
  117502. private _loadingText;
  117503. private _loadingDivBackgroundColor;
  117504. private _loadingDiv;
  117505. private _loadingTextDiv;
  117506. /** Gets or sets the logo url to use for the default loading screen */
  117507. static DefaultLogoUrl: string;
  117508. /** Gets or sets the spinner url to use for the default loading screen */
  117509. static DefaultSpinnerUrl: string;
  117510. /**
  117511. * Creates a new default loading screen
  117512. * @param _renderingCanvas defines the canvas used to render the scene
  117513. * @param _loadingText defines the default text to display
  117514. * @param _loadingDivBackgroundColor defines the default background color
  117515. */
  117516. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  117517. /**
  117518. * Function called to display the loading screen
  117519. */
  117520. displayLoadingUI(): void;
  117521. /**
  117522. * Function called to hide the loading screen
  117523. */
  117524. hideLoadingUI(): void;
  117525. /**
  117526. * Gets or sets the text to display while loading
  117527. */
  117528. set loadingUIText(text: string);
  117529. get loadingUIText(): string;
  117530. /**
  117531. * Gets or sets the color to use for the background
  117532. */
  117533. get loadingUIBackgroundColor(): string;
  117534. set loadingUIBackgroundColor(color: string);
  117535. private _resizeLoadingUI;
  117536. }
  117537. }
  117538. declare module BABYLON {
  117539. /**
  117540. * Interface for any object that can request an animation frame
  117541. */
  117542. export interface ICustomAnimationFrameRequester {
  117543. /**
  117544. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  117545. */
  117546. renderFunction?: Function;
  117547. /**
  117548. * Called to request the next frame to render to
  117549. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  117550. */
  117551. requestAnimationFrame: Function;
  117552. /**
  117553. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  117554. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  117555. */
  117556. requestID?: number;
  117557. }
  117558. }
  117559. declare module BABYLON {
  117560. /**
  117561. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  117562. */
  117563. export class PerformanceMonitor {
  117564. private _enabled;
  117565. private _rollingFrameTime;
  117566. private _lastFrameTimeMs;
  117567. /**
  117568. * constructor
  117569. * @param frameSampleSize The number of samples required to saturate the sliding window
  117570. */
  117571. constructor(frameSampleSize?: number);
  117572. /**
  117573. * Samples current frame
  117574. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  117575. */
  117576. sampleFrame(timeMs?: number): void;
  117577. /**
  117578. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117579. */
  117580. get averageFrameTime(): number;
  117581. /**
  117582. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117583. */
  117584. get averageFrameTimeVariance(): number;
  117585. /**
  117586. * Returns the frame time of the most recent frame
  117587. */
  117588. get instantaneousFrameTime(): number;
  117589. /**
  117590. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  117591. */
  117592. get averageFPS(): number;
  117593. /**
  117594. * Returns the average framerate in frames per second using the most recent frame time
  117595. */
  117596. get instantaneousFPS(): number;
  117597. /**
  117598. * Returns true if enough samples have been taken to completely fill the sliding window
  117599. */
  117600. get isSaturated(): boolean;
  117601. /**
  117602. * Enables contributions to the sliding window sample set
  117603. */
  117604. enable(): void;
  117605. /**
  117606. * Disables contributions to the sliding window sample set
  117607. * Samples will not be interpolated over the disabled period
  117608. */
  117609. disable(): void;
  117610. /**
  117611. * Returns true if sampling is enabled
  117612. */
  117613. get isEnabled(): boolean;
  117614. /**
  117615. * Resets performance monitor
  117616. */
  117617. reset(): void;
  117618. }
  117619. /**
  117620. * RollingAverage
  117621. *
  117622. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  117623. */
  117624. export class RollingAverage {
  117625. /**
  117626. * Current average
  117627. */
  117628. average: number;
  117629. /**
  117630. * Current variance
  117631. */
  117632. variance: number;
  117633. protected _samples: Array<number>;
  117634. protected _sampleCount: number;
  117635. protected _pos: number;
  117636. protected _m2: number;
  117637. /**
  117638. * constructor
  117639. * @param length The number of samples required to saturate the sliding window
  117640. */
  117641. constructor(length: number);
  117642. /**
  117643. * Adds a sample to the sample set
  117644. * @param v The sample value
  117645. */
  117646. add(v: number): void;
  117647. /**
  117648. * Returns previously added values or null if outside of history or outside the sliding window domain
  117649. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  117650. * @return Value previously recorded with add() or null if outside of range
  117651. */
  117652. history(i: number): number;
  117653. /**
  117654. * Returns true if enough samples have been taken to completely fill the sliding window
  117655. * @return true if sample-set saturated
  117656. */
  117657. isSaturated(): boolean;
  117658. /**
  117659. * Resets the rolling average (equivalent to 0 samples taken so far)
  117660. */
  117661. reset(): void;
  117662. /**
  117663. * Wraps a value around the sample range boundaries
  117664. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  117665. * @return Wrapped position in sample range
  117666. */
  117667. protected _wrapPosition(i: number): number;
  117668. }
  117669. }
  117670. declare module BABYLON {
  117671. /**
  117672. * This class is used to track a performance counter which is number based.
  117673. * The user has access to many properties which give statistics of different nature.
  117674. *
  117675. * The implementer can track two kinds of Performance Counter: time and count.
  117676. * 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.
  117677. * 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.
  117678. */
  117679. export class PerfCounter {
  117680. /**
  117681. * Gets or sets a global boolean to turn on and off all the counters
  117682. */
  117683. static Enabled: boolean;
  117684. /**
  117685. * Returns the smallest value ever
  117686. */
  117687. get min(): number;
  117688. /**
  117689. * Returns the biggest value ever
  117690. */
  117691. get max(): number;
  117692. /**
  117693. * Returns the average value since the performance counter is running
  117694. */
  117695. get average(): number;
  117696. /**
  117697. * Returns the average value of the last second the counter was monitored
  117698. */
  117699. get lastSecAverage(): number;
  117700. /**
  117701. * Returns the current value
  117702. */
  117703. get current(): number;
  117704. /**
  117705. * Gets the accumulated total
  117706. */
  117707. get total(): number;
  117708. /**
  117709. * Gets the total value count
  117710. */
  117711. get count(): number;
  117712. /**
  117713. * Creates a new counter
  117714. */
  117715. constructor();
  117716. /**
  117717. * Call this method to start monitoring a new frame.
  117718. * 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.
  117719. */
  117720. fetchNewFrame(): void;
  117721. /**
  117722. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  117723. * @param newCount the count value to add to the monitored count
  117724. * @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.
  117725. */
  117726. addCount(newCount: number, fetchResult: boolean): void;
  117727. /**
  117728. * Start monitoring this performance counter
  117729. */
  117730. beginMonitoring(): void;
  117731. /**
  117732. * Compute the time lapsed since the previous beginMonitoring() call.
  117733. * @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
  117734. */
  117735. endMonitoring(newFrame?: boolean): void;
  117736. private _fetchResult;
  117737. private _startMonitoringTime;
  117738. private _min;
  117739. private _max;
  117740. private _average;
  117741. private _current;
  117742. private _totalValueCount;
  117743. private _totalAccumulated;
  117744. private _lastSecAverage;
  117745. private _lastSecAccumulated;
  117746. private _lastSecTime;
  117747. private _lastSecValueCount;
  117748. }
  117749. }
  117750. declare module BABYLON {
  117751. interface ThinEngine {
  117752. /** @hidden */
  117753. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  117754. }
  117755. }
  117756. declare module BABYLON {
  117757. /**
  117758. * Defines the interface used by display changed events
  117759. */
  117760. export interface IDisplayChangedEventArgs {
  117761. /** Gets the vrDisplay object (if any) */
  117762. vrDisplay: Nullable<any>;
  117763. /** Gets a boolean indicating if webVR is supported */
  117764. vrSupported: boolean;
  117765. }
  117766. /**
  117767. * Defines the interface used by objects containing a viewport (like a camera)
  117768. */
  117769. interface IViewportOwnerLike {
  117770. /**
  117771. * Gets or sets the viewport
  117772. */
  117773. viewport: IViewportLike;
  117774. }
  117775. /**
  117776. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  117777. */
  117778. export class Engine extends ThinEngine {
  117779. /** Defines that alpha blending is disabled */
  117780. static readonly ALPHA_DISABLE: number;
  117781. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  117782. static readonly ALPHA_ADD: number;
  117783. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  117784. static readonly ALPHA_COMBINE: number;
  117785. /** Defines that alpha blending to DEST - SRC * DEST */
  117786. static readonly ALPHA_SUBTRACT: number;
  117787. /** Defines that alpha blending to SRC * DEST */
  117788. static readonly ALPHA_MULTIPLY: number;
  117789. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  117790. static readonly ALPHA_MAXIMIZED: number;
  117791. /** Defines that alpha blending to SRC + DEST */
  117792. static readonly ALPHA_ONEONE: number;
  117793. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  117794. static readonly ALPHA_PREMULTIPLIED: number;
  117795. /**
  117796. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  117797. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  117798. */
  117799. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  117800. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  117801. static readonly ALPHA_INTERPOLATE: number;
  117802. /**
  117803. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  117804. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  117805. */
  117806. static readonly ALPHA_SCREENMODE: number;
  117807. /** Defines that the ressource is not delayed*/
  117808. static readonly DELAYLOADSTATE_NONE: number;
  117809. /** Defines that the ressource was successfully delay loaded */
  117810. static readonly DELAYLOADSTATE_LOADED: number;
  117811. /** Defines that the ressource is currently delay loading */
  117812. static readonly DELAYLOADSTATE_LOADING: number;
  117813. /** Defines that the ressource is delayed and has not started loading */
  117814. static readonly DELAYLOADSTATE_NOTLOADED: number;
  117815. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  117816. static readonly NEVER: number;
  117817. /** 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 */
  117818. static readonly ALWAYS: number;
  117819. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  117820. static readonly LESS: number;
  117821. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  117822. static readonly EQUAL: number;
  117823. /** 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 */
  117824. static readonly LEQUAL: number;
  117825. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  117826. static readonly GREATER: number;
  117827. /** 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 */
  117828. static readonly GEQUAL: number;
  117829. /** 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 */
  117830. static readonly NOTEQUAL: number;
  117831. /** Passed to stencilOperation to specify that stencil value must be kept */
  117832. static readonly KEEP: number;
  117833. /** Passed to stencilOperation to specify that stencil value must be replaced */
  117834. static readonly REPLACE: number;
  117835. /** Passed to stencilOperation to specify that stencil value must be incremented */
  117836. static readonly INCR: number;
  117837. /** Passed to stencilOperation to specify that stencil value must be decremented */
  117838. static readonly DECR: number;
  117839. /** Passed to stencilOperation to specify that stencil value must be inverted */
  117840. static readonly INVERT: number;
  117841. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  117842. static readonly INCR_WRAP: number;
  117843. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  117844. static readonly DECR_WRAP: number;
  117845. /** Texture is not repeating outside of 0..1 UVs */
  117846. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  117847. /** Texture is repeating outside of 0..1 UVs */
  117848. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  117849. /** Texture is repeating and mirrored */
  117850. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  117851. /** ALPHA */
  117852. static readonly TEXTUREFORMAT_ALPHA: number;
  117853. /** LUMINANCE */
  117854. static readonly TEXTUREFORMAT_LUMINANCE: number;
  117855. /** LUMINANCE_ALPHA */
  117856. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  117857. /** RGB */
  117858. static readonly TEXTUREFORMAT_RGB: number;
  117859. /** RGBA */
  117860. static readonly TEXTUREFORMAT_RGBA: number;
  117861. /** RED */
  117862. static readonly TEXTUREFORMAT_RED: number;
  117863. /** RED (2nd reference) */
  117864. static readonly TEXTUREFORMAT_R: number;
  117865. /** RG */
  117866. static readonly TEXTUREFORMAT_RG: number;
  117867. /** RED_INTEGER */
  117868. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  117869. /** RED_INTEGER (2nd reference) */
  117870. static readonly TEXTUREFORMAT_R_INTEGER: number;
  117871. /** RG_INTEGER */
  117872. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  117873. /** RGB_INTEGER */
  117874. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  117875. /** RGBA_INTEGER */
  117876. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  117877. /** UNSIGNED_BYTE */
  117878. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  117879. /** UNSIGNED_BYTE (2nd reference) */
  117880. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  117881. /** FLOAT */
  117882. static readonly TEXTURETYPE_FLOAT: number;
  117883. /** HALF_FLOAT */
  117884. static readonly TEXTURETYPE_HALF_FLOAT: number;
  117885. /** BYTE */
  117886. static readonly TEXTURETYPE_BYTE: number;
  117887. /** SHORT */
  117888. static readonly TEXTURETYPE_SHORT: number;
  117889. /** UNSIGNED_SHORT */
  117890. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  117891. /** INT */
  117892. static readonly TEXTURETYPE_INT: number;
  117893. /** UNSIGNED_INT */
  117894. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  117895. /** UNSIGNED_SHORT_4_4_4_4 */
  117896. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  117897. /** UNSIGNED_SHORT_5_5_5_1 */
  117898. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  117899. /** UNSIGNED_SHORT_5_6_5 */
  117900. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  117901. /** UNSIGNED_INT_2_10_10_10_REV */
  117902. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  117903. /** UNSIGNED_INT_24_8 */
  117904. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  117905. /** UNSIGNED_INT_10F_11F_11F_REV */
  117906. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  117907. /** UNSIGNED_INT_5_9_9_9_REV */
  117908. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  117909. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  117910. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  117911. /** nearest is mag = nearest and min = nearest and mip = linear */
  117912. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  117913. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117914. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  117915. /** Trilinear is mag = linear and min = linear and mip = linear */
  117916. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  117917. /** nearest is mag = nearest and min = nearest and mip = linear */
  117918. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  117919. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117920. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  117921. /** Trilinear is mag = linear and min = linear and mip = linear */
  117922. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  117923. /** mag = nearest and min = nearest and mip = nearest */
  117924. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  117925. /** mag = nearest and min = linear and mip = nearest */
  117926. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  117927. /** mag = nearest and min = linear and mip = linear */
  117928. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  117929. /** mag = nearest and min = linear and mip = none */
  117930. static readonly TEXTURE_NEAREST_LINEAR: number;
  117931. /** mag = nearest and min = nearest and mip = none */
  117932. static readonly TEXTURE_NEAREST_NEAREST: number;
  117933. /** mag = linear and min = nearest and mip = nearest */
  117934. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  117935. /** mag = linear and min = nearest and mip = linear */
  117936. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  117937. /** mag = linear and min = linear and mip = none */
  117938. static readonly TEXTURE_LINEAR_LINEAR: number;
  117939. /** mag = linear and min = nearest and mip = none */
  117940. static readonly TEXTURE_LINEAR_NEAREST: number;
  117941. /** Explicit coordinates mode */
  117942. static readonly TEXTURE_EXPLICIT_MODE: number;
  117943. /** Spherical coordinates mode */
  117944. static readonly TEXTURE_SPHERICAL_MODE: number;
  117945. /** Planar coordinates mode */
  117946. static readonly TEXTURE_PLANAR_MODE: number;
  117947. /** Cubic coordinates mode */
  117948. static readonly TEXTURE_CUBIC_MODE: number;
  117949. /** Projection coordinates mode */
  117950. static readonly TEXTURE_PROJECTION_MODE: number;
  117951. /** Skybox coordinates mode */
  117952. static readonly TEXTURE_SKYBOX_MODE: number;
  117953. /** Inverse Cubic coordinates mode */
  117954. static readonly TEXTURE_INVCUBIC_MODE: number;
  117955. /** Equirectangular coordinates mode */
  117956. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  117957. /** Equirectangular Fixed coordinates mode */
  117958. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  117959. /** Equirectangular Fixed Mirrored coordinates mode */
  117960. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  117961. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  117962. static readonly SCALEMODE_FLOOR: number;
  117963. /** Defines that texture rescaling will look for the nearest power of 2 size */
  117964. static readonly SCALEMODE_NEAREST: number;
  117965. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  117966. static readonly SCALEMODE_CEILING: number;
  117967. /**
  117968. * Returns the current npm package of the sdk
  117969. */
  117970. static get NpmPackage(): string;
  117971. /**
  117972. * Returns the current version of the framework
  117973. */
  117974. static get Version(): string;
  117975. /** Gets the list of created engines */
  117976. static get Instances(): Engine[];
  117977. /**
  117978. * Gets the latest created engine
  117979. */
  117980. static get LastCreatedEngine(): Nullable<Engine>;
  117981. /**
  117982. * Gets the latest created scene
  117983. */
  117984. static get LastCreatedScene(): Nullable<Scene>;
  117985. /**
  117986. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  117987. * @param flag defines which part of the materials must be marked as dirty
  117988. * @param predicate defines a predicate used to filter which materials should be affected
  117989. */
  117990. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117991. /**
  117992. * Method called to create the default loading screen.
  117993. * This can be overriden in your own app.
  117994. * @param canvas The rendering canvas element
  117995. * @returns The loading screen
  117996. */
  117997. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  117998. /**
  117999. * Method called to create the default rescale post process on each engine.
  118000. */
  118001. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  118002. /**
  118003. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  118004. **/
  118005. enableOfflineSupport: boolean;
  118006. /**
  118007. * 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)
  118008. **/
  118009. disableManifestCheck: boolean;
  118010. /**
  118011. * Gets the list of created scenes
  118012. */
  118013. scenes: Scene[];
  118014. /**
  118015. * Event raised when a new scene is created
  118016. */
  118017. onNewSceneAddedObservable: Observable<Scene>;
  118018. /**
  118019. * Gets the list of created postprocesses
  118020. */
  118021. postProcesses: PostProcess[];
  118022. /**
  118023. * Gets a boolean indicating if the pointer is currently locked
  118024. */
  118025. isPointerLock: boolean;
  118026. /**
  118027. * Observable event triggered each time the rendering canvas is resized
  118028. */
  118029. onResizeObservable: Observable<Engine>;
  118030. /**
  118031. * Observable event triggered each time the canvas loses focus
  118032. */
  118033. onCanvasBlurObservable: Observable<Engine>;
  118034. /**
  118035. * Observable event triggered each time the canvas gains focus
  118036. */
  118037. onCanvasFocusObservable: Observable<Engine>;
  118038. /**
  118039. * Observable event triggered each time the canvas receives pointerout event
  118040. */
  118041. onCanvasPointerOutObservable: Observable<PointerEvent>;
  118042. /**
  118043. * Observable raised when the engine begins a new frame
  118044. */
  118045. onBeginFrameObservable: Observable<Engine>;
  118046. /**
  118047. * If set, will be used to request the next animation frame for the render loop
  118048. */
  118049. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  118050. /**
  118051. * Observable raised when the engine ends the current frame
  118052. */
  118053. onEndFrameObservable: Observable<Engine>;
  118054. /**
  118055. * Observable raised when the engine is about to compile a shader
  118056. */
  118057. onBeforeShaderCompilationObservable: Observable<Engine>;
  118058. /**
  118059. * Observable raised when the engine has jsut compiled a shader
  118060. */
  118061. onAfterShaderCompilationObservable: Observable<Engine>;
  118062. /**
  118063. * Gets the audio engine
  118064. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  118065. * @ignorenaming
  118066. */
  118067. static audioEngine: IAudioEngine;
  118068. /**
  118069. * Default AudioEngine factory responsible of creating the Audio Engine.
  118070. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  118071. */
  118072. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  118073. /**
  118074. * Default offline support factory responsible of creating a tool used to store data locally.
  118075. * By default, this will create a Database object if the workload has been embedded.
  118076. */
  118077. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  118078. private _loadingScreen;
  118079. private _pointerLockRequested;
  118080. private _rescalePostProcess;
  118081. private _deterministicLockstep;
  118082. private _lockstepMaxSteps;
  118083. private _timeStep;
  118084. protected get _supportsHardwareTextureRescaling(): boolean;
  118085. private _fps;
  118086. private _deltaTime;
  118087. /** @hidden */
  118088. _drawCalls: PerfCounter;
  118089. /** 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 */
  118090. canvasTabIndex: number;
  118091. /**
  118092. * Turn this value on if you want to pause FPS computation when in background
  118093. */
  118094. disablePerformanceMonitorInBackground: boolean;
  118095. private _performanceMonitor;
  118096. /**
  118097. * Gets the performance monitor attached to this engine
  118098. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118099. */
  118100. get performanceMonitor(): PerformanceMonitor;
  118101. private _onFocus;
  118102. private _onBlur;
  118103. private _onCanvasPointerOut;
  118104. private _onCanvasBlur;
  118105. private _onCanvasFocus;
  118106. private _onFullscreenChange;
  118107. private _onPointerLockChange;
  118108. /**
  118109. * Gets the HTML element used to attach event listeners
  118110. * @returns a HTML element
  118111. */
  118112. getInputElement(): Nullable<HTMLElement>;
  118113. /**
  118114. * Creates a new engine
  118115. * @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
  118116. * @param antialias defines enable antialiasing (default: false)
  118117. * @param options defines further options to be sent to the getContext() function
  118118. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  118119. */
  118120. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  118121. /**
  118122. * Gets current aspect ratio
  118123. * @param viewportOwner defines the camera to use to get the aspect ratio
  118124. * @param useScreen defines if screen size must be used (or the current render target if any)
  118125. * @returns a number defining the aspect ratio
  118126. */
  118127. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  118128. /**
  118129. * Gets current screen aspect ratio
  118130. * @returns a number defining the aspect ratio
  118131. */
  118132. getScreenAspectRatio(): number;
  118133. /**
  118134. * Gets the client rect of the HTML canvas attached with the current webGL context
  118135. * @returns a client rectanglee
  118136. */
  118137. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  118138. /**
  118139. * Gets the client rect of the HTML element used for events
  118140. * @returns a client rectanglee
  118141. */
  118142. getInputElementClientRect(): Nullable<ClientRect>;
  118143. /**
  118144. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  118145. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118146. * @returns true if engine is in deterministic lock step mode
  118147. */
  118148. isDeterministicLockStep(): boolean;
  118149. /**
  118150. * Gets the max steps when engine is running in deterministic lock step
  118151. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118152. * @returns the max steps
  118153. */
  118154. getLockstepMaxSteps(): number;
  118155. /**
  118156. * Returns the time in ms between steps when using deterministic lock step.
  118157. * @returns time step in (ms)
  118158. */
  118159. getTimeStep(): number;
  118160. /**
  118161. * Force the mipmap generation for the given render target texture
  118162. * @param texture defines the render target texture to use
  118163. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  118164. */
  118165. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  118166. /** States */
  118167. /**
  118168. * Set various states to the webGL context
  118169. * @param culling defines backface culling state
  118170. * @param zOffset defines the value to apply to zOffset (0 by default)
  118171. * @param force defines if states must be applied even if cache is up to date
  118172. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  118173. */
  118174. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  118175. /**
  118176. * Set the z offset to apply to current rendering
  118177. * @param value defines the offset to apply
  118178. */
  118179. setZOffset(value: number): void;
  118180. /**
  118181. * Gets the current value of the zOffset
  118182. * @returns the current zOffset state
  118183. */
  118184. getZOffset(): number;
  118185. /**
  118186. * Enable or disable depth buffering
  118187. * @param enable defines the state to set
  118188. */
  118189. setDepthBuffer(enable: boolean): void;
  118190. /**
  118191. * Gets a boolean indicating if depth writing is enabled
  118192. * @returns the current depth writing state
  118193. */
  118194. getDepthWrite(): boolean;
  118195. /**
  118196. * Enable or disable depth writing
  118197. * @param enable defines the state to set
  118198. */
  118199. setDepthWrite(enable: boolean): void;
  118200. /**
  118201. * Gets a boolean indicating if stencil buffer is enabled
  118202. * @returns the current stencil buffer state
  118203. */
  118204. getStencilBuffer(): boolean;
  118205. /**
  118206. * Enable or disable the stencil buffer
  118207. * @param enable defines if the stencil buffer must be enabled or disabled
  118208. */
  118209. setStencilBuffer(enable: boolean): void;
  118210. /**
  118211. * Gets the current stencil mask
  118212. * @returns a number defining the new stencil mask to use
  118213. */
  118214. getStencilMask(): number;
  118215. /**
  118216. * Sets the current stencil mask
  118217. * @param mask defines the new stencil mask to use
  118218. */
  118219. setStencilMask(mask: number): void;
  118220. /**
  118221. * Gets the current stencil function
  118222. * @returns a number defining the stencil function to use
  118223. */
  118224. getStencilFunction(): number;
  118225. /**
  118226. * Gets the current stencil reference value
  118227. * @returns a number defining the stencil reference value to use
  118228. */
  118229. getStencilFunctionReference(): number;
  118230. /**
  118231. * Gets the current stencil mask
  118232. * @returns a number defining the stencil mask to use
  118233. */
  118234. getStencilFunctionMask(): number;
  118235. /**
  118236. * Sets the current stencil function
  118237. * @param stencilFunc defines the new stencil function to use
  118238. */
  118239. setStencilFunction(stencilFunc: number): void;
  118240. /**
  118241. * Sets the current stencil reference
  118242. * @param reference defines the new stencil reference to use
  118243. */
  118244. setStencilFunctionReference(reference: number): void;
  118245. /**
  118246. * Sets the current stencil mask
  118247. * @param mask defines the new stencil mask to use
  118248. */
  118249. setStencilFunctionMask(mask: number): void;
  118250. /**
  118251. * Gets the current stencil operation when stencil fails
  118252. * @returns a number defining stencil operation to use when stencil fails
  118253. */
  118254. getStencilOperationFail(): number;
  118255. /**
  118256. * Gets the current stencil operation when depth fails
  118257. * @returns a number defining stencil operation to use when depth fails
  118258. */
  118259. getStencilOperationDepthFail(): number;
  118260. /**
  118261. * Gets the current stencil operation when stencil passes
  118262. * @returns a number defining stencil operation to use when stencil passes
  118263. */
  118264. getStencilOperationPass(): number;
  118265. /**
  118266. * Sets the stencil operation to use when stencil fails
  118267. * @param operation defines the stencil operation to use when stencil fails
  118268. */
  118269. setStencilOperationFail(operation: number): void;
  118270. /**
  118271. * Sets the stencil operation to use when depth fails
  118272. * @param operation defines the stencil operation to use when depth fails
  118273. */
  118274. setStencilOperationDepthFail(operation: number): void;
  118275. /**
  118276. * Sets the stencil operation to use when stencil passes
  118277. * @param operation defines the stencil operation to use when stencil passes
  118278. */
  118279. setStencilOperationPass(operation: number): void;
  118280. /**
  118281. * Sets a boolean indicating if the dithering state is enabled or disabled
  118282. * @param value defines the dithering state
  118283. */
  118284. setDitheringState(value: boolean): void;
  118285. /**
  118286. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  118287. * @param value defines the rasterizer state
  118288. */
  118289. setRasterizerState(value: boolean): void;
  118290. /**
  118291. * Gets the current depth function
  118292. * @returns a number defining the depth function
  118293. */
  118294. getDepthFunction(): Nullable<number>;
  118295. /**
  118296. * Sets the current depth function
  118297. * @param depthFunc defines the function to use
  118298. */
  118299. setDepthFunction(depthFunc: number): void;
  118300. /**
  118301. * Sets the current depth function to GREATER
  118302. */
  118303. setDepthFunctionToGreater(): void;
  118304. /**
  118305. * Sets the current depth function to GEQUAL
  118306. */
  118307. setDepthFunctionToGreaterOrEqual(): void;
  118308. /**
  118309. * Sets the current depth function to LESS
  118310. */
  118311. setDepthFunctionToLess(): void;
  118312. /**
  118313. * Sets the current depth function to LEQUAL
  118314. */
  118315. setDepthFunctionToLessOrEqual(): void;
  118316. private _cachedStencilBuffer;
  118317. private _cachedStencilFunction;
  118318. private _cachedStencilMask;
  118319. private _cachedStencilOperationPass;
  118320. private _cachedStencilOperationFail;
  118321. private _cachedStencilOperationDepthFail;
  118322. private _cachedStencilReference;
  118323. /**
  118324. * Caches the the state of the stencil buffer
  118325. */
  118326. cacheStencilState(): void;
  118327. /**
  118328. * Restores the state of the stencil buffer
  118329. */
  118330. restoreStencilState(): void;
  118331. /**
  118332. * Directly set the WebGL Viewport
  118333. * @param x defines the x coordinate of the viewport (in screen space)
  118334. * @param y defines the y coordinate of the viewport (in screen space)
  118335. * @param width defines the width of the viewport (in screen space)
  118336. * @param height defines the height of the viewport (in screen space)
  118337. * @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
  118338. */
  118339. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  118340. /**
  118341. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  118342. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  118343. * @param y defines the y-coordinate of the corner of the clear rectangle
  118344. * @param width defines the width of the clear rectangle
  118345. * @param height defines the height of the clear rectangle
  118346. * @param clearColor defines the clear color
  118347. */
  118348. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  118349. /**
  118350. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  118351. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  118352. * @param y defines the y-coordinate of the corner of the clear rectangle
  118353. * @param width defines the width of the clear rectangle
  118354. * @param height defines the height of the clear rectangle
  118355. */
  118356. enableScissor(x: number, y: number, width: number, height: number): void;
  118357. /**
  118358. * Disable previously set scissor test rectangle
  118359. */
  118360. disableScissor(): void;
  118361. protected _reportDrawCall(): void;
  118362. /**
  118363. * Initializes a webVR display and starts listening to display change events
  118364. * The onVRDisplayChangedObservable will be notified upon these changes
  118365. * @returns The onVRDisplayChangedObservable
  118366. */
  118367. initWebVR(): Observable<IDisplayChangedEventArgs>;
  118368. /** @hidden */
  118369. _prepareVRComponent(): void;
  118370. /** @hidden */
  118371. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  118372. /** @hidden */
  118373. _submitVRFrame(): void;
  118374. /**
  118375. * Call this function to leave webVR mode
  118376. * Will do nothing if webVR is not supported or if there is no webVR device
  118377. * @see https://doc.babylonjs.com/how_to/webvr_camera
  118378. */
  118379. disableVR(): void;
  118380. /**
  118381. * Gets a boolean indicating that the system is in VR mode and is presenting
  118382. * @returns true if VR mode is engaged
  118383. */
  118384. isVRPresenting(): boolean;
  118385. /** @hidden */
  118386. _requestVRFrame(): void;
  118387. /** @hidden */
  118388. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118389. /**
  118390. * Gets the source code of the vertex shader associated with a specific webGL program
  118391. * @param program defines the program to use
  118392. * @returns a string containing the source code of the vertex shader associated with the program
  118393. */
  118394. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  118395. /**
  118396. * Gets the source code of the fragment shader associated with a specific webGL program
  118397. * @param program defines the program to use
  118398. * @returns a string containing the source code of the fragment shader associated with the program
  118399. */
  118400. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  118401. /**
  118402. * Sets a depth stencil texture from a render target to the according uniform.
  118403. * @param channel The texture channel
  118404. * @param uniform The uniform to set
  118405. * @param texture The render target texture containing the depth stencil texture to apply
  118406. */
  118407. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  118408. /**
  118409. * Sets a texture to the webGL context from a postprocess
  118410. * @param channel defines the channel to use
  118411. * @param postProcess defines the source postprocess
  118412. */
  118413. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  118414. /**
  118415. * Binds the output of the passed in post process to the texture channel specified
  118416. * @param channel The channel the texture should be bound to
  118417. * @param postProcess The post process which's output should be bound
  118418. */
  118419. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  118420. protected _rebuildBuffers(): void;
  118421. /** @hidden */
  118422. _renderFrame(): void;
  118423. _renderLoop(): void;
  118424. /** @hidden */
  118425. _renderViews(): boolean;
  118426. /**
  118427. * Toggle full screen mode
  118428. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118429. */
  118430. switchFullscreen(requestPointerLock: boolean): void;
  118431. /**
  118432. * Enters full screen mode
  118433. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118434. */
  118435. enterFullscreen(requestPointerLock: boolean): void;
  118436. /**
  118437. * Exits full screen mode
  118438. */
  118439. exitFullscreen(): void;
  118440. /**
  118441. * Enters Pointerlock mode
  118442. */
  118443. enterPointerlock(): void;
  118444. /**
  118445. * Exits Pointerlock mode
  118446. */
  118447. exitPointerlock(): void;
  118448. /**
  118449. * Begin a new frame
  118450. */
  118451. beginFrame(): void;
  118452. /**
  118453. * Enf the current frame
  118454. */
  118455. endFrame(): void;
  118456. resize(): void;
  118457. /**
  118458. * Force a specific size of the canvas
  118459. * @param width defines the new canvas' width
  118460. * @param height defines the new canvas' height
  118461. * @returns true if the size was changed
  118462. */
  118463. setSize(width: number, height: number): boolean;
  118464. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  118465. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118466. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118467. _releaseTexture(texture: InternalTexture): void;
  118468. /**
  118469. * @hidden
  118470. * Rescales a texture
  118471. * @param source input texutre
  118472. * @param destination destination texture
  118473. * @param scene scene to use to render the resize
  118474. * @param internalFormat format to use when resizing
  118475. * @param onComplete callback to be called when resize has completed
  118476. */
  118477. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  118478. /**
  118479. * Gets the current framerate
  118480. * @returns a number representing the framerate
  118481. */
  118482. getFps(): number;
  118483. /**
  118484. * Gets the time spent between current and previous frame
  118485. * @returns a number representing the delta time in ms
  118486. */
  118487. getDeltaTime(): number;
  118488. private _measureFps;
  118489. /** @hidden */
  118490. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  118491. /**
  118492. * Updates the sample count of a render target texture
  118493. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  118494. * @param texture defines the texture to update
  118495. * @param samples defines the sample count to set
  118496. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  118497. */
  118498. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  118499. /**
  118500. * Updates a depth texture Comparison Mode and Function.
  118501. * If the comparison Function is equal to 0, the mode will be set to none.
  118502. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  118503. * @param texture The texture to set the comparison function for
  118504. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  118505. */
  118506. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  118507. /**
  118508. * Creates a webGL buffer to use with instanciation
  118509. * @param capacity defines the size of the buffer
  118510. * @returns the webGL buffer
  118511. */
  118512. createInstancesBuffer(capacity: number): DataBuffer;
  118513. /**
  118514. * Delete a webGL buffer used with instanciation
  118515. * @param buffer defines the webGL buffer to delete
  118516. */
  118517. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  118518. private _clientWaitAsync;
  118519. /** @hidden */
  118520. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  118521. dispose(): void;
  118522. private _disableTouchAction;
  118523. /**
  118524. * Display the loading screen
  118525. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118526. */
  118527. displayLoadingUI(): void;
  118528. /**
  118529. * Hide the loading screen
  118530. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118531. */
  118532. hideLoadingUI(): void;
  118533. /**
  118534. * Gets the current loading screen object
  118535. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118536. */
  118537. get loadingScreen(): ILoadingScreen;
  118538. /**
  118539. * Sets the current loading screen object
  118540. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118541. */
  118542. set loadingScreen(loadingScreen: ILoadingScreen);
  118543. /**
  118544. * Sets the current loading screen text
  118545. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118546. */
  118547. set loadingUIText(text: string);
  118548. /**
  118549. * Sets the current loading screen background color
  118550. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118551. */
  118552. set loadingUIBackgroundColor(color: string);
  118553. /** Pointerlock and fullscreen */
  118554. /**
  118555. * Ask the browser to promote the current element to pointerlock mode
  118556. * @param element defines the DOM element to promote
  118557. */
  118558. static _RequestPointerlock(element: HTMLElement): void;
  118559. /**
  118560. * Asks the browser to exit pointerlock mode
  118561. */
  118562. static _ExitPointerlock(): void;
  118563. /**
  118564. * Ask the browser to promote the current element to fullscreen rendering mode
  118565. * @param element defines the DOM element to promote
  118566. */
  118567. static _RequestFullscreen(element: HTMLElement): void;
  118568. /**
  118569. * Asks the browser to exit fullscreen mode
  118570. */
  118571. static _ExitFullscreen(): void;
  118572. }
  118573. }
  118574. declare module BABYLON {
  118575. /**
  118576. * The engine store class is responsible to hold all the instances of Engine and Scene created
  118577. * during the life time of the application.
  118578. */
  118579. export class EngineStore {
  118580. /** Gets the list of created engines */
  118581. static Instances: Engine[];
  118582. /** @hidden */
  118583. static _LastCreatedScene: Nullable<Scene>;
  118584. /**
  118585. * Gets the latest created engine
  118586. */
  118587. static get LastCreatedEngine(): Nullable<Engine>;
  118588. /**
  118589. * Gets the latest created scene
  118590. */
  118591. static get LastCreatedScene(): Nullable<Scene>;
  118592. /**
  118593. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118594. * @ignorenaming
  118595. */
  118596. static UseFallbackTexture: boolean;
  118597. /**
  118598. * Texture content used if a texture cannot loaded
  118599. * @ignorenaming
  118600. */
  118601. static FallbackTexture: string;
  118602. }
  118603. }
  118604. declare module BABYLON {
  118605. /**
  118606. * Helper class that provides a small promise polyfill
  118607. */
  118608. export class PromisePolyfill {
  118609. /**
  118610. * Static function used to check if the polyfill is required
  118611. * If this is the case then the function will inject the polyfill to window.Promise
  118612. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  118613. */
  118614. static Apply(force?: boolean): void;
  118615. }
  118616. }
  118617. declare module BABYLON {
  118618. /**
  118619. * Interface for screenshot methods with describe argument called `size` as object with options
  118620. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  118621. */
  118622. export interface IScreenshotSize {
  118623. /**
  118624. * number in pixels for canvas height
  118625. */
  118626. height?: number;
  118627. /**
  118628. * multiplier allowing render at a higher or lower resolution
  118629. * If value is defined then height and width will be ignored and taken from camera
  118630. */
  118631. precision?: number;
  118632. /**
  118633. * number in pixels for canvas width
  118634. */
  118635. width?: number;
  118636. }
  118637. }
  118638. declare module BABYLON {
  118639. interface IColor4Like {
  118640. r: float;
  118641. g: float;
  118642. b: float;
  118643. a: float;
  118644. }
  118645. /**
  118646. * Class containing a set of static utilities functions
  118647. */
  118648. export class Tools {
  118649. /**
  118650. * Gets or sets the base URL to use to load assets
  118651. */
  118652. static get BaseUrl(): string;
  118653. static set BaseUrl(value: string);
  118654. /**
  118655. * Enable/Disable Custom HTTP Request Headers globally.
  118656. * default = false
  118657. * @see CustomRequestHeaders
  118658. */
  118659. static UseCustomRequestHeaders: boolean;
  118660. /**
  118661. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  118662. * i.e. when loading files, where the server/service expects an Authorization header
  118663. */
  118664. static CustomRequestHeaders: {
  118665. [key: string]: string;
  118666. };
  118667. /**
  118668. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  118669. */
  118670. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  118671. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  118672. /**
  118673. * Default behaviour for cors in the application.
  118674. * It can be a string if the expected behavior is identical in the entire app.
  118675. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  118676. */
  118677. static get CorsBehavior(): string | ((url: string | string[]) => string);
  118678. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  118679. /**
  118680. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118681. * @ignorenaming
  118682. */
  118683. static get UseFallbackTexture(): boolean;
  118684. static set UseFallbackTexture(value: boolean);
  118685. /**
  118686. * Use this object to register external classes like custom textures or material
  118687. * to allow the laoders to instantiate them
  118688. */
  118689. static get RegisteredExternalClasses(): {
  118690. [key: string]: Object;
  118691. };
  118692. static set RegisteredExternalClasses(classes: {
  118693. [key: string]: Object;
  118694. });
  118695. /**
  118696. * Texture content used if a texture cannot loaded
  118697. * @ignorenaming
  118698. */
  118699. static get fallbackTexture(): string;
  118700. static set fallbackTexture(value: string);
  118701. /**
  118702. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  118703. * @param u defines the coordinate on X axis
  118704. * @param v defines the coordinate on Y axis
  118705. * @param width defines the width of the source data
  118706. * @param height defines the height of the source data
  118707. * @param pixels defines the source byte array
  118708. * @param color defines the output color
  118709. */
  118710. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  118711. /**
  118712. * Interpolates between a and b via alpha
  118713. * @param a The lower value (returned when alpha = 0)
  118714. * @param b The upper value (returned when alpha = 1)
  118715. * @param alpha The interpolation-factor
  118716. * @return The mixed value
  118717. */
  118718. static Mix(a: number, b: number, alpha: number): number;
  118719. /**
  118720. * Tries to instantiate a new object from a given class name
  118721. * @param className defines the class name to instantiate
  118722. * @returns the new object or null if the system was not able to do the instantiation
  118723. */
  118724. static Instantiate(className: string): any;
  118725. /**
  118726. * Provides a slice function that will work even on IE
  118727. * @param data defines the array to slice
  118728. * @param start defines the start of the data (optional)
  118729. * @param end defines the end of the data (optional)
  118730. * @returns the new sliced array
  118731. */
  118732. static Slice<T>(data: T, start?: number, end?: number): T;
  118733. /**
  118734. * Polyfill for setImmediate
  118735. * @param action defines the action to execute after the current execution block
  118736. */
  118737. static SetImmediate(action: () => void): void;
  118738. /**
  118739. * Function indicating if a number is an exponent of 2
  118740. * @param value defines the value to test
  118741. * @returns true if the value is an exponent of 2
  118742. */
  118743. static IsExponentOfTwo(value: number): boolean;
  118744. private static _tmpFloatArray;
  118745. /**
  118746. * Returns the nearest 32-bit single precision float representation of a Number
  118747. * @param value A Number. If the parameter is of a different type, it will get converted
  118748. * to a number or to NaN if it cannot be converted
  118749. * @returns number
  118750. */
  118751. static FloatRound(value: number): number;
  118752. /**
  118753. * Extracts the filename from a path
  118754. * @param path defines the path to use
  118755. * @returns the filename
  118756. */
  118757. static GetFilename(path: string): string;
  118758. /**
  118759. * Extracts the "folder" part of a path (everything before the filename).
  118760. * @param uri The URI to extract the info from
  118761. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  118762. * @returns The "folder" part of the path
  118763. */
  118764. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  118765. /**
  118766. * Extracts text content from a DOM element hierarchy
  118767. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  118768. */
  118769. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  118770. /**
  118771. * Convert an angle in radians to degrees
  118772. * @param angle defines the angle to convert
  118773. * @returns the angle in degrees
  118774. */
  118775. static ToDegrees(angle: number): number;
  118776. /**
  118777. * Convert an angle in degrees to radians
  118778. * @param angle defines the angle to convert
  118779. * @returns the angle in radians
  118780. */
  118781. static ToRadians(angle: number): number;
  118782. /**
  118783. * Returns an array if obj is not an array
  118784. * @param obj defines the object to evaluate as an array
  118785. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  118786. * @returns either obj directly if obj is an array or a new array containing obj
  118787. */
  118788. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  118789. /**
  118790. * Gets the pointer prefix to use
  118791. * @param engine defines the engine we are finding the prefix for
  118792. * @returns "pointer" if touch is enabled. Else returns "mouse"
  118793. */
  118794. static GetPointerPrefix(engine: Engine): string;
  118795. /**
  118796. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  118797. * @param url define the url we are trying
  118798. * @param element define the dom element where to configure the cors policy
  118799. */
  118800. static SetCorsBehavior(url: string | string[], element: {
  118801. crossOrigin: string | null;
  118802. }): void;
  118803. /**
  118804. * Removes unwanted characters from an url
  118805. * @param url defines the url to clean
  118806. * @returns the cleaned url
  118807. */
  118808. static CleanUrl(url: string): string;
  118809. /**
  118810. * Gets or sets a function used to pre-process url before using them to load assets
  118811. */
  118812. static get PreprocessUrl(): (url: string) => string;
  118813. static set PreprocessUrl(processor: (url: string) => string);
  118814. /**
  118815. * Loads an image as an HTMLImageElement.
  118816. * @param input url string, ArrayBuffer, or Blob to load
  118817. * @param onLoad callback called when the image successfully loads
  118818. * @param onError callback called when the image fails to load
  118819. * @param offlineProvider offline provider for caching
  118820. * @param mimeType optional mime type
  118821. * @returns the HTMLImageElement of the loaded image
  118822. */
  118823. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  118824. /**
  118825. * Loads a file from a url
  118826. * @param url url string, ArrayBuffer, or Blob to load
  118827. * @param onSuccess callback called when the file successfully loads
  118828. * @param onProgress callback called while file is loading (if the server supports this mode)
  118829. * @param offlineProvider defines the offline provider for caching
  118830. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118831. * @param onError callback called when the file fails to load
  118832. * @returns a file request object
  118833. */
  118834. 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;
  118835. /**
  118836. * Loads a file from a url
  118837. * @param url the file url to load
  118838. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118839. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  118840. */
  118841. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  118842. /**
  118843. * Load a script (identified by an url). When the url returns, the
  118844. * content of this file is added into a new script element, attached to the DOM (body element)
  118845. * @param scriptUrl defines the url of the script to laod
  118846. * @param onSuccess defines the callback called when the script is loaded
  118847. * @param onError defines the callback to call if an error occurs
  118848. * @param scriptId defines the id of the script element
  118849. */
  118850. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  118851. /**
  118852. * Load an asynchronous script (identified by an url). When the url returns, the
  118853. * content of this file is added into a new script element, attached to the DOM (body element)
  118854. * @param scriptUrl defines the url of the script to laod
  118855. * @param scriptId defines the id of the script element
  118856. * @returns a promise request object
  118857. */
  118858. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  118859. /**
  118860. * Loads a file from a blob
  118861. * @param fileToLoad defines the blob to use
  118862. * @param callback defines the callback to call when data is loaded
  118863. * @param progressCallback defines the callback to call during loading process
  118864. * @returns a file request object
  118865. */
  118866. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  118867. /**
  118868. * Reads a file from a File object
  118869. * @param file defines the file to load
  118870. * @param onSuccess defines the callback to call when data is loaded
  118871. * @param onProgress defines the callback to call during loading process
  118872. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  118873. * @param onError defines the callback to call when an error occurs
  118874. * @returns a file request object
  118875. */
  118876. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118877. /**
  118878. * Creates a data url from a given string content
  118879. * @param content defines the content to convert
  118880. * @returns the new data url link
  118881. */
  118882. static FileAsURL(content: string): string;
  118883. /**
  118884. * Format the given number to a specific decimal format
  118885. * @param value defines the number to format
  118886. * @param decimals defines the number of decimals to use
  118887. * @returns the formatted string
  118888. */
  118889. static Format(value: number, decimals?: number): string;
  118890. /**
  118891. * Tries to copy an object by duplicating every property
  118892. * @param source defines the source object
  118893. * @param destination defines the target object
  118894. * @param doNotCopyList defines a list of properties to avoid
  118895. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  118896. */
  118897. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  118898. /**
  118899. * Gets a boolean indicating if the given object has no own property
  118900. * @param obj defines the object to test
  118901. * @returns true if object has no own property
  118902. */
  118903. static IsEmpty(obj: any): boolean;
  118904. /**
  118905. * Function used to register events at window level
  118906. * @param windowElement defines the Window object to use
  118907. * @param events defines the events to register
  118908. */
  118909. static RegisterTopRootEvents(windowElement: Window, events: {
  118910. name: string;
  118911. handler: Nullable<(e: FocusEvent) => any>;
  118912. }[]): void;
  118913. /**
  118914. * Function used to unregister events from window level
  118915. * @param windowElement defines the Window object to use
  118916. * @param events defines the events to unregister
  118917. */
  118918. static UnregisterTopRootEvents(windowElement: Window, events: {
  118919. name: string;
  118920. handler: Nullable<(e: FocusEvent) => any>;
  118921. }[]): void;
  118922. /**
  118923. * @ignore
  118924. */
  118925. static _ScreenshotCanvas: HTMLCanvasElement;
  118926. /**
  118927. * Dumps the current bound framebuffer
  118928. * @param width defines the rendering width
  118929. * @param height defines the rendering height
  118930. * @param engine defines the hosting engine
  118931. * @param successCallback defines the callback triggered once the data are available
  118932. * @param mimeType defines the mime type of the result
  118933. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  118934. */
  118935. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118936. /**
  118937. * Converts the canvas data to blob.
  118938. * This acts as a polyfill for browsers not supporting the to blob function.
  118939. * @param canvas Defines the canvas to extract the data from
  118940. * @param successCallback Defines the callback triggered once the data are available
  118941. * @param mimeType Defines the mime type of the result
  118942. */
  118943. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  118944. /**
  118945. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  118946. * @param successCallback defines the callback triggered once the data are available
  118947. * @param mimeType defines the mime type of the result
  118948. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  118949. */
  118950. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118951. /**
  118952. * Downloads a blob in the browser
  118953. * @param blob defines the blob to download
  118954. * @param fileName defines the name of the downloaded file
  118955. */
  118956. static Download(blob: Blob, fileName: string): void;
  118957. /**
  118958. * Captures a screenshot of the current rendering
  118959. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118960. * @param engine defines the rendering engine
  118961. * @param camera defines the source camera
  118962. * @param size This parameter can be set to a single number or to an object with the
  118963. * following (optional) properties: precision, width, height. If a single number is passed,
  118964. * it will be used for both width and height. If an object is passed, the screenshot size
  118965. * will be derived from the parameters. The precision property is a multiplier allowing
  118966. * rendering at a higher or lower resolution
  118967. * @param successCallback defines the callback receives a single parameter which contains the
  118968. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118969. * src parameter of an <img> to display it
  118970. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118971. * Check your browser for supported MIME types
  118972. */
  118973. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  118974. /**
  118975. * Captures a screenshot of the current rendering
  118976. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118977. * @param engine defines the rendering engine
  118978. * @param camera defines the source camera
  118979. * @param size This parameter can be set to a single number or to an object with the
  118980. * following (optional) properties: precision, width, height. If a single number is passed,
  118981. * it will be used for both width and height. If an object is passed, the screenshot size
  118982. * will be derived from the parameters. The precision property is a multiplier allowing
  118983. * rendering at a higher or lower resolution
  118984. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118985. * Check your browser for supported MIME types
  118986. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118987. * to the src parameter of an <img> to display it
  118988. */
  118989. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  118990. /**
  118991. * Generates an image screenshot from the specified camera.
  118992. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118993. * @param engine The engine to use for rendering
  118994. * @param camera The camera to use for rendering
  118995. * @param size This parameter can be set to a single number or to an object with the
  118996. * following (optional) properties: precision, width, height. If a single number is passed,
  118997. * it will be used for both width and height. If an object is passed, the screenshot size
  118998. * will be derived from the parameters. The precision property is a multiplier allowing
  118999. * rendering at a higher or lower resolution
  119000. * @param successCallback The callback receives a single parameter which contains the
  119001. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  119002. * src parameter of an <img> to display it
  119003. * @param mimeType The MIME type of the screenshot image (default: image/png).
  119004. * Check your browser for supported MIME types
  119005. * @param samples Texture samples (default: 1)
  119006. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  119007. * @param fileName A name for for the downloaded file.
  119008. */
  119009. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  119010. /**
  119011. * Generates an image screenshot from the specified camera.
  119012. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  119013. * @param engine The engine to use for rendering
  119014. * @param camera The camera to use for rendering
  119015. * @param size This parameter can be set to a single number or to an object with the
  119016. * following (optional) properties: precision, width, height. If a single number is passed,
  119017. * it will be used for both width and height. If an object is passed, the screenshot size
  119018. * will be derived from the parameters. The precision property is a multiplier allowing
  119019. * rendering at a higher or lower resolution
  119020. * @param mimeType The MIME type of the screenshot image (default: image/png).
  119021. * Check your browser for supported MIME types
  119022. * @param samples Texture samples (default: 1)
  119023. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  119024. * @param fileName A name for for the downloaded file.
  119025. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  119026. * to the src parameter of an <img> to display it
  119027. */
  119028. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  119029. /**
  119030. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  119031. * Be aware Math.random() could cause collisions, but:
  119032. * "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"
  119033. * @returns a pseudo random id
  119034. */
  119035. static RandomId(): string;
  119036. /**
  119037. * Test if the given uri is a base64 string
  119038. * @param uri The uri to test
  119039. * @return True if the uri is a base64 string or false otherwise
  119040. */
  119041. static IsBase64(uri: string): boolean;
  119042. /**
  119043. * Decode the given base64 uri.
  119044. * @param uri The uri to decode
  119045. * @return The decoded base64 data.
  119046. */
  119047. static DecodeBase64(uri: string): ArrayBuffer;
  119048. /**
  119049. * Gets the absolute url.
  119050. * @param url the input url
  119051. * @return the absolute url
  119052. */
  119053. static GetAbsoluteUrl(url: string): string;
  119054. /**
  119055. * No log
  119056. */
  119057. static readonly NoneLogLevel: number;
  119058. /**
  119059. * Only message logs
  119060. */
  119061. static readonly MessageLogLevel: number;
  119062. /**
  119063. * Only warning logs
  119064. */
  119065. static readonly WarningLogLevel: number;
  119066. /**
  119067. * Only error logs
  119068. */
  119069. static readonly ErrorLogLevel: number;
  119070. /**
  119071. * All logs
  119072. */
  119073. static readonly AllLogLevel: number;
  119074. /**
  119075. * Gets a value indicating the number of loading errors
  119076. * @ignorenaming
  119077. */
  119078. static get errorsCount(): number;
  119079. /**
  119080. * Callback called when a new log is added
  119081. */
  119082. static OnNewCacheEntry: (entry: string) => void;
  119083. /**
  119084. * Log a message to the console
  119085. * @param message defines the message to log
  119086. */
  119087. static Log(message: string): void;
  119088. /**
  119089. * Write a warning message to the console
  119090. * @param message defines the message to log
  119091. */
  119092. static Warn(message: string): void;
  119093. /**
  119094. * Write an error message to the console
  119095. * @param message defines the message to log
  119096. */
  119097. static Error(message: string): void;
  119098. /**
  119099. * Gets current log cache (list of logs)
  119100. */
  119101. static get LogCache(): string;
  119102. /**
  119103. * Clears the log cache
  119104. */
  119105. static ClearLogCache(): void;
  119106. /**
  119107. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  119108. */
  119109. static set LogLevels(level: number);
  119110. /**
  119111. * Checks if the window object exists
  119112. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  119113. */
  119114. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  119115. /**
  119116. * No performance log
  119117. */
  119118. static readonly PerformanceNoneLogLevel: number;
  119119. /**
  119120. * Use user marks to log performance
  119121. */
  119122. static readonly PerformanceUserMarkLogLevel: number;
  119123. /**
  119124. * Log performance to the console
  119125. */
  119126. static readonly PerformanceConsoleLogLevel: number;
  119127. private static _performance;
  119128. /**
  119129. * Sets the current performance log level
  119130. */
  119131. static set PerformanceLogLevel(level: number);
  119132. private static _StartPerformanceCounterDisabled;
  119133. private static _EndPerformanceCounterDisabled;
  119134. private static _StartUserMark;
  119135. private static _EndUserMark;
  119136. private static _StartPerformanceConsole;
  119137. private static _EndPerformanceConsole;
  119138. /**
  119139. * Starts a performance counter
  119140. */
  119141. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  119142. /**
  119143. * Ends a specific performance coutner
  119144. */
  119145. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  119146. /**
  119147. * Gets either window.performance.now() if supported or Date.now() else
  119148. */
  119149. static get Now(): number;
  119150. /**
  119151. * This method will return the name of the class used to create the instance of the given object.
  119152. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  119153. * @param object the object to get the class name from
  119154. * @param isType defines if the object is actually a type
  119155. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  119156. */
  119157. static GetClassName(object: any, isType?: boolean): string;
  119158. /**
  119159. * Gets the first element of an array satisfying a given predicate
  119160. * @param array defines the array to browse
  119161. * @param predicate defines the predicate to use
  119162. * @returns null if not found or the element
  119163. */
  119164. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  119165. /**
  119166. * This method will return the name of the full name of the class, including its owning module (if any).
  119167. * 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).
  119168. * @param object the object to get the class name from
  119169. * @param isType defines if the object is actually a type
  119170. * @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.
  119171. * @ignorenaming
  119172. */
  119173. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  119174. /**
  119175. * Returns a promise that resolves after the given amount of time.
  119176. * @param delay Number of milliseconds to delay
  119177. * @returns Promise that resolves after the given amount of time
  119178. */
  119179. static DelayAsync(delay: number): Promise<void>;
  119180. /**
  119181. * Utility function to detect if the current user agent is Safari
  119182. * @returns whether or not the current user agent is safari
  119183. */
  119184. static IsSafari(): boolean;
  119185. }
  119186. /**
  119187. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  119188. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  119189. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  119190. * @param name The name of the class, case should be preserved
  119191. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  119192. */
  119193. export function className(name: string, module?: string): (target: Object) => void;
  119194. /**
  119195. * An implementation of a loop for asynchronous functions.
  119196. */
  119197. export class AsyncLoop {
  119198. /**
  119199. * Defines the number of iterations for the loop
  119200. */
  119201. iterations: number;
  119202. /**
  119203. * Defines the current index of the loop.
  119204. */
  119205. index: number;
  119206. private _done;
  119207. private _fn;
  119208. private _successCallback;
  119209. /**
  119210. * Constructor.
  119211. * @param iterations the number of iterations.
  119212. * @param func the function to run each iteration
  119213. * @param successCallback the callback that will be called upon succesful execution
  119214. * @param offset starting offset.
  119215. */
  119216. constructor(
  119217. /**
  119218. * Defines the number of iterations for the loop
  119219. */
  119220. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  119221. /**
  119222. * Execute the next iteration. Must be called after the last iteration was finished.
  119223. */
  119224. executeNext(): void;
  119225. /**
  119226. * Break the loop and run the success callback.
  119227. */
  119228. breakLoop(): void;
  119229. /**
  119230. * Create and run an async loop.
  119231. * @param iterations the number of iterations.
  119232. * @param fn the function to run each iteration
  119233. * @param successCallback the callback that will be called upon succesful execution
  119234. * @param offset starting offset.
  119235. * @returns the created async loop object
  119236. */
  119237. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  119238. /**
  119239. * A for-loop that will run a given number of iterations synchronous and the rest async.
  119240. * @param iterations total number of iterations
  119241. * @param syncedIterations number of synchronous iterations in each async iteration.
  119242. * @param fn the function to call each iteration.
  119243. * @param callback a success call back that will be called when iterating stops.
  119244. * @param breakFunction a break condition (optional)
  119245. * @param timeout timeout settings for the setTimeout function. default - 0.
  119246. * @returns the created async loop object
  119247. */
  119248. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  119249. }
  119250. }
  119251. declare module BABYLON {
  119252. /**
  119253. * This class implement a typical dictionary using a string as key and the generic type T as value.
  119254. * The underlying implementation relies on an associative array to ensure the best performances.
  119255. * The value can be anything including 'null' but except 'undefined'
  119256. */
  119257. export class StringDictionary<T> {
  119258. /**
  119259. * This will clear this dictionary and copy the content from the 'source' one.
  119260. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  119261. * @param source the dictionary to take the content from and copy to this dictionary
  119262. */
  119263. copyFrom(source: StringDictionary<T>): void;
  119264. /**
  119265. * Get a value based from its key
  119266. * @param key the given key to get the matching value from
  119267. * @return the value if found, otherwise undefined is returned
  119268. */
  119269. get(key: string): T | undefined;
  119270. /**
  119271. * Get a value from its key or add it if it doesn't exist.
  119272. * This method will ensure you that a given key/data will be present in the dictionary.
  119273. * @param key the given key to get the matching value from
  119274. * @param factory the factory that will create the value if the key is not present in the dictionary.
  119275. * The factory will only be invoked if there's no data for the given key.
  119276. * @return the value corresponding to the key.
  119277. */
  119278. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  119279. /**
  119280. * Get a value from its key if present in the dictionary otherwise add it
  119281. * @param key the key to get the value from
  119282. * @param val if there's no such key/value pair in the dictionary add it with this value
  119283. * @return the value corresponding to the key
  119284. */
  119285. getOrAdd(key: string, val: T): T;
  119286. /**
  119287. * Check if there's a given key in the dictionary
  119288. * @param key the key to check for
  119289. * @return true if the key is present, false otherwise
  119290. */
  119291. contains(key: string): boolean;
  119292. /**
  119293. * Add a new key and its corresponding value
  119294. * @param key the key to add
  119295. * @param value the value corresponding to the key
  119296. * @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
  119297. */
  119298. add(key: string, value: T): boolean;
  119299. /**
  119300. * Update a specific value associated to a key
  119301. * @param key defines the key to use
  119302. * @param value defines the value to store
  119303. * @returns true if the value was updated (or false if the key was not found)
  119304. */
  119305. set(key: string, value: T): boolean;
  119306. /**
  119307. * Get the element of the given key and remove it from the dictionary
  119308. * @param key defines the key to search
  119309. * @returns the value associated with the key or null if not found
  119310. */
  119311. getAndRemove(key: string): Nullable<T>;
  119312. /**
  119313. * Remove a key/value from the dictionary.
  119314. * @param key the key to remove
  119315. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  119316. */
  119317. remove(key: string): boolean;
  119318. /**
  119319. * Clear the whole content of the dictionary
  119320. */
  119321. clear(): void;
  119322. /**
  119323. * Gets the current count
  119324. */
  119325. get count(): number;
  119326. /**
  119327. * Execute a callback on each key/val of the dictionary.
  119328. * Note that you can remove any element in this dictionary in the callback implementation
  119329. * @param callback the callback to execute on a given key/value pair
  119330. */
  119331. forEach(callback: (key: string, val: T) => void): void;
  119332. /**
  119333. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  119334. * If the callback returns null or undefined the method will iterate to the next key/value pair
  119335. * Note that you can remove any element in this dictionary in the callback implementation
  119336. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  119337. * @returns the first item
  119338. */
  119339. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  119340. private _count;
  119341. private _data;
  119342. }
  119343. }
  119344. declare module BABYLON {
  119345. /** @hidden */
  119346. export interface ICollisionCoordinator {
  119347. createCollider(): Collider;
  119348. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  119349. init(scene: Scene): void;
  119350. }
  119351. /** @hidden */
  119352. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  119353. private _scene;
  119354. private _scaledPosition;
  119355. private _scaledVelocity;
  119356. private _finalPosition;
  119357. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  119358. createCollider(): Collider;
  119359. init(scene: Scene): void;
  119360. private _collideWithWorld;
  119361. }
  119362. }
  119363. declare module BABYLON {
  119364. /**
  119365. * Class used to manage all inputs for the scene.
  119366. */
  119367. export class InputManager {
  119368. /** The distance in pixel that you have to move to prevent some events */
  119369. static DragMovementThreshold: number;
  119370. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  119371. static LongPressDelay: number;
  119372. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  119373. static DoubleClickDelay: number;
  119374. /** If you need to check double click without raising a single click at first click, enable this flag */
  119375. static ExclusiveDoubleClickMode: boolean;
  119376. /** 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. */
  119377. private _alreadyAttached;
  119378. private _wheelEventName;
  119379. private _onPointerMove;
  119380. private _onPointerDown;
  119381. private _onPointerUp;
  119382. private _initClickEvent;
  119383. private _initActionManager;
  119384. private _delayedSimpleClick;
  119385. private _delayedSimpleClickTimeout;
  119386. private _previousDelayedSimpleClickTimeout;
  119387. private _meshPickProceed;
  119388. private _previousButtonPressed;
  119389. private _currentPickResult;
  119390. private _previousPickResult;
  119391. private _totalPointersPressed;
  119392. private _doubleClickOccured;
  119393. private _pointerOverMesh;
  119394. private _pickedDownMesh;
  119395. private _pickedUpMesh;
  119396. private _pointerX;
  119397. private _pointerY;
  119398. private _unTranslatedPointerX;
  119399. private _unTranslatedPointerY;
  119400. private _startingPointerPosition;
  119401. private _previousStartingPointerPosition;
  119402. private _startingPointerTime;
  119403. private _previousStartingPointerTime;
  119404. private _pointerCaptures;
  119405. private _meshUnderPointerId;
  119406. private _onKeyDown;
  119407. private _onKeyUp;
  119408. private _onCanvasFocusObserver;
  119409. private _onCanvasBlurObserver;
  119410. private _scene;
  119411. /**
  119412. * Creates a new InputManager
  119413. * @param scene defines the hosting scene
  119414. */
  119415. constructor(scene: Scene);
  119416. /**
  119417. * Gets the mesh that is currently under the pointer
  119418. */
  119419. get meshUnderPointer(): Nullable<AbstractMesh>;
  119420. /**
  119421. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  119422. * @param pointerId the pointer id to use
  119423. * @returns The mesh under this pointer id or null if not found
  119424. */
  119425. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  119426. /**
  119427. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  119428. */
  119429. get unTranslatedPointer(): Vector2;
  119430. /**
  119431. * Gets or sets the current on-screen X position of the pointer
  119432. */
  119433. get pointerX(): number;
  119434. set pointerX(value: number);
  119435. /**
  119436. * Gets or sets the current on-screen Y position of the pointer
  119437. */
  119438. get pointerY(): number;
  119439. set pointerY(value: number);
  119440. private _updatePointerPosition;
  119441. private _processPointerMove;
  119442. private _setRayOnPointerInfo;
  119443. private _checkPrePointerObservable;
  119444. /**
  119445. * Use this method to simulate a pointer move on a mesh
  119446. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119447. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119448. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119449. */
  119450. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119451. /**
  119452. * Use this method to simulate a pointer down on a mesh
  119453. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119454. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119455. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119456. */
  119457. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119458. private _processPointerDown;
  119459. /** @hidden */
  119460. _isPointerSwiping(): boolean;
  119461. /**
  119462. * Use this method to simulate a pointer up on a mesh
  119463. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119464. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119465. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119466. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119467. */
  119468. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  119469. private _processPointerUp;
  119470. /**
  119471. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119472. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119473. * @returns true if the pointer was captured
  119474. */
  119475. isPointerCaptured(pointerId?: number): boolean;
  119476. /**
  119477. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119478. * @param attachUp defines if you want to attach events to pointerup
  119479. * @param attachDown defines if you want to attach events to pointerdown
  119480. * @param attachMove defines if you want to attach events to pointermove
  119481. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  119482. */
  119483. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  119484. /**
  119485. * Detaches all event handlers
  119486. */
  119487. detachControl(): void;
  119488. /**
  119489. * Force the value of meshUnderPointer
  119490. * @param mesh defines the mesh to use
  119491. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  119492. */
  119493. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  119494. /**
  119495. * Gets the mesh under the pointer
  119496. * @returns a Mesh or null if no mesh is under the pointer
  119497. */
  119498. getPointerOverMesh(): Nullable<AbstractMesh>;
  119499. }
  119500. }
  119501. declare module BABYLON {
  119502. /**
  119503. * This class defines the direct association between an animation and a target
  119504. */
  119505. export class TargetedAnimation {
  119506. /**
  119507. * Animation to perform
  119508. */
  119509. animation: Animation;
  119510. /**
  119511. * Target to animate
  119512. */
  119513. target: any;
  119514. /**
  119515. * Returns the string "TargetedAnimation"
  119516. * @returns "TargetedAnimation"
  119517. */
  119518. getClassName(): string;
  119519. /**
  119520. * Serialize the object
  119521. * @returns the JSON object representing the current entity
  119522. */
  119523. serialize(): any;
  119524. }
  119525. /**
  119526. * Use this class to create coordinated animations on multiple targets
  119527. */
  119528. export class AnimationGroup implements IDisposable {
  119529. /** The name of the animation group */
  119530. name: string;
  119531. private _scene;
  119532. private _targetedAnimations;
  119533. private _animatables;
  119534. private _from;
  119535. private _to;
  119536. private _isStarted;
  119537. private _isPaused;
  119538. private _speedRatio;
  119539. private _loopAnimation;
  119540. private _isAdditive;
  119541. /**
  119542. * Gets or sets the unique id of the node
  119543. */
  119544. uniqueId: number;
  119545. /**
  119546. * This observable will notify when one animation have ended
  119547. */
  119548. onAnimationEndObservable: Observable<TargetedAnimation>;
  119549. /**
  119550. * Observer raised when one animation loops
  119551. */
  119552. onAnimationLoopObservable: Observable<TargetedAnimation>;
  119553. /**
  119554. * Observer raised when all animations have looped
  119555. */
  119556. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  119557. /**
  119558. * This observable will notify when all animations have ended.
  119559. */
  119560. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  119561. /**
  119562. * This observable will notify when all animations have paused.
  119563. */
  119564. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  119565. /**
  119566. * This observable will notify when all animations are playing.
  119567. */
  119568. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  119569. /**
  119570. * Gets the first frame
  119571. */
  119572. get from(): number;
  119573. /**
  119574. * Gets the last frame
  119575. */
  119576. get to(): number;
  119577. /**
  119578. * Define if the animations are started
  119579. */
  119580. get isStarted(): boolean;
  119581. /**
  119582. * Gets a value indicating that the current group is playing
  119583. */
  119584. get isPlaying(): boolean;
  119585. /**
  119586. * Gets or sets the speed ratio to use for all animations
  119587. */
  119588. get speedRatio(): number;
  119589. /**
  119590. * Gets or sets the speed ratio to use for all animations
  119591. */
  119592. set speedRatio(value: number);
  119593. /**
  119594. * Gets or sets if all animations should loop or not
  119595. */
  119596. get loopAnimation(): boolean;
  119597. set loopAnimation(value: boolean);
  119598. /**
  119599. * Gets or sets if all animations should be evaluated additively
  119600. */
  119601. get isAdditive(): boolean;
  119602. set isAdditive(value: boolean);
  119603. /**
  119604. * Gets the targeted animations for this animation group
  119605. */
  119606. get targetedAnimations(): Array<TargetedAnimation>;
  119607. /**
  119608. * returning the list of animatables controlled by this animation group.
  119609. */
  119610. get animatables(): Array<Animatable>;
  119611. /**
  119612. * Gets the list of target animations
  119613. */
  119614. get children(): TargetedAnimation[];
  119615. /**
  119616. * Instantiates a new Animation Group.
  119617. * This helps managing several animations at once.
  119618. * @see https://doc.babylonjs.com/how_to/group
  119619. * @param name Defines the name of the group
  119620. * @param scene Defines the scene the group belongs to
  119621. */
  119622. constructor(
  119623. /** The name of the animation group */
  119624. name: string, scene?: Nullable<Scene>);
  119625. /**
  119626. * Add an animation (with its target) in the group
  119627. * @param animation defines the animation we want to add
  119628. * @param target defines the target of the animation
  119629. * @returns the TargetedAnimation object
  119630. */
  119631. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  119632. /**
  119633. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  119634. * It can add constant keys at begin or end
  119635. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  119636. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  119637. * @returns the animation group
  119638. */
  119639. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  119640. private _animationLoopCount;
  119641. private _animationLoopFlags;
  119642. private _processLoop;
  119643. /**
  119644. * Start all animations on given targets
  119645. * @param loop defines if animations must loop
  119646. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  119647. * @param from defines the from key (optional)
  119648. * @param to defines the to key (optional)
  119649. * @param isAdditive defines the additive state for the resulting animatables (optional)
  119650. * @returns the current animation group
  119651. */
  119652. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  119653. /**
  119654. * Pause all animations
  119655. * @returns the animation group
  119656. */
  119657. pause(): AnimationGroup;
  119658. /**
  119659. * Play all animations to initial state
  119660. * This function will start() the animations if they were not started or will restart() them if they were paused
  119661. * @param loop defines if animations must loop
  119662. * @returns the animation group
  119663. */
  119664. play(loop?: boolean): AnimationGroup;
  119665. /**
  119666. * Reset all animations to initial state
  119667. * @returns the animation group
  119668. */
  119669. reset(): AnimationGroup;
  119670. /**
  119671. * Restart animations from key 0
  119672. * @returns the animation group
  119673. */
  119674. restart(): AnimationGroup;
  119675. /**
  119676. * Stop all animations
  119677. * @returns the animation group
  119678. */
  119679. stop(): AnimationGroup;
  119680. /**
  119681. * Set animation weight for all animatables
  119682. * @param weight defines the weight to use
  119683. * @return the animationGroup
  119684. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119685. */
  119686. setWeightForAllAnimatables(weight: number): AnimationGroup;
  119687. /**
  119688. * Synchronize and normalize all animatables with a source animatable
  119689. * @param root defines the root animatable to synchronize with
  119690. * @return the animationGroup
  119691. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119692. */
  119693. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  119694. /**
  119695. * Goes to a specific frame in this animation group
  119696. * @param frame the frame number to go to
  119697. * @return the animationGroup
  119698. */
  119699. goToFrame(frame: number): AnimationGroup;
  119700. /**
  119701. * Dispose all associated resources
  119702. */
  119703. dispose(): void;
  119704. private _checkAnimationGroupEnded;
  119705. /**
  119706. * Clone the current animation group and returns a copy
  119707. * @param newName defines the name of the new group
  119708. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  119709. * @returns the new aniamtion group
  119710. */
  119711. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  119712. /**
  119713. * Serializes the animationGroup to an object
  119714. * @returns Serialized object
  119715. */
  119716. serialize(): any;
  119717. /**
  119718. * Returns a new AnimationGroup object parsed from the source provided.
  119719. * @param parsedAnimationGroup defines the source
  119720. * @param scene defines the scene that will receive the animationGroup
  119721. * @returns a new AnimationGroup
  119722. */
  119723. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  119724. /**
  119725. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  119726. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  119727. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  119728. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  119729. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  119730. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  119731. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  119732. */
  119733. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  119734. /**
  119735. * Returns the string "AnimationGroup"
  119736. * @returns "AnimationGroup"
  119737. */
  119738. getClassName(): string;
  119739. /**
  119740. * Creates a detailled string about the object
  119741. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  119742. * @returns a string representing the object
  119743. */
  119744. toString(fullDetails?: boolean): string;
  119745. }
  119746. }
  119747. declare module BABYLON {
  119748. /**
  119749. * Define an interface for all classes that will hold resources
  119750. */
  119751. export interface IDisposable {
  119752. /**
  119753. * Releases all held resources
  119754. */
  119755. dispose(): void;
  119756. }
  119757. /** Interface defining initialization parameters for Scene class */
  119758. export interface SceneOptions {
  119759. /**
  119760. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  119761. * It will improve performance when the number of geometries becomes important.
  119762. */
  119763. useGeometryUniqueIdsMap?: boolean;
  119764. /**
  119765. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  119766. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119767. */
  119768. useMaterialMeshMap?: boolean;
  119769. /**
  119770. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  119771. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119772. */
  119773. useClonedMeshMap?: boolean;
  119774. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  119775. virtual?: boolean;
  119776. }
  119777. /**
  119778. * Represents a scene to be rendered by the engine.
  119779. * @see https://doc.babylonjs.com/features/scene
  119780. */
  119781. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  119782. /** The fog is deactivated */
  119783. static readonly FOGMODE_NONE: number;
  119784. /** The fog density is following an exponential function */
  119785. static readonly FOGMODE_EXP: number;
  119786. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  119787. static readonly FOGMODE_EXP2: number;
  119788. /** The fog density is following a linear function. */
  119789. static readonly FOGMODE_LINEAR: number;
  119790. /**
  119791. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  119792. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119793. */
  119794. static MinDeltaTime: number;
  119795. /**
  119796. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  119797. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119798. */
  119799. static MaxDeltaTime: number;
  119800. /**
  119801. * Factory used to create the default material.
  119802. * @param name The name of the material to create
  119803. * @param scene The scene to create the material for
  119804. * @returns The default material
  119805. */
  119806. static DefaultMaterialFactory(scene: Scene): Material;
  119807. /**
  119808. * Factory used to create the a collision coordinator.
  119809. * @returns The collision coordinator
  119810. */
  119811. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  119812. /** @hidden */
  119813. _inputManager: InputManager;
  119814. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  119815. cameraToUseForPointers: Nullable<Camera>;
  119816. /** @hidden */
  119817. readonly _isScene: boolean;
  119818. /** @hidden */
  119819. _blockEntityCollection: boolean;
  119820. /**
  119821. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  119822. */
  119823. autoClear: boolean;
  119824. /**
  119825. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  119826. */
  119827. autoClearDepthAndStencil: boolean;
  119828. /**
  119829. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  119830. */
  119831. clearColor: Color4;
  119832. /**
  119833. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  119834. */
  119835. ambientColor: Color3;
  119836. /**
  119837. * This is use to store the default BRDF lookup for PBR materials in your scene.
  119838. * It should only be one of the following (if not the default embedded one):
  119839. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  119840. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  119841. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  119842. * The material properties need to be setup according to the type of texture in use.
  119843. */
  119844. environmentBRDFTexture: BaseTexture;
  119845. /**
  119846. * Texture used in all pbr material as the reflection texture.
  119847. * As in the majority of the scene they are the same (exception for multi room and so on),
  119848. * this is easier to reference from here than from all the materials.
  119849. */
  119850. get environmentTexture(): Nullable<BaseTexture>;
  119851. /**
  119852. * Texture used in all pbr material as the reflection texture.
  119853. * As in the majority of the scene they are the same (exception for multi room and so on),
  119854. * this is easier to set here than in all the materials.
  119855. */
  119856. set environmentTexture(value: Nullable<BaseTexture>);
  119857. /** @hidden */
  119858. protected _environmentIntensity: number;
  119859. /**
  119860. * Intensity of the environment in all pbr material.
  119861. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119862. * As in the majority of the scene they are the same (exception for multi room and so on),
  119863. * this is easier to reference from here than from all the materials.
  119864. */
  119865. get environmentIntensity(): number;
  119866. /**
  119867. * Intensity of the environment in all pbr material.
  119868. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119869. * As in the majority of the scene they are the same (exception for multi room and so on),
  119870. * this is easier to set here than in all the materials.
  119871. */
  119872. set environmentIntensity(value: number);
  119873. /** @hidden */
  119874. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119875. /**
  119876. * Default image processing configuration used either in the rendering
  119877. * Forward main pass or through the imageProcessingPostProcess if present.
  119878. * As in the majority of the scene they are the same (exception for multi camera),
  119879. * this is easier to reference from here than from all the materials and post process.
  119880. *
  119881. * No setter as we it is a shared configuration, you can set the values instead.
  119882. */
  119883. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  119884. private _forceWireframe;
  119885. /**
  119886. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  119887. */
  119888. set forceWireframe(value: boolean);
  119889. get forceWireframe(): boolean;
  119890. private _skipFrustumClipping;
  119891. /**
  119892. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  119893. */
  119894. set skipFrustumClipping(value: boolean);
  119895. get skipFrustumClipping(): boolean;
  119896. private _forcePointsCloud;
  119897. /**
  119898. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  119899. */
  119900. set forcePointsCloud(value: boolean);
  119901. get forcePointsCloud(): boolean;
  119902. /**
  119903. * Gets or sets the active clipplane 1
  119904. */
  119905. clipPlane: Nullable<Plane>;
  119906. /**
  119907. * Gets or sets the active clipplane 2
  119908. */
  119909. clipPlane2: Nullable<Plane>;
  119910. /**
  119911. * Gets or sets the active clipplane 3
  119912. */
  119913. clipPlane3: Nullable<Plane>;
  119914. /**
  119915. * Gets or sets the active clipplane 4
  119916. */
  119917. clipPlane4: Nullable<Plane>;
  119918. /**
  119919. * Gets or sets the active clipplane 5
  119920. */
  119921. clipPlane5: Nullable<Plane>;
  119922. /**
  119923. * Gets or sets the active clipplane 6
  119924. */
  119925. clipPlane6: Nullable<Plane>;
  119926. /**
  119927. * Gets or sets a boolean indicating if animations are enabled
  119928. */
  119929. animationsEnabled: boolean;
  119930. private _animationPropertiesOverride;
  119931. /**
  119932. * Gets or sets the animation properties override
  119933. */
  119934. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  119935. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  119936. /**
  119937. * Gets or sets a boolean indicating if a constant deltatime has to be used
  119938. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  119939. */
  119940. useConstantAnimationDeltaTime: boolean;
  119941. /**
  119942. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  119943. * Please note that it requires to run a ray cast through the scene on every frame
  119944. */
  119945. constantlyUpdateMeshUnderPointer: boolean;
  119946. /**
  119947. * Defines the HTML cursor to use when hovering over interactive elements
  119948. */
  119949. hoverCursor: string;
  119950. /**
  119951. * Defines the HTML default cursor to use (empty by default)
  119952. */
  119953. defaultCursor: string;
  119954. /**
  119955. * Defines whether cursors are handled by the scene.
  119956. */
  119957. doNotHandleCursors: boolean;
  119958. /**
  119959. * This is used to call preventDefault() on pointer down
  119960. * in order to block unwanted artifacts like system double clicks
  119961. */
  119962. preventDefaultOnPointerDown: boolean;
  119963. /**
  119964. * This is used to call preventDefault() on pointer up
  119965. * in order to block unwanted artifacts like system double clicks
  119966. */
  119967. preventDefaultOnPointerUp: boolean;
  119968. /**
  119969. * Gets or sets user defined metadata
  119970. */
  119971. metadata: any;
  119972. /**
  119973. * For internal use only. Please do not use.
  119974. */
  119975. reservedDataStore: any;
  119976. /**
  119977. * Gets the name of the plugin used to load this scene (null by default)
  119978. */
  119979. loadingPluginName: string;
  119980. /**
  119981. * Use this array to add regular expressions used to disable offline support for specific urls
  119982. */
  119983. disableOfflineSupportExceptionRules: RegExp[];
  119984. /**
  119985. * An event triggered when the scene is disposed.
  119986. */
  119987. onDisposeObservable: Observable<Scene>;
  119988. private _onDisposeObserver;
  119989. /** Sets a function to be executed when this scene is disposed. */
  119990. set onDispose(callback: () => void);
  119991. /**
  119992. * An event triggered before rendering the scene (right after animations and physics)
  119993. */
  119994. onBeforeRenderObservable: Observable<Scene>;
  119995. private _onBeforeRenderObserver;
  119996. /** Sets a function to be executed before rendering this scene */
  119997. set beforeRender(callback: Nullable<() => void>);
  119998. /**
  119999. * An event triggered after rendering the scene
  120000. */
  120001. onAfterRenderObservable: Observable<Scene>;
  120002. /**
  120003. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  120004. */
  120005. onAfterRenderCameraObservable: Observable<Camera>;
  120006. private _onAfterRenderObserver;
  120007. /** Sets a function to be executed after rendering this scene */
  120008. set afterRender(callback: Nullable<() => void>);
  120009. /**
  120010. * An event triggered before animating the scene
  120011. */
  120012. onBeforeAnimationsObservable: Observable<Scene>;
  120013. /**
  120014. * An event triggered after animations processing
  120015. */
  120016. onAfterAnimationsObservable: Observable<Scene>;
  120017. /**
  120018. * An event triggered before draw calls are ready to be sent
  120019. */
  120020. onBeforeDrawPhaseObservable: Observable<Scene>;
  120021. /**
  120022. * An event triggered after draw calls have been sent
  120023. */
  120024. onAfterDrawPhaseObservable: Observable<Scene>;
  120025. /**
  120026. * An event triggered when the scene is ready
  120027. */
  120028. onReadyObservable: Observable<Scene>;
  120029. /**
  120030. * An event triggered before rendering a camera
  120031. */
  120032. onBeforeCameraRenderObservable: Observable<Camera>;
  120033. private _onBeforeCameraRenderObserver;
  120034. /** Sets a function to be executed before rendering a camera*/
  120035. set beforeCameraRender(callback: () => void);
  120036. /**
  120037. * An event triggered after rendering a camera
  120038. */
  120039. onAfterCameraRenderObservable: Observable<Camera>;
  120040. private _onAfterCameraRenderObserver;
  120041. /** Sets a function to be executed after rendering a camera*/
  120042. set afterCameraRender(callback: () => void);
  120043. /**
  120044. * An event triggered when active meshes evaluation is about to start
  120045. */
  120046. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  120047. /**
  120048. * An event triggered when active meshes evaluation is done
  120049. */
  120050. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  120051. /**
  120052. * An event triggered when particles rendering is about to start
  120053. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  120054. */
  120055. onBeforeParticlesRenderingObservable: Observable<Scene>;
  120056. /**
  120057. * An event triggered when particles rendering is done
  120058. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  120059. */
  120060. onAfterParticlesRenderingObservable: Observable<Scene>;
  120061. /**
  120062. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  120063. */
  120064. onDataLoadedObservable: Observable<Scene>;
  120065. /**
  120066. * An event triggered when a camera is created
  120067. */
  120068. onNewCameraAddedObservable: Observable<Camera>;
  120069. /**
  120070. * An event triggered when a camera is removed
  120071. */
  120072. onCameraRemovedObservable: Observable<Camera>;
  120073. /**
  120074. * An event triggered when a light is created
  120075. */
  120076. onNewLightAddedObservable: Observable<Light>;
  120077. /**
  120078. * An event triggered when a light is removed
  120079. */
  120080. onLightRemovedObservable: Observable<Light>;
  120081. /**
  120082. * An event triggered when a geometry is created
  120083. */
  120084. onNewGeometryAddedObservable: Observable<Geometry>;
  120085. /**
  120086. * An event triggered when a geometry is removed
  120087. */
  120088. onGeometryRemovedObservable: Observable<Geometry>;
  120089. /**
  120090. * An event triggered when a transform node is created
  120091. */
  120092. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  120093. /**
  120094. * An event triggered when a transform node is removed
  120095. */
  120096. onTransformNodeRemovedObservable: Observable<TransformNode>;
  120097. /**
  120098. * An event triggered when a mesh is created
  120099. */
  120100. onNewMeshAddedObservable: Observable<AbstractMesh>;
  120101. /**
  120102. * An event triggered when a mesh is removed
  120103. */
  120104. onMeshRemovedObservable: Observable<AbstractMesh>;
  120105. /**
  120106. * An event triggered when a skeleton is created
  120107. */
  120108. onNewSkeletonAddedObservable: Observable<Skeleton>;
  120109. /**
  120110. * An event triggered when a skeleton is removed
  120111. */
  120112. onSkeletonRemovedObservable: Observable<Skeleton>;
  120113. /**
  120114. * An event triggered when a material is created
  120115. */
  120116. onNewMaterialAddedObservable: Observable<Material>;
  120117. /**
  120118. * An event triggered when a material is removed
  120119. */
  120120. onMaterialRemovedObservable: Observable<Material>;
  120121. /**
  120122. * An event triggered when a texture is created
  120123. */
  120124. onNewTextureAddedObservable: Observable<BaseTexture>;
  120125. /**
  120126. * An event triggered when a texture is removed
  120127. */
  120128. onTextureRemovedObservable: Observable<BaseTexture>;
  120129. /**
  120130. * An event triggered when render targets are about to be rendered
  120131. * Can happen multiple times per frame.
  120132. */
  120133. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  120134. /**
  120135. * An event triggered when render targets were rendered.
  120136. * Can happen multiple times per frame.
  120137. */
  120138. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  120139. /**
  120140. * An event triggered before calculating deterministic simulation step
  120141. */
  120142. onBeforeStepObservable: Observable<Scene>;
  120143. /**
  120144. * An event triggered after calculating deterministic simulation step
  120145. */
  120146. onAfterStepObservable: Observable<Scene>;
  120147. /**
  120148. * An event triggered when the activeCamera property is updated
  120149. */
  120150. onActiveCameraChanged: Observable<Scene>;
  120151. /**
  120152. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  120153. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  120154. * 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)
  120155. */
  120156. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  120157. /**
  120158. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  120159. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  120160. * 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)
  120161. */
  120162. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  120163. /**
  120164. * This Observable will when a mesh has been imported into the scene.
  120165. */
  120166. onMeshImportedObservable: Observable<AbstractMesh>;
  120167. /**
  120168. * This Observable will when an animation file has been imported into the scene.
  120169. */
  120170. onAnimationFileImportedObservable: Observable<Scene>;
  120171. /**
  120172. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  120173. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  120174. */
  120175. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  120176. /** @hidden */
  120177. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  120178. /**
  120179. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  120180. */
  120181. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  120182. /**
  120183. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  120184. */
  120185. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  120186. /**
  120187. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  120188. */
  120189. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  120190. /** Callback called when a pointer move is detected */
  120191. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  120192. /** Callback called when a pointer down is detected */
  120193. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  120194. /** Callback called when a pointer up is detected */
  120195. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  120196. /** Callback called when a pointer pick is detected */
  120197. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  120198. /**
  120199. * 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).
  120200. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  120201. */
  120202. onPrePointerObservable: Observable<PointerInfoPre>;
  120203. /**
  120204. * Observable event triggered each time an input event is received from the rendering canvas
  120205. */
  120206. onPointerObservable: Observable<PointerInfo>;
  120207. /**
  120208. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  120209. */
  120210. get unTranslatedPointer(): Vector2;
  120211. /**
  120212. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  120213. */
  120214. static get DragMovementThreshold(): number;
  120215. static set DragMovementThreshold(value: number);
  120216. /**
  120217. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  120218. */
  120219. static get LongPressDelay(): number;
  120220. static set LongPressDelay(value: number);
  120221. /**
  120222. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  120223. */
  120224. static get DoubleClickDelay(): number;
  120225. static set DoubleClickDelay(value: number);
  120226. /** If you need to check double click without raising a single click at first click, enable this flag */
  120227. static get ExclusiveDoubleClickMode(): boolean;
  120228. static set ExclusiveDoubleClickMode(value: boolean);
  120229. /** @hidden */
  120230. _mirroredCameraPosition: Nullable<Vector3>;
  120231. /**
  120232. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  120233. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  120234. */
  120235. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  120236. /**
  120237. * Observable event triggered each time an keyboard event is received from the hosting window
  120238. */
  120239. onKeyboardObservable: Observable<KeyboardInfo>;
  120240. private _useRightHandedSystem;
  120241. /**
  120242. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  120243. */
  120244. set useRightHandedSystem(value: boolean);
  120245. get useRightHandedSystem(): boolean;
  120246. private _timeAccumulator;
  120247. private _currentStepId;
  120248. private _currentInternalStep;
  120249. /**
  120250. * Sets the step Id used by deterministic lock step
  120251. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120252. * @param newStepId defines the step Id
  120253. */
  120254. setStepId(newStepId: number): void;
  120255. /**
  120256. * Gets the step Id used by deterministic lock step
  120257. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120258. * @returns the step Id
  120259. */
  120260. getStepId(): number;
  120261. /**
  120262. * Gets the internal step used by deterministic lock step
  120263. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120264. * @returns the internal step
  120265. */
  120266. getInternalStep(): number;
  120267. private _fogEnabled;
  120268. /**
  120269. * Gets or sets a boolean indicating if fog is enabled on this scene
  120270. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120271. * (Default is true)
  120272. */
  120273. set fogEnabled(value: boolean);
  120274. get fogEnabled(): boolean;
  120275. private _fogMode;
  120276. /**
  120277. * Gets or sets the fog mode to use
  120278. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120279. * | mode | value |
  120280. * | --- | --- |
  120281. * | FOGMODE_NONE | 0 |
  120282. * | FOGMODE_EXP | 1 |
  120283. * | FOGMODE_EXP2 | 2 |
  120284. * | FOGMODE_LINEAR | 3 |
  120285. */
  120286. set fogMode(value: number);
  120287. get fogMode(): number;
  120288. /**
  120289. * Gets or sets the fog color to use
  120290. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120291. * (Default is Color3(0.2, 0.2, 0.3))
  120292. */
  120293. fogColor: Color3;
  120294. /**
  120295. * Gets or sets the fog density to use
  120296. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120297. * (Default is 0.1)
  120298. */
  120299. fogDensity: number;
  120300. /**
  120301. * Gets or sets the fog start distance to use
  120302. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120303. * (Default is 0)
  120304. */
  120305. fogStart: number;
  120306. /**
  120307. * Gets or sets the fog end distance to use
  120308. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120309. * (Default is 1000)
  120310. */
  120311. fogEnd: number;
  120312. /**
  120313. * Flag indicating that the frame buffer binding is handled by another component
  120314. */
  120315. prePass: boolean;
  120316. private _shadowsEnabled;
  120317. /**
  120318. * Gets or sets a boolean indicating if shadows are enabled on this scene
  120319. */
  120320. set shadowsEnabled(value: boolean);
  120321. get shadowsEnabled(): boolean;
  120322. private _lightsEnabled;
  120323. /**
  120324. * Gets or sets a boolean indicating if lights are enabled on this scene
  120325. */
  120326. set lightsEnabled(value: boolean);
  120327. get lightsEnabled(): boolean;
  120328. /** All of the active cameras added to this scene. */
  120329. activeCameras: Camera[];
  120330. /** @hidden */
  120331. _activeCamera: Nullable<Camera>;
  120332. /** Gets or sets the current active camera */
  120333. get activeCamera(): Nullable<Camera>;
  120334. set activeCamera(value: Nullable<Camera>);
  120335. private _defaultMaterial;
  120336. /** The default material used on meshes when no material is affected */
  120337. get defaultMaterial(): Material;
  120338. /** The default material used on meshes when no material is affected */
  120339. set defaultMaterial(value: Material);
  120340. private _texturesEnabled;
  120341. /**
  120342. * Gets or sets a boolean indicating if textures are enabled on this scene
  120343. */
  120344. set texturesEnabled(value: boolean);
  120345. get texturesEnabled(): boolean;
  120346. /**
  120347. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  120348. */
  120349. physicsEnabled: boolean;
  120350. /**
  120351. * Gets or sets a boolean indicating if particles are enabled on this scene
  120352. */
  120353. particlesEnabled: boolean;
  120354. /**
  120355. * Gets or sets a boolean indicating if sprites are enabled on this scene
  120356. */
  120357. spritesEnabled: boolean;
  120358. private _skeletonsEnabled;
  120359. /**
  120360. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  120361. */
  120362. set skeletonsEnabled(value: boolean);
  120363. get skeletonsEnabled(): boolean;
  120364. /**
  120365. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  120366. */
  120367. lensFlaresEnabled: boolean;
  120368. /**
  120369. * Gets or sets a boolean indicating if collisions are enabled on this scene
  120370. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120371. */
  120372. collisionsEnabled: boolean;
  120373. private _collisionCoordinator;
  120374. /** @hidden */
  120375. get collisionCoordinator(): ICollisionCoordinator;
  120376. /**
  120377. * Defines the gravity applied to this scene (used only for collisions)
  120378. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120379. */
  120380. gravity: Vector3;
  120381. /**
  120382. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  120383. */
  120384. postProcessesEnabled: boolean;
  120385. /**
  120386. * Gets the current postprocess manager
  120387. */
  120388. postProcessManager: PostProcessManager;
  120389. /**
  120390. * Gets or sets a boolean indicating if render targets are enabled on this scene
  120391. */
  120392. renderTargetsEnabled: boolean;
  120393. /**
  120394. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  120395. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  120396. */
  120397. dumpNextRenderTargets: boolean;
  120398. /**
  120399. * The list of user defined render targets added to the scene
  120400. */
  120401. customRenderTargets: RenderTargetTexture[];
  120402. /**
  120403. * Defines if texture loading must be delayed
  120404. * If true, textures will only be loaded when they need to be rendered
  120405. */
  120406. useDelayedTextureLoading: boolean;
  120407. /**
  120408. * Gets the list of meshes imported to the scene through SceneLoader
  120409. */
  120410. importedMeshesFiles: String[];
  120411. /**
  120412. * Gets or sets a boolean indicating if probes are enabled on this scene
  120413. */
  120414. probesEnabled: boolean;
  120415. /**
  120416. * Gets or sets the current offline provider to use to store scene data
  120417. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  120418. */
  120419. offlineProvider: IOfflineProvider;
  120420. /**
  120421. * Gets or sets the action manager associated with the scene
  120422. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120423. */
  120424. actionManager: AbstractActionManager;
  120425. private _meshesForIntersections;
  120426. /**
  120427. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  120428. */
  120429. proceduralTexturesEnabled: boolean;
  120430. private _engine;
  120431. private _totalVertices;
  120432. /** @hidden */
  120433. _activeIndices: PerfCounter;
  120434. /** @hidden */
  120435. _activeParticles: PerfCounter;
  120436. /** @hidden */
  120437. _activeBones: PerfCounter;
  120438. private _animationRatio;
  120439. /** @hidden */
  120440. _animationTimeLast: number;
  120441. /** @hidden */
  120442. _animationTime: number;
  120443. /**
  120444. * Gets or sets a general scale for animation speed
  120445. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  120446. */
  120447. animationTimeScale: number;
  120448. /** @hidden */
  120449. _cachedMaterial: Nullable<Material>;
  120450. /** @hidden */
  120451. _cachedEffect: Nullable<Effect>;
  120452. /** @hidden */
  120453. _cachedVisibility: Nullable<number>;
  120454. private _renderId;
  120455. private _frameId;
  120456. private _executeWhenReadyTimeoutId;
  120457. private _intermediateRendering;
  120458. private _viewUpdateFlag;
  120459. private _projectionUpdateFlag;
  120460. /** @hidden */
  120461. _toBeDisposed: Nullable<IDisposable>[];
  120462. private _activeRequests;
  120463. /** @hidden */
  120464. _pendingData: any[];
  120465. private _isDisposed;
  120466. /**
  120467. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  120468. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  120469. */
  120470. dispatchAllSubMeshesOfActiveMeshes: boolean;
  120471. private _activeMeshes;
  120472. private _processedMaterials;
  120473. private _renderTargets;
  120474. /** @hidden */
  120475. _activeParticleSystems: SmartArray<IParticleSystem>;
  120476. private _activeSkeletons;
  120477. private _softwareSkinnedMeshes;
  120478. private _renderingManager;
  120479. /** @hidden */
  120480. _activeAnimatables: Animatable[];
  120481. private _transformMatrix;
  120482. private _sceneUbo;
  120483. /** @hidden */
  120484. _viewMatrix: Matrix;
  120485. private _projectionMatrix;
  120486. /** @hidden */
  120487. _forcedViewPosition: Nullable<Vector3>;
  120488. /** @hidden */
  120489. _frustumPlanes: Plane[];
  120490. /**
  120491. * Gets the list of frustum planes (built from the active camera)
  120492. */
  120493. get frustumPlanes(): Plane[];
  120494. /**
  120495. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  120496. * This is useful if there are more lights that the maximum simulteanous authorized
  120497. */
  120498. requireLightSorting: boolean;
  120499. /** @hidden */
  120500. readonly useMaterialMeshMap: boolean;
  120501. /** @hidden */
  120502. readonly useClonedMeshMap: boolean;
  120503. private _externalData;
  120504. private _uid;
  120505. /**
  120506. * @hidden
  120507. * Backing store of defined scene components.
  120508. */
  120509. _components: ISceneComponent[];
  120510. /**
  120511. * @hidden
  120512. * Backing store of defined scene components.
  120513. */
  120514. _serializableComponents: ISceneSerializableComponent[];
  120515. /**
  120516. * List of components to register on the next registration step.
  120517. */
  120518. private _transientComponents;
  120519. /**
  120520. * Registers the transient components if needed.
  120521. */
  120522. private _registerTransientComponents;
  120523. /**
  120524. * @hidden
  120525. * Add a component to the scene.
  120526. * Note that the ccomponent could be registered on th next frame if this is called after
  120527. * the register component stage.
  120528. * @param component Defines the component to add to the scene
  120529. */
  120530. _addComponent(component: ISceneComponent): void;
  120531. /**
  120532. * @hidden
  120533. * Gets a component from the scene.
  120534. * @param name defines the name of the component to retrieve
  120535. * @returns the component or null if not present
  120536. */
  120537. _getComponent(name: string): Nullable<ISceneComponent>;
  120538. /**
  120539. * @hidden
  120540. * Defines the actions happening before camera updates.
  120541. */
  120542. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  120543. /**
  120544. * @hidden
  120545. * Defines the actions happening before clear the canvas.
  120546. */
  120547. _beforeClearStage: Stage<SimpleStageAction>;
  120548. /**
  120549. * @hidden
  120550. * Defines the actions when collecting render targets for the frame.
  120551. */
  120552. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120553. /**
  120554. * @hidden
  120555. * Defines the actions happening for one camera in the frame.
  120556. */
  120557. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120558. /**
  120559. * @hidden
  120560. * Defines the actions happening during the per mesh ready checks.
  120561. */
  120562. _isReadyForMeshStage: Stage<MeshStageAction>;
  120563. /**
  120564. * @hidden
  120565. * Defines the actions happening before evaluate active mesh checks.
  120566. */
  120567. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  120568. /**
  120569. * @hidden
  120570. * Defines the actions happening during the evaluate sub mesh checks.
  120571. */
  120572. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  120573. /**
  120574. * @hidden
  120575. * Defines the actions happening during the active mesh stage.
  120576. */
  120577. _activeMeshStage: Stage<ActiveMeshStageAction>;
  120578. /**
  120579. * @hidden
  120580. * Defines the actions happening during the per camera render target step.
  120581. */
  120582. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  120583. /**
  120584. * @hidden
  120585. * Defines the actions happening just before the active camera is drawing.
  120586. */
  120587. _beforeCameraDrawStage: Stage<CameraStageAction>;
  120588. /**
  120589. * @hidden
  120590. * Defines the actions happening just before a render target is drawing.
  120591. */
  120592. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120593. /**
  120594. * @hidden
  120595. * Defines the actions happening just before a rendering group is drawing.
  120596. */
  120597. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120598. /**
  120599. * @hidden
  120600. * Defines the actions happening just before a mesh is drawing.
  120601. */
  120602. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120603. /**
  120604. * @hidden
  120605. * Defines the actions happening just after a mesh has been drawn.
  120606. */
  120607. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120608. /**
  120609. * @hidden
  120610. * Defines the actions happening just after a rendering group has been drawn.
  120611. */
  120612. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120613. /**
  120614. * @hidden
  120615. * Defines the actions happening just after the active camera has been drawn.
  120616. */
  120617. _afterCameraDrawStage: Stage<CameraStageAction>;
  120618. /**
  120619. * @hidden
  120620. * Defines the actions happening just after a render target has been drawn.
  120621. */
  120622. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120623. /**
  120624. * @hidden
  120625. * Defines the actions happening just after rendering all cameras and computing intersections.
  120626. */
  120627. _afterRenderStage: Stage<SimpleStageAction>;
  120628. /**
  120629. * @hidden
  120630. * Defines the actions happening when a pointer move event happens.
  120631. */
  120632. _pointerMoveStage: Stage<PointerMoveStageAction>;
  120633. /**
  120634. * @hidden
  120635. * Defines the actions happening when a pointer down event happens.
  120636. */
  120637. _pointerDownStage: Stage<PointerUpDownStageAction>;
  120638. /**
  120639. * @hidden
  120640. * Defines the actions happening when a pointer up event happens.
  120641. */
  120642. _pointerUpStage: Stage<PointerUpDownStageAction>;
  120643. /**
  120644. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  120645. */
  120646. private geometriesByUniqueId;
  120647. /**
  120648. * Creates a new Scene
  120649. * @param engine defines the engine to use to render this scene
  120650. * @param options defines the scene options
  120651. */
  120652. constructor(engine: Engine, options?: SceneOptions);
  120653. /**
  120654. * Gets a string identifying the name of the class
  120655. * @returns "Scene" string
  120656. */
  120657. getClassName(): string;
  120658. private _defaultMeshCandidates;
  120659. /**
  120660. * @hidden
  120661. */
  120662. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120663. private _defaultSubMeshCandidates;
  120664. /**
  120665. * @hidden
  120666. */
  120667. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120668. /**
  120669. * Sets the default candidate providers for the scene.
  120670. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  120671. * and getCollidingSubMeshCandidates to their default function
  120672. */
  120673. setDefaultCandidateProviders(): void;
  120674. /**
  120675. * Gets the mesh that is currently under the pointer
  120676. */
  120677. get meshUnderPointer(): Nullable<AbstractMesh>;
  120678. /**
  120679. * Gets or sets the current on-screen X position of the pointer
  120680. */
  120681. get pointerX(): number;
  120682. set pointerX(value: number);
  120683. /**
  120684. * Gets or sets the current on-screen Y position of the pointer
  120685. */
  120686. get pointerY(): number;
  120687. set pointerY(value: number);
  120688. /**
  120689. * Gets the cached material (ie. the latest rendered one)
  120690. * @returns the cached material
  120691. */
  120692. getCachedMaterial(): Nullable<Material>;
  120693. /**
  120694. * Gets the cached effect (ie. the latest rendered one)
  120695. * @returns the cached effect
  120696. */
  120697. getCachedEffect(): Nullable<Effect>;
  120698. /**
  120699. * Gets the cached visibility state (ie. the latest rendered one)
  120700. * @returns the cached visibility state
  120701. */
  120702. getCachedVisibility(): Nullable<number>;
  120703. /**
  120704. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  120705. * @param material defines the current material
  120706. * @param effect defines the current effect
  120707. * @param visibility defines the current visibility state
  120708. * @returns true if one parameter is not cached
  120709. */
  120710. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  120711. /**
  120712. * Gets the engine associated with the scene
  120713. * @returns an Engine
  120714. */
  120715. getEngine(): Engine;
  120716. /**
  120717. * Gets the total number of vertices rendered per frame
  120718. * @returns the total number of vertices rendered per frame
  120719. */
  120720. getTotalVertices(): number;
  120721. /**
  120722. * Gets the performance counter for total vertices
  120723. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120724. */
  120725. get totalVerticesPerfCounter(): PerfCounter;
  120726. /**
  120727. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  120728. * @returns the total number of active indices rendered per frame
  120729. */
  120730. getActiveIndices(): number;
  120731. /**
  120732. * Gets the performance counter for active indices
  120733. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120734. */
  120735. get totalActiveIndicesPerfCounter(): PerfCounter;
  120736. /**
  120737. * Gets the total number of active particles rendered per frame
  120738. * @returns the total number of active particles rendered per frame
  120739. */
  120740. getActiveParticles(): number;
  120741. /**
  120742. * Gets the performance counter for active particles
  120743. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120744. */
  120745. get activeParticlesPerfCounter(): PerfCounter;
  120746. /**
  120747. * Gets the total number of active bones rendered per frame
  120748. * @returns the total number of active bones rendered per frame
  120749. */
  120750. getActiveBones(): number;
  120751. /**
  120752. * Gets the performance counter for active bones
  120753. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120754. */
  120755. get activeBonesPerfCounter(): PerfCounter;
  120756. /**
  120757. * Gets the array of active meshes
  120758. * @returns an array of AbstractMesh
  120759. */
  120760. getActiveMeshes(): SmartArray<AbstractMesh>;
  120761. /**
  120762. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  120763. * @returns a number
  120764. */
  120765. getAnimationRatio(): number;
  120766. /**
  120767. * Gets an unique Id for the current render phase
  120768. * @returns a number
  120769. */
  120770. getRenderId(): number;
  120771. /**
  120772. * Gets an unique Id for the current frame
  120773. * @returns a number
  120774. */
  120775. getFrameId(): number;
  120776. /** Call this function if you want to manually increment the render Id*/
  120777. incrementRenderId(): void;
  120778. private _createUbo;
  120779. /**
  120780. * Use this method to simulate a pointer move on a mesh
  120781. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120782. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120783. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120784. * @returns the current scene
  120785. */
  120786. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120787. /**
  120788. * Use this method to simulate a pointer down on a mesh
  120789. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120790. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120791. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120792. * @returns the current scene
  120793. */
  120794. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120795. /**
  120796. * Use this method to simulate a pointer up on a mesh
  120797. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120798. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120799. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120800. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  120801. * @returns the current scene
  120802. */
  120803. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  120804. /**
  120805. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  120806. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  120807. * @returns true if the pointer was captured
  120808. */
  120809. isPointerCaptured(pointerId?: number): boolean;
  120810. /**
  120811. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  120812. * @param attachUp defines if you want to attach events to pointerup
  120813. * @param attachDown defines if you want to attach events to pointerdown
  120814. * @param attachMove defines if you want to attach events to pointermove
  120815. */
  120816. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  120817. /** Detaches all event handlers*/
  120818. detachControl(): void;
  120819. /**
  120820. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  120821. * Delay loaded resources are not taking in account
  120822. * @return true if all required resources are ready
  120823. */
  120824. isReady(): boolean;
  120825. /** Resets all cached information relative to material (including effect and visibility) */
  120826. resetCachedMaterial(): void;
  120827. /**
  120828. * Registers a function to be called before every frame render
  120829. * @param func defines the function to register
  120830. */
  120831. registerBeforeRender(func: () => void): void;
  120832. /**
  120833. * Unregisters a function called before every frame render
  120834. * @param func defines the function to unregister
  120835. */
  120836. unregisterBeforeRender(func: () => void): void;
  120837. /**
  120838. * Registers a function to be called after every frame render
  120839. * @param func defines the function to register
  120840. */
  120841. registerAfterRender(func: () => void): void;
  120842. /**
  120843. * Unregisters a function called after every frame render
  120844. * @param func defines the function to unregister
  120845. */
  120846. unregisterAfterRender(func: () => void): void;
  120847. private _executeOnceBeforeRender;
  120848. /**
  120849. * The provided function will run before render once and will be disposed afterwards.
  120850. * A timeout delay can be provided so that the function will be executed in N ms.
  120851. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  120852. * @param func The function to be executed.
  120853. * @param timeout optional delay in ms
  120854. */
  120855. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  120856. /** @hidden */
  120857. _addPendingData(data: any): void;
  120858. /** @hidden */
  120859. _removePendingData(data: any): void;
  120860. /**
  120861. * Returns the number of items waiting to be loaded
  120862. * @returns the number of items waiting to be loaded
  120863. */
  120864. getWaitingItemsCount(): number;
  120865. /**
  120866. * Returns a boolean indicating if the scene is still loading data
  120867. */
  120868. get isLoading(): boolean;
  120869. /**
  120870. * Registers a function to be executed when the scene is ready
  120871. * @param {Function} func - the function to be executed
  120872. */
  120873. executeWhenReady(func: () => void): void;
  120874. /**
  120875. * Returns a promise that resolves when the scene is ready
  120876. * @returns A promise that resolves when the scene is ready
  120877. */
  120878. whenReadyAsync(): Promise<void>;
  120879. /** @hidden */
  120880. _checkIsReady(): void;
  120881. /**
  120882. * Gets all animatable attached to the scene
  120883. */
  120884. get animatables(): Animatable[];
  120885. /**
  120886. * Resets the last animation time frame.
  120887. * Useful to override when animations start running when loading a scene for the first time.
  120888. */
  120889. resetLastAnimationTimeFrame(): void;
  120890. /**
  120891. * Gets the current view matrix
  120892. * @returns a Matrix
  120893. */
  120894. getViewMatrix(): Matrix;
  120895. /**
  120896. * Gets the current projection matrix
  120897. * @returns a Matrix
  120898. */
  120899. getProjectionMatrix(): Matrix;
  120900. /**
  120901. * Gets the current transform matrix
  120902. * @returns a Matrix made of View * Projection
  120903. */
  120904. getTransformMatrix(): Matrix;
  120905. /**
  120906. * Sets the current transform matrix
  120907. * @param viewL defines the View matrix to use
  120908. * @param projectionL defines the Projection matrix to use
  120909. * @param viewR defines the right View matrix to use (if provided)
  120910. * @param projectionR defines the right Projection matrix to use (if provided)
  120911. */
  120912. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  120913. /**
  120914. * Gets the uniform buffer used to store scene data
  120915. * @returns a UniformBuffer
  120916. */
  120917. getSceneUniformBuffer(): UniformBuffer;
  120918. /**
  120919. * Gets an unique (relatively to the current scene) Id
  120920. * @returns an unique number for the scene
  120921. */
  120922. getUniqueId(): number;
  120923. /**
  120924. * Add a mesh to the list of scene's meshes
  120925. * @param newMesh defines the mesh to add
  120926. * @param recursive if all child meshes should also be added to the scene
  120927. */
  120928. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  120929. /**
  120930. * Remove a mesh for the list of scene's meshes
  120931. * @param toRemove defines the mesh to remove
  120932. * @param recursive if all child meshes should also be removed from the scene
  120933. * @returns the index where the mesh was in the mesh list
  120934. */
  120935. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  120936. /**
  120937. * Add a transform node to the list of scene's transform nodes
  120938. * @param newTransformNode defines the transform node to add
  120939. */
  120940. addTransformNode(newTransformNode: TransformNode): void;
  120941. /**
  120942. * Remove a transform node for the list of scene's transform nodes
  120943. * @param toRemove defines the transform node to remove
  120944. * @returns the index where the transform node was in the transform node list
  120945. */
  120946. removeTransformNode(toRemove: TransformNode): number;
  120947. /**
  120948. * Remove a skeleton for the list of scene's skeletons
  120949. * @param toRemove defines the skeleton to remove
  120950. * @returns the index where the skeleton was in the skeleton list
  120951. */
  120952. removeSkeleton(toRemove: Skeleton): number;
  120953. /**
  120954. * Remove a morph target for the list of scene's morph targets
  120955. * @param toRemove defines the morph target to remove
  120956. * @returns the index where the morph target was in the morph target list
  120957. */
  120958. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  120959. /**
  120960. * Remove a light for the list of scene's lights
  120961. * @param toRemove defines the light to remove
  120962. * @returns the index where the light was in the light list
  120963. */
  120964. removeLight(toRemove: Light): number;
  120965. /**
  120966. * Remove a camera for the list of scene's cameras
  120967. * @param toRemove defines the camera to remove
  120968. * @returns the index where the camera was in the camera list
  120969. */
  120970. removeCamera(toRemove: Camera): number;
  120971. /**
  120972. * Remove a particle system for the list of scene's particle systems
  120973. * @param toRemove defines the particle system to remove
  120974. * @returns the index where the particle system was in the particle system list
  120975. */
  120976. removeParticleSystem(toRemove: IParticleSystem): number;
  120977. /**
  120978. * Remove a animation for the list of scene's animations
  120979. * @param toRemove defines the animation to remove
  120980. * @returns the index where the animation was in the animation list
  120981. */
  120982. removeAnimation(toRemove: Animation): number;
  120983. /**
  120984. * Will stop the animation of the given target
  120985. * @param target - the target
  120986. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  120987. * @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)
  120988. */
  120989. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  120990. /**
  120991. * Removes the given animation group from this scene.
  120992. * @param toRemove The animation group to remove
  120993. * @returns The index of the removed animation group
  120994. */
  120995. removeAnimationGroup(toRemove: AnimationGroup): number;
  120996. /**
  120997. * Removes the given multi-material from this scene.
  120998. * @param toRemove The multi-material to remove
  120999. * @returns The index of the removed multi-material
  121000. */
  121001. removeMultiMaterial(toRemove: MultiMaterial): number;
  121002. /**
  121003. * Removes the given material from this scene.
  121004. * @param toRemove The material to remove
  121005. * @returns The index of the removed material
  121006. */
  121007. removeMaterial(toRemove: Material): number;
  121008. /**
  121009. * Removes the given action manager from this scene.
  121010. * @param toRemove The action manager to remove
  121011. * @returns The index of the removed action manager
  121012. */
  121013. removeActionManager(toRemove: AbstractActionManager): number;
  121014. /**
  121015. * Removes the given texture from this scene.
  121016. * @param toRemove The texture to remove
  121017. * @returns The index of the removed texture
  121018. */
  121019. removeTexture(toRemove: BaseTexture): number;
  121020. /**
  121021. * Adds the given light to this scene
  121022. * @param newLight The light to add
  121023. */
  121024. addLight(newLight: Light): void;
  121025. /**
  121026. * Sorts the list list based on light priorities
  121027. */
  121028. sortLightsByPriority(): void;
  121029. /**
  121030. * Adds the given camera to this scene
  121031. * @param newCamera The camera to add
  121032. */
  121033. addCamera(newCamera: Camera): void;
  121034. /**
  121035. * Adds the given skeleton to this scene
  121036. * @param newSkeleton The skeleton to add
  121037. */
  121038. addSkeleton(newSkeleton: Skeleton): void;
  121039. /**
  121040. * Adds the given particle system to this scene
  121041. * @param newParticleSystem The particle system to add
  121042. */
  121043. addParticleSystem(newParticleSystem: IParticleSystem): void;
  121044. /**
  121045. * Adds the given animation to this scene
  121046. * @param newAnimation The animation to add
  121047. */
  121048. addAnimation(newAnimation: Animation): void;
  121049. /**
  121050. * Adds the given animation group to this scene.
  121051. * @param newAnimationGroup The animation group to add
  121052. */
  121053. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  121054. /**
  121055. * Adds the given multi-material to this scene
  121056. * @param newMultiMaterial The multi-material to add
  121057. */
  121058. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  121059. /**
  121060. * Adds the given material to this scene
  121061. * @param newMaterial The material to add
  121062. */
  121063. addMaterial(newMaterial: Material): void;
  121064. /**
  121065. * Adds the given morph target to this scene
  121066. * @param newMorphTargetManager The morph target to add
  121067. */
  121068. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  121069. /**
  121070. * Adds the given geometry to this scene
  121071. * @param newGeometry The geometry to add
  121072. */
  121073. addGeometry(newGeometry: Geometry): void;
  121074. /**
  121075. * Adds the given action manager to this scene
  121076. * @param newActionManager The action manager to add
  121077. */
  121078. addActionManager(newActionManager: AbstractActionManager): void;
  121079. /**
  121080. * Adds the given texture to this scene.
  121081. * @param newTexture The texture to add
  121082. */
  121083. addTexture(newTexture: BaseTexture): void;
  121084. /**
  121085. * Switch active camera
  121086. * @param newCamera defines the new active camera
  121087. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  121088. */
  121089. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  121090. /**
  121091. * sets the active camera of the scene using its ID
  121092. * @param id defines the camera's ID
  121093. * @return the new active camera or null if none found.
  121094. */
  121095. setActiveCameraByID(id: string): Nullable<Camera>;
  121096. /**
  121097. * sets the active camera of the scene using its name
  121098. * @param name defines the camera's name
  121099. * @returns the new active camera or null if none found.
  121100. */
  121101. setActiveCameraByName(name: string): Nullable<Camera>;
  121102. /**
  121103. * get an animation group using its name
  121104. * @param name defines the material's name
  121105. * @return the animation group or null if none found.
  121106. */
  121107. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  121108. /**
  121109. * Get a material using its unique id
  121110. * @param uniqueId defines the material's unique id
  121111. * @return the material or null if none found.
  121112. */
  121113. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  121114. /**
  121115. * get a material using its id
  121116. * @param id defines the material's ID
  121117. * @return the material or null if none found.
  121118. */
  121119. getMaterialByID(id: string): Nullable<Material>;
  121120. /**
  121121. * Gets a the last added material using a given id
  121122. * @param id defines the material's ID
  121123. * @return the last material with the given id or null if none found.
  121124. */
  121125. getLastMaterialByID(id: string): Nullable<Material>;
  121126. /**
  121127. * Gets a material using its name
  121128. * @param name defines the material's name
  121129. * @return the material or null if none found.
  121130. */
  121131. getMaterialByName(name: string): Nullable<Material>;
  121132. /**
  121133. * Get a texture using its unique id
  121134. * @param uniqueId defines the texture's unique id
  121135. * @return the texture or null if none found.
  121136. */
  121137. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  121138. /**
  121139. * Gets a camera using its id
  121140. * @param id defines the id to look for
  121141. * @returns the camera or null if not found
  121142. */
  121143. getCameraByID(id: string): Nullable<Camera>;
  121144. /**
  121145. * Gets a camera using its unique id
  121146. * @param uniqueId defines the unique id to look for
  121147. * @returns the camera or null if not found
  121148. */
  121149. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  121150. /**
  121151. * Gets a camera using its name
  121152. * @param name defines the camera's name
  121153. * @return the camera or null if none found.
  121154. */
  121155. getCameraByName(name: string): Nullable<Camera>;
  121156. /**
  121157. * Gets a bone using its id
  121158. * @param id defines the bone's id
  121159. * @return the bone or null if not found
  121160. */
  121161. getBoneByID(id: string): Nullable<Bone>;
  121162. /**
  121163. * Gets a bone using its id
  121164. * @param name defines the bone's name
  121165. * @return the bone or null if not found
  121166. */
  121167. getBoneByName(name: string): Nullable<Bone>;
  121168. /**
  121169. * Gets a light node using its name
  121170. * @param name defines the the light's name
  121171. * @return the light or null if none found.
  121172. */
  121173. getLightByName(name: string): Nullable<Light>;
  121174. /**
  121175. * Gets a light node using its id
  121176. * @param id defines the light's id
  121177. * @return the light or null if none found.
  121178. */
  121179. getLightByID(id: string): Nullable<Light>;
  121180. /**
  121181. * Gets a light node using its scene-generated unique ID
  121182. * @param uniqueId defines the light's unique id
  121183. * @return the light or null if none found.
  121184. */
  121185. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  121186. /**
  121187. * Gets a particle system by id
  121188. * @param id defines the particle system id
  121189. * @return the corresponding system or null if none found
  121190. */
  121191. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  121192. /**
  121193. * Gets a geometry using its ID
  121194. * @param id defines the geometry's id
  121195. * @return the geometry or null if none found.
  121196. */
  121197. getGeometryByID(id: string): Nullable<Geometry>;
  121198. private _getGeometryByUniqueID;
  121199. /**
  121200. * Add a new geometry to this scene
  121201. * @param geometry defines the geometry to be added to the scene.
  121202. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  121203. * @return a boolean defining if the geometry was added or not
  121204. */
  121205. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  121206. /**
  121207. * Removes an existing geometry
  121208. * @param geometry defines the geometry to be removed from the scene
  121209. * @return a boolean defining if the geometry was removed or not
  121210. */
  121211. removeGeometry(geometry: Geometry): boolean;
  121212. /**
  121213. * Gets the list of geometries attached to the scene
  121214. * @returns an array of Geometry
  121215. */
  121216. getGeometries(): Geometry[];
  121217. /**
  121218. * Gets the first added mesh found of a given ID
  121219. * @param id defines the id to search for
  121220. * @return the mesh found or null if not found at all
  121221. */
  121222. getMeshByID(id: string): Nullable<AbstractMesh>;
  121223. /**
  121224. * Gets a list of meshes using their id
  121225. * @param id defines the id to search for
  121226. * @returns a list of meshes
  121227. */
  121228. getMeshesByID(id: string): Array<AbstractMesh>;
  121229. /**
  121230. * Gets the first added transform node found of a given ID
  121231. * @param id defines the id to search for
  121232. * @return the found transform node or null if not found at all.
  121233. */
  121234. getTransformNodeByID(id: string): Nullable<TransformNode>;
  121235. /**
  121236. * Gets a transform node with its auto-generated unique id
  121237. * @param uniqueId efines the unique id to search for
  121238. * @return the found transform node or null if not found at all.
  121239. */
  121240. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  121241. /**
  121242. * Gets a list of transform nodes using their id
  121243. * @param id defines the id to search for
  121244. * @returns a list of transform nodes
  121245. */
  121246. getTransformNodesByID(id: string): Array<TransformNode>;
  121247. /**
  121248. * Gets a mesh with its auto-generated unique id
  121249. * @param uniqueId defines the unique id to search for
  121250. * @return the found mesh or null if not found at all.
  121251. */
  121252. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  121253. /**
  121254. * Gets a the last added mesh using a given id
  121255. * @param id defines the id to search for
  121256. * @return the found mesh or null if not found at all.
  121257. */
  121258. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  121259. /**
  121260. * Gets a the last added node (Mesh, Camera, Light) using a given id
  121261. * @param id defines the id to search for
  121262. * @return the found node or null if not found at all
  121263. */
  121264. getLastEntryByID(id: string): Nullable<Node>;
  121265. /**
  121266. * Gets a node (Mesh, Camera, Light) using a given id
  121267. * @param id defines the id to search for
  121268. * @return the found node or null if not found at all
  121269. */
  121270. getNodeByID(id: string): Nullable<Node>;
  121271. /**
  121272. * Gets a node (Mesh, Camera, Light) using a given name
  121273. * @param name defines the name to search for
  121274. * @return the found node or null if not found at all.
  121275. */
  121276. getNodeByName(name: string): Nullable<Node>;
  121277. /**
  121278. * Gets a mesh using a given name
  121279. * @param name defines the name to search for
  121280. * @return the found mesh or null if not found at all.
  121281. */
  121282. getMeshByName(name: string): Nullable<AbstractMesh>;
  121283. /**
  121284. * Gets a transform node using a given name
  121285. * @param name defines the name to search for
  121286. * @return the found transform node or null if not found at all.
  121287. */
  121288. getTransformNodeByName(name: string): Nullable<TransformNode>;
  121289. /**
  121290. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  121291. * @param id defines the id to search for
  121292. * @return the found skeleton or null if not found at all.
  121293. */
  121294. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  121295. /**
  121296. * Gets a skeleton using a given auto generated unique id
  121297. * @param uniqueId defines the unique id to search for
  121298. * @return the found skeleton or null if not found at all.
  121299. */
  121300. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  121301. /**
  121302. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  121303. * @param id defines the id to search for
  121304. * @return the found skeleton or null if not found at all.
  121305. */
  121306. getSkeletonById(id: string): Nullable<Skeleton>;
  121307. /**
  121308. * Gets a skeleton using a given name
  121309. * @param name defines the name to search for
  121310. * @return the found skeleton or null if not found at all.
  121311. */
  121312. getSkeletonByName(name: string): Nullable<Skeleton>;
  121313. /**
  121314. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  121315. * @param id defines the id to search for
  121316. * @return the found morph target manager or null if not found at all.
  121317. */
  121318. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  121319. /**
  121320. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  121321. * @param id defines the id to search for
  121322. * @return the found morph target or null if not found at all.
  121323. */
  121324. getMorphTargetById(id: string): Nullable<MorphTarget>;
  121325. /**
  121326. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  121327. * @param name defines the name to search for
  121328. * @return the found morph target or null if not found at all.
  121329. */
  121330. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  121331. /**
  121332. * Gets a post process using a given name (if many are found, this function will pick the first one)
  121333. * @param name defines the name to search for
  121334. * @return the found post process or null if not found at all.
  121335. */
  121336. getPostProcessByName(name: string): Nullable<PostProcess>;
  121337. /**
  121338. * Gets a boolean indicating if the given mesh is active
  121339. * @param mesh defines the mesh to look for
  121340. * @returns true if the mesh is in the active list
  121341. */
  121342. isActiveMesh(mesh: AbstractMesh): boolean;
  121343. /**
  121344. * Return a unique id as a string which can serve as an identifier for the scene
  121345. */
  121346. get uid(): string;
  121347. /**
  121348. * Add an externaly attached data from its key.
  121349. * This method call will fail and return false, if such key already exists.
  121350. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  121351. * @param key the unique key that identifies the data
  121352. * @param data the data object to associate to the key for this Engine instance
  121353. * @return true if no such key were already present and the data was added successfully, false otherwise
  121354. */
  121355. addExternalData<T>(key: string, data: T): boolean;
  121356. /**
  121357. * Get an externaly attached data from its key
  121358. * @param key the unique key that identifies the data
  121359. * @return the associated data, if present (can be null), or undefined if not present
  121360. */
  121361. getExternalData<T>(key: string): Nullable<T>;
  121362. /**
  121363. * Get an externaly attached data from its key, create it using a factory if it's not already present
  121364. * @param key the unique key that identifies the data
  121365. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  121366. * @return the associated data, can be null if the factory returned null.
  121367. */
  121368. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  121369. /**
  121370. * Remove an externaly attached data from the Engine instance
  121371. * @param key the unique key that identifies the data
  121372. * @return true if the data was successfully removed, false if it doesn't exist
  121373. */
  121374. removeExternalData(key: string): boolean;
  121375. private _evaluateSubMesh;
  121376. /**
  121377. * Clear the processed materials smart array preventing retention point in material dispose.
  121378. */
  121379. freeProcessedMaterials(): void;
  121380. private _preventFreeActiveMeshesAndRenderingGroups;
  121381. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  121382. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  121383. * when disposing several meshes in a row or a hierarchy of meshes.
  121384. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  121385. */
  121386. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  121387. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  121388. /**
  121389. * Clear the active meshes smart array preventing retention point in mesh dispose.
  121390. */
  121391. freeActiveMeshes(): void;
  121392. /**
  121393. * Clear the info related to rendering groups preventing retention points during dispose.
  121394. */
  121395. freeRenderingGroups(): void;
  121396. /** @hidden */
  121397. _isInIntermediateRendering(): boolean;
  121398. /**
  121399. * Lambda returning the list of potentially active meshes.
  121400. */
  121401. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  121402. /**
  121403. * Lambda returning the list of potentially active sub meshes.
  121404. */
  121405. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  121406. /**
  121407. * Lambda returning the list of potentially intersecting sub meshes.
  121408. */
  121409. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  121410. /**
  121411. * Lambda returning the list of potentially colliding sub meshes.
  121412. */
  121413. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  121414. private _activeMeshesFrozen;
  121415. private _skipEvaluateActiveMeshesCompletely;
  121416. /**
  121417. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  121418. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  121419. * @returns the current scene
  121420. */
  121421. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  121422. /**
  121423. * Use this function to restart evaluating active meshes on every frame
  121424. * @returns the current scene
  121425. */
  121426. unfreezeActiveMeshes(): Scene;
  121427. private _evaluateActiveMeshes;
  121428. private _activeMesh;
  121429. /**
  121430. * Update the transform matrix to update from the current active camera
  121431. * @param force defines a boolean used to force the update even if cache is up to date
  121432. */
  121433. updateTransformMatrix(force?: boolean): void;
  121434. private _bindFrameBuffer;
  121435. /** @hidden */
  121436. _allowPostProcessClearColor: boolean;
  121437. /** @hidden */
  121438. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  121439. private _processSubCameras;
  121440. private _checkIntersections;
  121441. /** @hidden */
  121442. _advancePhysicsEngineStep(step: number): void;
  121443. /**
  121444. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  121445. */
  121446. getDeterministicFrameTime: () => number;
  121447. /** @hidden */
  121448. _animate(): void;
  121449. /** Execute all animations (for a frame) */
  121450. animate(): void;
  121451. /**
  121452. * Render the scene
  121453. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  121454. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  121455. */
  121456. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  121457. /**
  121458. * Freeze all materials
  121459. * A frozen material will not be updatable but should be faster to render
  121460. */
  121461. freezeMaterials(): void;
  121462. /**
  121463. * Unfreeze all materials
  121464. * A frozen material will not be updatable but should be faster to render
  121465. */
  121466. unfreezeMaterials(): void;
  121467. /**
  121468. * Releases all held ressources
  121469. */
  121470. dispose(): void;
  121471. /**
  121472. * Gets if the scene is already disposed
  121473. */
  121474. get isDisposed(): boolean;
  121475. /**
  121476. * Call this function to reduce memory footprint of the scene.
  121477. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  121478. */
  121479. clearCachedVertexData(): void;
  121480. /**
  121481. * This function will remove the local cached buffer data from texture.
  121482. * It will save memory but will prevent the texture from being rebuilt
  121483. */
  121484. cleanCachedTextureBuffer(): void;
  121485. /**
  121486. * Get the world extend vectors with an optional filter
  121487. *
  121488. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  121489. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  121490. */
  121491. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  121492. min: Vector3;
  121493. max: Vector3;
  121494. };
  121495. /**
  121496. * Creates a ray that can be used to pick in the scene
  121497. * @param x defines the x coordinate of the origin (on-screen)
  121498. * @param y defines the y coordinate of the origin (on-screen)
  121499. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121500. * @param camera defines the camera to use for the picking
  121501. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121502. * @returns a Ray
  121503. */
  121504. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  121505. /**
  121506. * Creates a ray that can be used to pick in the scene
  121507. * @param x defines the x coordinate of the origin (on-screen)
  121508. * @param y defines the y coordinate of the origin (on-screen)
  121509. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121510. * @param result defines the ray where to store the picking ray
  121511. * @param camera defines the camera to use for the picking
  121512. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121513. * @returns the current scene
  121514. */
  121515. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  121516. /**
  121517. * Creates a ray that can be used to pick in the scene
  121518. * @param x defines the x coordinate of the origin (on-screen)
  121519. * @param y defines the y coordinate of the origin (on-screen)
  121520. * @param camera defines the camera to use for the picking
  121521. * @returns a Ray
  121522. */
  121523. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  121524. /**
  121525. * Creates a ray that can be used to pick in the scene
  121526. * @param x defines the x coordinate of the origin (on-screen)
  121527. * @param y defines the y coordinate of the origin (on-screen)
  121528. * @param result defines the ray where to store the picking ray
  121529. * @param camera defines the camera to use for the picking
  121530. * @returns the current scene
  121531. */
  121532. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  121533. /** Launch a ray to try to pick a mesh in the scene
  121534. * @param x position on screen
  121535. * @param y position on screen
  121536. * @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
  121537. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121538. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121539. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121540. * @returns a PickingInfo
  121541. */
  121542. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121543. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  121544. * @param x position on screen
  121545. * @param y position on screen
  121546. * @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
  121547. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121548. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121549. * @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)
  121550. */
  121551. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  121552. /** Use the given ray to pick a mesh in the scene
  121553. * @param ray The ray to use to pick meshes
  121554. * @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
  121555. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121556. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121557. * @returns a PickingInfo
  121558. */
  121559. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121560. /**
  121561. * Launch a ray to try to pick a mesh in the scene
  121562. * @param x X position on screen
  121563. * @param y Y position on screen
  121564. * @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
  121565. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121566. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121567. * @returns an array of PickingInfo
  121568. */
  121569. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121570. /**
  121571. * Launch a ray to try to pick a mesh in the scene
  121572. * @param ray Ray to use
  121573. * @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
  121574. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121575. * @returns an array of PickingInfo
  121576. */
  121577. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121578. /**
  121579. * Force the value of meshUnderPointer
  121580. * @param mesh defines the mesh to use
  121581. * @param pointerId optional pointer id when using more than one pointer
  121582. */
  121583. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  121584. /**
  121585. * Gets the mesh under the pointer
  121586. * @returns a Mesh or null if no mesh is under the pointer
  121587. */
  121588. getPointerOverMesh(): Nullable<AbstractMesh>;
  121589. /** @hidden */
  121590. _rebuildGeometries(): void;
  121591. /** @hidden */
  121592. _rebuildTextures(): void;
  121593. private _getByTags;
  121594. /**
  121595. * Get a list of meshes by tags
  121596. * @param tagsQuery defines the tags query to use
  121597. * @param forEach defines a predicate used to filter results
  121598. * @returns an array of Mesh
  121599. */
  121600. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  121601. /**
  121602. * Get a list of cameras by tags
  121603. * @param tagsQuery defines the tags query to use
  121604. * @param forEach defines a predicate used to filter results
  121605. * @returns an array of Camera
  121606. */
  121607. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  121608. /**
  121609. * Get a list of lights by tags
  121610. * @param tagsQuery defines the tags query to use
  121611. * @param forEach defines a predicate used to filter results
  121612. * @returns an array of Light
  121613. */
  121614. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  121615. /**
  121616. * Get a list of materials by tags
  121617. * @param tagsQuery defines the tags query to use
  121618. * @param forEach defines a predicate used to filter results
  121619. * @returns an array of Material
  121620. */
  121621. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  121622. /**
  121623. * Get a list of transform nodes by tags
  121624. * @param tagsQuery defines the tags query to use
  121625. * @param forEach defines a predicate used to filter results
  121626. * @returns an array of TransformNode
  121627. */
  121628. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  121629. /**
  121630. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  121631. * This allowed control for front to back rendering or reversly depending of the special needs.
  121632. *
  121633. * @param renderingGroupId The rendering group id corresponding to its index
  121634. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  121635. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  121636. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  121637. */
  121638. 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;
  121639. /**
  121640. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  121641. *
  121642. * @param renderingGroupId The rendering group id corresponding to its index
  121643. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121644. * @param depth Automatically clears depth between groups if true and autoClear is true.
  121645. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  121646. */
  121647. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  121648. /**
  121649. * Gets the current auto clear configuration for one rendering group of the rendering
  121650. * manager.
  121651. * @param index the rendering group index to get the information for
  121652. * @returns The auto clear setup for the requested rendering group
  121653. */
  121654. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  121655. private _blockMaterialDirtyMechanism;
  121656. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  121657. get blockMaterialDirtyMechanism(): boolean;
  121658. set blockMaterialDirtyMechanism(value: boolean);
  121659. /**
  121660. * Will flag all materials as dirty to trigger new shader compilation
  121661. * @param flag defines the flag used to specify which material part must be marked as dirty
  121662. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  121663. */
  121664. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121665. /** @hidden */
  121666. _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;
  121667. /** @hidden */
  121668. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121669. /** @hidden */
  121670. _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;
  121671. /** @hidden */
  121672. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  121673. /** @hidden */
  121674. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  121675. /** @hidden */
  121676. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121677. }
  121678. }
  121679. declare module BABYLON {
  121680. /**
  121681. * Set of assets to keep when moving a scene into an asset container.
  121682. */
  121683. export class KeepAssets extends AbstractScene {
  121684. }
  121685. /**
  121686. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  121687. */
  121688. export class InstantiatedEntries {
  121689. /**
  121690. * List of new root nodes (eg. nodes with no parent)
  121691. */
  121692. rootNodes: TransformNode[];
  121693. /**
  121694. * List of new skeletons
  121695. */
  121696. skeletons: Skeleton[];
  121697. /**
  121698. * List of new animation groups
  121699. */
  121700. animationGroups: AnimationGroup[];
  121701. }
  121702. /**
  121703. * Container with a set of assets that can be added or removed from a scene.
  121704. */
  121705. export class AssetContainer extends AbstractScene {
  121706. private _wasAddedToScene;
  121707. /**
  121708. * The scene the AssetContainer belongs to.
  121709. */
  121710. scene: Scene;
  121711. /**
  121712. * Instantiates an AssetContainer.
  121713. * @param scene The scene the AssetContainer belongs to.
  121714. */
  121715. constructor(scene: Scene);
  121716. /**
  121717. * Instantiate or clone all meshes and add the new ones to the scene.
  121718. * Skeletons and animation groups will all be cloned
  121719. * @param nameFunction defines an optional function used to get new names for clones
  121720. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  121721. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  121722. */
  121723. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  121724. /**
  121725. * Adds all the assets from the container to the scene.
  121726. */
  121727. addAllToScene(): void;
  121728. /**
  121729. * Removes all the assets in the container from the scene
  121730. */
  121731. removeAllFromScene(): void;
  121732. /**
  121733. * Disposes all the assets in the container
  121734. */
  121735. dispose(): void;
  121736. private _moveAssets;
  121737. /**
  121738. * Removes all the assets contained in the scene and adds them to the container.
  121739. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  121740. */
  121741. moveAllFromScene(keepAssets?: KeepAssets): void;
  121742. /**
  121743. * 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.
  121744. * @returns the root mesh
  121745. */
  121746. createRootMesh(): Mesh;
  121747. /**
  121748. * Merge animations (direct and animation groups) from this asset container into a scene
  121749. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  121750. * @param animatables set of animatables to retarget to a node from the scene
  121751. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  121752. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  121753. */
  121754. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  121755. }
  121756. }
  121757. declare module BABYLON {
  121758. /**
  121759. * Defines how the parser contract is defined.
  121760. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  121761. */
  121762. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  121763. /**
  121764. * Defines how the individual parser contract is defined.
  121765. * These parser can parse an individual asset
  121766. */
  121767. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  121768. /**
  121769. * Base class of the scene acting as a container for the different elements composing a scene.
  121770. * This class is dynamically extended by the different components of the scene increasing
  121771. * flexibility and reducing coupling
  121772. */
  121773. export abstract class AbstractScene {
  121774. /**
  121775. * Stores the list of available parsers in the application.
  121776. */
  121777. private static _BabylonFileParsers;
  121778. /**
  121779. * Stores the list of available individual parsers in the application.
  121780. */
  121781. private static _IndividualBabylonFileParsers;
  121782. /**
  121783. * Adds a parser in the list of available ones
  121784. * @param name Defines the name of the parser
  121785. * @param parser Defines the parser to add
  121786. */
  121787. static AddParser(name: string, parser: BabylonFileParser): void;
  121788. /**
  121789. * Gets a general parser from the list of avaialble ones
  121790. * @param name Defines the name of the parser
  121791. * @returns the requested parser or null
  121792. */
  121793. static GetParser(name: string): Nullable<BabylonFileParser>;
  121794. /**
  121795. * Adds n individual parser in the list of available ones
  121796. * @param name Defines the name of the parser
  121797. * @param parser Defines the parser to add
  121798. */
  121799. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  121800. /**
  121801. * Gets an individual parser from the list of avaialble ones
  121802. * @param name Defines the name of the parser
  121803. * @returns the requested parser or null
  121804. */
  121805. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  121806. /**
  121807. * Parser json data and populate both a scene and its associated container object
  121808. * @param jsonData Defines the data to parse
  121809. * @param scene Defines the scene to parse the data for
  121810. * @param container Defines the container attached to the parsing sequence
  121811. * @param rootUrl Defines the root url of the data
  121812. */
  121813. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  121814. /**
  121815. * Gets the list of root nodes (ie. nodes with no parent)
  121816. */
  121817. rootNodes: Node[];
  121818. /** All of the cameras added to this scene
  121819. * @see https://doc.babylonjs.com/babylon101/cameras
  121820. */
  121821. cameras: Camera[];
  121822. /**
  121823. * All of the lights added to this scene
  121824. * @see https://doc.babylonjs.com/babylon101/lights
  121825. */
  121826. lights: Light[];
  121827. /**
  121828. * All of the (abstract) meshes added to this scene
  121829. */
  121830. meshes: AbstractMesh[];
  121831. /**
  121832. * The list of skeletons added to the scene
  121833. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  121834. */
  121835. skeletons: Skeleton[];
  121836. /**
  121837. * All of the particle systems added to this scene
  121838. * @see https://doc.babylonjs.com/babylon101/particles
  121839. */
  121840. particleSystems: IParticleSystem[];
  121841. /**
  121842. * Gets a list of Animations associated with the scene
  121843. */
  121844. animations: Animation[];
  121845. /**
  121846. * All of the animation groups added to this scene
  121847. * @see https://doc.babylonjs.com/how_to/group
  121848. */
  121849. animationGroups: AnimationGroup[];
  121850. /**
  121851. * All of the multi-materials added to this scene
  121852. * @see https://doc.babylonjs.com/how_to/multi_materials
  121853. */
  121854. multiMaterials: MultiMaterial[];
  121855. /**
  121856. * All of the materials added to this scene
  121857. * In the context of a Scene, it is not supposed to be modified manually.
  121858. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  121859. * Note also that the order of the Material within the array is not significant and might change.
  121860. * @see https://doc.babylonjs.com/babylon101/materials
  121861. */
  121862. materials: Material[];
  121863. /**
  121864. * The list of morph target managers added to the scene
  121865. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  121866. */
  121867. morphTargetManagers: MorphTargetManager[];
  121868. /**
  121869. * The list of geometries used in the scene.
  121870. */
  121871. geometries: Geometry[];
  121872. /**
  121873. * All of the tranform nodes added to this scene
  121874. * In the context of a Scene, it is not supposed to be modified manually.
  121875. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  121876. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  121877. * @see https://doc.babylonjs.com/how_to/transformnode
  121878. */
  121879. transformNodes: TransformNode[];
  121880. /**
  121881. * ActionManagers available on the scene.
  121882. */
  121883. actionManagers: AbstractActionManager[];
  121884. /**
  121885. * Textures to keep.
  121886. */
  121887. textures: BaseTexture[];
  121888. /** @hidden */
  121889. protected _environmentTexture: Nullable<BaseTexture>;
  121890. /**
  121891. * Texture used in all pbr material as the reflection texture.
  121892. * As in the majority of the scene they are the same (exception for multi room and so on),
  121893. * this is easier to reference from here than from all the materials.
  121894. */
  121895. get environmentTexture(): Nullable<BaseTexture>;
  121896. set environmentTexture(value: Nullable<BaseTexture>);
  121897. /**
  121898. * The list of postprocesses added to the scene
  121899. */
  121900. postProcesses: PostProcess[];
  121901. /**
  121902. * @returns all meshes, lights, cameras, transformNodes and bones
  121903. */
  121904. getNodes(): Array<Node>;
  121905. }
  121906. }
  121907. declare module BABYLON {
  121908. /**
  121909. * Interface used to define options for Sound class
  121910. */
  121911. export interface ISoundOptions {
  121912. /**
  121913. * Does the sound autoplay once loaded.
  121914. */
  121915. autoplay?: boolean;
  121916. /**
  121917. * Does the sound loop after it finishes playing once.
  121918. */
  121919. loop?: boolean;
  121920. /**
  121921. * Sound's volume
  121922. */
  121923. volume?: number;
  121924. /**
  121925. * Is it a spatial sound?
  121926. */
  121927. spatialSound?: boolean;
  121928. /**
  121929. * Maximum distance to hear that sound
  121930. */
  121931. maxDistance?: number;
  121932. /**
  121933. * Uses user defined attenuation function
  121934. */
  121935. useCustomAttenuation?: boolean;
  121936. /**
  121937. * Define the roll off factor of spatial sounds.
  121938. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121939. */
  121940. rolloffFactor?: number;
  121941. /**
  121942. * Define the reference distance the sound should be heard perfectly.
  121943. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121944. */
  121945. refDistance?: number;
  121946. /**
  121947. * Define the distance attenuation model the sound will follow.
  121948. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121949. */
  121950. distanceModel?: string;
  121951. /**
  121952. * Defines the playback speed (1 by default)
  121953. */
  121954. playbackRate?: number;
  121955. /**
  121956. * Defines if the sound is from a streaming source
  121957. */
  121958. streaming?: boolean;
  121959. /**
  121960. * Defines an optional length (in seconds) inside the sound file
  121961. */
  121962. length?: number;
  121963. /**
  121964. * Defines an optional offset (in seconds) inside the sound file
  121965. */
  121966. offset?: number;
  121967. /**
  121968. * If true, URLs will not be required to state the audio file codec to use.
  121969. */
  121970. skipCodecCheck?: boolean;
  121971. }
  121972. /**
  121973. * Defines a sound that can be played in the application.
  121974. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  121975. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121976. */
  121977. export class Sound {
  121978. /**
  121979. * The name of the sound in the scene.
  121980. */
  121981. name: string;
  121982. /**
  121983. * Does the sound autoplay once loaded.
  121984. */
  121985. autoplay: boolean;
  121986. /**
  121987. * Does the sound loop after it finishes playing once.
  121988. */
  121989. loop: boolean;
  121990. /**
  121991. * Does the sound use a custom attenuation curve to simulate the falloff
  121992. * happening when the source gets further away from the camera.
  121993. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121994. */
  121995. useCustomAttenuation: boolean;
  121996. /**
  121997. * The sound track id this sound belongs to.
  121998. */
  121999. soundTrackId: number;
  122000. /**
  122001. * Is this sound currently played.
  122002. */
  122003. isPlaying: boolean;
  122004. /**
  122005. * Is this sound currently paused.
  122006. */
  122007. isPaused: boolean;
  122008. /**
  122009. * Does this sound enables spatial sound.
  122010. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122011. */
  122012. spatialSound: boolean;
  122013. /**
  122014. * Define the reference distance the sound should be heard perfectly.
  122015. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122016. */
  122017. refDistance: number;
  122018. /**
  122019. * Define the roll off factor of spatial sounds.
  122020. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122021. */
  122022. rolloffFactor: number;
  122023. /**
  122024. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  122025. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122026. */
  122027. maxDistance: number;
  122028. /**
  122029. * Define the distance attenuation model the sound will follow.
  122030. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122031. */
  122032. distanceModel: string;
  122033. /**
  122034. * @hidden
  122035. * Back Compat
  122036. **/
  122037. onended: () => any;
  122038. /**
  122039. * Gets or sets an object used to store user defined information for the sound.
  122040. */
  122041. metadata: any;
  122042. /**
  122043. * Observable event when the current playing sound finishes.
  122044. */
  122045. onEndedObservable: Observable<Sound>;
  122046. private _panningModel;
  122047. private _playbackRate;
  122048. private _streaming;
  122049. private _startTime;
  122050. private _startOffset;
  122051. private _position;
  122052. /** @hidden */
  122053. _positionInEmitterSpace: boolean;
  122054. private _localDirection;
  122055. private _volume;
  122056. private _isReadyToPlay;
  122057. private _isDirectional;
  122058. private _readyToPlayCallback;
  122059. private _audioBuffer;
  122060. private _soundSource;
  122061. private _streamingSource;
  122062. private _soundPanner;
  122063. private _soundGain;
  122064. private _inputAudioNode;
  122065. private _outputAudioNode;
  122066. private _coneInnerAngle;
  122067. private _coneOuterAngle;
  122068. private _coneOuterGain;
  122069. private _scene;
  122070. private _connectedTransformNode;
  122071. private _customAttenuationFunction;
  122072. private _registerFunc;
  122073. private _isOutputConnected;
  122074. private _htmlAudioElement;
  122075. private _urlType;
  122076. private _length?;
  122077. private _offset?;
  122078. /** @hidden */
  122079. static _SceneComponentInitialization: (scene: Scene) => void;
  122080. /**
  122081. * Create a sound and attach it to a scene
  122082. * @param name Name of your sound
  122083. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  122084. * @param scene defines the scene the sound belongs to
  122085. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  122086. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  122087. */
  122088. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  122089. /**
  122090. * Release the sound and its associated resources
  122091. */
  122092. dispose(): void;
  122093. /**
  122094. * Gets if the sounds is ready to be played or not.
  122095. * @returns true if ready, otherwise false
  122096. */
  122097. isReady(): boolean;
  122098. private _soundLoaded;
  122099. /**
  122100. * Sets the data of the sound from an audiobuffer
  122101. * @param audioBuffer The audioBuffer containing the data
  122102. */
  122103. setAudioBuffer(audioBuffer: AudioBuffer): void;
  122104. /**
  122105. * Updates the current sounds options such as maxdistance, loop...
  122106. * @param options A JSON object containing values named as the object properties
  122107. */
  122108. updateOptions(options: ISoundOptions): void;
  122109. private _createSpatialParameters;
  122110. private _updateSpatialParameters;
  122111. /**
  122112. * Switch the panning model to HRTF:
  122113. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122114. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122115. */
  122116. switchPanningModelToHRTF(): void;
  122117. /**
  122118. * Switch the panning model to Equal Power:
  122119. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122120. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122121. */
  122122. switchPanningModelToEqualPower(): void;
  122123. private _switchPanningModel;
  122124. /**
  122125. * Connect this sound to a sound track audio node like gain...
  122126. * @param soundTrackAudioNode the sound track audio node to connect to
  122127. */
  122128. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  122129. /**
  122130. * Transform this sound into a directional source
  122131. * @param coneInnerAngle Size of the inner cone in degree
  122132. * @param coneOuterAngle Size of the outer cone in degree
  122133. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  122134. */
  122135. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  122136. /**
  122137. * Gets or sets the inner angle for the directional cone.
  122138. */
  122139. get directionalConeInnerAngle(): number;
  122140. /**
  122141. * Gets or sets the inner angle for the directional cone.
  122142. */
  122143. set directionalConeInnerAngle(value: number);
  122144. /**
  122145. * Gets or sets the outer angle for the directional cone.
  122146. */
  122147. get directionalConeOuterAngle(): number;
  122148. /**
  122149. * Gets or sets the outer angle for the directional cone.
  122150. */
  122151. set directionalConeOuterAngle(value: number);
  122152. /**
  122153. * Sets the position of the emitter if spatial sound is enabled
  122154. * @param newPosition Defines the new posisiton
  122155. */
  122156. setPosition(newPosition: Vector3): void;
  122157. /**
  122158. * Sets the local direction of the emitter if spatial sound is enabled
  122159. * @param newLocalDirection Defines the new local direction
  122160. */
  122161. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  122162. private _updateDirection;
  122163. /** @hidden */
  122164. updateDistanceFromListener(): void;
  122165. /**
  122166. * Sets a new custom attenuation function for the sound.
  122167. * @param callback Defines the function used for the attenuation
  122168. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  122169. */
  122170. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  122171. /**
  122172. * Play the sound
  122173. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  122174. * @param offset (optional) Start the sound at a specific time in seconds
  122175. * @param length (optional) Sound duration (in seconds)
  122176. */
  122177. play(time?: number, offset?: number, length?: number): void;
  122178. private _onended;
  122179. /**
  122180. * Stop the sound
  122181. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  122182. */
  122183. stop(time?: number): void;
  122184. /**
  122185. * Put the sound in pause
  122186. */
  122187. pause(): void;
  122188. /**
  122189. * Sets a dedicated volume for this sounds
  122190. * @param newVolume Define the new volume of the sound
  122191. * @param time Define time for gradual change to new volume
  122192. */
  122193. setVolume(newVolume: number, time?: number): void;
  122194. /**
  122195. * Set the sound play back rate
  122196. * @param newPlaybackRate Define the playback rate the sound should be played at
  122197. */
  122198. setPlaybackRate(newPlaybackRate: number): void;
  122199. /**
  122200. * Gets the volume of the sound.
  122201. * @returns the volume of the sound
  122202. */
  122203. getVolume(): number;
  122204. /**
  122205. * Attach the sound to a dedicated mesh
  122206. * @param transformNode The transform node to connect the sound with
  122207. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  122208. */
  122209. attachToMesh(transformNode: TransformNode): void;
  122210. /**
  122211. * Detach the sound from the previously attached mesh
  122212. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  122213. */
  122214. detachFromMesh(): void;
  122215. private _onRegisterAfterWorldMatrixUpdate;
  122216. /**
  122217. * Clone the current sound in the scene.
  122218. * @returns the new sound clone
  122219. */
  122220. clone(): Nullable<Sound>;
  122221. /**
  122222. * Gets the current underlying audio buffer containing the data
  122223. * @returns the audio buffer
  122224. */
  122225. getAudioBuffer(): Nullable<AudioBuffer>;
  122226. /**
  122227. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  122228. * @returns the source node
  122229. */
  122230. getSoundSource(): Nullable<AudioBufferSourceNode>;
  122231. /**
  122232. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  122233. * @returns the gain node
  122234. */
  122235. getSoundGain(): Nullable<GainNode>;
  122236. /**
  122237. * Serializes the Sound in a JSON representation
  122238. * @returns the JSON representation of the sound
  122239. */
  122240. serialize(): any;
  122241. /**
  122242. * Parse a JSON representation of a sound to innstantiate in a given scene
  122243. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  122244. * @param scene Define the scene the new parsed sound should be created in
  122245. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  122246. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  122247. * @returns the newly parsed sound
  122248. */
  122249. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  122250. }
  122251. }
  122252. declare module BABYLON {
  122253. /**
  122254. * This defines an action helpful to play a defined sound on a triggered action.
  122255. */
  122256. export class PlaySoundAction extends Action {
  122257. private _sound;
  122258. /**
  122259. * Instantiate the action
  122260. * @param triggerOptions defines the trigger options
  122261. * @param sound defines the sound to play
  122262. * @param condition defines the trigger related conditions
  122263. */
  122264. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  122265. /** @hidden */
  122266. _prepare(): void;
  122267. /**
  122268. * Execute the action and play the sound.
  122269. */
  122270. execute(): void;
  122271. /**
  122272. * Serializes the actions and its related information.
  122273. * @param parent defines the object to serialize in
  122274. * @returns the serialized object
  122275. */
  122276. serialize(parent: any): any;
  122277. }
  122278. /**
  122279. * This defines an action helpful to stop a defined sound on a triggered action.
  122280. */
  122281. export class StopSoundAction extends Action {
  122282. private _sound;
  122283. /**
  122284. * Instantiate the action
  122285. * @param triggerOptions defines the trigger options
  122286. * @param sound defines the sound to stop
  122287. * @param condition defines the trigger related conditions
  122288. */
  122289. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  122290. /** @hidden */
  122291. _prepare(): void;
  122292. /**
  122293. * Execute the action and stop the sound.
  122294. */
  122295. execute(): void;
  122296. /**
  122297. * Serializes the actions and its related information.
  122298. * @param parent defines the object to serialize in
  122299. * @returns the serialized object
  122300. */
  122301. serialize(parent: any): any;
  122302. }
  122303. }
  122304. declare module BABYLON {
  122305. /**
  122306. * This defines an action responsible to change the value of a property
  122307. * by interpolating between its current value and the newly set one once triggered.
  122308. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  122309. */
  122310. export class InterpolateValueAction extends Action {
  122311. /**
  122312. * Defines the path of the property where the value should be interpolated
  122313. */
  122314. propertyPath: string;
  122315. /**
  122316. * Defines the target value at the end of the interpolation.
  122317. */
  122318. value: any;
  122319. /**
  122320. * Defines the time it will take for the property to interpolate to the value.
  122321. */
  122322. duration: number;
  122323. /**
  122324. * Defines if the other scene animations should be stopped when the action has been triggered
  122325. */
  122326. stopOtherAnimations?: boolean;
  122327. /**
  122328. * Defines a callback raised once the interpolation animation has been done.
  122329. */
  122330. onInterpolationDone?: () => void;
  122331. /**
  122332. * Observable triggered once the interpolation animation has been done.
  122333. */
  122334. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  122335. private _target;
  122336. private _effectiveTarget;
  122337. private _property;
  122338. /**
  122339. * Instantiate the action
  122340. * @param triggerOptions defines the trigger options
  122341. * @param target defines the object containing the value to interpolate
  122342. * @param propertyPath defines the path to the property in the target object
  122343. * @param value defines the target value at the end of the interpolation
  122344. * @param duration deines the time it will take for the property to interpolate to the value.
  122345. * @param condition defines the trigger related conditions
  122346. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  122347. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  122348. */
  122349. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  122350. /** @hidden */
  122351. _prepare(): void;
  122352. /**
  122353. * Execute the action starts the value interpolation.
  122354. */
  122355. execute(): void;
  122356. /**
  122357. * Serializes the actions and its related information.
  122358. * @param parent defines the object to serialize in
  122359. * @returns the serialized object
  122360. */
  122361. serialize(parent: any): any;
  122362. }
  122363. }
  122364. declare module BABYLON {
  122365. /**
  122366. * Options allowed during the creation of a sound track.
  122367. */
  122368. export interface ISoundTrackOptions {
  122369. /**
  122370. * The volume the sound track should take during creation
  122371. */
  122372. volume?: number;
  122373. /**
  122374. * Define if the sound track is the main sound track of the scene
  122375. */
  122376. mainTrack?: boolean;
  122377. }
  122378. /**
  122379. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  122380. * It will be also used in a future release to apply effects on a specific track.
  122381. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122382. */
  122383. export class SoundTrack {
  122384. /**
  122385. * The unique identifier of the sound track in the scene.
  122386. */
  122387. id: number;
  122388. /**
  122389. * The list of sounds included in the sound track.
  122390. */
  122391. soundCollection: Array<Sound>;
  122392. private _outputAudioNode;
  122393. private _scene;
  122394. private _connectedAnalyser;
  122395. private _options;
  122396. private _isInitialized;
  122397. /**
  122398. * Creates a new sound track.
  122399. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122400. * @param scene Define the scene the sound track belongs to
  122401. * @param options
  122402. */
  122403. constructor(scene: Scene, options?: ISoundTrackOptions);
  122404. private _initializeSoundTrackAudioGraph;
  122405. /**
  122406. * Release the sound track and its associated resources
  122407. */
  122408. dispose(): void;
  122409. /**
  122410. * Adds a sound to this sound track
  122411. * @param sound define the cound to add
  122412. * @ignoreNaming
  122413. */
  122414. AddSound(sound: Sound): void;
  122415. /**
  122416. * Removes a sound to this sound track
  122417. * @param sound define the cound to remove
  122418. * @ignoreNaming
  122419. */
  122420. RemoveSound(sound: Sound): void;
  122421. /**
  122422. * Set a global volume for the full sound track.
  122423. * @param newVolume Define the new volume of the sound track
  122424. */
  122425. setVolume(newVolume: number): void;
  122426. /**
  122427. * Switch the panning model to HRTF:
  122428. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122429. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122430. */
  122431. switchPanningModelToHRTF(): void;
  122432. /**
  122433. * Switch the panning model to Equal Power:
  122434. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122435. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122436. */
  122437. switchPanningModelToEqualPower(): void;
  122438. /**
  122439. * Connect the sound track to an audio analyser allowing some amazing
  122440. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  122441. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  122442. * @param analyser The analyser to connect to the engine
  122443. */
  122444. connectToAnalyser(analyser: Analyser): void;
  122445. }
  122446. }
  122447. declare module BABYLON {
  122448. interface AbstractScene {
  122449. /**
  122450. * The list of sounds used in the scene.
  122451. */
  122452. sounds: Nullable<Array<Sound>>;
  122453. }
  122454. interface Scene {
  122455. /**
  122456. * @hidden
  122457. * Backing field
  122458. */
  122459. _mainSoundTrack: SoundTrack;
  122460. /**
  122461. * The main sound track played by the scene.
  122462. * It cotains your primary collection of sounds.
  122463. */
  122464. mainSoundTrack: SoundTrack;
  122465. /**
  122466. * The list of sound tracks added to the scene
  122467. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122468. */
  122469. soundTracks: Nullable<Array<SoundTrack>>;
  122470. /**
  122471. * Gets a sound using a given name
  122472. * @param name defines the name to search for
  122473. * @return the found sound or null if not found at all.
  122474. */
  122475. getSoundByName(name: string): Nullable<Sound>;
  122476. /**
  122477. * Gets or sets if audio support is enabled
  122478. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122479. */
  122480. audioEnabled: boolean;
  122481. /**
  122482. * Gets or sets if audio will be output to headphones
  122483. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122484. */
  122485. headphone: boolean;
  122486. /**
  122487. * Gets or sets custom audio listener position provider
  122488. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122489. */
  122490. audioListenerPositionProvider: Nullable<() => Vector3>;
  122491. /**
  122492. * Gets or sets a refresh rate when using 3D audio positioning
  122493. */
  122494. audioPositioningRefreshRate: number;
  122495. }
  122496. /**
  122497. * Defines the sound scene component responsible to manage any sounds
  122498. * in a given scene.
  122499. */
  122500. export class AudioSceneComponent implements ISceneSerializableComponent {
  122501. private static _CameraDirectionLH;
  122502. private static _CameraDirectionRH;
  122503. /**
  122504. * The component name helpfull to identify the component in the list of scene components.
  122505. */
  122506. readonly name: string;
  122507. /**
  122508. * The scene the component belongs to.
  122509. */
  122510. scene: Scene;
  122511. private _audioEnabled;
  122512. /**
  122513. * Gets whether audio is enabled or not.
  122514. * Please use related enable/disable method to switch state.
  122515. */
  122516. get audioEnabled(): boolean;
  122517. private _headphone;
  122518. /**
  122519. * Gets whether audio is outputing to headphone or not.
  122520. * Please use the according Switch methods to change output.
  122521. */
  122522. get headphone(): boolean;
  122523. /**
  122524. * Gets or sets a refresh rate when using 3D audio positioning
  122525. */
  122526. audioPositioningRefreshRate: number;
  122527. private _audioListenerPositionProvider;
  122528. /**
  122529. * Gets the current audio listener position provider
  122530. */
  122531. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  122532. /**
  122533. * Sets a custom listener position for all sounds in the scene
  122534. * By default, this is the position of the first active camera
  122535. */
  122536. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  122537. /**
  122538. * Creates a new instance of the component for the given scene
  122539. * @param scene Defines the scene to register the component in
  122540. */
  122541. constructor(scene: Scene);
  122542. /**
  122543. * Registers the component in a given scene
  122544. */
  122545. register(): void;
  122546. /**
  122547. * Rebuilds the elements related to this component in case of
  122548. * context lost for instance.
  122549. */
  122550. rebuild(): void;
  122551. /**
  122552. * Serializes the component data to the specified json object
  122553. * @param serializationObject The object to serialize to
  122554. */
  122555. serialize(serializationObject: any): void;
  122556. /**
  122557. * Adds all the elements from the container to the scene
  122558. * @param container the container holding the elements
  122559. */
  122560. addFromContainer(container: AbstractScene): void;
  122561. /**
  122562. * Removes all the elements in the container from the scene
  122563. * @param container contains the elements to remove
  122564. * @param dispose if the removed element should be disposed (default: false)
  122565. */
  122566. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122567. /**
  122568. * Disposes the component and the associated ressources.
  122569. */
  122570. dispose(): void;
  122571. /**
  122572. * Disables audio in the associated scene.
  122573. */
  122574. disableAudio(): void;
  122575. /**
  122576. * Enables audio in the associated scene.
  122577. */
  122578. enableAudio(): void;
  122579. /**
  122580. * Switch audio to headphone output.
  122581. */
  122582. switchAudioModeForHeadphones(): void;
  122583. /**
  122584. * Switch audio to normal speakers.
  122585. */
  122586. switchAudioModeForNormalSpeakers(): void;
  122587. private _cachedCameraDirection;
  122588. private _cachedCameraPosition;
  122589. private _lastCheck;
  122590. private _afterRender;
  122591. }
  122592. }
  122593. declare module BABYLON {
  122594. /**
  122595. * Wraps one or more Sound objects and selects one with random weight for playback.
  122596. */
  122597. export class WeightedSound {
  122598. /** When true a Sound will be selected and played when the current playing Sound completes. */
  122599. loop: boolean;
  122600. private _coneInnerAngle;
  122601. private _coneOuterAngle;
  122602. private _volume;
  122603. /** A Sound is currently playing. */
  122604. isPlaying: boolean;
  122605. /** A Sound is currently paused. */
  122606. isPaused: boolean;
  122607. private _sounds;
  122608. private _weights;
  122609. private _currentIndex?;
  122610. /**
  122611. * Creates a new WeightedSound from the list of sounds given.
  122612. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  122613. * @param sounds Array of Sounds that will be selected from.
  122614. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  122615. */
  122616. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  122617. /**
  122618. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  122619. */
  122620. get directionalConeInnerAngle(): number;
  122621. /**
  122622. * The size of cone in degress for a directional sound in which there will be no attenuation.
  122623. */
  122624. set directionalConeInnerAngle(value: number);
  122625. /**
  122626. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122627. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122628. */
  122629. get directionalConeOuterAngle(): number;
  122630. /**
  122631. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122632. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122633. */
  122634. set directionalConeOuterAngle(value: number);
  122635. /**
  122636. * Playback volume.
  122637. */
  122638. get volume(): number;
  122639. /**
  122640. * Playback volume.
  122641. */
  122642. set volume(value: number);
  122643. private _onended;
  122644. /**
  122645. * Suspend playback
  122646. */
  122647. pause(): void;
  122648. /**
  122649. * Stop playback
  122650. */
  122651. stop(): void;
  122652. /**
  122653. * Start playback.
  122654. * @param startOffset Position the clip head at a specific time in seconds.
  122655. */
  122656. play(startOffset?: number): void;
  122657. }
  122658. }
  122659. declare module BABYLON {
  122660. /**
  122661. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  122662. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122663. */
  122664. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  122665. /**
  122666. * Gets the name of the behavior.
  122667. */
  122668. get name(): string;
  122669. /**
  122670. * The easing function used by animations
  122671. */
  122672. static EasingFunction: BackEase;
  122673. /**
  122674. * The easing mode used by animations
  122675. */
  122676. static EasingMode: number;
  122677. /**
  122678. * The duration of the animation, in milliseconds
  122679. */
  122680. transitionDuration: number;
  122681. /**
  122682. * Length of the distance animated by the transition when lower radius is reached
  122683. */
  122684. lowerRadiusTransitionRange: number;
  122685. /**
  122686. * Length of the distance animated by the transition when upper radius is reached
  122687. */
  122688. upperRadiusTransitionRange: number;
  122689. private _autoTransitionRange;
  122690. /**
  122691. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122692. */
  122693. get autoTransitionRange(): boolean;
  122694. /**
  122695. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122696. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  122697. */
  122698. set autoTransitionRange(value: boolean);
  122699. private _attachedCamera;
  122700. private _onAfterCheckInputsObserver;
  122701. private _onMeshTargetChangedObserver;
  122702. /**
  122703. * Initializes the behavior.
  122704. */
  122705. init(): void;
  122706. /**
  122707. * Attaches the behavior to its arc rotate camera.
  122708. * @param camera Defines the camera to attach the behavior to
  122709. */
  122710. attach(camera: ArcRotateCamera): void;
  122711. /**
  122712. * Detaches the behavior from its current arc rotate camera.
  122713. */
  122714. detach(): void;
  122715. private _radiusIsAnimating;
  122716. private _radiusBounceTransition;
  122717. private _animatables;
  122718. private _cachedWheelPrecision;
  122719. /**
  122720. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  122721. * @param radiusLimit The limit to check against.
  122722. * @return Bool to indicate if at limit.
  122723. */
  122724. private _isRadiusAtLimit;
  122725. /**
  122726. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  122727. * @param radiusDelta The delta by which to animate to. Can be negative.
  122728. */
  122729. private _applyBoundRadiusAnimation;
  122730. /**
  122731. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  122732. */
  122733. protected _clearAnimationLocks(): void;
  122734. /**
  122735. * Stops and removes all animations that have been applied to the camera
  122736. */
  122737. stopAllAnimations(): void;
  122738. }
  122739. }
  122740. declare module BABYLON {
  122741. /**
  122742. * 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.
  122743. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122744. */
  122745. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  122746. /**
  122747. * Gets the name of the behavior.
  122748. */
  122749. get name(): string;
  122750. private _mode;
  122751. private _radiusScale;
  122752. private _positionScale;
  122753. private _defaultElevation;
  122754. private _elevationReturnTime;
  122755. private _elevationReturnWaitTime;
  122756. private _zoomStopsAnimation;
  122757. private _framingTime;
  122758. /**
  122759. * The easing function used by animations
  122760. */
  122761. static EasingFunction: ExponentialEase;
  122762. /**
  122763. * The easing mode used by animations
  122764. */
  122765. static EasingMode: number;
  122766. /**
  122767. * Sets the current mode used by the behavior
  122768. */
  122769. set mode(mode: number);
  122770. /**
  122771. * Gets current mode used by the behavior.
  122772. */
  122773. get mode(): number;
  122774. /**
  122775. * Sets the scale applied to the radius (1 by default)
  122776. */
  122777. set radiusScale(radius: number);
  122778. /**
  122779. * Gets the scale applied to the radius
  122780. */
  122781. get radiusScale(): number;
  122782. /**
  122783. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122784. */
  122785. set positionScale(scale: number);
  122786. /**
  122787. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122788. */
  122789. get positionScale(): number;
  122790. /**
  122791. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122792. * behaviour is triggered, in radians.
  122793. */
  122794. set defaultElevation(elevation: number);
  122795. /**
  122796. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122797. * behaviour is triggered, in radians.
  122798. */
  122799. get defaultElevation(): number;
  122800. /**
  122801. * Sets the time (in milliseconds) taken to return to the default beta position.
  122802. * Negative value indicates camera should not return to default.
  122803. */
  122804. set elevationReturnTime(speed: number);
  122805. /**
  122806. * Gets the time (in milliseconds) taken to return to the default beta position.
  122807. * Negative value indicates camera should not return to default.
  122808. */
  122809. get elevationReturnTime(): number;
  122810. /**
  122811. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122812. */
  122813. set elevationReturnWaitTime(time: number);
  122814. /**
  122815. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122816. */
  122817. get elevationReturnWaitTime(): number;
  122818. /**
  122819. * Sets the flag that indicates if user zooming should stop animation.
  122820. */
  122821. set zoomStopsAnimation(flag: boolean);
  122822. /**
  122823. * Gets the flag that indicates if user zooming should stop animation.
  122824. */
  122825. get zoomStopsAnimation(): boolean;
  122826. /**
  122827. * Sets the transition time when framing the mesh, in milliseconds
  122828. */
  122829. set framingTime(time: number);
  122830. /**
  122831. * Gets the transition time when framing the mesh, in milliseconds
  122832. */
  122833. get framingTime(): number;
  122834. /**
  122835. * Define if the behavior should automatically change the configured
  122836. * camera limits and sensibilities.
  122837. */
  122838. autoCorrectCameraLimitsAndSensibility: boolean;
  122839. private _onPrePointerObservableObserver;
  122840. private _onAfterCheckInputsObserver;
  122841. private _onMeshTargetChangedObserver;
  122842. private _attachedCamera;
  122843. private _isPointerDown;
  122844. private _lastInteractionTime;
  122845. /**
  122846. * Initializes the behavior.
  122847. */
  122848. init(): void;
  122849. /**
  122850. * Attaches the behavior to its arc rotate camera.
  122851. * @param camera Defines the camera to attach the behavior to
  122852. */
  122853. attach(camera: ArcRotateCamera): void;
  122854. /**
  122855. * Detaches the behavior from its current arc rotate camera.
  122856. */
  122857. detach(): void;
  122858. private _animatables;
  122859. private _betaIsAnimating;
  122860. private _betaTransition;
  122861. private _radiusTransition;
  122862. private _vectorTransition;
  122863. /**
  122864. * Targets the given mesh and updates zoom level accordingly.
  122865. * @param mesh The mesh to target.
  122866. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122867. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122868. */
  122869. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122870. /**
  122871. * Targets the given mesh with its children and updates zoom level accordingly.
  122872. * @param mesh The mesh to target.
  122873. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122874. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122875. */
  122876. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122877. /**
  122878. * Targets the given meshes with their children and updates zoom level accordingly.
  122879. * @param meshes The mesh to target.
  122880. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122881. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122882. */
  122883. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122884. /**
  122885. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  122886. * @param minimumWorld Determines the smaller position of the bounding box extend
  122887. * @param maximumWorld Determines the bigger position of the bounding box extend
  122888. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122889. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122890. */
  122891. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122892. /**
  122893. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  122894. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  122895. * frustum width.
  122896. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  122897. * to fully enclose the mesh in the viewing frustum.
  122898. */
  122899. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  122900. /**
  122901. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  122902. * is automatically returned to its default position (expected to be above ground plane).
  122903. */
  122904. private _maintainCameraAboveGround;
  122905. /**
  122906. * Returns the frustum slope based on the canvas ratio and camera FOV
  122907. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  122908. */
  122909. private _getFrustumSlope;
  122910. /**
  122911. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  122912. */
  122913. private _clearAnimationLocks;
  122914. /**
  122915. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122916. */
  122917. private _applyUserInteraction;
  122918. /**
  122919. * Stops and removes all animations that have been applied to the camera
  122920. */
  122921. stopAllAnimations(): void;
  122922. /**
  122923. * Gets a value indicating if the user is moving the camera
  122924. */
  122925. get isUserIsMoving(): boolean;
  122926. /**
  122927. * The camera can move all the way towards the mesh.
  122928. */
  122929. static IgnoreBoundsSizeMode: number;
  122930. /**
  122931. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  122932. */
  122933. static FitFrustumSidesMode: number;
  122934. }
  122935. }
  122936. declare module BABYLON {
  122937. /**
  122938. * Base class for Camera Pointer Inputs.
  122939. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  122940. * for example usage.
  122941. */
  122942. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  122943. /**
  122944. * Defines the camera the input is attached to.
  122945. */
  122946. abstract camera: Camera;
  122947. /**
  122948. * Whether keyboard modifier keys are pressed at time of last mouse event.
  122949. */
  122950. protected _altKey: boolean;
  122951. protected _ctrlKey: boolean;
  122952. protected _metaKey: boolean;
  122953. protected _shiftKey: boolean;
  122954. /**
  122955. * Which mouse buttons were pressed at time of last mouse event.
  122956. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  122957. */
  122958. protected _buttonsPressed: number;
  122959. /**
  122960. * Defines the buttons associated with the input to handle camera move.
  122961. */
  122962. buttons: number[];
  122963. /**
  122964. * Attach the input controls to a specific dom element to get the input from.
  122965. * @param element Defines the element the controls should be listened from
  122966. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122967. */
  122968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122969. /**
  122970. * Detach the current controls from the specified dom element.
  122971. * @param element Defines the element to stop listening the inputs from
  122972. */
  122973. detachControl(element: Nullable<HTMLElement>): void;
  122974. /**
  122975. * Gets the class name of the current input.
  122976. * @returns the class name
  122977. */
  122978. getClassName(): string;
  122979. /**
  122980. * Get the friendly name associated with the input class.
  122981. * @returns the input friendly name
  122982. */
  122983. getSimpleName(): string;
  122984. /**
  122985. * Called on pointer POINTERDOUBLETAP event.
  122986. * Override this method to provide functionality on POINTERDOUBLETAP event.
  122987. */
  122988. protected onDoubleTap(type: string): void;
  122989. /**
  122990. * Called on pointer POINTERMOVE event if only a single touch is active.
  122991. * Override this method to provide functionality.
  122992. */
  122993. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122994. /**
  122995. * Called on pointer POINTERMOVE event if multiple touches are active.
  122996. * Override this method to provide functionality.
  122997. */
  122998. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122999. /**
  123000. * Called on JS contextmenu event.
  123001. * Override this method to provide functionality.
  123002. */
  123003. protected onContextMenu(evt: PointerEvent): void;
  123004. /**
  123005. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  123006. * press.
  123007. * Override this method to provide functionality.
  123008. */
  123009. protected onButtonDown(evt: PointerEvent): void;
  123010. /**
  123011. * Called each time a new POINTERUP event occurs. Ie, for each button
  123012. * release.
  123013. * Override this method to provide functionality.
  123014. */
  123015. protected onButtonUp(evt: PointerEvent): void;
  123016. /**
  123017. * Called when window becomes inactive.
  123018. * Override this method to provide functionality.
  123019. */
  123020. protected onLostFocus(): void;
  123021. private _pointerInput;
  123022. private _observer;
  123023. private _onLostFocus;
  123024. private pointA;
  123025. private pointB;
  123026. }
  123027. }
  123028. declare module BABYLON {
  123029. /**
  123030. * Manage the pointers inputs to control an arc rotate camera.
  123031. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123032. */
  123033. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  123034. /**
  123035. * Defines the camera the input is attached to.
  123036. */
  123037. camera: ArcRotateCamera;
  123038. /**
  123039. * Gets the class name of the current input.
  123040. * @returns the class name
  123041. */
  123042. getClassName(): string;
  123043. /**
  123044. * Defines the buttons associated with the input to handle camera move.
  123045. */
  123046. buttons: number[];
  123047. /**
  123048. * Defines the pointer angular sensibility along the X axis or how fast is
  123049. * the camera rotating.
  123050. */
  123051. angularSensibilityX: number;
  123052. /**
  123053. * Defines the pointer angular sensibility along the Y axis or how fast is
  123054. * the camera rotating.
  123055. */
  123056. angularSensibilityY: number;
  123057. /**
  123058. * Defines the pointer pinch precision or how fast is the camera zooming.
  123059. */
  123060. pinchPrecision: number;
  123061. /**
  123062. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  123063. * from 0.
  123064. * It defines the percentage of current camera.radius to use as delta when
  123065. * pinch zoom is used.
  123066. */
  123067. pinchDeltaPercentage: number;
  123068. /**
  123069. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  123070. * that any object in the plane at the camera's target point will scale
  123071. * perfectly with finger motion.
  123072. * Overrides pinchDeltaPercentage and pinchPrecision.
  123073. */
  123074. useNaturalPinchZoom: boolean;
  123075. /**
  123076. * Defines the pointer panning sensibility or how fast is the camera moving.
  123077. */
  123078. panningSensibility: number;
  123079. /**
  123080. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  123081. */
  123082. multiTouchPanning: boolean;
  123083. /**
  123084. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  123085. * zoom (pinch) through multitouch.
  123086. */
  123087. multiTouchPanAndZoom: boolean;
  123088. /**
  123089. * Revers pinch action direction.
  123090. */
  123091. pinchInwards: boolean;
  123092. private _isPanClick;
  123093. private _twoFingerActivityCount;
  123094. private _isPinching;
  123095. /**
  123096. * Called on pointer POINTERMOVE event if only a single touch is active.
  123097. */
  123098. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123099. /**
  123100. * Called on pointer POINTERDOUBLETAP event.
  123101. */
  123102. protected onDoubleTap(type: string): void;
  123103. /**
  123104. * Called on pointer POINTERMOVE event if multiple touches are active.
  123105. */
  123106. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123107. /**
  123108. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  123109. * press.
  123110. */
  123111. protected onButtonDown(evt: PointerEvent): void;
  123112. /**
  123113. * Called each time a new POINTERUP event occurs. Ie, for each button
  123114. * release.
  123115. */
  123116. protected onButtonUp(evt: PointerEvent): void;
  123117. /**
  123118. * Called when window becomes inactive.
  123119. */
  123120. protected onLostFocus(): void;
  123121. }
  123122. }
  123123. declare module BABYLON {
  123124. /**
  123125. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  123126. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123127. */
  123128. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  123129. /**
  123130. * Defines the camera the input is attached to.
  123131. */
  123132. camera: ArcRotateCamera;
  123133. /**
  123134. * Defines the list of key codes associated with the up action (increase alpha)
  123135. */
  123136. keysUp: number[];
  123137. /**
  123138. * Defines the list of key codes associated with the down action (decrease alpha)
  123139. */
  123140. keysDown: number[];
  123141. /**
  123142. * Defines the list of key codes associated with the left action (increase beta)
  123143. */
  123144. keysLeft: number[];
  123145. /**
  123146. * Defines the list of key codes associated with the right action (decrease beta)
  123147. */
  123148. keysRight: number[];
  123149. /**
  123150. * Defines the list of key codes associated with the reset action.
  123151. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  123152. */
  123153. keysReset: number[];
  123154. /**
  123155. * Defines the panning sensibility of the inputs.
  123156. * (How fast is the camera panning)
  123157. */
  123158. panningSensibility: number;
  123159. /**
  123160. * Defines the zooming sensibility of the inputs.
  123161. * (How fast is the camera zooming)
  123162. */
  123163. zoomingSensibility: number;
  123164. /**
  123165. * Defines whether maintaining the alt key down switch the movement mode from
  123166. * orientation to zoom.
  123167. */
  123168. useAltToZoom: boolean;
  123169. /**
  123170. * Rotation speed of the camera
  123171. */
  123172. angularSpeed: number;
  123173. private _keys;
  123174. private _ctrlPressed;
  123175. private _altPressed;
  123176. private _onCanvasBlurObserver;
  123177. private _onKeyboardObserver;
  123178. private _engine;
  123179. private _scene;
  123180. /**
  123181. * Attach the input controls to a specific dom element to get the input from.
  123182. * @param element Defines the element the controls should be listened from
  123183. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123184. */
  123185. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123186. /**
  123187. * Detach the current controls from the specified dom element.
  123188. * @param element Defines the element to stop listening the inputs from
  123189. */
  123190. detachControl(element: Nullable<HTMLElement>): void;
  123191. /**
  123192. * Update the current camera state depending on the inputs that have been used this frame.
  123193. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123194. */
  123195. checkInputs(): void;
  123196. /**
  123197. * Gets the class name of the current intput.
  123198. * @returns the class name
  123199. */
  123200. getClassName(): string;
  123201. /**
  123202. * Get the friendly name associated with the input class.
  123203. * @returns the input friendly name
  123204. */
  123205. getSimpleName(): string;
  123206. }
  123207. }
  123208. declare module BABYLON {
  123209. /**
  123210. * Manage the mouse wheel inputs to control an arc rotate camera.
  123211. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123212. */
  123213. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  123214. /**
  123215. * Defines the camera the input is attached to.
  123216. */
  123217. camera: ArcRotateCamera;
  123218. /**
  123219. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123220. */
  123221. wheelPrecision: number;
  123222. /**
  123223. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  123224. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  123225. */
  123226. wheelDeltaPercentage: number;
  123227. private _wheel;
  123228. private _observer;
  123229. private computeDeltaFromMouseWheelLegacyEvent;
  123230. /**
  123231. * Attach the input controls to a specific dom element to get the input from.
  123232. * @param element Defines the element the controls should be listened from
  123233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123234. */
  123235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123236. /**
  123237. * Detach the current controls from the specified dom element.
  123238. * @param element Defines the element to stop listening the inputs from
  123239. */
  123240. detachControl(element: Nullable<HTMLElement>): void;
  123241. /**
  123242. * Gets the class name of the current intput.
  123243. * @returns the class name
  123244. */
  123245. getClassName(): string;
  123246. /**
  123247. * Get the friendly name associated with the input class.
  123248. * @returns the input friendly name
  123249. */
  123250. getSimpleName(): string;
  123251. }
  123252. }
  123253. declare module BABYLON {
  123254. /**
  123255. * Default Inputs manager for the ArcRotateCamera.
  123256. * It groups all the default supported inputs for ease of use.
  123257. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123258. */
  123259. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  123260. /**
  123261. * Instantiates a new ArcRotateCameraInputsManager.
  123262. * @param camera Defines the camera the inputs belong to
  123263. */
  123264. constructor(camera: ArcRotateCamera);
  123265. /**
  123266. * Add mouse wheel input support to the input manager.
  123267. * @returns the current input manager
  123268. */
  123269. addMouseWheel(): ArcRotateCameraInputsManager;
  123270. /**
  123271. * Add pointers input support to the input manager.
  123272. * @returns the current input manager
  123273. */
  123274. addPointers(): ArcRotateCameraInputsManager;
  123275. /**
  123276. * Add keyboard input support to the input manager.
  123277. * @returns the current input manager
  123278. */
  123279. addKeyboard(): ArcRotateCameraInputsManager;
  123280. }
  123281. }
  123282. declare module BABYLON {
  123283. /**
  123284. * This represents an orbital type of camera.
  123285. *
  123286. * 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.
  123287. * 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.
  123288. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  123289. */
  123290. export class ArcRotateCamera extends TargetCamera {
  123291. /**
  123292. * Defines the rotation angle of the camera along the longitudinal axis.
  123293. */
  123294. alpha: number;
  123295. /**
  123296. * Defines the rotation angle of the camera along the latitudinal axis.
  123297. */
  123298. beta: number;
  123299. /**
  123300. * Defines the radius of the camera from it s target point.
  123301. */
  123302. radius: number;
  123303. protected _target: Vector3;
  123304. protected _targetHost: Nullable<AbstractMesh>;
  123305. /**
  123306. * Defines the target point of the camera.
  123307. * The camera looks towards it form the radius distance.
  123308. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  123309. */
  123310. get target(): Vector3;
  123311. set target(value: Vector3);
  123312. /**
  123313. * Define the current local position of the camera in the scene
  123314. */
  123315. get position(): Vector3;
  123316. set position(newPosition: Vector3);
  123317. protected _upToYMatrix: Matrix;
  123318. protected _YToUpMatrix: Matrix;
  123319. /**
  123320. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  123321. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  123322. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  123323. */
  123324. set upVector(vec: Vector3);
  123325. get upVector(): Vector3;
  123326. /**
  123327. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  123328. */
  123329. setMatUp(): void;
  123330. /**
  123331. * Current inertia value on the longitudinal axis.
  123332. * The bigger this number the longer it will take for the camera to stop.
  123333. */
  123334. inertialAlphaOffset: number;
  123335. /**
  123336. * Current inertia value on the latitudinal axis.
  123337. * The bigger this number the longer it will take for the camera to stop.
  123338. */
  123339. inertialBetaOffset: number;
  123340. /**
  123341. * Current inertia value on the radius axis.
  123342. * The bigger this number the longer it will take for the camera to stop.
  123343. */
  123344. inertialRadiusOffset: number;
  123345. /**
  123346. * Minimum allowed angle on the longitudinal axis.
  123347. * This can help limiting how the Camera is able to move in the scene.
  123348. */
  123349. lowerAlphaLimit: Nullable<number>;
  123350. /**
  123351. * Maximum allowed angle on the longitudinal axis.
  123352. * This can help limiting how the Camera is able to move in the scene.
  123353. */
  123354. upperAlphaLimit: Nullable<number>;
  123355. /**
  123356. * Minimum allowed angle on the latitudinal axis.
  123357. * This can help limiting how the Camera is able to move in the scene.
  123358. */
  123359. lowerBetaLimit: number;
  123360. /**
  123361. * Maximum allowed angle on the latitudinal axis.
  123362. * This can help limiting how the Camera is able to move in the scene.
  123363. */
  123364. upperBetaLimit: number;
  123365. /**
  123366. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  123367. * This can help limiting how the Camera is able to move in the scene.
  123368. */
  123369. lowerRadiusLimit: Nullable<number>;
  123370. /**
  123371. * Maximum allowed distance of the camera to the target (The camera can not get further).
  123372. * This can help limiting how the Camera is able to move in the scene.
  123373. */
  123374. upperRadiusLimit: Nullable<number>;
  123375. /**
  123376. * Defines the current inertia value used during panning of the camera along the X axis.
  123377. */
  123378. inertialPanningX: number;
  123379. /**
  123380. * Defines the current inertia value used during panning of the camera along the Y axis.
  123381. */
  123382. inertialPanningY: number;
  123383. /**
  123384. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  123385. * Basically if your fingers moves away from more than this distance you will be considered
  123386. * in pinch mode.
  123387. */
  123388. pinchToPanMaxDistance: number;
  123389. /**
  123390. * Defines the maximum distance the camera can pan.
  123391. * This could help keeping the cammera always in your scene.
  123392. */
  123393. panningDistanceLimit: Nullable<number>;
  123394. /**
  123395. * Defines the target of the camera before paning.
  123396. */
  123397. panningOriginTarget: Vector3;
  123398. /**
  123399. * Defines the value of the inertia used during panning.
  123400. * 0 would mean stop inertia and one would mean no decelleration at all.
  123401. */
  123402. panningInertia: number;
  123403. /**
  123404. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  123405. */
  123406. get angularSensibilityX(): number;
  123407. set angularSensibilityX(value: number);
  123408. /**
  123409. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  123410. */
  123411. get angularSensibilityY(): number;
  123412. set angularSensibilityY(value: number);
  123413. /**
  123414. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  123415. */
  123416. get pinchPrecision(): number;
  123417. set pinchPrecision(value: number);
  123418. /**
  123419. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  123420. * It will be used instead of pinchDeltaPrecision if different from 0.
  123421. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123422. */
  123423. get pinchDeltaPercentage(): number;
  123424. set pinchDeltaPercentage(value: number);
  123425. /**
  123426. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  123427. * and pinch delta percentage.
  123428. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  123429. * that any object in the plane at the camera's target point will scale
  123430. * perfectly with finger motion.
  123431. */
  123432. get useNaturalPinchZoom(): boolean;
  123433. set useNaturalPinchZoom(value: boolean);
  123434. /**
  123435. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  123436. */
  123437. get panningSensibility(): number;
  123438. set panningSensibility(value: number);
  123439. /**
  123440. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  123441. */
  123442. get keysUp(): number[];
  123443. set keysUp(value: number[]);
  123444. /**
  123445. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  123446. */
  123447. get keysDown(): number[];
  123448. set keysDown(value: number[]);
  123449. /**
  123450. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  123451. */
  123452. get keysLeft(): number[];
  123453. set keysLeft(value: number[]);
  123454. /**
  123455. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  123456. */
  123457. get keysRight(): number[];
  123458. set keysRight(value: number[]);
  123459. /**
  123460. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123461. */
  123462. get wheelPrecision(): number;
  123463. set wheelPrecision(value: number);
  123464. /**
  123465. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  123466. * It will be used instead of pinchDeltaPrecision if different from 0.
  123467. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123468. */
  123469. get wheelDeltaPercentage(): number;
  123470. set wheelDeltaPercentage(value: number);
  123471. /**
  123472. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  123473. */
  123474. zoomOnFactor: number;
  123475. /**
  123476. * Defines a screen offset for the camera position.
  123477. */
  123478. targetScreenOffset: Vector2;
  123479. /**
  123480. * Allows the camera to be completely reversed.
  123481. * If false the camera can not arrive upside down.
  123482. */
  123483. allowUpsideDown: boolean;
  123484. /**
  123485. * Define if double tap/click is used to restore the previously saved state of the camera.
  123486. */
  123487. useInputToRestoreState: boolean;
  123488. /** @hidden */
  123489. _viewMatrix: Matrix;
  123490. /** @hidden */
  123491. _useCtrlForPanning: boolean;
  123492. /** @hidden */
  123493. _panningMouseButton: number;
  123494. /**
  123495. * Defines the input associated to the camera.
  123496. */
  123497. inputs: ArcRotateCameraInputsManager;
  123498. /** @hidden */
  123499. _reset: () => void;
  123500. /**
  123501. * Defines the allowed panning axis.
  123502. */
  123503. panningAxis: Vector3;
  123504. protected _localDirection: Vector3;
  123505. protected _transformedDirection: Vector3;
  123506. private _bouncingBehavior;
  123507. /**
  123508. * Gets the bouncing behavior of the camera if it has been enabled.
  123509. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123510. */
  123511. get bouncingBehavior(): Nullable<BouncingBehavior>;
  123512. /**
  123513. * Defines if the bouncing behavior of the camera is enabled on the camera.
  123514. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123515. */
  123516. get useBouncingBehavior(): boolean;
  123517. set useBouncingBehavior(value: boolean);
  123518. private _framingBehavior;
  123519. /**
  123520. * Gets the framing behavior of the camera if it has been enabled.
  123521. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123522. */
  123523. get framingBehavior(): Nullable<FramingBehavior>;
  123524. /**
  123525. * Defines if the framing behavior of the camera is enabled on the camera.
  123526. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123527. */
  123528. get useFramingBehavior(): boolean;
  123529. set useFramingBehavior(value: boolean);
  123530. private _autoRotationBehavior;
  123531. /**
  123532. * Gets the auto rotation behavior of the camera if it has been enabled.
  123533. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123534. */
  123535. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  123536. /**
  123537. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  123538. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123539. */
  123540. get useAutoRotationBehavior(): boolean;
  123541. set useAutoRotationBehavior(value: boolean);
  123542. /**
  123543. * Observable triggered when the mesh target has been changed on the camera.
  123544. */
  123545. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  123546. /**
  123547. * Event raised when the camera is colliding with a mesh.
  123548. */
  123549. onCollide: (collidedMesh: AbstractMesh) => void;
  123550. /**
  123551. * Defines whether the camera should check collision with the objects oh the scene.
  123552. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  123553. */
  123554. checkCollisions: boolean;
  123555. /**
  123556. * Defines the collision radius of the camera.
  123557. * This simulates a sphere around the camera.
  123558. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123559. */
  123560. collisionRadius: Vector3;
  123561. protected _collider: Collider;
  123562. protected _previousPosition: Vector3;
  123563. protected _collisionVelocity: Vector3;
  123564. protected _newPosition: Vector3;
  123565. protected _previousAlpha: number;
  123566. protected _previousBeta: number;
  123567. protected _previousRadius: number;
  123568. protected _collisionTriggered: boolean;
  123569. protected _targetBoundingCenter: Nullable<Vector3>;
  123570. private _computationVector;
  123571. /**
  123572. * Instantiates a new ArcRotateCamera in a given scene
  123573. * @param name Defines the name of the camera
  123574. * @param alpha Defines the camera rotation along the logitudinal axis
  123575. * @param beta Defines the camera rotation along the latitudinal axis
  123576. * @param radius Defines the camera distance from its target
  123577. * @param target Defines the camera target
  123578. * @param scene Defines the scene the camera belongs to
  123579. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  123580. */
  123581. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123582. /** @hidden */
  123583. _initCache(): void;
  123584. /** @hidden */
  123585. _updateCache(ignoreParentClass?: boolean): void;
  123586. protected _getTargetPosition(): Vector3;
  123587. private _storedAlpha;
  123588. private _storedBeta;
  123589. private _storedRadius;
  123590. private _storedTarget;
  123591. private _storedTargetScreenOffset;
  123592. /**
  123593. * Stores the current state of the camera (alpha, beta, radius and target)
  123594. * @returns the camera itself
  123595. */
  123596. storeState(): Camera;
  123597. /**
  123598. * @hidden
  123599. * Restored camera state. You must call storeState() first
  123600. */
  123601. _restoreStateValues(): boolean;
  123602. /** @hidden */
  123603. _isSynchronizedViewMatrix(): boolean;
  123604. /**
  123605. * Attached controls to the current camera.
  123606. * @param element Defines the element the controls should be listened from
  123607. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123608. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  123609. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  123610. */
  123611. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  123612. /**
  123613. * Detach the current controls from the camera.
  123614. * The camera will stop reacting to inputs.
  123615. * @param element Defines the element to stop listening the inputs from
  123616. */
  123617. detachControl(element: HTMLElement): void;
  123618. /** @hidden */
  123619. _checkInputs(): void;
  123620. protected _checkLimits(): void;
  123621. /**
  123622. * Rebuilds angles (alpha, beta) and radius from the give position and target
  123623. */
  123624. rebuildAnglesAndRadius(): void;
  123625. /**
  123626. * Use a position to define the current camera related information like alpha, beta and radius
  123627. * @param position Defines the position to set the camera at
  123628. */
  123629. setPosition(position: Vector3): void;
  123630. /**
  123631. * Defines the target the camera should look at.
  123632. * This will automatically adapt alpha beta and radius to fit within the new target.
  123633. * @param target Defines the new target as a Vector or a mesh
  123634. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  123635. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  123636. */
  123637. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  123638. /** @hidden */
  123639. _getViewMatrix(): Matrix;
  123640. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  123641. /**
  123642. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  123643. * @param meshes Defines the mesh to zoom on
  123644. * @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)
  123645. */
  123646. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  123647. /**
  123648. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  123649. * The target will be changed but the radius
  123650. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  123651. * @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)
  123652. */
  123653. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  123654. min: Vector3;
  123655. max: Vector3;
  123656. distance: number;
  123657. }, doNotUpdateMaxZ?: boolean): void;
  123658. /**
  123659. * @override
  123660. * Override Camera.createRigCamera
  123661. */
  123662. createRigCamera(name: string, cameraIndex: number): Camera;
  123663. /**
  123664. * @hidden
  123665. * @override
  123666. * Override Camera._updateRigCameras
  123667. */
  123668. _updateRigCameras(): void;
  123669. /**
  123670. * Destroy the camera and release the current resources hold by it.
  123671. */
  123672. dispose(): void;
  123673. /**
  123674. * Gets the current object class name.
  123675. * @return the class name
  123676. */
  123677. getClassName(): string;
  123678. }
  123679. }
  123680. declare module BABYLON {
  123681. /**
  123682. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  123683. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123684. */
  123685. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  123686. /**
  123687. * Gets the name of the behavior.
  123688. */
  123689. get name(): string;
  123690. private _zoomStopsAnimation;
  123691. private _idleRotationSpeed;
  123692. private _idleRotationWaitTime;
  123693. private _idleRotationSpinupTime;
  123694. /**
  123695. * Sets the flag that indicates if user zooming should stop animation.
  123696. */
  123697. set zoomStopsAnimation(flag: boolean);
  123698. /**
  123699. * Gets the flag that indicates if user zooming should stop animation.
  123700. */
  123701. get zoomStopsAnimation(): boolean;
  123702. /**
  123703. * Sets the default speed at which the camera rotates around the model.
  123704. */
  123705. set idleRotationSpeed(speed: number);
  123706. /**
  123707. * Gets the default speed at which the camera rotates around the model.
  123708. */
  123709. get idleRotationSpeed(): number;
  123710. /**
  123711. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  123712. */
  123713. set idleRotationWaitTime(time: number);
  123714. /**
  123715. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  123716. */
  123717. get idleRotationWaitTime(): number;
  123718. /**
  123719. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123720. */
  123721. set idleRotationSpinupTime(time: number);
  123722. /**
  123723. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123724. */
  123725. get idleRotationSpinupTime(): number;
  123726. /**
  123727. * Gets a value indicating if the camera is currently rotating because of this behavior
  123728. */
  123729. get rotationInProgress(): boolean;
  123730. private _onPrePointerObservableObserver;
  123731. private _onAfterCheckInputsObserver;
  123732. private _attachedCamera;
  123733. private _isPointerDown;
  123734. private _lastFrameTime;
  123735. private _lastInteractionTime;
  123736. private _cameraRotationSpeed;
  123737. /**
  123738. * Initializes the behavior.
  123739. */
  123740. init(): void;
  123741. /**
  123742. * Attaches the behavior to its arc rotate camera.
  123743. * @param camera Defines the camera to attach the behavior to
  123744. */
  123745. attach(camera: ArcRotateCamera): void;
  123746. /**
  123747. * Detaches the behavior from its current arc rotate camera.
  123748. */
  123749. detach(): void;
  123750. /**
  123751. * Returns true if user is scrolling.
  123752. * @return true if user is scrolling.
  123753. */
  123754. private _userIsZooming;
  123755. private _lastFrameRadius;
  123756. private _shouldAnimationStopForInteraction;
  123757. /**
  123758. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  123759. */
  123760. private _applyUserInteraction;
  123761. private _userIsMoving;
  123762. }
  123763. }
  123764. declare module BABYLON {
  123765. /**
  123766. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  123767. */
  123768. export class AttachToBoxBehavior implements Behavior<Mesh> {
  123769. private ui;
  123770. /**
  123771. * The name of the behavior
  123772. */
  123773. name: string;
  123774. /**
  123775. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  123776. */
  123777. distanceAwayFromFace: number;
  123778. /**
  123779. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  123780. */
  123781. distanceAwayFromBottomOfFace: number;
  123782. private _faceVectors;
  123783. private _target;
  123784. private _scene;
  123785. private _onRenderObserver;
  123786. private _tmpMatrix;
  123787. private _tmpVector;
  123788. /**
  123789. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  123790. * @param ui The transform node that should be attched to the mesh
  123791. */
  123792. constructor(ui: TransformNode);
  123793. /**
  123794. * Initializes the behavior
  123795. */
  123796. init(): void;
  123797. private _closestFace;
  123798. private _zeroVector;
  123799. private _lookAtTmpMatrix;
  123800. private _lookAtToRef;
  123801. /**
  123802. * Attaches the AttachToBoxBehavior to the passed in mesh
  123803. * @param target The mesh that the specified node will be attached to
  123804. */
  123805. attach(target: Mesh): void;
  123806. /**
  123807. * Detaches the behavior from the mesh
  123808. */
  123809. detach(): void;
  123810. }
  123811. }
  123812. declare module BABYLON {
  123813. /**
  123814. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  123815. */
  123816. export class FadeInOutBehavior implements Behavior<Mesh> {
  123817. /**
  123818. * Time in milliseconds to delay before fading in (Default: 0)
  123819. */
  123820. delay: number;
  123821. /**
  123822. * Time in milliseconds for the mesh to fade in (Default: 300)
  123823. */
  123824. fadeInTime: number;
  123825. private _millisecondsPerFrame;
  123826. private _hovered;
  123827. private _hoverValue;
  123828. private _ownerNode;
  123829. /**
  123830. * Instatiates the FadeInOutBehavior
  123831. */
  123832. constructor();
  123833. /**
  123834. * The name of the behavior
  123835. */
  123836. get name(): string;
  123837. /**
  123838. * Initializes the behavior
  123839. */
  123840. init(): void;
  123841. /**
  123842. * Attaches the fade behavior on the passed in mesh
  123843. * @param ownerNode The mesh that will be faded in/out once attached
  123844. */
  123845. attach(ownerNode: Mesh): void;
  123846. /**
  123847. * Detaches the behavior from the mesh
  123848. */
  123849. detach(): void;
  123850. /**
  123851. * Triggers the mesh to begin fading in or out
  123852. * @param value if the object should fade in or out (true to fade in)
  123853. */
  123854. fadeIn(value: boolean): void;
  123855. private _update;
  123856. private _setAllVisibility;
  123857. }
  123858. }
  123859. declare module BABYLON {
  123860. /**
  123861. * Class containing a set of static utilities functions for managing Pivots
  123862. * @hidden
  123863. */
  123864. export class PivotTools {
  123865. private static _PivotCached;
  123866. private static _OldPivotPoint;
  123867. private static _PivotTranslation;
  123868. private static _PivotTmpVector;
  123869. private static _PivotPostMultiplyPivotMatrix;
  123870. /** @hidden */
  123871. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  123872. /** @hidden */
  123873. static _RestorePivotPoint(mesh: AbstractMesh): void;
  123874. }
  123875. }
  123876. declare module BABYLON {
  123877. /**
  123878. * Class containing static functions to help procedurally build meshes
  123879. */
  123880. export class PlaneBuilder {
  123881. /**
  123882. * Creates a plane mesh
  123883. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123884. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123885. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123889. * @param name defines the name of the mesh
  123890. * @param options defines the options used to create the mesh
  123891. * @param scene defines the hosting scene
  123892. * @returns the plane mesh
  123893. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123894. */
  123895. static CreatePlane(name: string, options: {
  123896. size?: number;
  123897. width?: number;
  123898. height?: number;
  123899. sideOrientation?: number;
  123900. frontUVs?: Vector4;
  123901. backUVs?: Vector4;
  123902. updatable?: boolean;
  123903. sourcePlane?: Plane;
  123904. }, scene?: Nullable<Scene>): Mesh;
  123905. }
  123906. }
  123907. declare module BABYLON {
  123908. /**
  123909. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  123910. */
  123911. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  123912. private static _AnyMouseID;
  123913. /**
  123914. * Abstract mesh the behavior is set on
  123915. */
  123916. attachedNode: AbstractMesh;
  123917. private _dragPlane;
  123918. private _scene;
  123919. private _pointerObserver;
  123920. private _beforeRenderObserver;
  123921. private static _planeScene;
  123922. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  123923. /**
  123924. * 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)
  123925. */
  123926. maxDragAngle: number;
  123927. /**
  123928. * @hidden
  123929. */
  123930. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  123931. /**
  123932. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123933. */
  123934. currentDraggingPointerID: number;
  123935. /**
  123936. * The last position where the pointer hit the drag plane in world space
  123937. */
  123938. lastDragPosition: Vector3;
  123939. /**
  123940. * If the behavior is currently in a dragging state
  123941. */
  123942. dragging: boolean;
  123943. /**
  123944. * 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)
  123945. */
  123946. dragDeltaRatio: number;
  123947. /**
  123948. * If the drag plane orientation should be updated during the dragging (Default: true)
  123949. */
  123950. updateDragPlane: boolean;
  123951. private _debugMode;
  123952. private _moving;
  123953. /**
  123954. * Fires each time the attached mesh is dragged with the pointer
  123955. * * delta between last drag position and current drag position in world space
  123956. * * dragDistance along the drag axis
  123957. * * dragPlaneNormal normal of the current drag plane used during the drag
  123958. * * dragPlanePoint in world space where the drag intersects the drag plane
  123959. */
  123960. onDragObservable: Observable<{
  123961. delta: Vector3;
  123962. dragPlanePoint: Vector3;
  123963. dragPlaneNormal: Vector3;
  123964. dragDistance: number;
  123965. pointerId: number;
  123966. }>;
  123967. /**
  123968. * Fires each time a drag begins (eg. mouse down on mesh)
  123969. */
  123970. onDragStartObservable: Observable<{
  123971. dragPlanePoint: Vector3;
  123972. pointerId: number;
  123973. }>;
  123974. /**
  123975. * Fires each time a drag ends (eg. mouse release after drag)
  123976. */
  123977. onDragEndObservable: Observable<{
  123978. dragPlanePoint: Vector3;
  123979. pointerId: number;
  123980. }>;
  123981. /**
  123982. * If the attached mesh should be moved when dragged
  123983. */
  123984. moveAttached: boolean;
  123985. /**
  123986. * If the drag behavior will react to drag events (Default: true)
  123987. */
  123988. enabled: boolean;
  123989. /**
  123990. * If pointer events should start and release the drag (Default: true)
  123991. */
  123992. startAndReleaseDragOnPointerEvents: boolean;
  123993. /**
  123994. * If camera controls should be detached during the drag
  123995. */
  123996. detachCameraControls: boolean;
  123997. /**
  123998. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  123999. */
  124000. useObjectOrientationForDragging: boolean;
  124001. private _options;
  124002. /**
  124003. * Gets the options used by the behavior
  124004. */
  124005. get options(): {
  124006. dragAxis?: Vector3;
  124007. dragPlaneNormal?: Vector3;
  124008. };
  124009. /**
  124010. * Sets the options used by the behavior
  124011. */
  124012. set options(options: {
  124013. dragAxis?: Vector3;
  124014. dragPlaneNormal?: Vector3;
  124015. });
  124016. /**
  124017. * Creates a pointer drag behavior that can be attached to a mesh
  124018. * @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)
  124019. */
  124020. constructor(options?: {
  124021. dragAxis?: Vector3;
  124022. dragPlaneNormal?: Vector3;
  124023. });
  124024. /**
  124025. * Predicate to determine if it is valid to move the object to a new position when it is moved
  124026. */
  124027. validateDrag: (targetPosition: Vector3) => boolean;
  124028. /**
  124029. * The name of the behavior
  124030. */
  124031. get name(): string;
  124032. /**
  124033. * Initializes the behavior
  124034. */
  124035. init(): void;
  124036. private _tmpVector;
  124037. private _alternatePickedPoint;
  124038. private _worldDragAxis;
  124039. private _targetPosition;
  124040. private _attachedElement;
  124041. /**
  124042. * Attaches the drag behavior the passed in mesh
  124043. * @param ownerNode The mesh that will be dragged around once attached
  124044. * @param predicate Predicate to use for pick filtering
  124045. */
  124046. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  124047. /**
  124048. * Force relase the drag action by code.
  124049. */
  124050. releaseDrag(): void;
  124051. private _startDragRay;
  124052. private _lastPointerRay;
  124053. /**
  124054. * Simulates the start of a pointer drag event on the behavior
  124055. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  124056. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  124057. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  124058. */
  124059. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  124060. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  124061. private _dragDelta;
  124062. protected _moveDrag(ray: Ray): void;
  124063. private _pickWithRayOnDragPlane;
  124064. private _pointA;
  124065. private _pointC;
  124066. private _localAxis;
  124067. private _lookAt;
  124068. private _updateDragPlanePosition;
  124069. /**
  124070. * Detaches the behavior from the mesh
  124071. */
  124072. detach(): void;
  124073. }
  124074. }
  124075. declare module BABYLON {
  124076. /**
  124077. * A behavior that when attached to a mesh will allow the mesh to be scaled
  124078. */
  124079. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  124080. private _dragBehaviorA;
  124081. private _dragBehaviorB;
  124082. private _startDistance;
  124083. private _initialScale;
  124084. private _targetScale;
  124085. private _ownerNode;
  124086. private _sceneRenderObserver;
  124087. /**
  124088. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  124089. */
  124090. constructor();
  124091. /**
  124092. * The name of the behavior
  124093. */
  124094. get name(): string;
  124095. /**
  124096. * Initializes the behavior
  124097. */
  124098. init(): void;
  124099. private _getCurrentDistance;
  124100. /**
  124101. * Attaches the scale behavior the passed in mesh
  124102. * @param ownerNode The mesh that will be scaled around once attached
  124103. */
  124104. attach(ownerNode: Mesh): void;
  124105. /**
  124106. * Detaches the behavior from the mesh
  124107. */
  124108. detach(): void;
  124109. }
  124110. }
  124111. declare module BABYLON {
  124112. /**
  124113. * 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
  124114. */
  124115. export class SixDofDragBehavior implements Behavior<Mesh> {
  124116. private static _virtualScene;
  124117. private _ownerNode;
  124118. private _sceneRenderObserver;
  124119. private _scene;
  124120. private _targetPosition;
  124121. private _virtualOriginMesh;
  124122. private _virtualDragMesh;
  124123. private _pointerObserver;
  124124. private _moving;
  124125. private _startingOrientation;
  124126. private _attachedElement;
  124127. /**
  124128. * 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)
  124129. */
  124130. private zDragFactor;
  124131. /**
  124132. * If the object should rotate to face the drag origin
  124133. */
  124134. rotateDraggedObject: boolean;
  124135. /**
  124136. * If the behavior is currently in a dragging state
  124137. */
  124138. dragging: boolean;
  124139. /**
  124140. * 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)
  124141. */
  124142. dragDeltaRatio: number;
  124143. /**
  124144. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  124145. */
  124146. currentDraggingPointerID: number;
  124147. /**
  124148. * If camera controls should be detached during the drag
  124149. */
  124150. detachCameraControls: boolean;
  124151. /**
  124152. * Fires each time a drag starts
  124153. */
  124154. onDragStartObservable: Observable<{}>;
  124155. /**
  124156. * Fires each time a drag ends (eg. mouse release after drag)
  124157. */
  124158. onDragEndObservable: Observable<{}>;
  124159. /**
  124160. * 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
  124161. */
  124162. constructor();
  124163. /**
  124164. * The name of the behavior
  124165. */
  124166. get name(): string;
  124167. /**
  124168. * Initializes the behavior
  124169. */
  124170. init(): void;
  124171. /**
  124172. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  124173. */
  124174. private get _pointerCamera();
  124175. /**
  124176. * Attaches the scale behavior the passed in mesh
  124177. * @param ownerNode The mesh that will be scaled around once attached
  124178. */
  124179. attach(ownerNode: Mesh): void;
  124180. /**
  124181. * Detaches the behavior from the mesh
  124182. */
  124183. detach(): void;
  124184. }
  124185. }
  124186. declare module BABYLON {
  124187. /**
  124188. * Class used to apply inverse kinematics to bones
  124189. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  124190. */
  124191. export class BoneIKController {
  124192. private static _tmpVecs;
  124193. private static _tmpQuat;
  124194. private static _tmpMats;
  124195. /**
  124196. * Gets or sets the target mesh
  124197. */
  124198. targetMesh: AbstractMesh;
  124199. /** Gets or sets the mesh used as pole */
  124200. poleTargetMesh: AbstractMesh;
  124201. /**
  124202. * Gets or sets the bone used as pole
  124203. */
  124204. poleTargetBone: Nullable<Bone>;
  124205. /**
  124206. * Gets or sets the target position
  124207. */
  124208. targetPosition: Vector3;
  124209. /**
  124210. * Gets or sets the pole target position
  124211. */
  124212. poleTargetPosition: Vector3;
  124213. /**
  124214. * Gets or sets the pole target local offset
  124215. */
  124216. poleTargetLocalOffset: Vector3;
  124217. /**
  124218. * Gets or sets the pole angle
  124219. */
  124220. poleAngle: number;
  124221. /**
  124222. * Gets or sets the mesh associated with the controller
  124223. */
  124224. mesh: AbstractMesh;
  124225. /**
  124226. * 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)
  124227. */
  124228. slerpAmount: number;
  124229. private _bone1Quat;
  124230. private _bone1Mat;
  124231. private _bone2Ang;
  124232. private _bone1;
  124233. private _bone2;
  124234. private _bone1Length;
  124235. private _bone2Length;
  124236. private _maxAngle;
  124237. private _maxReach;
  124238. private _rightHandedSystem;
  124239. private _bendAxis;
  124240. private _slerping;
  124241. private _adjustRoll;
  124242. /**
  124243. * Gets or sets maximum allowed angle
  124244. */
  124245. get maxAngle(): number;
  124246. set maxAngle(value: number);
  124247. /**
  124248. * Creates a new BoneIKController
  124249. * @param mesh defines the mesh to control
  124250. * @param bone defines the bone to control
  124251. * @param options defines options to set up the controller
  124252. */
  124253. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  124254. targetMesh?: AbstractMesh;
  124255. poleTargetMesh?: AbstractMesh;
  124256. poleTargetBone?: Bone;
  124257. poleTargetLocalOffset?: Vector3;
  124258. poleAngle?: number;
  124259. bendAxis?: Vector3;
  124260. maxAngle?: number;
  124261. slerpAmount?: number;
  124262. });
  124263. private _setMaxAngle;
  124264. /**
  124265. * Force the controller to update the bones
  124266. */
  124267. update(): void;
  124268. }
  124269. }
  124270. declare module BABYLON {
  124271. /**
  124272. * Class used to make a bone look toward a point in space
  124273. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  124274. */
  124275. export class BoneLookController {
  124276. private static _tmpVecs;
  124277. private static _tmpQuat;
  124278. private static _tmpMats;
  124279. /**
  124280. * The target Vector3 that the bone will look at
  124281. */
  124282. target: Vector3;
  124283. /**
  124284. * The mesh that the bone is attached to
  124285. */
  124286. mesh: AbstractMesh;
  124287. /**
  124288. * The bone that will be looking to the target
  124289. */
  124290. bone: Bone;
  124291. /**
  124292. * The up axis of the coordinate system that is used when the bone is rotated
  124293. */
  124294. upAxis: Vector3;
  124295. /**
  124296. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  124297. */
  124298. upAxisSpace: Space;
  124299. /**
  124300. * Used to make an adjustment to the yaw of the bone
  124301. */
  124302. adjustYaw: number;
  124303. /**
  124304. * Used to make an adjustment to the pitch of the bone
  124305. */
  124306. adjustPitch: number;
  124307. /**
  124308. * Used to make an adjustment to the roll of the bone
  124309. */
  124310. adjustRoll: number;
  124311. /**
  124312. * 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)
  124313. */
  124314. slerpAmount: number;
  124315. private _minYaw;
  124316. private _maxYaw;
  124317. private _minPitch;
  124318. private _maxPitch;
  124319. private _minYawSin;
  124320. private _minYawCos;
  124321. private _maxYawSin;
  124322. private _maxYawCos;
  124323. private _midYawConstraint;
  124324. private _minPitchTan;
  124325. private _maxPitchTan;
  124326. private _boneQuat;
  124327. private _slerping;
  124328. private _transformYawPitch;
  124329. private _transformYawPitchInv;
  124330. private _firstFrameSkipped;
  124331. private _yawRange;
  124332. private _fowardAxis;
  124333. /**
  124334. * Gets or sets the minimum yaw angle that the bone can look to
  124335. */
  124336. get minYaw(): number;
  124337. set minYaw(value: number);
  124338. /**
  124339. * Gets or sets the maximum yaw angle that the bone can look to
  124340. */
  124341. get maxYaw(): number;
  124342. set maxYaw(value: number);
  124343. /**
  124344. * Gets or sets the minimum pitch angle that the bone can look to
  124345. */
  124346. get minPitch(): number;
  124347. set minPitch(value: number);
  124348. /**
  124349. * Gets or sets the maximum pitch angle that the bone can look to
  124350. */
  124351. get maxPitch(): number;
  124352. set maxPitch(value: number);
  124353. /**
  124354. * Create a BoneLookController
  124355. * @param mesh the mesh that the bone belongs to
  124356. * @param bone the bone that will be looking to the target
  124357. * @param target the target Vector3 to look at
  124358. * @param options optional settings:
  124359. * * maxYaw: the maximum angle the bone will yaw to
  124360. * * minYaw: the minimum angle the bone will yaw to
  124361. * * maxPitch: the maximum angle the bone will pitch to
  124362. * * minPitch: the minimum angle the bone will yaw to
  124363. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  124364. * * upAxis: the up axis of the coordinate system
  124365. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  124366. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  124367. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  124368. * * adjustYaw: used to make an adjustment to the yaw of the bone
  124369. * * adjustPitch: used to make an adjustment to the pitch of the bone
  124370. * * adjustRoll: used to make an adjustment to the roll of the bone
  124371. **/
  124372. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  124373. maxYaw?: number;
  124374. minYaw?: number;
  124375. maxPitch?: number;
  124376. minPitch?: number;
  124377. slerpAmount?: number;
  124378. upAxis?: Vector3;
  124379. upAxisSpace?: Space;
  124380. yawAxis?: Vector3;
  124381. pitchAxis?: Vector3;
  124382. adjustYaw?: number;
  124383. adjustPitch?: number;
  124384. adjustRoll?: number;
  124385. });
  124386. /**
  124387. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  124388. */
  124389. update(): void;
  124390. private _getAngleDiff;
  124391. private _getAngleBetween;
  124392. private _isAngleBetween;
  124393. }
  124394. }
  124395. declare module BABYLON {
  124396. /**
  124397. * Manage the gamepad inputs to control an arc rotate camera.
  124398. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124399. */
  124400. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  124401. /**
  124402. * Defines the camera the input is attached to.
  124403. */
  124404. camera: ArcRotateCamera;
  124405. /**
  124406. * Defines the gamepad the input is gathering event from.
  124407. */
  124408. gamepad: Nullable<Gamepad>;
  124409. /**
  124410. * Defines the gamepad rotation sensiblity.
  124411. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124412. */
  124413. gamepadRotationSensibility: number;
  124414. /**
  124415. * Defines the gamepad move sensiblity.
  124416. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124417. */
  124418. gamepadMoveSensibility: number;
  124419. private _yAxisScale;
  124420. /**
  124421. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  124422. */
  124423. get invertYAxis(): boolean;
  124424. set invertYAxis(value: boolean);
  124425. private _onGamepadConnectedObserver;
  124426. private _onGamepadDisconnectedObserver;
  124427. /**
  124428. * Attach the input controls to a specific dom element to get the input from.
  124429. * @param element Defines the element the controls should be listened from
  124430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124431. */
  124432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124433. /**
  124434. * Detach the current controls from the specified dom element.
  124435. * @param element Defines the element to stop listening the inputs from
  124436. */
  124437. detachControl(element: Nullable<HTMLElement>): void;
  124438. /**
  124439. * Update the current camera state depending on the inputs that have been used this frame.
  124440. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124441. */
  124442. checkInputs(): void;
  124443. /**
  124444. * Gets the class name of the current intput.
  124445. * @returns the class name
  124446. */
  124447. getClassName(): string;
  124448. /**
  124449. * Get the friendly name associated with the input class.
  124450. * @returns the input friendly name
  124451. */
  124452. getSimpleName(): string;
  124453. }
  124454. }
  124455. declare module BABYLON {
  124456. interface ArcRotateCameraInputsManager {
  124457. /**
  124458. * Add orientation input support to the input manager.
  124459. * @returns the current input manager
  124460. */
  124461. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  124462. }
  124463. /**
  124464. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  124465. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124466. */
  124467. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  124468. /**
  124469. * Defines the camera the input is attached to.
  124470. */
  124471. camera: ArcRotateCamera;
  124472. /**
  124473. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  124474. */
  124475. alphaCorrection: number;
  124476. /**
  124477. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  124478. */
  124479. gammaCorrection: number;
  124480. private _alpha;
  124481. private _gamma;
  124482. private _dirty;
  124483. private _deviceOrientationHandler;
  124484. /**
  124485. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  124486. */
  124487. constructor();
  124488. /**
  124489. * Attach the input controls to a specific dom element to get the input from.
  124490. * @param element Defines the element the controls should be listened from
  124491. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124492. */
  124493. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124494. /** @hidden */
  124495. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  124496. /**
  124497. * Update the current camera state depending on the inputs that have been used this frame.
  124498. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124499. */
  124500. checkInputs(): void;
  124501. /**
  124502. * Detach the current controls from the specified dom element.
  124503. * @param element Defines the element to stop listening the inputs from
  124504. */
  124505. detachControl(element: Nullable<HTMLElement>): void;
  124506. /**
  124507. * Gets the class name of the current intput.
  124508. * @returns the class name
  124509. */
  124510. getClassName(): string;
  124511. /**
  124512. * Get the friendly name associated with the input class.
  124513. * @returns the input friendly name
  124514. */
  124515. getSimpleName(): string;
  124516. }
  124517. }
  124518. declare module BABYLON {
  124519. /**
  124520. * Listen to mouse events to control the camera.
  124521. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124522. */
  124523. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  124524. /**
  124525. * Defines the camera the input is attached to.
  124526. */
  124527. camera: FlyCamera;
  124528. /**
  124529. * Defines if touch is enabled. (Default is true.)
  124530. */
  124531. touchEnabled: boolean;
  124532. /**
  124533. * Defines the buttons associated with the input to handle camera rotation.
  124534. */
  124535. buttons: number[];
  124536. /**
  124537. * Assign buttons for Yaw control.
  124538. */
  124539. buttonsYaw: number[];
  124540. /**
  124541. * Assign buttons for Pitch control.
  124542. */
  124543. buttonsPitch: number[];
  124544. /**
  124545. * Assign buttons for Roll control.
  124546. */
  124547. buttonsRoll: number[];
  124548. /**
  124549. * Detect if any button is being pressed while mouse is moved.
  124550. * -1 = Mouse locked.
  124551. * 0 = Left button.
  124552. * 1 = Middle Button.
  124553. * 2 = Right Button.
  124554. */
  124555. activeButton: number;
  124556. /**
  124557. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  124558. * Higher values reduce its sensitivity.
  124559. */
  124560. angularSensibility: number;
  124561. private _mousemoveCallback;
  124562. private _observer;
  124563. private _rollObserver;
  124564. private previousPosition;
  124565. private noPreventDefault;
  124566. private element;
  124567. /**
  124568. * Listen to mouse events to control the camera.
  124569. * @param touchEnabled Define if touch is enabled. (Default is true.)
  124570. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124571. */
  124572. constructor(touchEnabled?: boolean);
  124573. /**
  124574. * Attach the mouse control to the HTML DOM element.
  124575. * @param element Defines the element that listens to the input events.
  124576. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  124577. */
  124578. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124579. /**
  124580. * Detach the current controls from the specified dom element.
  124581. * @param element Defines the element to stop listening the inputs from
  124582. */
  124583. detachControl(element: Nullable<HTMLElement>): void;
  124584. /**
  124585. * Gets the class name of the current input.
  124586. * @returns the class name.
  124587. */
  124588. getClassName(): string;
  124589. /**
  124590. * Get the friendly name associated with the input class.
  124591. * @returns the input's friendly name.
  124592. */
  124593. getSimpleName(): string;
  124594. private _pointerInput;
  124595. private _onMouseMove;
  124596. /**
  124597. * Rotate camera by mouse offset.
  124598. */
  124599. private rotateCamera;
  124600. }
  124601. }
  124602. declare module BABYLON {
  124603. /**
  124604. * Default Inputs manager for the FlyCamera.
  124605. * It groups all the default supported inputs for ease of use.
  124606. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124607. */
  124608. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  124609. /**
  124610. * Instantiates a new FlyCameraInputsManager.
  124611. * @param camera Defines the camera the inputs belong to.
  124612. */
  124613. constructor(camera: FlyCamera);
  124614. /**
  124615. * Add keyboard input support to the input manager.
  124616. * @returns the new FlyCameraKeyboardMoveInput().
  124617. */
  124618. addKeyboard(): FlyCameraInputsManager;
  124619. /**
  124620. * Add mouse input support to the input manager.
  124621. * @param touchEnabled Enable touch screen support.
  124622. * @returns the new FlyCameraMouseInput().
  124623. */
  124624. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  124625. }
  124626. }
  124627. declare module BABYLON {
  124628. /**
  124629. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124630. * such as in a 3D Space Shooter or a Flight Simulator.
  124631. */
  124632. export class FlyCamera extends TargetCamera {
  124633. /**
  124634. * Define the collision ellipsoid of the camera.
  124635. * This is helpful for simulating a camera body, like a player's body.
  124636. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  124637. */
  124638. ellipsoid: Vector3;
  124639. /**
  124640. * Define an offset for the position of the ellipsoid around the camera.
  124641. * This can be helpful if the camera is attached away from the player's body center,
  124642. * such as at its head.
  124643. */
  124644. ellipsoidOffset: Vector3;
  124645. /**
  124646. * Enable or disable collisions of the camera with the rest of the scene objects.
  124647. */
  124648. checkCollisions: boolean;
  124649. /**
  124650. * Enable or disable gravity on the camera.
  124651. */
  124652. applyGravity: boolean;
  124653. /**
  124654. * Define the current direction the camera is moving to.
  124655. */
  124656. cameraDirection: Vector3;
  124657. /**
  124658. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  124659. * This overrides and empties cameraRotation.
  124660. */
  124661. rotationQuaternion: Quaternion;
  124662. /**
  124663. * Track Roll to maintain the wanted Rolling when looking around.
  124664. */
  124665. _trackRoll: number;
  124666. /**
  124667. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  124668. */
  124669. rollCorrect: number;
  124670. /**
  124671. * Mimic a banked turn, Rolling the camera when Yawing.
  124672. * It's recommended to use rollCorrect = 10 for faster banking correction.
  124673. */
  124674. bankedTurn: boolean;
  124675. /**
  124676. * Limit in radians for how much Roll banking will add. (Default: 90°)
  124677. */
  124678. bankedTurnLimit: number;
  124679. /**
  124680. * Value of 0 disables the banked Roll.
  124681. * Value of 1 is equal to the Yaw angle in radians.
  124682. */
  124683. bankedTurnMultiplier: number;
  124684. /**
  124685. * The inputs manager loads all the input sources, such as keyboard and mouse.
  124686. */
  124687. inputs: FlyCameraInputsManager;
  124688. /**
  124689. * Gets the input sensibility for mouse input.
  124690. * Higher values reduce sensitivity.
  124691. */
  124692. get angularSensibility(): number;
  124693. /**
  124694. * Sets the input sensibility for a mouse input.
  124695. * Higher values reduce sensitivity.
  124696. */
  124697. set angularSensibility(value: number);
  124698. /**
  124699. * Get the keys for camera movement forward.
  124700. */
  124701. get keysForward(): number[];
  124702. /**
  124703. * Set the keys for camera movement forward.
  124704. */
  124705. set keysForward(value: number[]);
  124706. /**
  124707. * Get the keys for camera movement backward.
  124708. */
  124709. get keysBackward(): number[];
  124710. set keysBackward(value: number[]);
  124711. /**
  124712. * Get the keys for camera movement up.
  124713. */
  124714. get keysUp(): number[];
  124715. /**
  124716. * Set the keys for camera movement up.
  124717. */
  124718. set keysUp(value: number[]);
  124719. /**
  124720. * Get the keys for camera movement down.
  124721. */
  124722. get keysDown(): number[];
  124723. /**
  124724. * Set the keys for camera movement down.
  124725. */
  124726. set keysDown(value: number[]);
  124727. /**
  124728. * Get the keys for camera movement left.
  124729. */
  124730. get keysLeft(): number[];
  124731. /**
  124732. * Set the keys for camera movement left.
  124733. */
  124734. set keysLeft(value: number[]);
  124735. /**
  124736. * Set the keys for camera movement right.
  124737. */
  124738. get keysRight(): number[];
  124739. /**
  124740. * Set the keys for camera movement right.
  124741. */
  124742. set keysRight(value: number[]);
  124743. /**
  124744. * Event raised when the camera collides with a mesh in the scene.
  124745. */
  124746. onCollide: (collidedMesh: AbstractMesh) => void;
  124747. private _collider;
  124748. private _needMoveForGravity;
  124749. private _oldPosition;
  124750. private _diffPosition;
  124751. private _newPosition;
  124752. /** @hidden */
  124753. _localDirection: Vector3;
  124754. /** @hidden */
  124755. _transformedDirection: Vector3;
  124756. /**
  124757. * Instantiates a FlyCamera.
  124758. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124759. * such as in a 3D Space Shooter or a Flight Simulator.
  124760. * @param name Define the name of the camera in the scene.
  124761. * @param position Define the starting position of the camera in the scene.
  124762. * @param scene Define the scene the camera belongs to.
  124763. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  124764. */
  124765. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  124766. /**
  124767. * Attach a control to the HTML DOM element.
  124768. * @param element Defines the element that listens to the input events.
  124769. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  124770. */
  124771. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124772. /**
  124773. * Detach a control from the HTML DOM element.
  124774. * The camera will stop reacting to that input.
  124775. * @param element Defines the element that listens to the input events.
  124776. */
  124777. detachControl(element: HTMLElement): void;
  124778. private _collisionMask;
  124779. /**
  124780. * Get the mask that the camera ignores in collision events.
  124781. */
  124782. get collisionMask(): number;
  124783. /**
  124784. * Set the mask that the camera ignores in collision events.
  124785. */
  124786. set collisionMask(mask: number);
  124787. /** @hidden */
  124788. _collideWithWorld(displacement: Vector3): void;
  124789. /** @hidden */
  124790. private _onCollisionPositionChange;
  124791. /** @hidden */
  124792. _checkInputs(): void;
  124793. /** @hidden */
  124794. _decideIfNeedsToMove(): boolean;
  124795. /** @hidden */
  124796. _updatePosition(): void;
  124797. /**
  124798. * Restore the Roll to its target value at the rate specified.
  124799. * @param rate - Higher means slower restoring.
  124800. * @hidden
  124801. */
  124802. restoreRoll(rate: number): void;
  124803. /**
  124804. * Destroy the camera and release the current resources held by it.
  124805. */
  124806. dispose(): void;
  124807. /**
  124808. * Get the current object class name.
  124809. * @returns the class name.
  124810. */
  124811. getClassName(): string;
  124812. }
  124813. }
  124814. declare module BABYLON {
  124815. /**
  124816. * Listen to keyboard events to control the camera.
  124817. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124818. */
  124819. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  124820. /**
  124821. * Defines the camera the input is attached to.
  124822. */
  124823. camera: FlyCamera;
  124824. /**
  124825. * The list of keyboard keys used to control the forward move of the camera.
  124826. */
  124827. keysForward: number[];
  124828. /**
  124829. * The list of keyboard keys used to control the backward move of the camera.
  124830. */
  124831. keysBackward: number[];
  124832. /**
  124833. * The list of keyboard keys used to control the forward move of the camera.
  124834. */
  124835. keysUp: number[];
  124836. /**
  124837. * The list of keyboard keys used to control the backward move of the camera.
  124838. */
  124839. keysDown: number[];
  124840. /**
  124841. * The list of keyboard keys used to control the right strafe move of the camera.
  124842. */
  124843. keysRight: number[];
  124844. /**
  124845. * The list of keyboard keys used to control the left strafe move of the camera.
  124846. */
  124847. keysLeft: number[];
  124848. private _keys;
  124849. private _onCanvasBlurObserver;
  124850. private _onKeyboardObserver;
  124851. private _engine;
  124852. private _scene;
  124853. /**
  124854. * Attach the input controls to a specific dom element to get the input from.
  124855. * @param element Defines the element the controls should be listened from
  124856. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124857. */
  124858. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124859. /**
  124860. * Detach the current controls from the specified dom element.
  124861. * @param element Defines the element to stop listening the inputs from
  124862. */
  124863. detachControl(element: Nullable<HTMLElement>): void;
  124864. /**
  124865. * Gets the class name of the current intput.
  124866. * @returns the class name
  124867. */
  124868. getClassName(): string;
  124869. /** @hidden */
  124870. _onLostFocus(e: FocusEvent): void;
  124871. /**
  124872. * Get the friendly name associated with the input class.
  124873. * @returns the input friendly name
  124874. */
  124875. getSimpleName(): string;
  124876. /**
  124877. * Update the current camera state depending on the inputs that have been used this frame.
  124878. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124879. */
  124880. checkInputs(): void;
  124881. }
  124882. }
  124883. declare module BABYLON {
  124884. /**
  124885. * Manage the mouse wheel inputs to control a follow camera.
  124886. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124887. */
  124888. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  124889. /**
  124890. * Defines the camera the input is attached to.
  124891. */
  124892. camera: FollowCamera;
  124893. /**
  124894. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  124895. */
  124896. axisControlRadius: boolean;
  124897. /**
  124898. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  124899. */
  124900. axisControlHeight: boolean;
  124901. /**
  124902. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  124903. */
  124904. axisControlRotation: boolean;
  124905. /**
  124906. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  124907. * relation to mouseWheel events.
  124908. */
  124909. wheelPrecision: number;
  124910. /**
  124911. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  124912. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  124913. */
  124914. wheelDeltaPercentage: number;
  124915. private _wheel;
  124916. private _observer;
  124917. /**
  124918. * Attach the input controls to a specific dom element to get the input from.
  124919. * @param element Defines the element the controls should be listened from
  124920. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124921. */
  124922. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124923. /**
  124924. * Detach the current controls from the specified dom element.
  124925. * @param element Defines the element to stop listening the inputs from
  124926. */
  124927. detachControl(element: Nullable<HTMLElement>): void;
  124928. /**
  124929. * Gets the class name of the current intput.
  124930. * @returns the class name
  124931. */
  124932. getClassName(): string;
  124933. /**
  124934. * Get the friendly name associated with the input class.
  124935. * @returns the input friendly name
  124936. */
  124937. getSimpleName(): string;
  124938. }
  124939. }
  124940. declare module BABYLON {
  124941. /**
  124942. * Manage the pointers inputs to control an follow camera.
  124943. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124944. */
  124945. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  124946. /**
  124947. * Defines the camera the input is attached to.
  124948. */
  124949. camera: FollowCamera;
  124950. /**
  124951. * Gets the class name of the current input.
  124952. * @returns the class name
  124953. */
  124954. getClassName(): string;
  124955. /**
  124956. * Defines the pointer angular sensibility along the X axis or how fast is
  124957. * the camera rotating.
  124958. * A negative number will reverse the axis direction.
  124959. */
  124960. angularSensibilityX: number;
  124961. /**
  124962. * Defines the pointer angular sensibility along the Y axis or how fast is
  124963. * the camera rotating.
  124964. * A negative number will reverse the axis direction.
  124965. */
  124966. angularSensibilityY: number;
  124967. /**
  124968. * Defines the pointer pinch precision or how fast is the camera zooming.
  124969. * A negative number will reverse the axis direction.
  124970. */
  124971. pinchPrecision: number;
  124972. /**
  124973. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  124974. * from 0.
  124975. * It defines the percentage of current camera.radius to use as delta when
  124976. * pinch zoom is used.
  124977. */
  124978. pinchDeltaPercentage: number;
  124979. /**
  124980. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  124981. */
  124982. axisXControlRadius: boolean;
  124983. /**
  124984. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  124985. */
  124986. axisXControlHeight: boolean;
  124987. /**
  124988. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  124989. */
  124990. axisXControlRotation: boolean;
  124991. /**
  124992. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  124993. */
  124994. axisYControlRadius: boolean;
  124995. /**
  124996. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  124997. */
  124998. axisYControlHeight: boolean;
  124999. /**
  125000. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  125001. */
  125002. axisYControlRotation: boolean;
  125003. /**
  125004. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  125005. */
  125006. axisPinchControlRadius: boolean;
  125007. /**
  125008. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  125009. */
  125010. axisPinchControlHeight: boolean;
  125011. /**
  125012. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  125013. */
  125014. axisPinchControlRotation: boolean;
  125015. /**
  125016. * Log error messages if basic misconfiguration has occurred.
  125017. */
  125018. warningEnable: boolean;
  125019. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  125020. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  125021. private _warningCounter;
  125022. private _warning;
  125023. }
  125024. }
  125025. declare module BABYLON {
  125026. /**
  125027. * Default Inputs manager for the FollowCamera.
  125028. * It groups all the default supported inputs for ease of use.
  125029. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125030. */
  125031. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  125032. /**
  125033. * Instantiates a new FollowCameraInputsManager.
  125034. * @param camera Defines the camera the inputs belong to
  125035. */
  125036. constructor(camera: FollowCamera);
  125037. /**
  125038. * Add keyboard input support to the input manager.
  125039. * @returns the current input manager
  125040. */
  125041. addKeyboard(): FollowCameraInputsManager;
  125042. /**
  125043. * Add mouse wheel input support to the input manager.
  125044. * @returns the current input manager
  125045. */
  125046. addMouseWheel(): FollowCameraInputsManager;
  125047. /**
  125048. * Add pointers input support to the input manager.
  125049. * @returns the current input manager
  125050. */
  125051. addPointers(): FollowCameraInputsManager;
  125052. /**
  125053. * Add orientation input support to the input manager.
  125054. * @returns the current input manager
  125055. */
  125056. addVRDeviceOrientation(): FollowCameraInputsManager;
  125057. }
  125058. }
  125059. declare module BABYLON {
  125060. /**
  125061. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  125062. * an arc rotate version arcFollowCamera are available.
  125063. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125064. */
  125065. export class FollowCamera extends TargetCamera {
  125066. /**
  125067. * Distance the follow camera should follow an object at
  125068. */
  125069. radius: number;
  125070. /**
  125071. * Minimum allowed distance of the camera to the axis of rotation
  125072. * (The camera can not get closer).
  125073. * This can help limiting how the Camera is able to move in the scene.
  125074. */
  125075. lowerRadiusLimit: Nullable<number>;
  125076. /**
  125077. * Maximum allowed distance of the camera to the axis of rotation
  125078. * (The camera can not get further).
  125079. * This can help limiting how the Camera is able to move in the scene.
  125080. */
  125081. upperRadiusLimit: Nullable<number>;
  125082. /**
  125083. * Define a rotation offset between the camera and the object it follows
  125084. */
  125085. rotationOffset: number;
  125086. /**
  125087. * Minimum allowed angle to camera position relative to target object.
  125088. * This can help limiting how the Camera is able to move in the scene.
  125089. */
  125090. lowerRotationOffsetLimit: Nullable<number>;
  125091. /**
  125092. * Maximum allowed angle to camera position relative to target object.
  125093. * This can help limiting how the Camera is able to move in the scene.
  125094. */
  125095. upperRotationOffsetLimit: Nullable<number>;
  125096. /**
  125097. * Define a height offset between the camera and the object it follows.
  125098. * It can help following an object from the top (like a car chaing a plane)
  125099. */
  125100. heightOffset: number;
  125101. /**
  125102. * Minimum allowed height of camera position relative to target object.
  125103. * This can help limiting how the Camera is able to move in the scene.
  125104. */
  125105. lowerHeightOffsetLimit: Nullable<number>;
  125106. /**
  125107. * Maximum allowed height of camera position relative to target object.
  125108. * This can help limiting how the Camera is able to move in the scene.
  125109. */
  125110. upperHeightOffsetLimit: Nullable<number>;
  125111. /**
  125112. * Define how fast the camera can accelerate to follow it s target.
  125113. */
  125114. cameraAcceleration: number;
  125115. /**
  125116. * Define the speed limit of the camera following an object.
  125117. */
  125118. maxCameraSpeed: number;
  125119. /**
  125120. * Define the target of the camera.
  125121. */
  125122. lockedTarget: Nullable<AbstractMesh>;
  125123. /**
  125124. * Defines the input associated with the camera.
  125125. */
  125126. inputs: FollowCameraInputsManager;
  125127. /**
  125128. * Instantiates the follow camera.
  125129. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125130. * @param name Define the name of the camera in the scene
  125131. * @param position Define the position of the camera
  125132. * @param scene Define the scene the camera belong to
  125133. * @param lockedTarget Define the target of the camera
  125134. */
  125135. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  125136. private _follow;
  125137. /**
  125138. * Attached controls to the current camera.
  125139. * @param element Defines the element the controls should be listened from
  125140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125141. */
  125142. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125143. /**
  125144. * Detach the current controls from the camera.
  125145. * The camera will stop reacting to inputs.
  125146. * @param element Defines the element to stop listening the inputs from
  125147. */
  125148. detachControl(element: HTMLElement): void;
  125149. /** @hidden */
  125150. _checkInputs(): void;
  125151. private _checkLimits;
  125152. /**
  125153. * Gets the camera class name.
  125154. * @returns the class name
  125155. */
  125156. getClassName(): string;
  125157. }
  125158. /**
  125159. * Arc Rotate version of the follow camera.
  125160. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  125161. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125162. */
  125163. export class ArcFollowCamera extends TargetCamera {
  125164. /** The longitudinal angle of the camera */
  125165. alpha: number;
  125166. /** The latitudinal angle of the camera */
  125167. beta: number;
  125168. /** The radius of the camera from its target */
  125169. radius: number;
  125170. private _cartesianCoordinates;
  125171. /** Define the camera target (the mesh it should follow) */
  125172. private _meshTarget;
  125173. /**
  125174. * Instantiates a new ArcFollowCamera
  125175. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125176. * @param name Define the name of the camera
  125177. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  125178. * @param beta Define the rotation angle of the camera around the elevation axis
  125179. * @param radius Define the radius of the camera from its target point
  125180. * @param target Define the target of the camera
  125181. * @param scene Define the scene the camera belongs to
  125182. */
  125183. constructor(name: string,
  125184. /** The longitudinal angle of the camera */
  125185. alpha: number,
  125186. /** The latitudinal angle of the camera */
  125187. beta: number,
  125188. /** The radius of the camera from its target */
  125189. radius: number,
  125190. /** Define the camera target (the mesh it should follow) */
  125191. target: Nullable<AbstractMesh>, scene: Scene);
  125192. private _follow;
  125193. /** @hidden */
  125194. _checkInputs(): void;
  125195. /**
  125196. * Returns the class name of the object.
  125197. * It is mostly used internally for serialization purposes.
  125198. */
  125199. getClassName(): string;
  125200. }
  125201. }
  125202. declare module BABYLON {
  125203. /**
  125204. * Manage the keyboard inputs to control the movement of a follow camera.
  125205. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125206. */
  125207. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  125208. /**
  125209. * Defines the camera the input is attached to.
  125210. */
  125211. camera: FollowCamera;
  125212. /**
  125213. * Defines the list of key codes associated with the up action (increase heightOffset)
  125214. */
  125215. keysHeightOffsetIncr: number[];
  125216. /**
  125217. * Defines the list of key codes associated with the down action (decrease heightOffset)
  125218. */
  125219. keysHeightOffsetDecr: number[];
  125220. /**
  125221. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  125222. */
  125223. keysHeightOffsetModifierAlt: boolean;
  125224. /**
  125225. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  125226. */
  125227. keysHeightOffsetModifierCtrl: boolean;
  125228. /**
  125229. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  125230. */
  125231. keysHeightOffsetModifierShift: boolean;
  125232. /**
  125233. * Defines the list of key codes associated with the left action (increase rotationOffset)
  125234. */
  125235. keysRotationOffsetIncr: number[];
  125236. /**
  125237. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  125238. */
  125239. keysRotationOffsetDecr: number[];
  125240. /**
  125241. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  125242. */
  125243. keysRotationOffsetModifierAlt: boolean;
  125244. /**
  125245. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  125246. */
  125247. keysRotationOffsetModifierCtrl: boolean;
  125248. /**
  125249. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  125250. */
  125251. keysRotationOffsetModifierShift: boolean;
  125252. /**
  125253. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  125254. */
  125255. keysRadiusIncr: number[];
  125256. /**
  125257. * Defines the list of key codes associated with the zoom-out action (increase radius)
  125258. */
  125259. keysRadiusDecr: number[];
  125260. /**
  125261. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  125262. */
  125263. keysRadiusModifierAlt: boolean;
  125264. /**
  125265. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  125266. */
  125267. keysRadiusModifierCtrl: boolean;
  125268. /**
  125269. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  125270. */
  125271. keysRadiusModifierShift: boolean;
  125272. /**
  125273. * Defines the rate of change of heightOffset.
  125274. */
  125275. heightSensibility: number;
  125276. /**
  125277. * Defines the rate of change of rotationOffset.
  125278. */
  125279. rotationSensibility: number;
  125280. /**
  125281. * Defines the rate of change of radius.
  125282. */
  125283. radiusSensibility: number;
  125284. private _keys;
  125285. private _ctrlPressed;
  125286. private _altPressed;
  125287. private _shiftPressed;
  125288. private _onCanvasBlurObserver;
  125289. private _onKeyboardObserver;
  125290. private _engine;
  125291. private _scene;
  125292. /**
  125293. * Attach the input controls to a specific dom element to get the input from.
  125294. * @param element Defines the element the controls should be listened from
  125295. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125296. */
  125297. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125298. /**
  125299. * Detach the current controls from the specified dom element.
  125300. * @param element Defines the element to stop listening the inputs from
  125301. */
  125302. detachControl(element: Nullable<HTMLElement>): void;
  125303. /**
  125304. * Update the current camera state depending on the inputs that have been used this frame.
  125305. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125306. */
  125307. checkInputs(): void;
  125308. /**
  125309. * Gets the class name of the current input.
  125310. * @returns the class name
  125311. */
  125312. getClassName(): string;
  125313. /**
  125314. * Get the friendly name associated with the input class.
  125315. * @returns the input friendly name
  125316. */
  125317. getSimpleName(): string;
  125318. /**
  125319. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125320. * allow modification of the heightOffset value.
  125321. */
  125322. private _modifierHeightOffset;
  125323. /**
  125324. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125325. * allow modification of the rotationOffset value.
  125326. */
  125327. private _modifierRotationOffset;
  125328. /**
  125329. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125330. * allow modification of the radius value.
  125331. */
  125332. private _modifierRadius;
  125333. }
  125334. }
  125335. declare module BABYLON {
  125336. interface FreeCameraInputsManager {
  125337. /**
  125338. * @hidden
  125339. */
  125340. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  125341. /**
  125342. * Add orientation input support to the input manager.
  125343. * @returns the current input manager
  125344. */
  125345. addDeviceOrientation(): FreeCameraInputsManager;
  125346. }
  125347. /**
  125348. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  125349. * Screen rotation is taken into account.
  125350. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125351. */
  125352. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  125353. private _camera;
  125354. private _screenOrientationAngle;
  125355. private _constantTranform;
  125356. private _screenQuaternion;
  125357. private _alpha;
  125358. private _beta;
  125359. private _gamma;
  125360. /**
  125361. * Can be used to detect if a device orientation sensor is available on a device
  125362. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  125363. * @returns a promise that will resolve on orientation change
  125364. */
  125365. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  125366. /**
  125367. * @hidden
  125368. */
  125369. _onDeviceOrientationChangedObservable: Observable<void>;
  125370. /**
  125371. * Instantiates a new input
  125372. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125373. */
  125374. constructor();
  125375. /**
  125376. * Define the camera controlled by the input.
  125377. */
  125378. get camera(): FreeCamera;
  125379. set camera(camera: FreeCamera);
  125380. /**
  125381. * Attach the input controls to a specific dom element to get the input from.
  125382. * @param element Defines the element the controls should be listened from
  125383. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125384. */
  125385. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125386. private _orientationChanged;
  125387. private _deviceOrientation;
  125388. /**
  125389. * Detach the current controls from the specified dom element.
  125390. * @param element Defines the element to stop listening the inputs from
  125391. */
  125392. detachControl(element: Nullable<HTMLElement>): void;
  125393. /**
  125394. * Update the current camera state depending on the inputs that have been used this frame.
  125395. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125396. */
  125397. checkInputs(): void;
  125398. /**
  125399. * Gets the class name of the current intput.
  125400. * @returns the class name
  125401. */
  125402. getClassName(): string;
  125403. /**
  125404. * Get the friendly name associated with the input class.
  125405. * @returns the input friendly name
  125406. */
  125407. getSimpleName(): string;
  125408. }
  125409. }
  125410. declare module BABYLON {
  125411. /**
  125412. * Manage the gamepad inputs to control a free camera.
  125413. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125414. */
  125415. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  125416. /**
  125417. * Define the camera the input is attached to.
  125418. */
  125419. camera: FreeCamera;
  125420. /**
  125421. * Define the Gamepad controlling the input
  125422. */
  125423. gamepad: Nullable<Gamepad>;
  125424. /**
  125425. * Defines the gamepad rotation sensiblity.
  125426. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  125427. */
  125428. gamepadAngularSensibility: number;
  125429. /**
  125430. * Defines the gamepad move sensiblity.
  125431. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  125432. */
  125433. gamepadMoveSensibility: number;
  125434. private _yAxisScale;
  125435. /**
  125436. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  125437. */
  125438. get invertYAxis(): boolean;
  125439. set invertYAxis(value: boolean);
  125440. private _onGamepadConnectedObserver;
  125441. private _onGamepadDisconnectedObserver;
  125442. private _cameraTransform;
  125443. private _deltaTransform;
  125444. private _vector3;
  125445. private _vector2;
  125446. /**
  125447. * Attach the input controls to a specific dom element to get the input from.
  125448. * @param element Defines the element the controls should be listened from
  125449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125450. */
  125451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125452. /**
  125453. * Detach the current controls from the specified dom element.
  125454. * @param element Defines the element to stop listening the inputs from
  125455. */
  125456. detachControl(element: Nullable<HTMLElement>): void;
  125457. /**
  125458. * Update the current camera state depending on the inputs that have been used this frame.
  125459. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125460. */
  125461. checkInputs(): void;
  125462. /**
  125463. * Gets the class name of the current intput.
  125464. * @returns the class name
  125465. */
  125466. getClassName(): string;
  125467. /**
  125468. * Get the friendly name associated with the input class.
  125469. * @returns the input friendly name
  125470. */
  125471. getSimpleName(): string;
  125472. }
  125473. }
  125474. declare module BABYLON {
  125475. /**
  125476. * Defines the potential axis of a Joystick
  125477. */
  125478. export enum JoystickAxis {
  125479. /** X axis */
  125480. X = 0,
  125481. /** Y axis */
  125482. Y = 1,
  125483. /** Z axis */
  125484. Z = 2
  125485. }
  125486. /**
  125487. * Represents the different customization options available
  125488. * for VirtualJoystick
  125489. */
  125490. interface VirtualJoystickCustomizations {
  125491. /**
  125492. * Size of the joystick's puck
  125493. */
  125494. puckSize: number;
  125495. /**
  125496. * Size of the joystick's container
  125497. */
  125498. containerSize: number;
  125499. /**
  125500. * Color of the joystick && puck
  125501. */
  125502. color: string;
  125503. /**
  125504. * Image URL for the joystick's puck
  125505. */
  125506. puckImage?: string;
  125507. /**
  125508. * Image URL for the joystick's container
  125509. */
  125510. containerImage?: string;
  125511. /**
  125512. * Defines the unmoving position of the joystick container
  125513. */
  125514. position?: {
  125515. x: number;
  125516. y: number;
  125517. };
  125518. /**
  125519. * Defines whether or not the joystick container is always visible
  125520. */
  125521. alwaysVisible: boolean;
  125522. /**
  125523. * Defines whether or not to limit the movement of the puck to the joystick's container
  125524. */
  125525. limitToContainer: boolean;
  125526. }
  125527. /**
  125528. * Class used to define virtual joystick (used in touch mode)
  125529. */
  125530. export class VirtualJoystick {
  125531. /**
  125532. * Gets or sets a boolean indicating that left and right values must be inverted
  125533. */
  125534. reverseLeftRight: boolean;
  125535. /**
  125536. * Gets or sets a boolean indicating that up and down values must be inverted
  125537. */
  125538. reverseUpDown: boolean;
  125539. /**
  125540. * Gets the offset value for the position (ie. the change of the position value)
  125541. */
  125542. deltaPosition: Vector3;
  125543. /**
  125544. * Gets a boolean indicating if the virtual joystick was pressed
  125545. */
  125546. pressed: boolean;
  125547. /**
  125548. * Canvas the virtual joystick will render onto, default z-index of this is 5
  125549. */
  125550. static Canvas: Nullable<HTMLCanvasElement>;
  125551. /**
  125552. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  125553. */
  125554. limitToContainer: boolean;
  125555. private static _globalJoystickIndex;
  125556. private static _alwaysVisibleSticks;
  125557. private static vjCanvasContext;
  125558. private static vjCanvasWidth;
  125559. private static vjCanvasHeight;
  125560. private static halfWidth;
  125561. private static _GetDefaultOptions;
  125562. private _action;
  125563. private _axisTargetedByLeftAndRight;
  125564. private _axisTargetedByUpAndDown;
  125565. private _joystickSensibility;
  125566. private _inversedSensibility;
  125567. private _joystickPointerID;
  125568. private _joystickColor;
  125569. private _joystickPointerPos;
  125570. private _joystickPreviousPointerPos;
  125571. private _joystickPointerStartPos;
  125572. private _deltaJoystickVector;
  125573. private _leftJoystick;
  125574. private _touches;
  125575. private _joystickPosition;
  125576. private _alwaysVisible;
  125577. private _puckImage;
  125578. private _containerImage;
  125579. private _joystickPuckSize;
  125580. private _joystickContainerSize;
  125581. private _clearPuckSize;
  125582. private _clearContainerSize;
  125583. private _clearPuckSizeOffset;
  125584. private _clearContainerSizeOffset;
  125585. private _onPointerDownHandlerRef;
  125586. private _onPointerMoveHandlerRef;
  125587. private _onPointerUpHandlerRef;
  125588. private _onResize;
  125589. /**
  125590. * Creates a new virtual joystick
  125591. * @param leftJoystick defines that the joystick is for left hand (false by default)
  125592. * @param customizations Defines the options we want to customize the VirtualJoystick
  125593. */
  125594. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  125595. /**
  125596. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  125597. * @param newJoystickSensibility defines the new sensibility
  125598. */
  125599. setJoystickSensibility(newJoystickSensibility: number): void;
  125600. private _onPointerDown;
  125601. private _onPointerMove;
  125602. private _onPointerUp;
  125603. /**
  125604. * Change the color of the virtual joystick
  125605. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  125606. */
  125607. setJoystickColor(newColor: string): void;
  125608. /**
  125609. * Size of the joystick's container
  125610. */
  125611. set containerSize(newSize: number);
  125612. get containerSize(): number;
  125613. /**
  125614. * Size of the joystick's puck
  125615. */
  125616. set puckSize(newSize: number);
  125617. get puckSize(): number;
  125618. /**
  125619. * Clears the set position of the joystick
  125620. */
  125621. clearPosition(): void;
  125622. /**
  125623. * Defines whether or not the joystick container is always visible
  125624. */
  125625. set alwaysVisible(value: boolean);
  125626. get alwaysVisible(): boolean;
  125627. /**
  125628. * Sets the constant position of the Joystick container
  125629. * @param x X axis coordinate
  125630. * @param y Y axis coordinate
  125631. */
  125632. setPosition(x: number, y: number): void;
  125633. /**
  125634. * Defines a callback to call when the joystick is touched
  125635. * @param action defines the callback
  125636. */
  125637. setActionOnTouch(action: () => any): void;
  125638. /**
  125639. * Defines which axis you'd like to control for left & right
  125640. * @param axis defines the axis to use
  125641. */
  125642. setAxisForLeftRight(axis: JoystickAxis): void;
  125643. /**
  125644. * Defines which axis you'd like to control for up & down
  125645. * @param axis defines the axis to use
  125646. */
  125647. setAxisForUpDown(axis: JoystickAxis): void;
  125648. /**
  125649. * Clears the canvas from the previous puck / container draw
  125650. */
  125651. private _clearPreviousDraw;
  125652. /**
  125653. * Loads `urlPath` to be used for the container's image
  125654. * @param urlPath defines the urlPath of an image to use
  125655. */
  125656. setContainerImage(urlPath: string): void;
  125657. /**
  125658. * Loads `urlPath` to be used for the puck's image
  125659. * @param urlPath defines the urlPath of an image to use
  125660. */
  125661. setPuckImage(urlPath: string): void;
  125662. /**
  125663. * Draws the Virtual Joystick's container
  125664. */
  125665. private _drawContainer;
  125666. /**
  125667. * Draws the Virtual Joystick's puck
  125668. */
  125669. private _drawPuck;
  125670. private _drawVirtualJoystick;
  125671. /**
  125672. * Release internal HTML canvas
  125673. */
  125674. releaseCanvas(): void;
  125675. }
  125676. }
  125677. declare module BABYLON {
  125678. interface FreeCameraInputsManager {
  125679. /**
  125680. * Add virtual joystick input support to the input manager.
  125681. * @returns the current input manager
  125682. */
  125683. addVirtualJoystick(): FreeCameraInputsManager;
  125684. }
  125685. /**
  125686. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  125687. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125688. */
  125689. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  125690. /**
  125691. * Defines the camera the input is attached to.
  125692. */
  125693. camera: FreeCamera;
  125694. private _leftjoystick;
  125695. private _rightjoystick;
  125696. /**
  125697. * Gets the left stick of the virtual joystick.
  125698. * @returns The virtual Joystick
  125699. */
  125700. getLeftJoystick(): VirtualJoystick;
  125701. /**
  125702. * Gets the right stick of the virtual joystick.
  125703. * @returns The virtual Joystick
  125704. */
  125705. getRightJoystick(): VirtualJoystick;
  125706. /**
  125707. * Update the current camera state depending on the inputs that have been used this frame.
  125708. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125709. */
  125710. checkInputs(): void;
  125711. /**
  125712. * Attach the input controls to a specific dom element to get the input from.
  125713. * @param element Defines the element the controls should be listened from
  125714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125715. */
  125716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125717. /**
  125718. * Detach the current controls from the specified dom element.
  125719. * @param element Defines the element to stop listening the inputs from
  125720. */
  125721. detachControl(element: Nullable<HTMLElement>): void;
  125722. /**
  125723. * Gets the class name of the current intput.
  125724. * @returns the class name
  125725. */
  125726. getClassName(): string;
  125727. /**
  125728. * Get the friendly name associated with the input class.
  125729. * @returns the input friendly name
  125730. */
  125731. getSimpleName(): string;
  125732. }
  125733. }
  125734. declare module BABYLON {
  125735. /**
  125736. * This represents a FPS type of camera controlled by touch.
  125737. * This is like a universal camera minus the Gamepad controls.
  125738. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125739. */
  125740. export class TouchCamera extends FreeCamera {
  125741. /**
  125742. * Defines the touch sensibility for rotation.
  125743. * The higher the faster.
  125744. */
  125745. get touchAngularSensibility(): number;
  125746. set touchAngularSensibility(value: number);
  125747. /**
  125748. * Defines the touch sensibility for move.
  125749. * The higher the faster.
  125750. */
  125751. get touchMoveSensibility(): number;
  125752. set touchMoveSensibility(value: number);
  125753. /**
  125754. * Instantiates a new touch camera.
  125755. * This represents a FPS type of camera controlled by touch.
  125756. * This is like a universal camera minus the Gamepad controls.
  125757. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125758. * @param name Define the name of the camera in the scene
  125759. * @param position Define the start position of the camera in the scene
  125760. * @param scene Define the scene the camera belongs to
  125761. */
  125762. constructor(name: string, position: Vector3, scene: Scene);
  125763. /**
  125764. * Gets the current object class name.
  125765. * @return the class name
  125766. */
  125767. getClassName(): string;
  125768. /** @hidden */
  125769. _setupInputs(): void;
  125770. }
  125771. }
  125772. declare module BABYLON {
  125773. /**
  125774. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  125775. * being tilted forward or back and left or right.
  125776. */
  125777. export class DeviceOrientationCamera extends FreeCamera {
  125778. private _initialQuaternion;
  125779. private _quaternionCache;
  125780. private _tmpDragQuaternion;
  125781. private _disablePointerInputWhenUsingDeviceOrientation;
  125782. /**
  125783. * Creates a new device orientation camera
  125784. * @param name The name of the camera
  125785. * @param position The start position camera
  125786. * @param scene The scene the camera belongs to
  125787. */
  125788. constructor(name: string, position: Vector3, scene: Scene);
  125789. /**
  125790. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  125791. */
  125792. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  125793. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  125794. private _dragFactor;
  125795. /**
  125796. * Enabled turning on the y axis when the orientation sensor is active
  125797. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  125798. */
  125799. enableHorizontalDragging(dragFactor?: number): void;
  125800. /**
  125801. * Gets the current instance class name ("DeviceOrientationCamera").
  125802. * This helps avoiding instanceof at run time.
  125803. * @returns the class name
  125804. */
  125805. getClassName(): string;
  125806. /**
  125807. * @hidden
  125808. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  125809. */
  125810. _checkInputs(): void;
  125811. /**
  125812. * Reset the camera to its default orientation on the specified axis only.
  125813. * @param axis The axis to reset
  125814. */
  125815. resetToCurrentRotation(axis?: Axis): void;
  125816. }
  125817. }
  125818. declare module BABYLON {
  125819. /**
  125820. * Defines supported buttons for XBox360 compatible gamepads
  125821. */
  125822. export enum Xbox360Button {
  125823. /** A */
  125824. A = 0,
  125825. /** B */
  125826. B = 1,
  125827. /** X */
  125828. X = 2,
  125829. /** Y */
  125830. Y = 3,
  125831. /** Left button */
  125832. LB = 4,
  125833. /** Right button */
  125834. RB = 5,
  125835. /** Back */
  125836. Back = 8,
  125837. /** Start */
  125838. Start = 9,
  125839. /** Left stick */
  125840. LeftStick = 10,
  125841. /** Right stick */
  125842. RightStick = 11
  125843. }
  125844. /** Defines values for XBox360 DPad */
  125845. export enum Xbox360Dpad {
  125846. /** Up */
  125847. Up = 12,
  125848. /** Down */
  125849. Down = 13,
  125850. /** Left */
  125851. Left = 14,
  125852. /** Right */
  125853. Right = 15
  125854. }
  125855. /**
  125856. * Defines a XBox360 gamepad
  125857. */
  125858. export class Xbox360Pad extends Gamepad {
  125859. private _leftTrigger;
  125860. private _rightTrigger;
  125861. private _onlefttriggerchanged;
  125862. private _onrighttriggerchanged;
  125863. private _onbuttondown;
  125864. private _onbuttonup;
  125865. private _ondpaddown;
  125866. private _ondpadup;
  125867. /** Observable raised when a button is pressed */
  125868. onButtonDownObservable: Observable<Xbox360Button>;
  125869. /** Observable raised when a button is released */
  125870. onButtonUpObservable: Observable<Xbox360Button>;
  125871. /** Observable raised when a pad is pressed */
  125872. onPadDownObservable: Observable<Xbox360Dpad>;
  125873. /** Observable raised when a pad is released */
  125874. onPadUpObservable: Observable<Xbox360Dpad>;
  125875. private _buttonA;
  125876. private _buttonB;
  125877. private _buttonX;
  125878. private _buttonY;
  125879. private _buttonBack;
  125880. private _buttonStart;
  125881. private _buttonLB;
  125882. private _buttonRB;
  125883. private _buttonLeftStick;
  125884. private _buttonRightStick;
  125885. private _dPadUp;
  125886. private _dPadDown;
  125887. private _dPadLeft;
  125888. private _dPadRight;
  125889. private _isXboxOnePad;
  125890. /**
  125891. * Creates a new XBox360 gamepad object
  125892. * @param id defines the id of this gamepad
  125893. * @param index defines its index
  125894. * @param gamepad defines the internal HTML gamepad object
  125895. * @param xboxOne defines if it is a XBox One gamepad
  125896. */
  125897. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  125898. /**
  125899. * Defines the callback to call when left trigger is pressed
  125900. * @param callback defines the callback to use
  125901. */
  125902. onlefttriggerchanged(callback: (value: number) => void): void;
  125903. /**
  125904. * Defines the callback to call when right trigger is pressed
  125905. * @param callback defines the callback to use
  125906. */
  125907. onrighttriggerchanged(callback: (value: number) => void): void;
  125908. /**
  125909. * Gets the left trigger value
  125910. */
  125911. get leftTrigger(): number;
  125912. /**
  125913. * Sets the left trigger value
  125914. */
  125915. set leftTrigger(newValue: number);
  125916. /**
  125917. * Gets the right trigger value
  125918. */
  125919. get rightTrigger(): number;
  125920. /**
  125921. * Sets the right trigger value
  125922. */
  125923. set rightTrigger(newValue: number);
  125924. /**
  125925. * Defines the callback to call when a button is pressed
  125926. * @param callback defines the callback to use
  125927. */
  125928. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  125929. /**
  125930. * Defines the callback to call when a button is released
  125931. * @param callback defines the callback to use
  125932. */
  125933. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  125934. /**
  125935. * Defines the callback to call when a pad is pressed
  125936. * @param callback defines the callback to use
  125937. */
  125938. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  125939. /**
  125940. * Defines the callback to call when a pad is released
  125941. * @param callback defines the callback to use
  125942. */
  125943. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  125944. private _setButtonValue;
  125945. private _setDPadValue;
  125946. /**
  125947. * Gets the value of the `A` button
  125948. */
  125949. get buttonA(): number;
  125950. /**
  125951. * Sets the value of the `A` button
  125952. */
  125953. set buttonA(value: number);
  125954. /**
  125955. * Gets the value of the `B` button
  125956. */
  125957. get buttonB(): number;
  125958. /**
  125959. * Sets the value of the `B` button
  125960. */
  125961. set buttonB(value: number);
  125962. /**
  125963. * Gets the value of the `X` button
  125964. */
  125965. get buttonX(): number;
  125966. /**
  125967. * Sets the value of the `X` button
  125968. */
  125969. set buttonX(value: number);
  125970. /**
  125971. * Gets the value of the `Y` button
  125972. */
  125973. get buttonY(): number;
  125974. /**
  125975. * Sets the value of the `Y` button
  125976. */
  125977. set buttonY(value: number);
  125978. /**
  125979. * Gets the value of the `Start` button
  125980. */
  125981. get buttonStart(): number;
  125982. /**
  125983. * Sets the value of the `Start` button
  125984. */
  125985. set buttonStart(value: number);
  125986. /**
  125987. * Gets the value of the `Back` button
  125988. */
  125989. get buttonBack(): number;
  125990. /**
  125991. * Sets the value of the `Back` button
  125992. */
  125993. set buttonBack(value: number);
  125994. /**
  125995. * Gets the value of the `Left` button
  125996. */
  125997. get buttonLB(): number;
  125998. /**
  125999. * Sets the value of the `Left` button
  126000. */
  126001. set buttonLB(value: number);
  126002. /**
  126003. * Gets the value of the `Right` button
  126004. */
  126005. get buttonRB(): number;
  126006. /**
  126007. * Sets the value of the `Right` button
  126008. */
  126009. set buttonRB(value: number);
  126010. /**
  126011. * Gets the value of the Left joystick
  126012. */
  126013. get buttonLeftStick(): number;
  126014. /**
  126015. * Sets the value of the Left joystick
  126016. */
  126017. set buttonLeftStick(value: number);
  126018. /**
  126019. * Gets the value of the Right joystick
  126020. */
  126021. get buttonRightStick(): number;
  126022. /**
  126023. * Sets the value of the Right joystick
  126024. */
  126025. set buttonRightStick(value: number);
  126026. /**
  126027. * Gets the value of D-pad up
  126028. */
  126029. get dPadUp(): number;
  126030. /**
  126031. * Sets the value of D-pad up
  126032. */
  126033. set dPadUp(value: number);
  126034. /**
  126035. * Gets the value of D-pad down
  126036. */
  126037. get dPadDown(): number;
  126038. /**
  126039. * Sets the value of D-pad down
  126040. */
  126041. set dPadDown(value: number);
  126042. /**
  126043. * Gets the value of D-pad left
  126044. */
  126045. get dPadLeft(): number;
  126046. /**
  126047. * Sets the value of D-pad left
  126048. */
  126049. set dPadLeft(value: number);
  126050. /**
  126051. * Gets the value of D-pad right
  126052. */
  126053. get dPadRight(): number;
  126054. /**
  126055. * Sets the value of D-pad right
  126056. */
  126057. set dPadRight(value: number);
  126058. /**
  126059. * Force the gamepad to synchronize with device values
  126060. */
  126061. update(): void;
  126062. /**
  126063. * Disposes the gamepad
  126064. */
  126065. dispose(): void;
  126066. }
  126067. }
  126068. declare module BABYLON {
  126069. /**
  126070. * Defines supported buttons for DualShock compatible gamepads
  126071. */
  126072. export enum DualShockButton {
  126073. /** Cross */
  126074. Cross = 0,
  126075. /** Circle */
  126076. Circle = 1,
  126077. /** Square */
  126078. Square = 2,
  126079. /** Triangle */
  126080. Triangle = 3,
  126081. /** L1 */
  126082. L1 = 4,
  126083. /** R1 */
  126084. R1 = 5,
  126085. /** Share */
  126086. Share = 8,
  126087. /** Options */
  126088. Options = 9,
  126089. /** Left stick */
  126090. LeftStick = 10,
  126091. /** Right stick */
  126092. RightStick = 11
  126093. }
  126094. /** Defines values for DualShock DPad */
  126095. export enum DualShockDpad {
  126096. /** Up */
  126097. Up = 12,
  126098. /** Down */
  126099. Down = 13,
  126100. /** Left */
  126101. Left = 14,
  126102. /** Right */
  126103. Right = 15
  126104. }
  126105. /**
  126106. * Defines a DualShock gamepad
  126107. */
  126108. export class DualShockPad extends Gamepad {
  126109. private _leftTrigger;
  126110. private _rightTrigger;
  126111. private _onlefttriggerchanged;
  126112. private _onrighttriggerchanged;
  126113. private _onbuttondown;
  126114. private _onbuttonup;
  126115. private _ondpaddown;
  126116. private _ondpadup;
  126117. /** Observable raised when a button is pressed */
  126118. onButtonDownObservable: Observable<DualShockButton>;
  126119. /** Observable raised when a button is released */
  126120. onButtonUpObservable: Observable<DualShockButton>;
  126121. /** Observable raised when a pad is pressed */
  126122. onPadDownObservable: Observable<DualShockDpad>;
  126123. /** Observable raised when a pad is released */
  126124. onPadUpObservable: Observable<DualShockDpad>;
  126125. private _buttonCross;
  126126. private _buttonCircle;
  126127. private _buttonSquare;
  126128. private _buttonTriangle;
  126129. private _buttonShare;
  126130. private _buttonOptions;
  126131. private _buttonL1;
  126132. private _buttonR1;
  126133. private _buttonLeftStick;
  126134. private _buttonRightStick;
  126135. private _dPadUp;
  126136. private _dPadDown;
  126137. private _dPadLeft;
  126138. private _dPadRight;
  126139. /**
  126140. * Creates a new DualShock gamepad object
  126141. * @param id defines the id of this gamepad
  126142. * @param index defines its index
  126143. * @param gamepad defines the internal HTML gamepad object
  126144. */
  126145. constructor(id: string, index: number, gamepad: any);
  126146. /**
  126147. * Defines the callback to call when left trigger is pressed
  126148. * @param callback defines the callback to use
  126149. */
  126150. onlefttriggerchanged(callback: (value: number) => void): void;
  126151. /**
  126152. * Defines the callback to call when right trigger is pressed
  126153. * @param callback defines the callback to use
  126154. */
  126155. onrighttriggerchanged(callback: (value: number) => void): void;
  126156. /**
  126157. * Gets the left trigger value
  126158. */
  126159. get leftTrigger(): number;
  126160. /**
  126161. * Sets the left trigger value
  126162. */
  126163. set leftTrigger(newValue: number);
  126164. /**
  126165. * Gets the right trigger value
  126166. */
  126167. get rightTrigger(): number;
  126168. /**
  126169. * Sets the right trigger value
  126170. */
  126171. set rightTrigger(newValue: number);
  126172. /**
  126173. * Defines the callback to call when a button is pressed
  126174. * @param callback defines the callback to use
  126175. */
  126176. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  126177. /**
  126178. * Defines the callback to call when a button is released
  126179. * @param callback defines the callback to use
  126180. */
  126181. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  126182. /**
  126183. * Defines the callback to call when a pad is pressed
  126184. * @param callback defines the callback to use
  126185. */
  126186. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  126187. /**
  126188. * Defines the callback to call when a pad is released
  126189. * @param callback defines the callback to use
  126190. */
  126191. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  126192. private _setButtonValue;
  126193. private _setDPadValue;
  126194. /**
  126195. * Gets the value of the `Cross` button
  126196. */
  126197. get buttonCross(): number;
  126198. /**
  126199. * Sets the value of the `Cross` button
  126200. */
  126201. set buttonCross(value: number);
  126202. /**
  126203. * Gets the value of the `Circle` button
  126204. */
  126205. get buttonCircle(): number;
  126206. /**
  126207. * Sets the value of the `Circle` button
  126208. */
  126209. set buttonCircle(value: number);
  126210. /**
  126211. * Gets the value of the `Square` button
  126212. */
  126213. get buttonSquare(): number;
  126214. /**
  126215. * Sets the value of the `Square` button
  126216. */
  126217. set buttonSquare(value: number);
  126218. /**
  126219. * Gets the value of the `Triangle` button
  126220. */
  126221. get buttonTriangle(): number;
  126222. /**
  126223. * Sets the value of the `Triangle` button
  126224. */
  126225. set buttonTriangle(value: number);
  126226. /**
  126227. * Gets the value of the `Options` button
  126228. */
  126229. get buttonOptions(): number;
  126230. /**
  126231. * Sets the value of the `Options` button
  126232. */
  126233. set buttonOptions(value: number);
  126234. /**
  126235. * Gets the value of the `Share` button
  126236. */
  126237. get buttonShare(): number;
  126238. /**
  126239. * Sets the value of the `Share` button
  126240. */
  126241. set buttonShare(value: number);
  126242. /**
  126243. * Gets the value of the `L1` button
  126244. */
  126245. get buttonL1(): number;
  126246. /**
  126247. * Sets the value of the `L1` button
  126248. */
  126249. set buttonL1(value: number);
  126250. /**
  126251. * Gets the value of the `R1` button
  126252. */
  126253. get buttonR1(): number;
  126254. /**
  126255. * Sets the value of the `R1` button
  126256. */
  126257. set buttonR1(value: number);
  126258. /**
  126259. * Gets the value of the Left joystick
  126260. */
  126261. get buttonLeftStick(): number;
  126262. /**
  126263. * Sets the value of the Left joystick
  126264. */
  126265. set buttonLeftStick(value: number);
  126266. /**
  126267. * Gets the value of the Right joystick
  126268. */
  126269. get buttonRightStick(): number;
  126270. /**
  126271. * Sets the value of the Right joystick
  126272. */
  126273. set buttonRightStick(value: number);
  126274. /**
  126275. * Gets the value of D-pad up
  126276. */
  126277. get dPadUp(): number;
  126278. /**
  126279. * Sets the value of D-pad up
  126280. */
  126281. set dPadUp(value: number);
  126282. /**
  126283. * Gets the value of D-pad down
  126284. */
  126285. get dPadDown(): number;
  126286. /**
  126287. * Sets the value of D-pad down
  126288. */
  126289. set dPadDown(value: number);
  126290. /**
  126291. * Gets the value of D-pad left
  126292. */
  126293. get dPadLeft(): number;
  126294. /**
  126295. * Sets the value of D-pad left
  126296. */
  126297. set dPadLeft(value: number);
  126298. /**
  126299. * Gets the value of D-pad right
  126300. */
  126301. get dPadRight(): number;
  126302. /**
  126303. * Sets the value of D-pad right
  126304. */
  126305. set dPadRight(value: number);
  126306. /**
  126307. * Force the gamepad to synchronize with device values
  126308. */
  126309. update(): void;
  126310. /**
  126311. * Disposes the gamepad
  126312. */
  126313. dispose(): void;
  126314. }
  126315. }
  126316. declare module BABYLON {
  126317. /**
  126318. * Manager for handling gamepads
  126319. */
  126320. export class GamepadManager {
  126321. private _scene?;
  126322. private _babylonGamepads;
  126323. private _oneGamepadConnected;
  126324. /** @hidden */
  126325. _isMonitoring: boolean;
  126326. private _gamepadEventSupported;
  126327. private _gamepadSupport?;
  126328. /**
  126329. * observable to be triggered when the gamepad controller has been connected
  126330. */
  126331. onGamepadConnectedObservable: Observable<Gamepad>;
  126332. /**
  126333. * observable to be triggered when the gamepad controller has been disconnected
  126334. */
  126335. onGamepadDisconnectedObservable: Observable<Gamepad>;
  126336. private _onGamepadConnectedEvent;
  126337. private _onGamepadDisconnectedEvent;
  126338. /**
  126339. * Initializes the gamepad manager
  126340. * @param _scene BabylonJS scene
  126341. */
  126342. constructor(_scene?: Scene | undefined);
  126343. /**
  126344. * The gamepads in the game pad manager
  126345. */
  126346. get gamepads(): Gamepad[];
  126347. /**
  126348. * Get the gamepad controllers based on type
  126349. * @param type The type of gamepad controller
  126350. * @returns Nullable gamepad
  126351. */
  126352. getGamepadByType(type?: number): Nullable<Gamepad>;
  126353. /**
  126354. * Disposes the gamepad manager
  126355. */
  126356. dispose(): void;
  126357. private _addNewGamepad;
  126358. private _startMonitoringGamepads;
  126359. private _stopMonitoringGamepads;
  126360. /** @hidden */
  126361. _checkGamepadsStatus(): void;
  126362. private _updateGamepadObjects;
  126363. }
  126364. }
  126365. declare module BABYLON {
  126366. interface Scene {
  126367. /** @hidden */
  126368. _gamepadManager: Nullable<GamepadManager>;
  126369. /**
  126370. * Gets the gamepad manager associated with the scene
  126371. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  126372. */
  126373. gamepadManager: GamepadManager;
  126374. }
  126375. /**
  126376. * Interface representing a free camera inputs manager
  126377. */
  126378. interface FreeCameraInputsManager {
  126379. /**
  126380. * Adds gamepad input support to the FreeCameraInputsManager.
  126381. * @returns the FreeCameraInputsManager
  126382. */
  126383. addGamepad(): FreeCameraInputsManager;
  126384. }
  126385. /**
  126386. * Interface representing an arc rotate camera inputs manager
  126387. */
  126388. interface ArcRotateCameraInputsManager {
  126389. /**
  126390. * Adds gamepad input support to the ArcRotateCamera InputManager.
  126391. * @returns the camera inputs manager
  126392. */
  126393. addGamepad(): ArcRotateCameraInputsManager;
  126394. }
  126395. /**
  126396. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  126397. */
  126398. export class GamepadSystemSceneComponent implements ISceneComponent {
  126399. /**
  126400. * The component name helpfull to identify the component in the list of scene components.
  126401. */
  126402. readonly name: string;
  126403. /**
  126404. * The scene the component belongs to.
  126405. */
  126406. scene: Scene;
  126407. /**
  126408. * Creates a new instance of the component for the given scene
  126409. * @param scene Defines the scene to register the component in
  126410. */
  126411. constructor(scene: Scene);
  126412. /**
  126413. * Registers the component in a given scene
  126414. */
  126415. register(): void;
  126416. /**
  126417. * Rebuilds the elements related to this component in case of
  126418. * context lost for instance.
  126419. */
  126420. rebuild(): void;
  126421. /**
  126422. * Disposes the component and the associated ressources
  126423. */
  126424. dispose(): void;
  126425. private _beforeCameraUpdate;
  126426. }
  126427. }
  126428. declare module BABYLON {
  126429. /**
  126430. * 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,
  126431. * which still works and will still be found in many Playgrounds.
  126432. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126433. */
  126434. export class UniversalCamera extends TouchCamera {
  126435. /**
  126436. * Defines the gamepad rotation sensiblity.
  126437. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  126438. */
  126439. get gamepadAngularSensibility(): number;
  126440. set gamepadAngularSensibility(value: number);
  126441. /**
  126442. * Defines the gamepad move sensiblity.
  126443. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  126444. */
  126445. get gamepadMoveSensibility(): number;
  126446. set gamepadMoveSensibility(value: number);
  126447. /**
  126448. * 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,
  126449. * which still works and will still be found in many Playgrounds.
  126450. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126451. * @param name Define the name of the camera in the scene
  126452. * @param position Define the start position of the camera in the scene
  126453. * @param scene Define the scene the camera belongs to
  126454. */
  126455. constructor(name: string, position: Vector3, scene: Scene);
  126456. /**
  126457. * Gets the current object class name.
  126458. * @return the class name
  126459. */
  126460. getClassName(): string;
  126461. }
  126462. }
  126463. declare module BABYLON {
  126464. /**
  126465. * This represents a FPS type of camera. This is only here for back compat purpose.
  126466. * Please use the UniversalCamera instead as both are identical.
  126467. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126468. */
  126469. export class GamepadCamera extends UniversalCamera {
  126470. /**
  126471. * Instantiates a new Gamepad Camera
  126472. * This represents a FPS type of camera. This is only here for back compat purpose.
  126473. * Please use the UniversalCamera instead as both are identical.
  126474. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126475. * @param name Define the name of the camera in the scene
  126476. * @param position Define the start position of the camera in the scene
  126477. * @param scene Define the scene the camera belongs to
  126478. */
  126479. constructor(name: string, position: Vector3, scene: Scene);
  126480. /**
  126481. * Gets the current object class name.
  126482. * @return the class name
  126483. */
  126484. getClassName(): string;
  126485. }
  126486. }
  126487. declare module BABYLON {
  126488. /** @hidden */
  126489. export var passPixelShader: {
  126490. name: string;
  126491. shader: string;
  126492. };
  126493. }
  126494. declare module BABYLON {
  126495. /** @hidden */
  126496. export var passCubePixelShader: {
  126497. name: string;
  126498. shader: string;
  126499. };
  126500. }
  126501. declare module BABYLON {
  126502. /**
  126503. * PassPostProcess which produces an output the same as it's input
  126504. */
  126505. export class PassPostProcess extends PostProcess {
  126506. /**
  126507. * Gets a string identifying the name of the class
  126508. * @returns "PassPostProcess" string
  126509. */
  126510. getClassName(): string;
  126511. /**
  126512. * Creates the PassPostProcess
  126513. * @param name The name of the effect.
  126514. * @param options The required width/height ratio to downsize to before computing the render pass.
  126515. * @param camera The camera to apply the render pass to.
  126516. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126517. * @param engine The engine which the post process will be applied. (default: current engine)
  126518. * @param reusable If the post process can be reused on the same frame. (default: false)
  126519. * @param textureType The type of texture to be used when performing the post processing.
  126520. * @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)
  126521. */
  126522. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126523. /** @hidden */
  126524. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  126525. }
  126526. /**
  126527. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  126528. */
  126529. export class PassCubePostProcess extends PostProcess {
  126530. private _face;
  126531. /**
  126532. * Gets or sets the cube face to display.
  126533. * * 0 is +X
  126534. * * 1 is -X
  126535. * * 2 is +Y
  126536. * * 3 is -Y
  126537. * * 4 is +Z
  126538. * * 5 is -Z
  126539. */
  126540. get face(): number;
  126541. set face(value: number);
  126542. /**
  126543. * Gets a string identifying the name of the class
  126544. * @returns "PassCubePostProcess" string
  126545. */
  126546. getClassName(): string;
  126547. /**
  126548. * Creates the PassCubePostProcess
  126549. * @param name The name of the effect.
  126550. * @param options The required width/height ratio to downsize to before computing the render pass.
  126551. * @param camera The camera to apply the render pass to.
  126552. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126553. * @param engine The engine which the post process will be applied. (default: current engine)
  126554. * @param reusable If the post process can be reused on the same frame. (default: false)
  126555. * @param textureType The type of texture to be used when performing the post processing.
  126556. * @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)
  126557. */
  126558. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126559. /** @hidden */
  126560. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  126561. }
  126562. }
  126563. declare module BABYLON {
  126564. /** @hidden */
  126565. export var anaglyphPixelShader: {
  126566. name: string;
  126567. shader: string;
  126568. };
  126569. }
  126570. declare module BABYLON {
  126571. /**
  126572. * Postprocess used to generate anaglyphic rendering
  126573. */
  126574. export class AnaglyphPostProcess extends PostProcess {
  126575. private _passedProcess;
  126576. /**
  126577. * Gets a string identifying the name of the class
  126578. * @returns "AnaglyphPostProcess" string
  126579. */
  126580. getClassName(): string;
  126581. /**
  126582. * Creates a new AnaglyphPostProcess
  126583. * @param name defines postprocess name
  126584. * @param options defines creation options or target ratio scale
  126585. * @param rigCameras defines cameras using this postprocess
  126586. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  126587. * @param engine defines hosting engine
  126588. * @param reusable defines if the postprocess will be reused multiple times per frame
  126589. */
  126590. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  126591. }
  126592. }
  126593. declare module BABYLON {
  126594. /**
  126595. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  126596. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126597. */
  126598. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  126599. /**
  126600. * Creates a new AnaglyphArcRotateCamera
  126601. * @param name defines camera name
  126602. * @param alpha defines alpha angle (in radians)
  126603. * @param beta defines beta angle (in radians)
  126604. * @param radius defines radius
  126605. * @param target defines camera target
  126606. * @param interaxialDistance defines distance between each color axis
  126607. * @param scene defines the hosting scene
  126608. */
  126609. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  126610. /**
  126611. * Gets camera class name
  126612. * @returns AnaglyphArcRotateCamera
  126613. */
  126614. getClassName(): string;
  126615. }
  126616. }
  126617. declare module BABYLON {
  126618. /**
  126619. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  126620. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126621. */
  126622. export class AnaglyphFreeCamera extends FreeCamera {
  126623. /**
  126624. * Creates a new AnaglyphFreeCamera
  126625. * @param name defines camera name
  126626. * @param position defines initial position
  126627. * @param interaxialDistance defines distance between each color axis
  126628. * @param scene defines the hosting scene
  126629. */
  126630. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126631. /**
  126632. * Gets camera class name
  126633. * @returns AnaglyphFreeCamera
  126634. */
  126635. getClassName(): string;
  126636. }
  126637. }
  126638. declare module BABYLON {
  126639. /**
  126640. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  126641. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126642. */
  126643. export class AnaglyphGamepadCamera extends GamepadCamera {
  126644. /**
  126645. * Creates a new AnaglyphGamepadCamera
  126646. * @param name defines camera name
  126647. * @param position defines initial position
  126648. * @param interaxialDistance defines distance between each color axis
  126649. * @param scene defines the hosting scene
  126650. */
  126651. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126652. /**
  126653. * Gets camera class name
  126654. * @returns AnaglyphGamepadCamera
  126655. */
  126656. getClassName(): string;
  126657. }
  126658. }
  126659. declare module BABYLON {
  126660. /**
  126661. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  126662. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126663. */
  126664. export class AnaglyphUniversalCamera extends UniversalCamera {
  126665. /**
  126666. * Creates a new AnaglyphUniversalCamera
  126667. * @param name defines camera name
  126668. * @param position defines initial position
  126669. * @param interaxialDistance defines distance between each color axis
  126670. * @param scene defines the hosting scene
  126671. */
  126672. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126673. /**
  126674. * Gets camera class name
  126675. * @returns AnaglyphUniversalCamera
  126676. */
  126677. getClassName(): string;
  126678. }
  126679. }
  126680. declare module BABYLON {
  126681. /**
  126682. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  126683. * @see https://doc.babylonjs.com/features/cameras
  126684. */
  126685. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  126686. /**
  126687. * Creates a new StereoscopicArcRotateCamera
  126688. * @param name defines camera name
  126689. * @param alpha defines alpha angle (in radians)
  126690. * @param beta defines beta angle (in radians)
  126691. * @param radius defines radius
  126692. * @param target defines camera target
  126693. * @param interaxialDistance defines distance between each color axis
  126694. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126695. * @param scene defines the hosting scene
  126696. */
  126697. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126698. /**
  126699. * Gets camera class name
  126700. * @returns StereoscopicArcRotateCamera
  126701. */
  126702. getClassName(): string;
  126703. }
  126704. }
  126705. declare module BABYLON {
  126706. /**
  126707. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  126708. * @see https://doc.babylonjs.com/features/cameras
  126709. */
  126710. export class StereoscopicFreeCamera extends FreeCamera {
  126711. /**
  126712. * Creates a new StereoscopicFreeCamera
  126713. * @param name defines camera name
  126714. * @param position defines initial position
  126715. * @param interaxialDistance defines distance between each color axis
  126716. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126717. * @param scene defines the hosting scene
  126718. */
  126719. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126720. /**
  126721. * Gets camera class name
  126722. * @returns StereoscopicFreeCamera
  126723. */
  126724. getClassName(): string;
  126725. }
  126726. }
  126727. declare module BABYLON {
  126728. /**
  126729. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  126730. * @see https://doc.babylonjs.com/features/cameras
  126731. */
  126732. export class StereoscopicGamepadCamera extends GamepadCamera {
  126733. /**
  126734. * Creates a new StereoscopicGamepadCamera
  126735. * @param name defines camera name
  126736. * @param position defines initial position
  126737. * @param interaxialDistance defines distance between each color axis
  126738. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126739. * @param scene defines the hosting scene
  126740. */
  126741. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126742. /**
  126743. * Gets camera class name
  126744. * @returns StereoscopicGamepadCamera
  126745. */
  126746. getClassName(): string;
  126747. }
  126748. }
  126749. declare module BABYLON {
  126750. /**
  126751. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  126752. * @see https://doc.babylonjs.com/features/cameras
  126753. */
  126754. export class StereoscopicUniversalCamera extends UniversalCamera {
  126755. /**
  126756. * Creates a new StereoscopicUniversalCamera
  126757. * @param name defines camera name
  126758. * @param position defines initial position
  126759. * @param interaxialDistance defines distance between each color axis
  126760. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126761. * @param scene defines the hosting scene
  126762. */
  126763. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126764. /**
  126765. * Gets camera class name
  126766. * @returns StereoscopicUniversalCamera
  126767. */
  126768. getClassName(): string;
  126769. }
  126770. }
  126771. declare module BABYLON {
  126772. /**
  126773. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  126774. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126775. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126776. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126777. */
  126778. export class VirtualJoysticksCamera extends FreeCamera {
  126779. /**
  126780. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  126781. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126782. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126783. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126784. * @param name Define the name of the camera in the scene
  126785. * @param position Define the start position of the camera in the scene
  126786. * @param scene Define the scene the camera belongs to
  126787. */
  126788. constructor(name: string, position: Vector3, scene: Scene);
  126789. /**
  126790. * Gets the current object class name.
  126791. * @return the class name
  126792. */
  126793. getClassName(): string;
  126794. }
  126795. }
  126796. declare module BABYLON {
  126797. /**
  126798. * This represents all the required metrics to create a VR camera.
  126799. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  126800. */
  126801. export class VRCameraMetrics {
  126802. /**
  126803. * Define the horizontal resolution off the screen.
  126804. */
  126805. hResolution: number;
  126806. /**
  126807. * Define the vertical resolution off the screen.
  126808. */
  126809. vResolution: number;
  126810. /**
  126811. * Define the horizontal screen size.
  126812. */
  126813. hScreenSize: number;
  126814. /**
  126815. * Define the vertical screen size.
  126816. */
  126817. vScreenSize: number;
  126818. /**
  126819. * Define the vertical screen center position.
  126820. */
  126821. vScreenCenter: number;
  126822. /**
  126823. * Define the distance of the eyes to the screen.
  126824. */
  126825. eyeToScreenDistance: number;
  126826. /**
  126827. * Define the distance between both lenses
  126828. */
  126829. lensSeparationDistance: number;
  126830. /**
  126831. * Define the distance between both viewer's eyes.
  126832. */
  126833. interpupillaryDistance: number;
  126834. /**
  126835. * Define the distortion factor of the VR postprocess.
  126836. * Please, touch with care.
  126837. */
  126838. distortionK: number[];
  126839. /**
  126840. * Define the chromatic aberration correction factors for the VR post process.
  126841. */
  126842. chromaAbCorrection: number[];
  126843. /**
  126844. * Define the scale factor of the post process.
  126845. * The smaller the better but the slower.
  126846. */
  126847. postProcessScaleFactor: number;
  126848. /**
  126849. * Define an offset for the lens center.
  126850. */
  126851. lensCenterOffset: number;
  126852. /**
  126853. * Define if the current vr camera should compensate the distortion of the lense or not.
  126854. */
  126855. compensateDistortion: boolean;
  126856. /**
  126857. * Defines if multiview should be enabled when rendering (Default: false)
  126858. */
  126859. multiviewEnabled: boolean;
  126860. /**
  126861. * Gets the rendering aspect ratio based on the provided resolutions.
  126862. */
  126863. get aspectRatio(): number;
  126864. /**
  126865. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  126866. */
  126867. get aspectRatioFov(): number;
  126868. /**
  126869. * @hidden
  126870. */
  126871. get leftHMatrix(): Matrix;
  126872. /**
  126873. * @hidden
  126874. */
  126875. get rightHMatrix(): Matrix;
  126876. /**
  126877. * @hidden
  126878. */
  126879. get leftPreViewMatrix(): Matrix;
  126880. /**
  126881. * @hidden
  126882. */
  126883. get rightPreViewMatrix(): Matrix;
  126884. /**
  126885. * Get the default VRMetrics based on the most generic setup.
  126886. * @returns the default vr metrics
  126887. */
  126888. static GetDefault(): VRCameraMetrics;
  126889. }
  126890. }
  126891. declare module BABYLON {
  126892. /** @hidden */
  126893. export var vrDistortionCorrectionPixelShader: {
  126894. name: string;
  126895. shader: string;
  126896. };
  126897. }
  126898. declare module BABYLON {
  126899. /**
  126900. * VRDistortionCorrectionPostProcess used for mobile VR
  126901. */
  126902. export class VRDistortionCorrectionPostProcess extends PostProcess {
  126903. private _isRightEye;
  126904. private _distortionFactors;
  126905. private _postProcessScaleFactor;
  126906. private _lensCenterOffset;
  126907. private _scaleIn;
  126908. private _scaleFactor;
  126909. private _lensCenter;
  126910. /**
  126911. * Gets a string identifying the name of the class
  126912. * @returns "VRDistortionCorrectionPostProcess" string
  126913. */
  126914. getClassName(): string;
  126915. /**
  126916. * Initializes the VRDistortionCorrectionPostProcess
  126917. * @param name The name of the effect.
  126918. * @param camera The camera to apply the render pass to.
  126919. * @param isRightEye If this is for the right eye distortion
  126920. * @param vrMetrics All the required metrics for the VR camera
  126921. */
  126922. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  126923. }
  126924. }
  126925. declare module BABYLON {
  126926. /**
  126927. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  126928. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126929. */
  126930. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  126931. /**
  126932. * Creates a new VRDeviceOrientationArcRotateCamera
  126933. * @param name defines camera name
  126934. * @param alpha defines the camera rotation along the logitudinal axis
  126935. * @param beta defines the camera rotation along the latitudinal axis
  126936. * @param radius defines the camera distance from its target
  126937. * @param target defines the camera target
  126938. * @param scene defines the scene the camera belongs to
  126939. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126940. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126941. */
  126942. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126943. /**
  126944. * Gets camera class name
  126945. * @returns VRDeviceOrientationArcRotateCamera
  126946. */
  126947. getClassName(): string;
  126948. }
  126949. }
  126950. declare module BABYLON {
  126951. /**
  126952. * Camera used to simulate VR rendering (based on FreeCamera)
  126953. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126954. */
  126955. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  126956. /**
  126957. * Creates a new VRDeviceOrientationFreeCamera
  126958. * @param name defines camera name
  126959. * @param position defines the start position of the camera
  126960. * @param scene defines the scene the camera belongs to
  126961. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126962. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126963. */
  126964. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126965. /**
  126966. * Gets camera class name
  126967. * @returns VRDeviceOrientationFreeCamera
  126968. */
  126969. getClassName(): string;
  126970. }
  126971. }
  126972. declare module BABYLON {
  126973. /**
  126974. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  126975. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126976. */
  126977. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  126978. /**
  126979. * Creates a new VRDeviceOrientationGamepadCamera
  126980. * @param name defines camera name
  126981. * @param position defines the start position of the camera
  126982. * @param scene defines the scene the camera belongs to
  126983. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126984. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126985. */
  126986. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126987. /**
  126988. * Gets camera class name
  126989. * @returns VRDeviceOrientationGamepadCamera
  126990. */
  126991. getClassName(): string;
  126992. }
  126993. }
  126994. declare module BABYLON {
  126995. /**
  126996. * A class extending Texture allowing drawing on a texture
  126997. * @see https://doc.babylonjs.com/how_to/dynamictexture
  126998. */
  126999. export class DynamicTexture extends Texture {
  127000. private _generateMipMaps;
  127001. private _canvas;
  127002. private _context;
  127003. /**
  127004. * Creates a DynamicTexture
  127005. * @param name defines the name of the texture
  127006. * @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
  127007. * @param scene defines the scene where you want the texture
  127008. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  127009. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  127010. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  127011. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  127012. */
  127013. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  127014. /**
  127015. * Get the current class name of the texture useful for serialization or dynamic coding.
  127016. * @returns "DynamicTexture"
  127017. */
  127018. getClassName(): string;
  127019. /**
  127020. * Gets the current state of canRescale
  127021. */
  127022. get canRescale(): boolean;
  127023. private _recreate;
  127024. /**
  127025. * Scales the texture
  127026. * @param ratio the scale factor to apply to both width and height
  127027. */
  127028. scale(ratio: number): void;
  127029. /**
  127030. * Resizes the texture
  127031. * @param width the new width
  127032. * @param height the new height
  127033. */
  127034. scaleTo(width: number, height: number): void;
  127035. /**
  127036. * Gets the context of the canvas used by the texture
  127037. * @returns the canvas context of the dynamic texture
  127038. */
  127039. getContext(): CanvasRenderingContext2D;
  127040. /**
  127041. * Clears the texture
  127042. */
  127043. clear(): void;
  127044. /**
  127045. * Updates the texture
  127046. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  127047. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  127048. */
  127049. update(invertY?: boolean, premulAlpha?: boolean): void;
  127050. /**
  127051. * Draws text onto the texture
  127052. * @param text defines the text to be drawn
  127053. * @param x defines the placement of the text from the left
  127054. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  127055. * @param font defines the font to be used with font-style, font-size, font-name
  127056. * @param color defines the color used for the text
  127057. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  127058. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  127059. * @param update defines whether texture is immediately update (default is true)
  127060. */
  127061. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  127062. /**
  127063. * Clones the texture
  127064. * @returns the clone of the texture.
  127065. */
  127066. clone(): DynamicTexture;
  127067. /**
  127068. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  127069. * @returns a serialized dynamic texture object
  127070. */
  127071. serialize(): any;
  127072. private _IsCanvasElement;
  127073. /** @hidden */
  127074. _rebuild(): void;
  127075. }
  127076. }
  127077. declare module BABYLON {
  127078. /**
  127079. * Class containing static functions to help procedurally build meshes
  127080. */
  127081. export class GroundBuilder {
  127082. /**
  127083. * Creates a ground mesh
  127084. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  127085. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  127086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127087. * @param name defines the name of the mesh
  127088. * @param options defines the options used to create the mesh
  127089. * @param scene defines the hosting scene
  127090. * @returns the ground mesh
  127091. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  127092. */
  127093. static CreateGround(name: string, options: {
  127094. width?: number;
  127095. height?: number;
  127096. subdivisions?: number;
  127097. subdivisionsX?: number;
  127098. subdivisionsY?: number;
  127099. updatable?: boolean;
  127100. }, scene: any): Mesh;
  127101. /**
  127102. * Creates a tiled ground mesh
  127103. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  127104. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  127105. * * 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
  127106. * * 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
  127107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127108. * @param name defines the name of the mesh
  127109. * @param options defines the options used to create the mesh
  127110. * @param scene defines the hosting scene
  127111. * @returns the tiled ground mesh
  127112. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  127113. */
  127114. static CreateTiledGround(name: string, options: {
  127115. xmin: number;
  127116. zmin: number;
  127117. xmax: number;
  127118. zmax: number;
  127119. subdivisions?: {
  127120. w: number;
  127121. h: number;
  127122. };
  127123. precision?: {
  127124. w: number;
  127125. h: number;
  127126. };
  127127. updatable?: boolean;
  127128. }, scene?: Nullable<Scene>): Mesh;
  127129. /**
  127130. * Creates a ground mesh from a height map
  127131. * * The parameter `url` sets the URL of the height map image resource.
  127132. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  127133. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  127134. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  127135. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  127136. * * 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.
  127137. * * 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).
  127138. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  127139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127140. * @param name defines the name of the mesh
  127141. * @param url defines the url to the height map
  127142. * @param options defines the options used to create the mesh
  127143. * @param scene defines the hosting scene
  127144. * @returns the ground mesh
  127145. * @see https://doc.babylonjs.com/babylon101/height_map
  127146. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  127147. */
  127148. static CreateGroundFromHeightMap(name: string, url: string, options: {
  127149. width?: number;
  127150. height?: number;
  127151. subdivisions?: number;
  127152. minHeight?: number;
  127153. maxHeight?: number;
  127154. colorFilter?: Color3;
  127155. alphaFilter?: number;
  127156. updatable?: boolean;
  127157. onReady?: (mesh: GroundMesh) => void;
  127158. }, scene?: Nullable<Scene>): GroundMesh;
  127159. }
  127160. }
  127161. declare module BABYLON {
  127162. /**
  127163. * Class containing static functions to help procedurally build meshes
  127164. */
  127165. export class TorusBuilder {
  127166. /**
  127167. * Creates a torus mesh
  127168. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  127169. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  127170. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  127171. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127172. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127174. * @param name defines the name of the mesh
  127175. * @param options defines the options used to create the mesh
  127176. * @param scene defines the hosting scene
  127177. * @returns the torus mesh
  127178. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  127179. */
  127180. static CreateTorus(name: string, options: {
  127181. diameter?: number;
  127182. thickness?: number;
  127183. tessellation?: number;
  127184. updatable?: boolean;
  127185. sideOrientation?: number;
  127186. frontUVs?: Vector4;
  127187. backUVs?: Vector4;
  127188. }, scene: any): Mesh;
  127189. }
  127190. }
  127191. declare module BABYLON {
  127192. /**
  127193. * Class containing static functions to help procedurally build meshes
  127194. */
  127195. export class CylinderBuilder {
  127196. /**
  127197. * Creates a cylinder or a cone mesh
  127198. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  127199. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  127200. * * 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.
  127201. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  127202. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  127203. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  127204. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  127205. * * 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).
  127206. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  127207. * * 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).
  127208. * * 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
  127209. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  127210. * * 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
  127211. * * 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.
  127212. * * If `enclose` is false, a ring surface is one element.
  127213. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  127214. * * 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
  127215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127216. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127218. * @param name defines the name of the mesh
  127219. * @param options defines the options used to create the mesh
  127220. * @param scene defines the hosting scene
  127221. * @returns the cylinder mesh
  127222. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  127223. */
  127224. static CreateCylinder(name: string, options: {
  127225. height?: number;
  127226. diameterTop?: number;
  127227. diameterBottom?: number;
  127228. diameter?: number;
  127229. tessellation?: number;
  127230. subdivisions?: number;
  127231. arc?: number;
  127232. faceColors?: Color4[];
  127233. faceUV?: Vector4[];
  127234. updatable?: boolean;
  127235. hasRings?: boolean;
  127236. enclose?: boolean;
  127237. cap?: number;
  127238. sideOrientation?: number;
  127239. frontUVs?: Vector4;
  127240. backUVs?: Vector4;
  127241. }, scene: any): Mesh;
  127242. }
  127243. }
  127244. declare module BABYLON {
  127245. /**
  127246. * States of the webXR experience
  127247. */
  127248. export enum WebXRState {
  127249. /**
  127250. * Transitioning to being in XR mode
  127251. */
  127252. ENTERING_XR = 0,
  127253. /**
  127254. * Transitioning to non XR mode
  127255. */
  127256. EXITING_XR = 1,
  127257. /**
  127258. * In XR mode and presenting
  127259. */
  127260. IN_XR = 2,
  127261. /**
  127262. * Not entered XR mode
  127263. */
  127264. NOT_IN_XR = 3
  127265. }
  127266. /**
  127267. * Abstraction of the XR render target
  127268. */
  127269. export interface WebXRRenderTarget extends IDisposable {
  127270. /**
  127271. * xrpresent context of the canvas which can be used to display/mirror xr content
  127272. */
  127273. canvasContext: WebGLRenderingContext;
  127274. /**
  127275. * xr layer for the canvas
  127276. */
  127277. xrLayer: Nullable<XRWebGLLayer>;
  127278. /**
  127279. * Initializes the xr layer for the session
  127280. * @param xrSession xr session
  127281. * @returns a promise that will resolve once the XR Layer has been created
  127282. */
  127283. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  127284. }
  127285. }
  127286. declare module BABYLON {
  127287. /**
  127288. * COnfiguration object for WebXR output canvas
  127289. */
  127290. export class WebXRManagedOutputCanvasOptions {
  127291. /**
  127292. * An optional canvas in case you wish to create it yourself and provide it here.
  127293. * If not provided, a new canvas will be created
  127294. */
  127295. canvasElement?: HTMLCanvasElement;
  127296. /**
  127297. * Options for this XR Layer output
  127298. */
  127299. canvasOptions?: XRWebGLLayerOptions;
  127300. /**
  127301. * CSS styling for a newly created canvas (if not provided)
  127302. */
  127303. newCanvasCssStyle?: string;
  127304. /**
  127305. * Get the default values of the configuration object
  127306. * @param engine defines the engine to use (can be null)
  127307. * @returns default values of this configuration object
  127308. */
  127309. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  127310. }
  127311. /**
  127312. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  127313. */
  127314. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  127315. private _options;
  127316. private _canvas;
  127317. private _engine;
  127318. private _originalCanvasSize;
  127319. /**
  127320. * Rendering context of the canvas which can be used to display/mirror xr content
  127321. */
  127322. canvasContext: WebGLRenderingContext;
  127323. /**
  127324. * xr layer for the canvas
  127325. */
  127326. xrLayer: Nullable<XRWebGLLayer>;
  127327. /**
  127328. * Obseervers registered here will be triggered when the xr layer was initialized
  127329. */
  127330. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  127331. /**
  127332. * Initializes the canvas to be added/removed upon entering/exiting xr
  127333. * @param _xrSessionManager The XR Session manager
  127334. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  127335. */
  127336. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  127337. /**
  127338. * Disposes of the object
  127339. */
  127340. dispose(): void;
  127341. /**
  127342. * Initializes the xr layer for the session
  127343. * @param xrSession xr session
  127344. * @returns a promise that will resolve once the XR Layer has been created
  127345. */
  127346. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  127347. private _addCanvas;
  127348. private _removeCanvas;
  127349. private _setCanvasSize;
  127350. private _setManagedOutputCanvas;
  127351. }
  127352. }
  127353. declare module BABYLON {
  127354. /**
  127355. * Manages an XRSession to work with Babylon's engine
  127356. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  127357. */
  127358. export class WebXRSessionManager implements IDisposable {
  127359. /** The scene which the session should be created for */
  127360. scene: Scene;
  127361. private _referenceSpace;
  127362. private _rttProvider;
  127363. private _sessionEnded;
  127364. private _xrNavigator;
  127365. private baseLayer;
  127366. /**
  127367. * The base reference space from which the session started. good if you want to reset your
  127368. * reference space
  127369. */
  127370. baseReferenceSpace: XRReferenceSpace;
  127371. /**
  127372. * Current XR frame
  127373. */
  127374. currentFrame: Nullable<XRFrame>;
  127375. /** WebXR timestamp updated every frame */
  127376. currentTimestamp: number;
  127377. /**
  127378. * Used just in case of a failure to initialize an immersive session.
  127379. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  127380. */
  127381. defaultHeightCompensation: number;
  127382. /**
  127383. * Fires every time a new xrFrame arrives which can be used to update the camera
  127384. */
  127385. onXRFrameObservable: Observable<XRFrame>;
  127386. /**
  127387. * Fires when the reference space changed
  127388. */
  127389. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  127390. /**
  127391. * Fires when the xr session is ended either by the device or manually done
  127392. */
  127393. onXRSessionEnded: Observable<any>;
  127394. /**
  127395. * Fires when the xr session is ended either by the device or manually done
  127396. */
  127397. onXRSessionInit: Observable<XRSession>;
  127398. /**
  127399. * Underlying xr session
  127400. */
  127401. session: XRSession;
  127402. /**
  127403. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  127404. * or get the offset the player is currently at.
  127405. */
  127406. viewerReferenceSpace: XRReferenceSpace;
  127407. /**
  127408. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  127409. * @param scene The scene which the session should be created for
  127410. */
  127411. constructor(
  127412. /** The scene which the session should be created for */
  127413. scene: Scene);
  127414. /**
  127415. * The current reference space used in this session. This reference space can constantly change!
  127416. * It is mainly used to offset the camera's position.
  127417. */
  127418. get referenceSpace(): XRReferenceSpace;
  127419. /**
  127420. * Set a new reference space and triggers the observable
  127421. */
  127422. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  127423. /**
  127424. * Disposes of the session manager
  127425. */
  127426. dispose(): void;
  127427. /**
  127428. * Stops the xrSession and restores the render loop
  127429. * @returns Promise which resolves after it exits XR
  127430. */
  127431. exitXRAsync(): Promise<void>;
  127432. /**
  127433. * Gets the correct render target texture to be rendered this frame for this eye
  127434. * @param eye the eye for which to get the render target
  127435. * @returns the render target for the specified eye
  127436. */
  127437. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  127438. /**
  127439. * Creates a WebXRRenderTarget object for the XR session
  127440. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  127441. * @param options optional options to provide when creating a new render target
  127442. * @returns a WebXR render target to which the session can render
  127443. */
  127444. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  127445. /**
  127446. * Initializes the manager
  127447. * After initialization enterXR can be called to start an XR session
  127448. * @returns Promise which resolves after it is initialized
  127449. */
  127450. initializeAsync(): Promise<void>;
  127451. /**
  127452. * Initializes an xr session
  127453. * @param xrSessionMode mode to initialize
  127454. * @param xrSessionInit defines optional and required values to pass to the session builder
  127455. * @returns a promise which will resolve once the session has been initialized
  127456. */
  127457. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  127458. /**
  127459. * Checks if a session would be supported for the creation options specified
  127460. * @param sessionMode session mode to check if supported eg. immersive-vr
  127461. * @returns A Promise that resolves to true if supported and false if not
  127462. */
  127463. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127464. /**
  127465. * Resets the reference space to the one started the session
  127466. */
  127467. resetReferenceSpace(): void;
  127468. /**
  127469. * Starts rendering to the xr layer
  127470. */
  127471. runXRRenderLoop(): void;
  127472. /**
  127473. * Sets the reference space on the xr session
  127474. * @param referenceSpaceType space to set
  127475. * @returns a promise that will resolve once the reference space has been set
  127476. */
  127477. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  127478. /**
  127479. * Updates the render state of the session
  127480. * @param state state to set
  127481. * @returns a promise that resolves once the render state has been updated
  127482. */
  127483. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  127484. /**
  127485. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  127486. * @param sessionMode defines the session to test
  127487. * @returns a promise with boolean as final value
  127488. */
  127489. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127490. private _createRenderTargetTexture;
  127491. }
  127492. }
  127493. declare module BABYLON {
  127494. /**
  127495. * WebXR Camera which holds the views for the xrSession
  127496. * @see https://doc.babylonjs.com/how_to/webxr_camera
  127497. */
  127498. export class WebXRCamera extends FreeCamera {
  127499. private _xrSessionManager;
  127500. private _firstFrame;
  127501. private _referenceQuaternion;
  127502. private _referencedPosition;
  127503. private _xrInvPositionCache;
  127504. private _xrInvQuaternionCache;
  127505. /**
  127506. * Observable raised before camera teleportation
  127507. */
  127508. onBeforeCameraTeleport: Observable<Vector3>;
  127509. /**
  127510. * Observable raised after camera teleportation
  127511. */
  127512. onAfterCameraTeleport: Observable<Vector3>;
  127513. /**
  127514. * Should position compensation execute on first frame.
  127515. * This is used when copying the position from a native (non XR) camera
  127516. */
  127517. compensateOnFirstFrame: boolean;
  127518. /**
  127519. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  127520. * @param name the name of the camera
  127521. * @param scene the scene to add the camera to
  127522. * @param _xrSessionManager a constructed xr session manager
  127523. */
  127524. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  127525. /**
  127526. * Return the user's height, unrelated to the current ground.
  127527. * This will be the y position of this camera, when ground level is 0.
  127528. */
  127529. get realWorldHeight(): number;
  127530. /** @hidden */
  127531. _updateForDualEyeDebugging(): void;
  127532. /**
  127533. * Sets this camera's transformation based on a non-vr camera
  127534. * @param otherCamera the non-vr camera to copy the transformation from
  127535. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  127536. */
  127537. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  127538. /**
  127539. * Gets the current instance class name ("WebXRCamera").
  127540. * @returns the class name
  127541. */
  127542. getClassName(): string;
  127543. private _rotate180;
  127544. private _updateFromXRSession;
  127545. private _updateNumberOfRigCameras;
  127546. private _updateReferenceSpace;
  127547. private _updateReferenceSpaceOffset;
  127548. }
  127549. }
  127550. declare module BABYLON {
  127551. /**
  127552. * Defining the interface required for a (webxr) feature
  127553. */
  127554. export interface IWebXRFeature extends IDisposable {
  127555. /**
  127556. * Is this feature attached
  127557. */
  127558. attached: boolean;
  127559. /**
  127560. * Should auto-attach be disabled?
  127561. */
  127562. disableAutoAttach: boolean;
  127563. /**
  127564. * Attach the feature to the session
  127565. * Will usually be called by the features manager
  127566. *
  127567. * @param force should attachment be forced (even when already attached)
  127568. * @returns true if successful.
  127569. */
  127570. attach(force?: boolean): boolean;
  127571. /**
  127572. * Detach the feature from the session
  127573. * Will usually be called by the features manager
  127574. *
  127575. * @returns true if successful.
  127576. */
  127577. detach(): boolean;
  127578. /**
  127579. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127580. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127581. *
  127582. * @returns whether or not the feature is compatible in this environment
  127583. */
  127584. isCompatible(): boolean;
  127585. /**
  127586. * Was this feature disposed;
  127587. */
  127588. isDisposed: boolean;
  127589. /**
  127590. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  127591. */
  127592. xrNativeFeatureName?: string;
  127593. /**
  127594. * A list of (Babylon WebXR) features this feature depends on
  127595. */
  127596. dependsOn?: string[];
  127597. }
  127598. /**
  127599. * A list of the currently available features without referencing them
  127600. */
  127601. export class WebXRFeatureName {
  127602. /**
  127603. * The name of the anchor system feature
  127604. */
  127605. static readonly ANCHOR_SYSTEM: string;
  127606. /**
  127607. * The name of the background remover feature
  127608. */
  127609. static readonly BACKGROUND_REMOVER: string;
  127610. /**
  127611. * The name of the hit test feature
  127612. */
  127613. static readonly HIT_TEST: string;
  127614. /**
  127615. * physics impostors for xr controllers feature
  127616. */
  127617. static readonly PHYSICS_CONTROLLERS: string;
  127618. /**
  127619. * The name of the plane detection feature
  127620. */
  127621. static readonly PLANE_DETECTION: string;
  127622. /**
  127623. * The name of the pointer selection feature
  127624. */
  127625. static readonly POINTER_SELECTION: string;
  127626. /**
  127627. * The name of the teleportation feature
  127628. */
  127629. static readonly TELEPORTATION: string;
  127630. /**
  127631. * The name of the feature points feature.
  127632. */
  127633. static readonly FEATURE_POINTS: string;
  127634. /**
  127635. * The name of the hand tracking feature.
  127636. */
  127637. static readonly HAND_TRACKING: string;
  127638. }
  127639. /**
  127640. * Defining the constructor of a feature. Used to register the modules.
  127641. */
  127642. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  127643. /**
  127644. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  127645. * It is mainly used in AR sessions.
  127646. *
  127647. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  127648. */
  127649. export class WebXRFeaturesManager implements IDisposable {
  127650. private _xrSessionManager;
  127651. private static readonly _AvailableFeatures;
  127652. private _features;
  127653. /**
  127654. * constructs a new features manages.
  127655. *
  127656. * @param _xrSessionManager an instance of WebXRSessionManager
  127657. */
  127658. constructor(_xrSessionManager: WebXRSessionManager);
  127659. /**
  127660. * Used to register a module. After calling this function a developer can use this feature in the scene.
  127661. * Mainly used internally.
  127662. *
  127663. * @param featureName the name of the feature to register
  127664. * @param constructorFunction the function used to construct the module
  127665. * @param version the (babylon) version of the module
  127666. * @param stable is that a stable version of this module
  127667. */
  127668. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  127669. /**
  127670. * Returns a constructor of a specific feature.
  127671. *
  127672. * @param featureName the name of the feature to construct
  127673. * @param version the version of the feature to load
  127674. * @param xrSessionManager the xrSessionManager. Used to construct the module
  127675. * @param options optional options provided to the module.
  127676. * @returns a function that, when called, will return a new instance of this feature
  127677. */
  127678. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  127679. /**
  127680. * Can be used to return the list of features currently registered
  127681. *
  127682. * @returns an Array of available features
  127683. */
  127684. static GetAvailableFeatures(): string[];
  127685. /**
  127686. * Gets the versions available for a specific feature
  127687. * @param featureName the name of the feature
  127688. * @returns an array with the available versions
  127689. */
  127690. static GetAvailableVersions(featureName: string): string[];
  127691. /**
  127692. * Return the latest unstable version of this feature
  127693. * @param featureName the name of the feature to search
  127694. * @returns the version number. if not found will return -1
  127695. */
  127696. static GetLatestVersionOfFeature(featureName: string): number;
  127697. /**
  127698. * Return the latest stable version of this feature
  127699. * @param featureName the name of the feature to search
  127700. * @returns the version number. if not found will return -1
  127701. */
  127702. static GetStableVersionOfFeature(featureName: string): number;
  127703. /**
  127704. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  127705. * Can be used during a session to start a feature
  127706. * @param featureName the name of feature to attach
  127707. */
  127708. attachFeature(featureName: string): void;
  127709. /**
  127710. * Can be used inside a session or when the session ends to detach a specific feature
  127711. * @param featureName the name of the feature to detach
  127712. */
  127713. detachFeature(featureName: string): void;
  127714. /**
  127715. * Used to disable an already-enabled feature
  127716. * The feature will be disposed and will be recreated once enabled.
  127717. * @param featureName the feature to disable
  127718. * @returns true if disable was successful
  127719. */
  127720. disableFeature(featureName: string | {
  127721. Name: string;
  127722. }): boolean;
  127723. /**
  127724. * dispose this features manager
  127725. */
  127726. dispose(): void;
  127727. /**
  127728. * 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.
  127729. * 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.
  127730. *
  127731. * @param featureName the name of the feature to load or the class of the feature
  127732. * @param version optional version to load. if not provided the latest version will be enabled
  127733. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  127734. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  127735. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  127736. * @returns a new constructed feature or throws an error if feature not found.
  127737. */
  127738. enableFeature(featureName: string | {
  127739. Name: string;
  127740. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  127741. /**
  127742. * get the implementation of an enabled feature.
  127743. * @param featureName the name of the feature to load
  127744. * @returns the feature class, if found
  127745. */
  127746. getEnabledFeature(featureName: string): IWebXRFeature;
  127747. /**
  127748. * Get the list of enabled features
  127749. * @returns an array of enabled features
  127750. */
  127751. getEnabledFeatures(): string[];
  127752. /**
  127753. * This function will exten the session creation configuration object with enabled features.
  127754. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  127755. * according to the defined "required" variable, provided during enableFeature call
  127756. * @param xrSessionInit the xr Session init object to extend
  127757. *
  127758. * @returns an extended XRSessionInit object
  127759. */
  127760. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  127761. }
  127762. }
  127763. declare module BABYLON {
  127764. /**
  127765. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  127766. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  127767. */
  127768. export class WebXRExperienceHelper implements IDisposable {
  127769. private scene;
  127770. private _nonVRCamera;
  127771. private _originalSceneAutoClear;
  127772. private _supported;
  127773. /**
  127774. * Camera used to render xr content
  127775. */
  127776. camera: WebXRCamera;
  127777. /** A features manager for this xr session */
  127778. featuresManager: WebXRFeaturesManager;
  127779. /**
  127780. * Observers registered here will be triggered after the camera's initial transformation is set
  127781. * This can be used to set a different ground level or an extra rotation.
  127782. *
  127783. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  127784. * to the position set after this observable is done executing.
  127785. */
  127786. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  127787. /**
  127788. * Fires when the state of the experience helper has changed
  127789. */
  127790. onStateChangedObservable: Observable<WebXRState>;
  127791. /** Session manager used to keep track of xr session */
  127792. sessionManager: WebXRSessionManager;
  127793. /**
  127794. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  127795. */
  127796. state: WebXRState;
  127797. /**
  127798. * Creates a WebXRExperienceHelper
  127799. * @param scene The scene the helper should be created in
  127800. */
  127801. private constructor();
  127802. /**
  127803. * Creates the experience helper
  127804. * @param scene the scene to attach the experience helper to
  127805. * @returns a promise for the experience helper
  127806. */
  127807. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  127808. /**
  127809. * Disposes of the experience helper
  127810. */
  127811. dispose(): void;
  127812. /**
  127813. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  127814. * @param sessionMode options for the XR session
  127815. * @param referenceSpaceType frame of reference of the XR session
  127816. * @param renderTarget the output canvas that will be used to enter XR mode
  127817. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  127818. * @returns promise that resolves after xr mode has entered
  127819. */
  127820. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  127821. /**
  127822. * Exits XR mode and returns the scene to its original state
  127823. * @returns promise that resolves after xr mode has exited
  127824. */
  127825. exitXRAsync(): Promise<void>;
  127826. private _nonXRToXRCamera;
  127827. private _setState;
  127828. }
  127829. }
  127830. declare module BABYLON {
  127831. /**
  127832. * X-Y values for axes in WebXR
  127833. */
  127834. export interface IWebXRMotionControllerAxesValue {
  127835. /**
  127836. * The value of the x axis
  127837. */
  127838. x: number;
  127839. /**
  127840. * The value of the y-axis
  127841. */
  127842. y: number;
  127843. }
  127844. /**
  127845. * changed / previous values for the values of this component
  127846. */
  127847. export interface IWebXRMotionControllerComponentChangesValues<T> {
  127848. /**
  127849. * current (this frame) value
  127850. */
  127851. current: T;
  127852. /**
  127853. * previous (last change) value
  127854. */
  127855. previous: T;
  127856. }
  127857. /**
  127858. * Represents changes in the component between current frame and last values recorded
  127859. */
  127860. export interface IWebXRMotionControllerComponentChanges {
  127861. /**
  127862. * will be populated with previous and current values if axes changed
  127863. */
  127864. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  127865. /**
  127866. * will be populated with previous and current values if pressed changed
  127867. */
  127868. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127869. /**
  127870. * will be populated with previous and current values if touched changed
  127871. */
  127872. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127873. /**
  127874. * will be populated with previous and current values if value changed
  127875. */
  127876. value?: IWebXRMotionControllerComponentChangesValues<number>;
  127877. }
  127878. /**
  127879. * This class represents a single component (for example button or thumbstick) of a motion controller
  127880. */
  127881. export class WebXRControllerComponent implements IDisposable {
  127882. /**
  127883. * the id of this component
  127884. */
  127885. id: string;
  127886. /**
  127887. * the type of the component
  127888. */
  127889. type: MotionControllerComponentType;
  127890. private _buttonIndex;
  127891. private _axesIndices;
  127892. private _axes;
  127893. private _changes;
  127894. private _currentValue;
  127895. private _hasChanges;
  127896. private _pressed;
  127897. private _touched;
  127898. /**
  127899. * button component type
  127900. */
  127901. static BUTTON_TYPE: MotionControllerComponentType;
  127902. /**
  127903. * squeeze component type
  127904. */
  127905. static SQUEEZE_TYPE: MotionControllerComponentType;
  127906. /**
  127907. * Thumbstick component type
  127908. */
  127909. static THUMBSTICK_TYPE: MotionControllerComponentType;
  127910. /**
  127911. * Touchpad component type
  127912. */
  127913. static TOUCHPAD_TYPE: MotionControllerComponentType;
  127914. /**
  127915. * trigger component type
  127916. */
  127917. static TRIGGER_TYPE: MotionControllerComponentType;
  127918. /**
  127919. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  127920. * the axes data changes
  127921. */
  127922. onAxisValueChangedObservable: Observable<{
  127923. x: number;
  127924. y: number;
  127925. }>;
  127926. /**
  127927. * Observers registered here will be triggered when the state of a button changes
  127928. * State change is either pressed / touched / value
  127929. */
  127930. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  127931. /**
  127932. * Creates a new component for a motion controller.
  127933. * It is created by the motion controller itself
  127934. *
  127935. * @param id the id of this component
  127936. * @param type the type of the component
  127937. * @param _buttonIndex index in the buttons array of the gamepad
  127938. * @param _axesIndices indices of the values in the axes array of the gamepad
  127939. */
  127940. constructor(
  127941. /**
  127942. * the id of this component
  127943. */
  127944. id: string,
  127945. /**
  127946. * the type of the component
  127947. */
  127948. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  127949. /**
  127950. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  127951. */
  127952. get axes(): IWebXRMotionControllerAxesValue;
  127953. /**
  127954. * Get the changes. Elements will be populated only if they changed with their previous and current value
  127955. */
  127956. get changes(): IWebXRMotionControllerComponentChanges;
  127957. /**
  127958. * Return whether or not the component changed the last frame
  127959. */
  127960. get hasChanges(): boolean;
  127961. /**
  127962. * is the button currently pressed
  127963. */
  127964. get pressed(): boolean;
  127965. /**
  127966. * is the button currently touched
  127967. */
  127968. get touched(): boolean;
  127969. /**
  127970. * Get the current value of this component
  127971. */
  127972. get value(): number;
  127973. /**
  127974. * Dispose this component
  127975. */
  127976. dispose(): void;
  127977. /**
  127978. * Are there axes correlating to this component
  127979. * @return true is axes data is available
  127980. */
  127981. isAxes(): boolean;
  127982. /**
  127983. * Is this component a button (hence - pressable)
  127984. * @returns true if can be pressed
  127985. */
  127986. isButton(): boolean;
  127987. /**
  127988. * update this component using the gamepad object it is in. Called on every frame
  127989. * @param nativeController the native gamepad controller object
  127990. */
  127991. update(nativeController: IMinimalMotionControllerObject): void;
  127992. }
  127993. }
  127994. declare module BABYLON {
  127995. /**
  127996. * Interface used to represent data loading progression
  127997. */
  127998. export interface ISceneLoaderProgressEvent {
  127999. /**
  128000. * Defines if data length to load can be evaluated
  128001. */
  128002. readonly lengthComputable: boolean;
  128003. /**
  128004. * Defines the loaded data length
  128005. */
  128006. readonly loaded: number;
  128007. /**
  128008. * Defines the data length to load
  128009. */
  128010. readonly total: number;
  128011. }
  128012. /**
  128013. * Interface used by SceneLoader plugins to define supported file extensions
  128014. */
  128015. export interface ISceneLoaderPluginExtensions {
  128016. /**
  128017. * Defines the list of supported extensions
  128018. */
  128019. [extension: string]: {
  128020. isBinary: boolean;
  128021. };
  128022. }
  128023. /**
  128024. * Interface used by SceneLoader plugin factory
  128025. */
  128026. export interface ISceneLoaderPluginFactory {
  128027. /**
  128028. * Defines the name of the factory
  128029. */
  128030. name: string;
  128031. /**
  128032. * Function called to create a new plugin
  128033. * @return the new plugin
  128034. */
  128035. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  128036. /**
  128037. * The callback that returns true if the data can be directly loaded.
  128038. * @param data string containing the file data
  128039. * @returns if the data can be loaded directly
  128040. */
  128041. canDirectLoad?(data: string): boolean;
  128042. }
  128043. /**
  128044. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  128045. */
  128046. export interface ISceneLoaderPluginBase {
  128047. /**
  128048. * The friendly name of this plugin.
  128049. */
  128050. name: string;
  128051. /**
  128052. * The file extensions supported by this plugin.
  128053. */
  128054. extensions: string | ISceneLoaderPluginExtensions;
  128055. /**
  128056. * The callback called when loading from a url.
  128057. * @param scene scene loading this url
  128058. * @param url url to load
  128059. * @param onSuccess callback called when the file successfully loads
  128060. * @param onProgress callback called while file is loading (if the server supports this mode)
  128061. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  128062. * @param onError callback called when the file fails to load
  128063. * @returns a file request object
  128064. */
  128065. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  128066. /**
  128067. * The callback called when loading from a file object.
  128068. * @param scene scene loading this file
  128069. * @param file defines the file to load
  128070. * @param onSuccess defines the callback to call when data is loaded
  128071. * @param onProgress defines the callback to call during loading process
  128072. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  128073. * @param onError defines the callback to call when an error occurs
  128074. * @returns a file request object
  128075. */
  128076. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  128077. /**
  128078. * The callback that returns true if the data can be directly loaded.
  128079. * @param data string containing the file data
  128080. * @returns if the data can be loaded directly
  128081. */
  128082. canDirectLoad?(data: string): boolean;
  128083. /**
  128084. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  128085. * @param scene scene loading this data
  128086. * @param data string containing the data
  128087. * @returns data to pass to the plugin
  128088. */
  128089. directLoad?(scene: Scene, data: string): any;
  128090. /**
  128091. * The callback that allows custom handling of the root url based on the response url.
  128092. * @param rootUrl the original root url
  128093. * @param responseURL the response url if available
  128094. * @returns the new root url
  128095. */
  128096. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  128097. }
  128098. /**
  128099. * Interface used to define a SceneLoader plugin
  128100. */
  128101. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  128102. /**
  128103. * Import meshes into a scene.
  128104. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128105. * @param scene The scene to import into
  128106. * @param data The data to import
  128107. * @param rootUrl The root url for scene and resources
  128108. * @param meshes The meshes array to import into
  128109. * @param particleSystems The particle systems array to import into
  128110. * @param skeletons The skeletons array to import into
  128111. * @param onError The callback when import fails
  128112. * @returns True if successful or false otherwise
  128113. */
  128114. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  128115. /**
  128116. * Load into a scene.
  128117. * @param scene The scene to load into
  128118. * @param data The data to import
  128119. * @param rootUrl The root url for scene and resources
  128120. * @param onError The callback when import fails
  128121. * @returns True if successful or false otherwise
  128122. */
  128123. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  128124. /**
  128125. * Load into an asset container.
  128126. * @param scene The scene to load into
  128127. * @param data The data to import
  128128. * @param rootUrl The root url for scene and resources
  128129. * @param onError The callback when import fails
  128130. * @returns The loaded asset container
  128131. */
  128132. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  128133. }
  128134. /**
  128135. * Interface used to define an async SceneLoader plugin
  128136. */
  128137. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  128138. /**
  128139. * Import meshes into a scene.
  128140. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128141. * @param scene The scene to import into
  128142. * @param data The data to import
  128143. * @param rootUrl The root url for scene and resources
  128144. * @param onProgress The callback when the load progresses
  128145. * @param fileName Defines the name of the file to load
  128146. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  128147. */
  128148. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  128149. meshes: AbstractMesh[];
  128150. particleSystems: IParticleSystem[];
  128151. skeletons: Skeleton[];
  128152. animationGroups: AnimationGroup[];
  128153. }>;
  128154. /**
  128155. * Load into a scene.
  128156. * @param scene The scene to load into
  128157. * @param data The data to import
  128158. * @param rootUrl The root url for scene and resources
  128159. * @param onProgress The callback when the load progresses
  128160. * @param fileName Defines the name of the file to load
  128161. * @returns Nothing
  128162. */
  128163. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  128164. /**
  128165. * Load into an asset container.
  128166. * @param scene The scene to load into
  128167. * @param data The data to import
  128168. * @param rootUrl The root url for scene and resources
  128169. * @param onProgress The callback when the load progresses
  128170. * @param fileName Defines the name of the file to load
  128171. * @returns The loaded asset container
  128172. */
  128173. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  128174. }
  128175. /**
  128176. * Mode that determines how to handle old animation groups before loading new ones.
  128177. */
  128178. export enum SceneLoaderAnimationGroupLoadingMode {
  128179. /**
  128180. * Reset all old animations to initial state then dispose them.
  128181. */
  128182. Clean = 0,
  128183. /**
  128184. * Stop all old animations.
  128185. */
  128186. Stop = 1,
  128187. /**
  128188. * Restart old animations from first frame.
  128189. */
  128190. Sync = 2,
  128191. /**
  128192. * Old animations remains untouched.
  128193. */
  128194. NoSync = 3
  128195. }
  128196. /**
  128197. * Defines a plugin registered by the SceneLoader
  128198. */
  128199. interface IRegisteredPlugin {
  128200. /**
  128201. * Defines the plugin to use
  128202. */
  128203. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  128204. /**
  128205. * Defines if the plugin supports binary data
  128206. */
  128207. isBinary: boolean;
  128208. }
  128209. /**
  128210. * Class used to load scene from various file formats using registered plugins
  128211. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  128212. */
  128213. export class SceneLoader {
  128214. /**
  128215. * No logging while loading
  128216. */
  128217. static readonly NO_LOGGING: number;
  128218. /**
  128219. * Minimal logging while loading
  128220. */
  128221. static readonly MINIMAL_LOGGING: number;
  128222. /**
  128223. * Summary logging while loading
  128224. */
  128225. static readonly SUMMARY_LOGGING: number;
  128226. /**
  128227. * Detailled logging while loading
  128228. */
  128229. static readonly DETAILED_LOGGING: number;
  128230. /**
  128231. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  128232. */
  128233. static get ForceFullSceneLoadingForIncremental(): boolean;
  128234. static set ForceFullSceneLoadingForIncremental(value: boolean);
  128235. /**
  128236. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  128237. */
  128238. static get ShowLoadingScreen(): boolean;
  128239. static set ShowLoadingScreen(value: boolean);
  128240. /**
  128241. * Defines the current logging level (while loading the scene)
  128242. * @ignorenaming
  128243. */
  128244. static get loggingLevel(): number;
  128245. static set loggingLevel(value: number);
  128246. /**
  128247. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  128248. */
  128249. static get CleanBoneMatrixWeights(): boolean;
  128250. static set CleanBoneMatrixWeights(value: boolean);
  128251. /**
  128252. * Event raised when a plugin is used to load a scene
  128253. */
  128254. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  128255. private static _registeredPlugins;
  128256. private static _showingLoadingScreen;
  128257. /**
  128258. * Gets the default plugin (used to load Babylon files)
  128259. * @returns the .babylon plugin
  128260. */
  128261. static GetDefaultPlugin(): IRegisteredPlugin;
  128262. private static _GetPluginForExtension;
  128263. private static _GetPluginForDirectLoad;
  128264. private static _GetPluginForFilename;
  128265. private static _GetDirectLoad;
  128266. private static _LoadData;
  128267. private static _GetFileInfo;
  128268. /**
  128269. * Gets a plugin that can load the given extension
  128270. * @param extension defines the extension to load
  128271. * @returns a plugin or null if none works
  128272. */
  128273. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  128274. /**
  128275. * Gets a boolean indicating that the given extension can be loaded
  128276. * @param extension defines the extension to load
  128277. * @returns true if the extension is supported
  128278. */
  128279. static IsPluginForExtensionAvailable(extension: string): boolean;
  128280. /**
  128281. * Adds a new plugin to the list of registered plugins
  128282. * @param plugin defines the plugin to add
  128283. */
  128284. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  128285. /**
  128286. * Import meshes into a scene
  128287. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128288. * @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)
  128289. * @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)
  128290. * @param scene the instance of BABYLON.Scene to append to
  128291. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  128292. * @param onProgress a callback with a progress event for each file being loaded
  128293. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128294. * @param pluginExtension the extension used to determine the plugin
  128295. * @returns The loaded plugin
  128296. */
  128297. 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>;
  128298. /**
  128299. * Import meshes into a scene
  128300. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128301. * @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)
  128302. * @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)
  128303. * @param scene the instance of BABYLON.Scene to append to
  128304. * @param onProgress a callback with a progress event for each file being loaded
  128305. * @param pluginExtension the extension used to determine the plugin
  128306. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  128307. */
  128308. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  128309. meshes: AbstractMesh[];
  128310. particleSystems: IParticleSystem[];
  128311. skeletons: Skeleton[];
  128312. animationGroups: AnimationGroup[];
  128313. }>;
  128314. /**
  128315. * Load a scene
  128316. * @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)
  128317. * @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)
  128318. * @param engine is the instance of BABYLON.Engine to use to create the scene
  128319. * @param onSuccess a callback with the scene when import succeeds
  128320. * @param onProgress a callback with a progress event for each file being loaded
  128321. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128322. * @param pluginExtension the extension used to determine the plugin
  128323. * @returns The loaded plugin
  128324. */
  128325. 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>;
  128326. /**
  128327. * Load a scene
  128328. * @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)
  128329. * @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)
  128330. * @param engine is the instance of BABYLON.Engine to use to create the scene
  128331. * @param onProgress a callback with a progress event for each file being loaded
  128332. * @param pluginExtension the extension used to determine the plugin
  128333. * @returns The loaded scene
  128334. */
  128335. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  128336. /**
  128337. * Append a scene
  128338. * @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)
  128339. * @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)
  128340. * @param scene is the instance of BABYLON.Scene to append to
  128341. * @param onSuccess a callback with the scene when import succeeds
  128342. * @param onProgress a callback with a progress event for each file being loaded
  128343. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128344. * @param pluginExtension the extension used to determine the plugin
  128345. * @returns The loaded plugin
  128346. */
  128347. 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>;
  128348. /**
  128349. * Append a scene
  128350. * @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)
  128351. * @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)
  128352. * @param scene is the instance of BABYLON.Scene to append to
  128353. * @param onProgress a callback with a progress event for each file being loaded
  128354. * @param pluginExtension the extension used to determine the plugin
  128355. * @returns The given scene
  128356. */
  128357. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  128358. /**
  128359. * Load a scene into an asset container
  128360. * @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)
  128361. * @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)
  128362. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128363. * @param onSuccess a callback with the scene when import succeeds
  128364. * @param onProgress a callback with a progress event for each file being loaded
  128365. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128366. * @param pluginExtension the extension used to determine the plugin
  128367. * @returns The loaded plugin
  128368. */
  128369. 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>;
  128370. /**
  128371. * Load a scene into an asset container
  128372. * @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)
  128373. * @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)
  128374. * @param scene is the instance of Scene to append to
  128375. * @param onProgress a callback with a progress event for each file being loaded
  128376. * @param pluginExtension the extension used to determine the plugin
  128377. * @returns The loaded asset container
  128378. */
  128379. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  128380. /**
  128381. * Import animations from a file into a scene
  128382. * @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)
  128383. * @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)
  128384. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128385. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128386. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128387. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128388. * @param onSuccess a callback with the scene when import succeeds
  128389. * @param onProgress a callback with a progress event for each file being loaded
  128390. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128391. * @param pluginExtension the extension used to determine the plugin
  128392. */
  128393. 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;
  128394. /**
  128395. * Import animations from a file into a scene
  128396. * @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)
  128397. * @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)
  128398. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128399. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128400. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128401. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128402. * @param onSuccess a callback with the scene when import succeeds
  128403. * @param onProgress a callback with a progress event for each file being loaded
  128404. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128405. * @param pluginExtension the extension used to determine the plugin
  128406. * @returns the updated scene with imported animations
  128407. */
  128408. 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>;
  128409. }
  128410. }
  128411. declare module BABYLON {
  128412. /**
  128413. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  128414. */
  128415. export type MotionControllerHandedness = "none" | "left" | "right";
  128416. /**
  128417. * The type of components available in motion controllers.
  128418. * This is not the name of the component.
  128419. */
  128420. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  128421. /**
  128422. * The state of a controller component
  128423. */
  128424. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  128425. /**
  128426. * The schema of motion controller layout.
  128427. * No object will be initialized using this interface
  128428. * This is used just to define the profile.
  128429. */
  128430. export interface IMotionControllerLayout {
  128431. /**
  128432. * Path to load the assets. Usually relative to the base path
  128433. */
  128434. assetPath: string;
  128435. /**
  128436. * Available components (unsorted)
  128437. */
  128438. components: {
  128439. /**
  128440. * A map of component Ids
  128441. */
  128442. [componentId: string]: {
  128443. /**
  128444. * The type of input the component outputs
  128445. */
  128446. type: MotionControllerComponentType;
  128447. /**
  128448. * The indices of this component in the gamepad object
  128449. */
  128450. gamepadIndices: {
  128451. /**
  128452. * Index of button
  128453. */
  128454. button?: number;
  128455. /**
  128456. * If available, index of x-axis
  128457. */
  128458. xAxis?: number;
  128459. /**
  128460. * If available, index of y-axis
  128461. */
  128462. yAxis?: number;
  128463. };
  128464. /**
  128465. * The mesh's root node name
  128466. */
  128467. rootNodeName: string;
  128468. /**
  128469. * Animation definitions for this model
  128470. */
  128471. visualResponses: {
  128472. [stateKey: string]: {
  128473. /**
  128474. * What property will be animated
  128475. */
  128476. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  128477. /**
  128478. * What states influence this visual response
  128479. */
  128480. states: MotionControllerComponentStateType[];
  128481. /**
  128482. * Type of animation - movement or visibility
  128483. */
  128484. valueNodeProperty: "transform" | "visibility";
  128485. /**
  128486. * Base node name to move. Its position will be calculated according to the min and max nodes
  128487. */
  128488. valueNodeName?: string;
  128489. /**
  128490. * Minimum movement node
  128491. */
  128492. minNodeName?: string;
  128493. /**
  128494. * Max movement node
  128495. */
  128496. maxNodeName?: string;
  128497. };
  128498. };
  128499. /**
  128500. * If touch enabled, what is the name of node to display user feedback
  128501. */
  128502. touchPointNodeName?: string;
  128503. };
  128504. };
  128505. /**
  128506. * Is it xr standard mapping or not
  128507. */
  128508. gamepadMapping: "" | "xr-standard";
  128509. /**
  128510. * Base root node of this entire model
  128511. */
  128512. rootNodeName: string;
  128513. /**
  128514. * Defines the main button component id
  128515. */
  128516. selectComponentId: string;
  128517. }
  128518. /**
  128519. * A definition for the layout map in the input profile
  128520. */
  128521. export interface IMotionControllerLayoutMap {
  128522. /**
  128523. * Layouts with handedness type as a key
  128524. */
  128525. [handedness: string]: IMotionControllerLayout;
  128526. }
  128527. /**
  128528. * The XR Input profile schema
  128529. * Profiles can be found here:
  128530. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  128531. */
  128532. export interface IMotionControllerProfile {
  128533. /**
  128534. * fallback profiles for this profileId
  128535. */
  128536. fallbackProfileIds: string[];
  128537. /**
  128538. * The layout map, with handedness as key
  128539. */
  128540. layouts: IMotionControllerLayoutMap;
  128541. /**
  128542. * The id of this profile
  128543. * correlates to the profile(s) in the xrInput.profiles array
  128544. */
  128545. profileId: string;
  128546. }
  128547. /**
  128548. * A helper-interface for the 3 meshes needed for controller button animation
  128549. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  128550. */
  128551. export interface IMotionControllerButtonMeshMap {
  128552. /**
  128553. * the mesh that defines the pressed value mesh position.
  128554. * This is used to find the max-position of this button
  128555. */
  128556. pressedMesh: AbstractMesh;
  128557. /**
  128558. * the mesh that defines the unpressed value mesh position.
  128559. * This is used to find the min (or initial) position of this button
  128560. */
  128561. unpressedMesh: AbstractMesh;
  128562. /**
  128563. * The mesh that will be changed when value changes
  128564. */
  128565. valueMesh: AbstractMesh;
  128566. }
  128567. /**
  128568. * A helper-interface for the 3 meshes needed for controller axis animation.
  128569. * This will be expanded when touchpad animations are fully supported
  128570. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  128571. */
  128572. export interface IMotionControllerMeshMap {
  128573. /**
  128574. * the mesh that defines the maximum value mesh position.
  128575. */
  128576. maxMesh?: AbstractMesh;
  128577. /**
  128578. * the mesh that defines the minimum value mesh position.
  128579. */
  128580. minMesh?: AbstractMesh;
  128581. /**
  128582. * The mesh that will be changed when axis value changes
  128583. */
  128584. valueMesh?: AbstractMesh;
  128585. }
  128586. /**
  128587. * The elements needed for change-detection of the gamepad objects in motion controllers
  128588. */
  128589. export interface IMinimalMotionControllerObject {
  128590. /**
  128591. * Available axes of this controller
  128592. */
  128593. axes: number[];
  128594. /**
  128595. * An array of available buttons
  128596. */
  128597. buttons: Array<{
  128598. /**
  128599. * Value of the button/trigger
  128600. */
  128601. value: number;
  128602. /**
  128603. * If the button/trigger is currently touched
  128604. */
  128605. touched: boolean;
  128606. /**
  128607. * If the button/trigger is currently pressed
  128608. */
  128609. pressed: boolean;
  128610. }>;
  128611. /**
  128612. * EXPERIMENTAL haptic support.
  128613. */
  128614. hapticActuators?: Array<{
  128615. pulse: (value: number, duration: number) => Promise<boolean>;
  128616. }>;
  128617. }
  128618. /**
  128619. * An Abstract Motion controller
  128620. * This class receives an xrInput and a profile layout and uses those to initialize the components
  128621. * Each component has an observable to check for changes in value and state
  128622. */
  128623. export abstract class WebXRAbstractMotionController implements IDisposable {
  128624. protected scene: Scene;
  128625. protected layout: IMotionControllerLayout;
  128626. /**
  128627. * The gamepad object correlating to this controller
  128628. */
  128629. gamepadObject: IMinimalMotionControllerObject;
  128630. /**
  128631. * handedness (left/right/none) of this controller
  128632. */
  128633. handedness: MotionControllerHandedness;
  128634. private _initComponent;
  128635. private _modelReady;
  128636. /**
  128637. * A map of components (WebXRControllerComponent) in this motion controller
  128638. * Components have a ComponentType and can also have both button and axis definitions
  128639. */
  128640. readonly components: {
  128641. [id: string]: WebXRControllerComponent;
  128642. };
  128643. /**
  128644. * Disable the model's animation. Can be set at any time.
  128645. */
  128646. disableAnimation: boolean;
  128647. /**
  128648. * Observers registered here will be triggered when the model of this controller is done loading
  128649. */
  128650. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  128651. /**
  128652. * The profile id of this motion controller
  128653. */
  128654. abstract profileId: string;
  128655. /**
  128656. * The root mesh of the model. It is null if the model was not yet initialized
  128657. */
  128658. rootMesh: Nullable<AbstractMesh>;
  128659. /**
  128660. * constructs a new abstract motion controller
  128661. * @param scene the scene to which the model of the controller will be added
  128662. * @param layout The profile layout to load
  128663. * @param gamepadObject The gamepad object correlating to this controller
  128664. * @param handedness handedness (left/right/none) of this controller
  128665. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  128666. */
  128667. constructor(scene: Scene, layout: IMotionControllerLayout,
  128668. /**
  128669. * The gamepad object correlating to this controller
  128670. */
  128671. gamepadObject: IMinimalMotionControllerObject,
  128672. /**
  128673. * handedness (left/right/none) of this controller
  128674. */
  128675. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  128676. /**
  128677. * Dispose this controller, the model mesh and all its components
  128678. */
  128679. dispose(): void;
  128680. /**
  128681. * Returns all components of specific type
  128682. * @param type the type to search for
  128683. * @return an array of components with this type
  128684. */
  128685. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  128686. /**
  128687. * get a component based an its component id as defined in layout.components
  128688. * @param id the id of the component
  128689. * @returns the component correlates to the id or undefined if not found
  128690. */
  128691. getComponent(id: string): WebXRControllerComponent;
  128692. /**
  128693. * Get the list of components available in this motion controller
  128694. * @returns an array of strings correlating to available components
  128695. */
  128696. getComponentIds(): string[];
  128697. /**
  128698. * Get the first component of specific type
  128699. * @param type type of component to find
  128700. * @return a controller component or null if not found
  128701. */
  128702. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  128703. /**
  128704. * Get the main (Select) component of this controller as defined in the layout
  128705. * @returns the main component of this controller
  128706. */
  128707. getMainComponent(): WebXRControllerComponent;
  128708. /**
  128709. * Loads the model correlating to this controller
  128710. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  128711. * @returns A promise fulfilled with the result of the model loading
  128712. */
  128713. loadModel(): Promise<boolean>;
  128714. /**
  128715. * Update this model using the current XRFrame
  128716. * @param xrFrame the current xr frame to use and update the model
  128717. */
  128718. updateFromXRFrame(xrFrame: XRFrame): void;
  128719. /**
  128720. * Backwards compatibility due to a deeply-integrated typo
  128721. */
  128722. get handness(): XREye;
  128723. /**
  128724. * Pulse (vibrate) this controller
  128725. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  128726. * Consecutive calls to this function will cancel the last pulse call
  128727. *
  128728. * @param value the strength of the pulse in 0.0...1.0 range
  128729. * @param duration Duration of the pulse in milliseconds
  128730. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  128731. * @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
  128732. */
  128733. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  128734. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128735. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128736. /**
  128737. * Moves the axis on the controller mesh based on its current state
  128738. * @param axis the index of the axis
  128739. * @param axisValue the value of the axis which determines the meshes new position
  128740. * @hidden
  128741. */
  128742. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  128743. /**
  128744. * Update the model itself with the current frame data
  128745. * @param xrFrame the frame to use for updating the model mesh
  128746. */
  128747. protected updateModel(xrFrame: XRFrame): void;
  128748. /**
  128749. * Get the filename and path for this controller's model
  128750. * @returns a map of filename and path
  128751. */
  128752. protected abstract _getFilenameAndPath(): {
  128753. filename: string;
  128754. path: string;
  128755. };
  128756. /**
  128757. * This function is called before the mesh is loaded. It checks for loading constraints.
  128758. * For example, this function can check if the GLB loader is available
  128759. * If this function returns false, the generic controller will be loaded instead
  128760. * @returns Is the client ready to load the mesh
  128761. */
  128762. protected abstract _getModelLoadingConstraints(): boolean;
  128763. /**
  128764. * This function will be called after the model was successfully loaded and can be used
  128765. * for mesh transformations before it is available for the user
  128766. * @param meshes the loaded meshes
  128767. */
  128768. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  128769. /**
  128770. * Set the root mesh for this controller. Important for the WebXR controller class
  128771. * @param meshes the loaded meshes
  128772. */
  128773. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  128774. /**
  128775. * A function executed each frame that updates the mesh (if needed)
  128776. * @param xrFrame the current xrFrame
  128777. */
  128778. protected abstract _updateModel(xrFrame: XRFrame): void;
  128779. private _getGenericFilenameAndPath;
  128780. private _getGenericParentMesh;
  128781. }
  128782. }
  128783. declare module BABYLON {
  128784. /**
  128785. * A generic trigger-only motion controller for WebXR
  128786. */
  128787. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  128788. /**
  128789. * Static version of the profile id of this controller
  128790. */
  128791. static ProfileId: string;
  128792. profileId: string;
  128793. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  128794. protected _getFilenameAndPath(): {
  128795. filename: string;
  128796. path: string;
  128797. };
  128798. protected _getModelLoadingConstraints(): boolean;
  128799. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  128800. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128801. protected _updateModel(): void;
  128802. }
  128803. }
  128804. declare module BABYLON {
  128805. /**
  128806. * Class containing static functions to help procedurally build meshes
  128807. */
  128808. export class SphereBuilder {
  128809. /**
  128810. * Creates a sphere mesh
  128811. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  128812. * * 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`)
  128813. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  128814. * * 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
  128815. * * 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)
  128816. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128817. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128819. * @param name defines the name of the mesh
  128820. * @param options defines the options used to create the mesh
  128821. * @param scene defines the hosting scene
  128822. * @returns the sphere mesh
  128823. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  128824. */
  128825. static CreateSphere(name: string, options: {
  128826. segments?: number;
  128827. diameter?: number;
  128828. diameterX?: number;
  128829. diameterY?: number;
  128830. diameterZ?: number;
  128831. arc?: number;
  128832. slice?: number;
  128833. sideOrientation?: number;
  128834. frontUVs?: Vector4;
  128835. backUVs?: Vector4;
  128836. updatable?: boolean;
  128837. }, scene?: Nullable<Scene>): Mesh;
  128838. }
  128839. }
  128840. declare module BABYLON {
  128841. /**
  128842. * A profiled motion controller has its profile loaded from an online repository.
  128843. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  128844. */
  128845. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  128846. private _repositoryUrl;
  128847. private _buttonMeshMapping;
  128848. private _touchDots;
  128849. /**
  128850. * The profile ID of this controller. Will be populated when the controller initializes.
  128851. */
  128852. profileId: string;
  128853. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  128854. dispose(): void;
  128855. protected _getFilenameAndPath(): {
  128856. filename: string;
  128857. path: string;
  128858. };
  128859. protected _getModelLoadingConstraints(): boolean;
  128860. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  128861. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128862. protected _updateModel(_xrFrame: XRFrame): void;
  128863. }
  128864. }
  128865. declare module BABYLON {
  128866. /**
  128867. * A construction function type to create a new controller based on an xrInput object
  128868. */
  128869. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  128870. /**
  128871. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  128872. *
  128873. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  128874. * it should be replaced with auto-loaded controllers.
  128875. *
  128876. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  128877. */
  128878. export class WebXRMotionControllerManager {
  128879. private static _AvailableControllers;
  128880. private static _Fallbacks;
  128881. private static _ProfileLoadingPromises;
  128882. private static _ProfilesList;
  128883. /**
  128884. * The base URL of the online controller repository. Can be changed at any time.
  128885. */
  128886. static BaseRepositoryUrl: string;
  128887. /**
  128888. * Which repository gets priority - local or online
  128889. */
  128890. static PrioritizeOnlineRepository: boolean;
  128891. /**
  128892. * Use the online repository, or use only locally-defined controllers
  128893. */
  128894. static UseOnlineRepository: boolean;
  128895. /**
  128896. * Clear the cache used for profile loading and reload when requested again
  128897. */
  128898. static ClearProfilesCache(): void;
  128899. /**
  128900. * Register the default fallbacks.
  128901. * This function is called automatically when this file is imported.
  128902. */
  128903. static DefaultFallbacks(): void;
  128904. /**
  128905. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  128906. * @param profileId the profile to which a fallback needs to be found
  128907. * @return an array with corresponding fallback profiles
  128908. */
  128909. static FindFallbackWithProfileId(profileId: string): string[];
  128910. /**
  128911. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  128912. * The order of search:
  128913. *
  128914. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  128915. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  128916. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  128917. * 4) return the generic trigger controller if none were found
  128918. *
  128919. * @param xrInput the xrInput to which a new controller is initialized
  128920. * @param scene the scene to which the model will be added
  128921. * @param forceProfile force a certain profile for this controller
  128922. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  128923. */
  128924. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  128925. /**
  128926. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  128927. *
  128928. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  128929. *
  128930. * @param type the profile type to register
  128931. * @param constructFunction the function to be called when loading this profile
  128932. */
  128933. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  128934. /**
  128935. * Register a fallback to a specific profile.
  128936. * @param profileId the profileId that will receive the fallbacks
  128937. * @param fallbacks A list of fallback profiles
  128938. */
  128939. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  128940. /**
  128941. * Will update the list of profiles available in the repository
  128942. * @return a promise that resolves to a map of profiles available online
  128943. */
  128944. static UpdateProfilesList(): Promise<{
  128945. [profile: string]: string;
  128946. }>;
  128947. private static _LoadProfileFromRepository;
  128948. private static _LoadProfilesFromAvailableControllers;
  128949. }
  128950. }
  128951. declare module BABYLON {
  128952. /**
  128953. * Configuration options for the WebXR controller creation
  128954. */
  128955. export interface IWebXRControllerOptions {
  128956. /**
  128957. * Should the controller mesh be animated when a user interacts with it
  128958. * The pressed buttons / thumbstick and touchpad animations will be disabled
  128959. */
  128960. disableMotionControllerAnimation?: boolean;
  128961. /**
  128962. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  128963. */
  128964. doNotLoadControllerMesh?: boolean;
  128965. /**
  128966. * Force a specific controller type for this controller.
  128967. * This can be used when creating your own profile or when testing different controllers
  128968. */
  128969. forceControllerProfile?: string;
  128970. /**
  128971. * Defines a rendering group ID for meshes that will be loaded.
  128972. * This is for the default controllers only.
  128973. */
  128974. renderingGroupId?: number;
  128975. }
  128976. /**
  128977. * Represents an XR controller
  128978. */
  128979. export class WebXRInputSource {
  128980. private _scene;
  128981. /** The underlying input source for the controller */
  128982. inputSource: XRInputSource;
  128983. private _options;
  128984. private _tmpVector;
  128985. private _uniqueId;
  128986. private _disposed;
  128987. /**
  128988. * 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
  128989. */
  128990. grip?: AbstractMesh;
  128991. /**
  128992. * If available, this is the gamepad object related to this controller.
  128993. * Using this object it is possible to get click events and trackpad changes of the
  128994. * webxr controller that is currently being used.
  128995. */
  128996. motionController?: WebXRAbstractMotionController;
  128997. /**
  128998. * Event that fires when the controller is removed/disposed.
  128999. * The object provided as event data is this controller, after associated assets were disposed.
  129000. * uniqueId is still available.
  129001. */
  129002. onDisposeObservable: Observable<WebXRInputSource>;
  129003. /**
  129004. * Will be triggered when the mesh associated with the motion controller is done loading.
  129005. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  129006. * A shortened version of controller -> motion controller -> on mesh loaded.
  129007. */
  129008. onMeshLoadedObservable: Observable<AbstractMesh>;
  129009. /**
  129010. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  129011. */
  129012. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  129013. /**
  129014. * Pointer which can be used to select objects or attach a visible laser to
  129015. */
  129016. pointer: AbstractMesh;
  129017. /**
  129018. * Creates the input source object
  129019. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  129020. * @param _scene the scene which the controller should be associated to
  129021. * @param inputSource the underlying input source for the controller
  129022. * @param _options options for this controller creation
  129023. */
  129024. constructor(_scene: Scene,
  129025. /** The underlying input source for the controller */
  129026. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  129027. /**
  129028. * Get this controllers unique id
  129029. */
  129030. get uniqueId(): string;
  129031. /**
  129032. * Disposes of the object
  129033. */
  129034. dispose(): void;
  129035. /**
  129036. * Gets a world space ray coming from the pointer or grip
  129037. * @param result the resulting ray
  129038. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  129039. */
  129040. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  129041. /**
  129042. * Updates the controller pose based on the given XRFrame
  129043. * @param xrFrame xr frame to update the pose with
  129044. * @param referenceSpace reference space to use
  129045. */
  129046. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  129047. }
  129048. }
  129049. declare module BABYLON {
  129050. /**
  129051. * The schema for initialization options of the XR Input class
  129052. */
  129053. export interface IWebXRInputOptions {
  129054. /**
  129055. * If set to true no model will be automatically loaded
  129056. */
  129057. doNotLoadControllerMeshes?: boolean;
  129058. /**
  129059. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  129060. * If not found, the xr input profile data will be used.
  129061. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  129062. */
  129063. forceInputProfile?: string;
  129064. /**
  129065. * Do not send a request to the controller repository to load the profile.
  129066. *
  129067. * Instead, use the controllers available in babylon itself.
  129068. */
  129069. disableOnlineControllerRepository?: boolean;
  129070. /**
  129071. * A custom URL for the controllers repository
  129072. */
  129073. customControllersRepositoryURL?: string;
  129074. /**
  129075. * Should the controller model's components not move according to the user input
  129076. */
  129077. disableControllerAnimation?: boolean;
  129078. /**
  129079. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  129080. */
  129081. controllerOptions?: IWebXRControllerOptions;
  129082. }
  129083. /**
  129084. * XR input used to track XR inputs such as controllers/rays
  129085. */
  129086. export class WebXRInput implements IDisposable {
  129087. /**
  129088. * the xr session manager for this session
  129089. */
  129090. xrSessionManager: WebXRSessionManager;
  129091. /**
  129092. * the WebXR camera for this session. Mainly used for teleportation
  129093. */
  129094. xrCamera: WebXRCamera;
  129095. private readonly options;
  129096. /**
  129097. * XR controllers being tracked
  129098. */
  129099. controllers: Array<WebXRInputSource>;
  129100. private _frameObserver;
  129101. private _sessionEndedObserver;
  129102. private _sessionInitObserver;
  129103. /**
  129104. * Event when a controller has been connected/added
  129105. */
  129106. onControllerAddedObservable: Observable<WebXRInputSource>;
  129107. /**
  129108. * Event when a controller has been removed/disconnected
  129109. */
  129110. onControllerRemovedObservable: Observable<WebXRInputSource>;
  129111. /**
  129112. * Initializes the WebXRInput
  129113. * @param xrSessionManager the xr session manager for this session
  129114. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  129115. * @param options = initialization options for this xr input
  129116. */
  129117. constructor(
  129118. /**
  129119. * the xr session manager for this session
  129120. */
  129121. xrSessionManager: WebXRSessionManager,
  129122. /**
  129123. * the WebXR camera for this session. Mainly used for teleportation
  129124. */
  129125. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  129126. private _onInputSourcesChange;
  129127. private _addAndRemoveControllers;
  129128. /**
  129129. * Disposes of the object
  129130. */
  129131. dispose(): void;
  129132. }
  129133. }
  129134. declare module BABYLON {
  129135. /**
  129136. * This is the base class for all WebXR features.
  129137. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  129138. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  129139. */
  129140. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  129141. protected _xrSessionManager: WebXRSessionManager;
  129142. private _attached;
  129143. private _removeOnDetach;
  129144. /**
  129145. * Is this feature disposed?
  129146. */
  129147. isDisposed: boolean;
  129148. /**
  129149. * Should auto-attach be disabled?
  129150. */
  129151. disableAutoAttach: boolean;
  129152. /**
  129153. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  129154. */
  129155. xrNativeFeatureName: string;
  129156. /**
  129157. * Construct a new (abstract) WebXR feature
  129158. * @param _xrSessionManager the xr session manager for this feature
  129159. */
  129160. constructor(_xrSessionManager: WebXRSessionManager);
  129161. /**
  129162. * Is this feature attached
  129163. */
  129164. get attached(): boolean;
  129165. /**
  129166. * attach this feature
  129167. *
  129168. * @param force should attachment be forced (even when already attached)
  129169. * @returns true if successful, false is failed or already attached
  129170. */
  129171. attach(force?: boolean): boolean;
  129172. /**
  129173. * detach this feature.
  129174. *
  129175. * @returns true if successful, false if failed or already detached
  129176. */
  129177. detach(): boolean;
  129178. /**
  129179. * Dispose this feature and all of the resources attached
  129180. */
  129181. dispose(): void;
  129182. /**
  129183. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  129184. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  129185. *
  129186. * @returns whether or not the feature is compatible in this environment
  129187. */
  129188. isCompatible(): boolean;
  129189. /**
  129190. * This is used to register callbacks that will automatically be removed when detach is called.
  129191. * @param observable the observable to which the observer will be attached
  129192. * @param callback the callback to register
  129193. */
  129194. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  129195. /**
  129196. * Code in this function will be executed on each xrFrame received from the browser.
  129197. * This function will not execute after the feature is detached.
  129198. * @param _xrFrame the current frame
  129199. */
  129200. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  129201. }
  129202. }
  129203. declare module BABYLON {
  129204. /**
  129205. * Renders a layer on top of an existing scene
  129206. */
  129207. export class UtilityLayerRenderer implements IDisposable {
  129208. /** the original scene that will be rendered on top of */
  129209. originalScene: Scene;
  129210. private _pointerCaptures;
  129211. private _lastPointerEvents;
  129212. private static _DefaultUtilityLayer;
  129213. private static _DefaultKeepDepthUtilityLayer;
  129214. private _sharedGizmoLight;
  129215. private _renderCamera;
  129216. /**
  129217. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  129218. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  129219. * @returns the camera that is used when rendering the utility layer
  129220. */
  129221. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  129222. /**
  129223. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  129224. * @param cam the camera that should be used when rendering the utility layer
  129225. */
  129226. setRenderCamera(cam: Nullable<Camera>): void;
  129227. /**
  129228. * @hidden
  129229. * Light which used by gizmos to get light shading
  129230. */
  129231. _getSharedGizmoLight(): HemisphericLight;
  129232. /**
  129233. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  129234. */
  129235. pickUtilitySceneFirst: boolean;
  129236. /**
  129237. * 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)
  129238. */
  129239. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  129240. /**
  129241. * 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)
  129242. */
  129243. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  129244. /**
  129245. * The scene that is rendered on top of the original scene
  129246. */
  129247. utilityLayerScene: Scene;
  129248. /**
  129249. * If the utility layer should automatically be rendered on top of existing scene
  129250. */
  129251. shouldRender: boolean;
  129252. /**
  129253. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  129254. */
  129255. onlyCheckPointerDownEvents: boolean;
  129256. /**
  129257. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  129258. */
  129259. processAllEvents: boolean;
  129260. /**
  129261. * Observable raised when the pointer move from the utility layer scene to the main scene
  129262. */
  129263. onPointerOutObservable: Observable<number>;
  129264. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  129265. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  129266. private _afterRenderObserver;
  129267. private _sceneDisposeObserver;
  129268. private _originalPointerObserver;
  129269. /**
  129270. * Instantiates a UtilityLayerRenderer
  129271. * @param originalScene the original scene that will be rendered on top of
  129272. * @param handleEvents boolean indicating if the utility layer should handle events
  129273. */
  129274. constructor(
  129275. /** the original scene that will be rendered on top of */
  129276. originalScene: Scene, handleEvents?: boolean);
  129277. private _notifyObservers;
  129278. /**
  129279. * Renders the utility layers scene on top of the original scene
  129280. */
  129281. render(): void;
  129282. /**
  129283. * Disposes of the renderer
  129284. */
  129285. dispose(): void;
  129286. private _updateCamera;
  129287. }
  129288. }
  129289. declare module BABYLON {
  129290. /**
  129291. * Options interface for the pointer selection module
  129292. */
  129293. export interface IWebXRControllerPointerSelectionOptions {
  129294. /**
  129295. * if provided, this scene will be used to render meshes.
  129296. */
  129297. customUtilityLayerScene?: Scene;
  129298. /**
  129299. * 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)
  129300. * If not disabled, the last picked point will be used to execute a pointer up event
  129301. * If disabled, pointer up event will be triggered right after the pointer down event.
  129302. * Used in screen and gaze target ray mode only
  129303. */
  129304. disablePointerUpOnTouchOut: boolean;
  129305. /**
  129306. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  129307. */
  129308. forceGazeMode: boolean;
  129309. /**
  129310. * 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
  129311. * to start a new countdown to the pointer down event.
  129312. * Defaults to 1.
  129313. */
  129314. gazeModePointerMovedFactor?: number;
  129315. /**
  129316. * Different button type to use instead of the main component
  129317. */
  129318. overrideButtonId?: string;
  129319. /**
  129320. * use this rendering group id for the meshes (optional)
  129321. */
  129322. renderingGroupId?: number;
  129323. /**
  129324. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  129325. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  129326. * 3000 means 3 seconds between pointing at something and selecting it
  129327. */
  129328. timeToSelect?: number;
  129329. /**
  129330. * Should meshes created here be added to a utility layer or the main scene
  129331. */
  129332. useUtilityLayer?: boolean;
  129333. /**
  129334. * Optional WebXR camera to be used for gaze selection
  129335. */
  129336. gazeCamera?: WebXRCamera;
  129337. /**
  129338. * the xr input to use with this pointer selection
  129339. */
  129340. xrInput: WebXRInput;
  129341. }
  129342. /**
  129343. * A module that will enable pointer selection for motion controllers of XR Input Sources
  129344. */
  129345. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  129346. private readonly _options;
  129347. private static _idCounter;
  129348. private _attachController;
  129349. private _controllers;
  129350. private _scene;
  129351. private _tmpVectorForPickCompare;
  129352. /**
  129353. * The module's name
  129354. */
  129355. static readonly Name: string;
  129356. /**
  129357. * The (Babylon) version of this module.
  129358. * This is an integer representing the implementation version.
  129359. * This number does not correspond to the WebXR specs version
  129360. */
  129361. static readonly Version: number;
  129362. /**
  129363. * Disable lighting on the laser pointer (so it will always be visible)
  129364. */
  129365. disablePointerLighting: boolean;
  129366. /**
  129367. * Disable lighting on the selection mesh (so it will always be visible)
  129368. */
  129369. disableSelectionMeshLighting: boolean;
  129370. /**
  129371. * Should the laser pointer be displayed
  129372. */
  129373. displayLaserPointer: boolean;
  129374. /**
  129375. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  129376. */
  129377. displaySelectionMesh: boolean;
  129378. /**
  129379. * This color will be set to the laser pointer when selection is triggered
  129380. */
  129381. laserPointerPickedColor: Color3;
  129382. /**
  129383. * Default color of the laser pointer
  129384. */
  129385. laserPointerDefaultColor: Color3;
  129386. /**
  129387. * default color of the selection ring
  129388. */
  129389. selectionMeshDefaultColor: Color3;
  129390. /**
  129391. * This color will be applied to the selection ring when selection is triggered
  129392. */
  129393. selectionMeshPickedColor: Color3;
  129394. /**
  129395. * Optional filter to be used for ray selection. This predicate shares behavior with
  129396. * scene.pointerMovePredicate which takes priority if it is also assigned.
  129397. */
  129398. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  129399. /**
  129400. * constructs a new background remover module
  129401. * @param _xrSessionManager the session manager for this module
  129402. * @param _options read-only options to be used in this module
  129403. */
  129404. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  129405. /**
  129406. * attach this feature
  129407. * Will usually be called by the features manager
  129408. *
  129409. * @returns true if successful.
  129410. */
  129411. attach(): boolean;
  129412. /**
  129413. * detach this feature.
  129414. * Will usually be called by the features manager
  129415. *
  129416. * @returns true if successful.
  129417. */
  129418. detach(): boolean;
  129419. /**
  129420. * Will get the mesh under a specific pointer.
  129421. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  129422. * @param controllerId the controllerId to check
  129423. * @returns The mesh under pointer or null if no mesh is under the pointer
  129424. */
  129425. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  129426. /**
  129427. * Get the xr controller that correlates to the pointer id in the pointer event
  129428. *
  129429. * @param id the pointer id to search for
  129430. * @returns the controller that correlates to this id or null if not found
  129431. */
  129432. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  129433. protected _onXRFrame(_xrFrame: XRFrame): void;
  129434. private _attachGazeMode;
  129435. private _attachScreenRayMode;
  129436. private _attachTrackedPointerRayMode;
  129437. private _convertNormalToDirectionOfRay;
  129438. private _detachController;
  129439. private _generateNewMeshPair;
  129440. private _pickingMoved;
  129441. private _updatePointerDistance;
  129442. /** @hidden */
  129443. get lasterPointerDefaultColor(): Color3;
  129444. }
  129445. }
  129446. declare module BABYLON {
  129447. /**
  129448. * Button which can be used to enter a different mode of XR
  129449. */
  129450. export class WebXREnterExitUIButton {
  129451. /** button element */
  129452. element: HTMLElement;
  129453. /** XR initialization options for the button */
  129454. sessionMode: XRSessionMode;
  129455. /** Reference space type */
  129456. referenceSpaceType: XRReferenceSpaceType;
  129457. /**
  129458. * Creates a WebXREnterExitUIButton
  129459. * @param element button element
  129460. * @param sessionMode XR initialization session mode
  129461. * @param referenceSpaceType the type of reference space to be used
  129462. */
  129463. constructor(
  129464. /** button element */
  129465. element: HTMLElement,
  129466. /** XR initialization options for the button */
  129467. sessionMode: XRSessionMode,
  129468. /** Reference space type */
  129469. referenceSpaceType: XRReferenceSpaceType);
  129470. /**
  129471. * Extendable function which can be used to update the button's visuals when the state changes
  129472. * @param activeButton the current active button in the UI
  129473. */
  129474. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  129475. }
  129476. /**
  129477. * Options to create the webXR UI
  129478. */
  129479. export class WebXREnterExitUIOptions {
  129480. /**
  129481. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  129482. */
  129483. customButtons?: Array<WebXREnterExitUIButton>;
  129484. /**
  129485. * A reference space type to use when creating the default button.
  129486. * Default is local-floor
  129487. */
  129488. referenceSpaceType?: XRReferenceSpaceType;
  129489. /**
  129490. * Context to enter xr with
  129491. */
  129492. renderTarget?: Nullable<WebXRRenderTarget>;
  129493. /**
  129494. * A session mode to use when creating the default button.
  129495. * Default is immersive-vr
  129496. */
  129497. sessionMode?: XRSessionMode;
  129498. /**
  129499. * A list of optional features to init the session with
  129500. */
  129501. optionalFeatures?: string[];
  129502. /**
  129503. * A list of optional features to init the session with
  129504. */
  129505. requiredFeatures?: string[];
  129506. }
  129507. /**
  129508. * UI to allow the user to enter/exit XR mode
  129509. */
  129510. export class WebXREnterExitUI implements IDisposable {
  129511. private scene;
  129512. /** version of the options passed to this UI */
  129513. options: WebXREnterExitUIOptions;
  129514. private _activeButton;
  129515. private _buttons;
  129516. /**
  129517. * The HTML Div Element to which buttons are added.
  129518. */
  129519. readonly overlay: HTMLDivElement;
  129520. /**
  129521. * Fired every time the active button is changed.
  129522. *
  129523. * When xr is entered via a button that launches xr that button will be the callback parameter
  129524. *
  129525. * When exiting xr the callback parameter will be null)
  129526. */
  129527. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  129528. /**
  129529. *
  129530. * @param scene babylon scene object to use
  129531. * @param options (read-only) version of the options passed to this UI
  129532. */
  129533. private constructor();
  129534. /**
  129535. * Creates UI to allow the user to enter/exit XR mode
  129536. * @param scene the scene to add the ui to
  129537. * @param helper the xr experience helper to enter/exit xr with
  129538. * @param options options to configure the UI
  129539. * @returns the created ui
  129540. */
  129541. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  129542. /**
  129543. * Disposes of the XR UI component
  129544. */
  129545. dispose(): void;
  129546. private _updateButtons;
  129547. }
  129548. }
  129549. declare module BABYLON {
  129550. /**
  129551. * Class containing static functions to help procedurally build meshes
  129552. */
  129553. export class LinesBuilder {
  129554. /**
  129555. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  129556. * * 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
  129557. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  129558. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  129559. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  129560. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  129561. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129562. * * 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
  129563. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  129564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129565. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  129566. * @param name defines the name of the new line system
  129567. * @param options defines the options used to create the line system
  129568. * @param scene defines the hosting scene
  129569. * @returns a new line system mesh
  129570. */
  129571. static CreateLineSystem(name: string, options: {
  129572. lines: Vector3[][];
  129573. updatable?: boolean;
  129574. instance?: Nullable<LinesMesh>;
  129575. colors?: Nullable<Color4[][]>;
  129576. useVertexAlpha?: boolean;
  129577. }, scene: Nullable<Scene>): LinesMesh;
  129578. /**
  129579. * Creates a line mesh
  129580. * 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
  129581. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129582. * * The parameter `points` is an array successive Vector3
  129583. * * 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
  129584. * * The optional parameter `colors` is an array of successive Color4, one per line point
  129585. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  129586. * * When updating an instance, remember that only point positions can change, not the number of points
  129587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129588. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  129589. * @param name defines the name of the new line system
  129590. * @param options defines the options used to create the line system
  129591. * @param scene defines the hosting scene
  129592. * @returns a new line mesh
  129593. */
  129594. static CreateLines(name: string, options: {
  129595. points: Vector3[];
  129596. updatable?: boolean;
  129597. instance?: Nullable<LinesMesh>;
  129598. colors?: Color4[];
  129599. useVertexAlpha?: boolean;
  129600. }, scene?: Nullable<Scene>): LinesMesh;
  129601. /**
  129602. * Creates a dashed line mesh
  129603. * * 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
  129604. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129605. * * The parameter `points` is an array successive Vector3
  129606. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  129607. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  129608. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  129609. * * 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
  129610. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129611. * * When updating an instance, remember that only point positions can change, not the number of points
  129612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129613. * @param name defines the name of the mesh
  129614. * @param options defines the options used to create the mesh
  129615. * @param scene defines the hosting scene
  129616. * @returns the dashed line mesh
  129617. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  129618. */
  129619. static CreateDashedLines(name: string, options: {
  129620. points: Vector3[];
  129621. dashSize?: number;
  129622. gapSize?: number;
  129623. dashNb?: number;
  129624. updatable?: boolean;
  129625. instance?: LinesMesh;
  129626. useVertexAlpha?: boolean;
  129627. }, scene?: Nullable<Scene>): LinesMesh;
  129628. }
  129629. }
  129630. declare module BABYLON {
  129631. /**
  129632. * Construction options for a timer
  129633. */
  129634. export interface ITimerOptions<T> {
  129635. /**
  129636. * Time-to-end
  129637. */
  129638. timeout: number;
  129639. /**
  129640. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  129641. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  129642. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  129643. */
  129644. contextObservable: Observable<T>;
  129645. /**
  129646. * Optional parameters when adding an observer to the observable
  129647. */
  129648. observableParameters?: {
  129649. mask?: number;
  129650. insertFirst?: boolean;
  129651. scope?: any;
  129652. };
  129653. /**
  129654. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  129655. */
  129656. breakCondition?: (data?: ITimerData<T>) => boolean;
  129657. /**
  129658. * Will be triggered when the time condition has met
  129659. */
  129660. onEnded?: (data: ITimerData<any>) => void;
  129661. /**
  129662. * Will be triggered when the break condition has met (prematurely ended)
  129663. */
  129664. onAborted?: (data: ITimerData<any>) => void;
  129665. /**
  129666. * Optional function to execute on each tick (or count)
  129667. */
  129668. onTick?: (data: ITimerData<any>) => void;
  129669. }
  129670. /**
  129671. * An interface defining the data sent by the timer
  129672. */
  129673. export interface ITimerData<T> {
  129674. /**
  129675. * When did it start
  129676. */
  129677. startTime: number;
  129678. /**
  129679. * Time now
  129680. */
  129681. currentTime: number;
  129682. /**
  129683. * Time passed since started
  129684. */
  129685. deltaTime: number;
  129686. /**
  129687. * How much is completed, in [0.0...1.0].
  129688. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  129689. */
  129690. completeRate: number;
  129691. /**
  129692. * What the registered observable sent in the last count
  129693. */
  129694. payload: T;
  129695. }
  129696. /**
  129697. * The current state of the timer
  129698. */
  129699. export enum TimerState {
  129700. /**
  129701. * Timer initialized, not yet started
  129702. */
  129703. INIT = 0,
  129704. /**
  129705. * Timer started and counting
  129706. */
  129707. STARTED = 1,
  129708. /**
  129709. * Timer ended (whether aborted or time reached)
  129710. */
  129711. ENDED = 2
  129712. }
  129713. /**
  129714. * A simple version of the timer. Will take options and start the timer immediately after calling it
  129715. *
  129716. * @param options options with which to initialize this timer
  129717. */
  129718. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  129719. /**
  129720. * An advanced implementation of a timer class
  129721. */
  129722. export class AdvancedTimer<T = any> implements IDisposable {
  129723. /**
  129724. * Will notify each time the timer calculates the remaining time
  129725. */
  129726. onEachCountObservable: Observable<ITimerData<T>>;
  129727. /**
  129728. * Will trigger when the timer was aborted due to the break condition
  129729. */
  129730. onTimerAbortedObservable: Observable<ITimerData<T>>;
  129731. /**
  129732. * Will trigger when the timer ended successfully
  129733. */
  129734. onTimerEndedObservable: Observable<ITimerData<T>>;
  129735. /**
  129736. * Will trigger when the timer state has changed
  129737. */
  129738. onStateChangedObservable: Observable<TimerState>;
  129739. private _observer;
  129740. private _contextObservable;
  129741. private _observableParameters;
  129742. private _startTime;
  129743. private _timer;
  129744. private _state;
  129745. private _breakCondition;
  129746. private _timeToEnd;
  129747. private _breakOnNextTick;
  129748. /**
  129749. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  129750. * @param options construction options for this advanced timer
  129751. */
  129752. constructor(options: ITimerOptions<T>);
  129753. /**
  129754. * set a breaking condition for this timer. Default is to never break during count
  129755. * @param predicate the new break condition. Returns true to break, false otherwise
  129756. */
  129757. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  129758. /**
  129759. * Reset ALL associated observables in this advanced timer
  129760. */
  129761. clearObservables(): void;
  129762. /**
  129763. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  129764. *
  129765. * @param timeToEnd how much time to measure until timer ended
  129766. */
  129767. start(timeToEnd?: number): void;
  129768. /**
  129769. * Will force a stop on the next tick.
  129770. */
  129771. stop(): void;
  129772. /**
  129773. * Dispose this timer, clearing all resources
  129774. */
  129775. dispose(): void;
  129776. private _setState;
  129777. private _tick;
  129778. private _stop;
  129779. }
  129780. }
  129781. declare module BABYLON {
  129782. /**
  129783. * The options container for the teleportation module
  129784. */
  129785. export interface IWebXRTeleportationOptions {
  129786. /**
  129787. * if provided, this scene will be used to render meshes.
  129788. */
  129789. customUtilityLayerScene?: Scene;
  129790. /**
  129791. * Values to configure the default target mesh
  129792. */
  129793. defaultTargetMeshOptions?: {
  129794. /**
  129795. * Fill color of the teleportation area
  129796. */
  129797. teleportationFillColor?: string;
  129798. /**
  129799. * Border color for the teleportation area
  129800. */
  129801. teleportationBorderColor?: string;
  129802. /**
  129803. * Disable the mesh's animation sequence
  129804. */
  129805. disableAnimation?: boolean;
  129806. /**
  129807. * Disable lighting on the material or the ring and arrow
  129808. */
  129809. disableLighting?: boolean;
  129810. /**
  129811. * Override the default material of the torus and arrow
  129812. */
  129813. torusArrowMaterial?: Material;
  129814. };
  129815. /**
  129816. * A list of meshes to use as floor meshes.
  129817. * Meshes can be added and removed after initializing the feature using the
  129818. * addFloorMesh and removeFloorMesh functions
  129819. * If empty, rotation will still work
  129820. */
  129821. floorMeshes?: AbstractMesh[];
  129822. /**
  129823. * use this rendering group id for the meshes (optional)
  129824. */
  129825. renderingGroupId?: number;
  129826. /**
  129827. * Should teleportation move only to snap points
  129828. */
  129829. snapPointsOnly?: boolean;
  129830. /**
  129831. * An array of points to which the teleportation will snap to.
  129832. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  129833. */
  129834. snapPositions?: Vector3[];
  129835. /**
  129836. * How close should the teleportation ray be in order to snap to position.
  129837. * Default to 0.8 units (meters)
  129838. */
  129839. snapToPositionRadius?: number;
  129840. /**
  129841. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  129842. * If you want to support rotation, make sure your mesh has a direction indicator.
  129843. *
  129844. * When left untouched, the default mesh will be initialized.
  129845. */
  129846. teleportationTargetMesh?: AbstractMesh;
  129847. /**
  129848. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  129849. */
  129850. timeToTeleport?: number;
  129851. /**
  129852. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  129853. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  129854. */
  129855. useMainComponentOnly?: boolean;
  129856. /**
  129857. * Should meshes created here be added to a utility layer or the main scene
  129858. */
  129859. useUtilityLayer?: boolean;
  129860. /**
  129861. * Babylon XR Input class for controller
  129862. */
  129863. xrInput: WebXRInput;
  129864. /**
  129865. * Meshes that the teleportation ray cannot go through
  129866. */
  129867. pickBlockerMeshes?: AbstractMesh[];
  129868. }
  129869. /**
  129870. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  129871. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  129872. * the input of the attached controllers.
  129873. */
  129874. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  129875. private _options;
  129876. private _controllers;
  129877. private _currentTeleportationControllerId;
  129878. private _floorMeshes;
  129879. private _quadraticBezierCurve;
  129880. private _selectionFeature;
  129881. private _snapToPositions;
  129882. private _snappedToPoint;
  129883. private _teleportationRingMaterial?;
  129884. private _tmpRay;
  129885. private _tmpVector;
  129886. private _tmpQuaternion;
  129887. /**
  129888. * The module's name
  129889. */
  129890. static readonly Name: string;
  129891. /**
  129892. * The (Babylon) version of this module.
  129893. * This is an integer representing the implementation version.
  129894. * This number does not correspond to the webxr specs version
  129895. */
  129896. static readonly Version: number;
  129897. /**
  129898. * Is movement backwards enabled
  129899. */
  129900. backwardsMovementEnabled: boolean;
  129901. /**
  129902. * Distance to travel when moving backwards
  129903. */
  129904. backwardsTeleportationDistance: number;
  129905. /**
  129906. * The distance from the user to the inspection point in the direction of the controller
  129907. * A higher number will allow the user to move further
  129908. * defaults to 5 (meters, in xr units)
  129909. */
  129910. parabolicCheckRadius: number;
  129911. /**
  129912. * Should the module support parabolic ray on top of direct ray
  129913. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  129914. * Very helpful when moving between floors / different heights
  129915. */
  129916. parabolicRayEnabled: boolean;
  129917. /**
  129918. * How much rotation should be applied when rotating right and left
  129919. */
  129920. rotationAngle: number;
  129921. /**
  129922. * Is rotation enabled when moving forward?
  129923. * Disabling this feature will prevent the user from deciding the direction when teleporting
  129924. */
  129925. rotationEnabled: boolean;
  129926. /**
  129927. * constructs a new anchor system
  129928. * @param _xrSessionManager an instance of WebXRSessionManager
  129929. * @param _options configuration object for this feature
  129930. */
  129931. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  129932. /**
  129933. * Get the snapPointsOnly flag
  129934. */
  129935. get snapPointsOnly(): boolean;
  129936. /**
  129937. * Sets the snapPointsOnly flag
  129938. * @param snapToPoints should teleportation be exclusively to snap points
  129939. */
  129940. set snapPointsOnly(snapToPoints: boolean);
  129941. /**
  129942. * Add a new mesh to the floor meshes array
  129943. * @param mesh the mesh to use as floor mesh
  129944. */
  129945. addFloorMesh(mesh: AbstractMesh): void;
  129946. /**
  129947. * Add a new snap-to point to fix teleportation to this position
  129948. * @param newSnapPoint The new Snap-To point
  129949. */
  129950. addSnapPoint(newSnapPoint: Vector3): void;
  129951. attach(): boolean;
  129952. detach(): boolean;
  129953. dispose(): void;
  129954. /**
  129955. * Remove a mesh from the floor meshes array
  129956. * @param mesh the mesh to remove
  129957. */
  129958. removeFloorMesh(mesh: AbstractMesh): void;
  129959. /**
  129960. * Remove a mesh from the floor meshes array using its name
  129961. * @param name the mesh name to remove
  129962. */
  129963. removeFloorMeshByName(name: string): void;
  129964. /**
  129965. * 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
  129966. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  129967. * @returns was the point found and removed or not
  129968. */
  129969. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  129970. /**
  129971. * This function sets a selection feature that will be disabled when
  129972. * the forward ray is shown and will be reattached when hidden.
  129973. * This is used to remove the selection rays when moving.
  129974. * @param selectionFeature the feature to disable when forward movement is enabled
  129975. */
  129976. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  129977. protected _onXRFrame(_xrFrame: XRFrame): void;
  129978. private _attachController;
  129979. private _createDefaultTargetMesh;
  129980. private _detachController;
  129981. private _findClosestSnapPointWithRadius;
  129982. private _setTargetMeshPosition;
  129983. private _setTargetMeshVisibility;
  129984. private _showParabolicPath;
  129985. private _teleportForward;
  129986. }
  129987. }
  129988. declare module BABYLON {
  129989. /**
  129990. * Options for the default xr helper
  129991. */
  129992. export class WebXRDefaultExperienceOptions {
  129993. /**
  129994. * Enable or disable default UI to enter XR
  129995. */
  129996. disableDefaultUI?: boolean;
  129997. /**
  129998. * Should teleportation not initialize. defaults to false.
  129999. */
  130000. disableTeleportation?: boolean;
  130001. /**
  130002. * Floor meshes that will be used for teleport
  130003. */
  130004. floorMeshes?: Array<AbstractMesh>;
  130005. /**
  130006. * If set to true, the first frame will not be used to reset position
  130007. * The first frame is mainly used when copying transformation from the old camera
  130008. * Mainly used in AR
  130009. */
  130010. ignoreNativeCameraTransformation?: boolean;
  130011. /**
  130012. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  130013. */
  130014. inputOptions?: IWebXRInputOptions;
  130015. /**
  130016. * optional configuration for the output canvas
  130017. */
  130018. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  130019. /**
  130020. * optional UI options. This can be used among other to change session mode and reference space type
  130021. */
  130022. uiOptions?: WebXREnterExitUIOptions;
  130023. /**
  130024. * When loading teleportation and pointer select, use stable versions instead of latest.
  130025. */
  130026. useStablePlugins?: boolean;
  130027. /**
  130028. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  130029. */
  130030. renderingGroupId?: number;
  130031. /**
  130032. * A list of optional features to init the session with
  130033. * If set to true, all features we support will be added
  130034. */
  130035. optionalFeatures?: boolean | string[];
  130036. }
  130037. /**
  130038. * Default experience which provides a similar setup to the previous webVRExperience
  130039. */
  130040. export class WebXRDefaultExperience {
  130041. /**
  130042. * Base experience
  130043. */
  130044. baseExperience: WebXRExperienceHelper;
  130045. /**
  130046. * Enables ui for entering/exiting xr
  130047. */
  130048. enterExitUI: WebXREnterExitUI;
  130049. /**
  130050. * Input experience extension
  130051. */
  130052. input: WebXRInput;
  130053. /**
  130054. * Enables laser pointer and selection
  130055. */
  130056. pointerSelection: WebXRControllerPointerSelection;
  130057. /**
  130058. * Default target xr should render to
  130059. */
  130060. renderTarget: WebXRRenderTarget;
  130061. /**
  130062. * Enables teleportation
  130063. */
  130064. teleportation: WebXRMotionControllerTeleportation;
  130065. private constructor();
  130066. /**
  130067. * Creates the default xr experience
  130068. * @param scene scene
  130069. * @param options options for basic configuration
  130070. * @returns resulting WebXRDefaultExperience
  130071. */
  130072. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  130073. /**
  130074. * DIsposes of the experience helper
  130075. */
  130076. dispose(): void;
  130077. }
  130078. }
  130079. declare module BABYLON {
  130080. /**
  130081. * Options to modify the vr teleportation behavior.
  130082. */
  130083. export interface VRTeleportationOptions {
  130084. /**
  130085. * The name of the mesh which should be used as the teleportation floor. (default: null)
  130086. */
  130087. floorMeshName?: string;
  130088. /**
  130089. * A list of meshes to be used as the teleportation floor. (default: empty)
  130090. */
  130091. floorMeshes?: Mesh[];
  130092. /**
  130093. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  130094. */
  130095. teleportationMode?: number;
  130096. /**
  130097. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  130098. */
  130099. teleportationTime?: number;
  130100. /**
  130101. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  130102. */
  130103. teleportationSpeed?: number;
  130104. /**
  130105. * The easing function used in the animation or null for Linear. (default CircleEase)
  130106. */
  130107. easingFunction?: EasingFunction;
  130108. }
  130109. /**
  130110. * Options to modify the vr experience helper's behavior.
  130111. */
  130112. export interface VRExperienceHelperOptions extends WebVROptions {
  130113. /**
  130114. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  130115. */
  130116. createDeviceOrientationCamera?: boolean;
  130117. /**
  130118. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  130119. */
  130120. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  130121. /**
  130122. * Uses the main button on the controller to toggle the laser casted. (default: true)
  130123. */
  130124. laserToggle?: boolean;
  130125. /**
  130126. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  130127. */
  130128. floorMeshes?: Mesh[];
  130129. /**
  130130. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  130131. */
  130132. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  130133. /**
  130134. * Defines if WebXR should be used instead of WebVR (if available)
  130135. */
  130136. useXR?: boolean;
  130137. }
  130138. /**
  130139. * Event containing information after VR has been entered
  130140. */
  130141. export class OnAfterEnteringVRObservableEvent {
  130142. /**
  130143. * If entering vr was successful
  130144. */
  130145. success: boolean;
  130146. }
  130147. /**
  130148. * Helps to quickly add VR support to an existing scene.
  130149. * See https://doc.babylonjs.com/how_to/webvr_helper
  130150. */
  130151. export class VRExperienceHelper {
  130152. /** Options to modify the vr experience helper's behavior. */
  130153. webVROptions: VRExperienceHelperOptions;
  130154. private _scene;
  130155. private _position;
  130156. private _btnVR;
  130157. private _btnVRDisplayed;
  130158. private _webVRsupported;
  130159. private _webVRready;
  130160. private _webVRrequesting;
  130161. private _webVRpresenting;
  130162. private _hasEnteredVR;
  130163. private _fullscreenVRpresenting;
  130164. private _inputElement;
  130165. private _webVRCamera;
  130166. private _vrDeviceOrientationCamera;
  130167. private _deviceOrientationCamera;
  130168. private _existingCamera;
  130169. private _onKeyDown;
  130170. private _onVrDisplayPresentChange;
  130171. private _onVRDisplayChanged;
  130172. private _onVRRequestPresentStart;
  130173. private _onVRRequestPresentComplete;
  130174. /**
  130175. * 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)
  130176. */
  130177. enableGazeEvenWhenNoPointerLock: boolean;
  130178. /**
  130179. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  130180. */
  130181. exitVROnDoubleTap: boolean;
  130182. /**
  130183. * Observable raised right before entering VR.
  130184. */
  130185. onEnteringVRObservable: Observable<VRExperienceHelper>;
  130186. /**
  130187. * Observable raised when entering VR has completed.
  130188. */
  130189. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  130190. /**
  130191. * Observable raised when exiting VR.
  130192. */
  130193. onExitingVRObservable: Observable<VRExperienceHelper>;
  130194. /**
  130195. * Observable raised when controller mesh is loaded.
  130196. */
  130197. onControllerMeshLoadedObservable: Observable<WebVRController>;
  130198. /** Return this.onEnteringVRObservable
  130199. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  130200. */
  130201. get onEnteringVR(): Observable<VRExperienceHelper>;
  130202. /** Return this.onExitingVRObservable
  130203. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  130204. */
  130205. get onExitingVR(): Observable<VRExperienceHelper>;
  130206. /** Return this.onControllerMeshLoadedObservable
  130207. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  130208. */
  130209. get onControllerMeshLoaded(): Observable<WebVRController>;
  130210. private _rayLength;
  130211. private _useCustomVRButton;
  130212. private _teleportationRequested;
  130213. private _teleportActive;
  130214. private _floorMeshName;
  130215. private _floorMeshesCollection;
  130216. private _teleportationMode;
  130217. private _teleportationTime;
  130218. private _teleportationSpeed;
  130219. private _teleportationEasing;
  130220. private _rotationAllowed;
  130221. private _teleportBackwardsVector;
  130222. private _teleportationTarget;
  130223. private _isDefaultTeleportationTarget;
  130224. private _postProcessMove;
  130225. private _teleportationFillColor;
  130226. private _teleportationBorderColor;
  130227. private _rotationAngle;
  130228. private _haloCenter;
  130229. private _cameraGazer;
  130230. private _padSensibilityUp;
  130231. private _padSensibilityDown;
  130232. private _leftController;
  130233. private _rightController;
  130234. private _gazeColor;
  130235. private _laserColor;
  130236. private _pickedLaserColor;
  130237. private _pickedGazeColor;
  130238. /**
  130239. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  130240. */
  130241. onNewMeshSelected: Observable<AbstractMesh>;
  130242. /**
  130243. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  130244. * This observable will provide the mesh and the controller used to select the mesh
  130245. */
  130246. onMeshSelectedWithController: Observable<{
  130247. mesh: AbstractMesh;
  130248. controller: WebVRController;
  130249. }>;
  130250. /**
  130251. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  130252. */
  130253. onNewMeshPicked: Observable<PickingInfo>;
  130254. private _circleEase;
  130255. /**
  130256. * Observable raised before camera teleportation
  130257. */
  130258. onBeforeCameraTeleport: Observable<Vector3>;
  130259. /**
  130260. * Observable raised after camera teleportation
  130261. */
  130262. onAfterCameraTeleport: Observable<Vector3>;
  130263. /**
  130264. * Observable raised when current selected mesh gets unselected
  130265. */
  130266. onSelectedMeshUnselected: Observable<AbstractMesh>;
  130267. private _raySelectionPredicate;
  130268. /**
  130269. * To be optionaly changed by user to define custom ray selection
  130270. */
  130271. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  130272. /**
  130273. * To be optionaly changed by user to define custom selection logic (after ray selection)
  130274. */
  130275. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  130276. /**
  130277. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  130278. */
  130279. teleportationEnabled: boolean;
  130280. private _defaultHeight;
  130281. private _teleportationInitialized;
  130282. private _interactionsEnabled;
  130283. private _interactionsRequested;
  130284. private _displayGaze;
  130285. private _displayLaserPointer;
  130286. /**
  130287. * The mesh used to display where the user is going to teleport.
  130288. */
  130289. get teleportationTarget(): Mesh;
  130290. /**
  130291. * Sets the mesh to be used to display where the user is going to teleport.
  130292. */
  130293. set teleportationTarget(value: Mesh);
  130294. /**
  130295. * 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
  130296. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  130297. * See https://doc.babylonjs.com/resources/baking_transformations
  130298. */
  130299. get gazeTrackerMesh(): Mesh;
  130300. set gazeTrackerMesh(value: Mesh);
  130301. /**
  130302. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  130303. */
  130304. updateGazeTrackerScale: boolean;
  130305. /**
  130306. * If the gaze trackers color should be updated when selecting meshes
  130307. */
  130308. updateGazeTrackerColor: boolean;
  130309. /**
  130310. * If the controller laser color should be updated when selecting meshes
  130311. */
  130312. updateControllerLaserColor: boolean;
  130313. /**
  130314. * The gaze tracking mesh corresponding to the left controller
  130315. */
  130316. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  130317. /**
  130318. * The gaze tracking mesh corresponding to the right controller
  130319. */
  130320. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  130321. /**
  130322. * If the ray of the gaze should be displayed.
  130323. */
  130324. get displayGaze(): boolean;
  130325. /**
  130326. * Sets if the ray of the gaze should be displayed.
  130327. */
  130328. set displayGaze(value: boolean);
  130329. /**
  130330. * If the ray of the LaserPointer should be displayed.
  130331. */
  130332. get displayLaserPointer(): boolean;
  130333. /**
  130334. * Sets if the ray of the LaserPointer should be displayed.
  130335. */
  130336. set displayLaserPointer(value: boolean);
  130337. /**
  130338. * The deviceOrientationCamera used as the camera when not in VR.
  130339. */
  130340. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  130341. /**
  130342. * Based on the current WebVR support, returns the current VR camera used.
  130343. */
  130344. get currentVRCamera(): Nullable<Camera>;
  130345. /**
  130346. * The webVRCamera which is used when in VR.
  130347. */
  130348. get webVRCamera(): WebVRFreeCamera;
  130349. /**
  130350. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  130351. */
  130352. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  130353. /**
  130354. * The html button that is used to trigger entering into VR.
  130355. */
  130356. get vrButton(): Nullable<HTMLButtonElement>;
  130357. private get _teleportationRequestInitiated();
  130358. /**
  130359. * Defines whether or not Pointer lock should be requested when switching to
  130360. * full screen.
  130361. */
  130362. requestPointerLockOnFullScreen: boolean;
  130363. /**
  130364. * If asking to force XR, this will be populated with the default xr experience
  130365. */
  130366. xr: WebXRDefaultExperience;
  130367. /**
  130368. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  130369. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  130370. */
  130371. xrTestDone: boolean;
  130372. /**
  130373. * Instantiates a VRExperienceHelper.
  130374. * Helps to quickly add VR support to an existing scene.
  130375. * @param scene The scene the VRExperienceHelper belongs to.
  130376. * @param webVROptions Options to modify the vr experience helper's behavior.
  130377. */
  130378. constructor(scene: Scene,
  130379. /** Options to modify the vr experience helper's behavior. */
  130380. webVROptions?: VRExperienceHelperOptions);
  130381. private completeVRInit;
  130382. private _onDefaultMeshLoaded;
  130383. private _onResize;
  130384. private _onFullscreenChange;
  130385. /**
  130386. * Gets a value indicating if we are currently in VR mode.
  130387. */
  130388. get isInVRMode(): boolean;
  130389. private onVrDisplayPresentChange;
  130390. private onVRDisplayChanged;
  130391. private moveButtonToBottomRight;
  130392. private displayVRButton;
  130393. private updateButtonVisibility;
  130394. private _cachedAngularSensibility;
  130395. /**
  130396. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  130397. * Otherwise, will use the fullscreen API.
  130398. */
  130399. enterVR(): void;
  130400. /**
  130401. * Attempt to exit VR, or fullscreen.
  130402. */
  130403. exitVR(): void;
  130404. /**
  130405. * The position of the vr experience helper.
  130406. */
  130407. get position(): Vector3;
  130408. /**
  130409. * Sets the position of the vr experience helper.
  130410. */
  130411. set position(value: Vector3);
  130412. /**
  130413. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  130414. */
  130415. enableInteractions(): void;
  130416. private get _noControllerIsActive();
  130417. private beforeRender;
  130418. private _isTeleportationFloor;
  130419. /**
  130420. * Adds a floor mesh to be used for teleportation.
  130421. * @param floorMesh the mesh to be used for teleportation.
  130422. */
  130423. addFloorMesh(floorMesh: Mesh): void;
  130424. /**
  130425. * Removes a floor mesh from being used for teleportation.
  130426. * @param floorMesh the mesh to be removed.
  130427. */
  130428. removeFloorMesh(floorMesh: Mesh): void;
  130429. /**
  130430. * Enables interactions and teleportation using the VR controllers and gaze.
  130431. * @param vrTeleportationOptions options to modify teleportation behavior.
  130432. */
  130433. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  130434. private _onNewGamepadConnected;
  130435. private _tryEnableInteractionOnController;
  130436. private _onNewGamepadDisconnected;
  130437. private _enableInteractionOnController;
  130438. private _checkTeleportWithRay;
  130439. private _checkRotate;
  130440. private _checkTeleportBackwards;
  130441. private _enableTeleportationOnController;
  130442. private _createTeleportationCircles;
  130443. private _displayTeleportationTarget;
  130444. private _hideTeleportationTarget;
  130445. private _rotateCamera;
  130446. private _moveTeleportationSelectorTo;
  130447. private _workingVector;
  130448. private _workingQuaternion;
  130449. private _workingMatrix;
  130450. /**
  130451. * Time Constant Teleportation Mode
  130452. */
  130453. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  130454. /**
  130455. * Speed Constant Teleportation Mode
  130456. */
  130457. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  130458. /**
  130459. * Teleports the users feet to the desired location
  130460. * @param location The location where the user's feet should be placed
  130461. */
  130462. teleportCamera(location: Vector3): void;
  130463. private _convertNormalToDirectionOfRay;
  130464. private _castRayAndSelectObject;
  130465. private _notifySelectedMeshUnselected;
  130466. /**
  130467. * Permanently set new colors for the laser pointer
  130468. * @param color the new laser color
  130469. * @param pickedColor the new laser color when picked mesh detected
  130470. */
  130471. setLaserColor(color: Color3, pickedColor?: Color3): void;
  130472. /**
  130473. * Set lighting enabled / disabled on the laser pointer of both controllers
  130474. * @param enabled should the lighting be enabled on the laser pointer
  130475. */
  130476. setLaserLightingState(enabled?: boolean): void;
  130477. /**
  130478. * Permanently set new colors for the gaze pointer
  130479. * @param color the new gaze color
  130480. * @param pickedColor the new gaze color when picked mesh detected
  130481. */
  130482. setGazeColor(color: Color3, pickedColor?: Color3): void;
  130483. /**
  130484. * Sets the color of the laser ray from the vr controllers.
  130485. * @param color new color for the ray.
  130486. */
  130487. changeLaserColor(color: Color3): void;
  130488. /**
  130489. * Sets the color of the ray from the vr headsets gaze.
  130490. * @param color new color for the ray.
  130491. */
  130492. changeGazeColor(color: Color3): void;
  130493. /**
  130494. * Exits VR and disposes of the vr experience helper
  130495. */
  130496. dispose(): void;
  130497. /**
  130498. * Gets the name of the VRExperienceHelper class
  130499. * @returns "VRExperienceHelper"
  130500. */
  130501. getClassName(): string;
  130502. }
  130503. }
  130504. declare module BABYLON {
  130505. /**
  130506. * Contains an array of blocks representing the octree
  130507. */
  130508. export interface IOctreeContainer<T> {
  130509. /**
  130510. * Blocks within the octree
  130511. */
  130512. blocks: Array<OctreeBlock<T>>;
  130513. }
  130514. /**
  130515. * Class used to store a cell in an octree
  130516. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130517. */
  130518. export class OctreeBlock<T> {
  130519. /**
  130520. * Gets the content of the current block
  130521. */
  130522. entries: T[];
  130523. /**
  130524. * Gets the list of block children
  130525. */
  130526. blocks: Array<OctreeBlock<T>>;
  130527. private _depth;
  130528. private _maxDepth;
  130529. private _capacity;
  130530. private _minPoint;
  130531. private _maxPoint;
  130532. private _boundingVectors;
  130533. private _creationFunc;
  130534. /**
  130535. * Creates a new block
  130536. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  130537. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  130538. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130539. * @param depth defines the current depth of this block in the octree
  130540. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  130541. * @param creationFunc defines a callback to call when an element is added to the block
  130542. */
  130543. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  130544. /**
  130545. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130546. */
  130547. get capacity(): number;
  130548. /**
  130549. * Gets the minimum vector (in world space) of the block's bounding box
  130550. */
  130551. get minPoint(): Vector3;
  130552. /**
  130553. * Gets the maximum vector (in world space) of the block's bounding box
  130554. */
  130555. get maxPoint(): Vector3;
  130556. /**
  130557. * Add a new element to this block
  130558. * @param entry defines the element to add
  130559. */
  130560. addEntry(entry: T): void;
  130561. /**
  130562. * Remove an element from this block
  130563. * @param entry defines the element to remove
  130564. */
  130565. removeEntry(entry: T): void;
  130566. /**
  130567. * Add an array of elements to this block
  130568. * @param entries defines the array of elements to add
  130569. */
  130570. addEntries(entries: T[]): void;
  130571. /**
  130572. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  130573. * @param frustumPlanes defines the frustum planes to test
  130574. * @param selection defines the array to store current content if selection is positive
  130575. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130576. */
  130577. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130578. /**
  130579. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  130580. * @param sphereCenter defines the bounding sphere center
  130581. * @param sphereRadius defines the bounding sphere radius
  130582. * @param selection defines the array to store current content if selection is positive
  130583. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130584. */
  130585. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130586. /**
  130587. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  130588. * @param ray defines the ray to test with
  130589. * @param selection defines the array to store current content if selection is positive
  130590. */
  130591. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  130592. /**
  130593. * Subdivide the content into child blocks (this block will then be empty)
  130594. */
  130595. createInnerBlocks(): void;
  130596. /**
  130597. * @hidden
  130598. */
  130599. 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;
  130600. }
  130601. }
  130602. declare module BABYLON {
  130603. /**
  130604. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  130605. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130606. */
  130607. export class Octree<T> {
  130608. /** 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.) */
  130609. maxDepth: number;
  130610. /**
  130611. * Blocks within the octree containing objects
  130612. */
  130613. blocks: Array<OctreeBlock<T>>;
  130614. /**
  130615. * Content stored in the octree
  130616. */
  130617. dynamicContent: T[];
  130618. private _maxBlockCapacity;
  130619. private _selectionContent;
  130620. private _creationFunc;
  130621. /**
  130622. * Creates a octree
  130623. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130624. * @param creationFunc function to be used to instatiate the octree
  130625. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  130626. * @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.)
  130627. */
  130628. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  130629. /** 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.) */
  130630. maxDepth?: number);
  130631. /**
  130632. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  130633. * @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);
  130634. * @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);
  130635. * @param entries meshes to be added to the octree blocks
  130636. */
  130637. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  130638. /**
  130639. * Adds a mesh to the octree
  130640. * @param entry Mesh to add to the octree
  130641. */
  130642. addMesh(entry: T): void;
  130643. /**
  130644. * Remove an element from the octree
  130645. * @param entry defines the element to remove
  130646. */
  130647. removeMesh(entry: T): void;
  130648. /**
  130649. * Selects an array of meshes within the frustum
  130650. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  130651. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  130652. * @returns array of meshes within the frustum
  130653. */
  130654. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  130655. /**
  130656. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  130657. * @param sphereCenter defines the bounding sphere center
  130658. * @param sphereRadius defines the bounding sphere radius
  130659. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130660. * @returns an array of objects that intersect the sphere
  130661. */
  130662. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  130663. /**
  130664. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  130665. * @param ray defines the ray to test with
  130666. * @returns array of intersected objects
  130667. */
  130668. intersectsRay(ray: Ray): SmartArray<T>;
  130669. /**
  130670. * Adds a mesh into the octree block if it intersects the block
  130671. */
  130672. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  130673. /**
  130674. * Adds a submesh into the octree block if it intersects the block
  130675. */
  130676. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  130677. }
  130678. }
  130679. declare module BABYLON {
  130680. interface Scene {
  130681. /**
  130682. * @hidden
  130683. * Backing Filed
  130684. */
  130685. _selectionOctree: Octree<AbstractMesh>;
  130686. /**
  130687. * Gets the octree used to boost mesh selection (picking)
  130688. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130689. */
  130690. selectionOctree: Octree<AbstractMesh>;
  130691. /**
  130692. * Creates or updates the octree used to boost selection (picking)
  130693. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130694. * @param maxCapacity defines the maximum capacity per leaf
  130695. * @param maxDepth defines the maximum depth of the octree
  130696. * @returns an octree of AbstractMesh
  130697. */
  130698. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  130699. }
  130700. interface AbstractMesh {
  130701. /**
  130702. * @hidden
  130703. * Backing Field
  130704. */
  130705. _submeshesOctree: Octree<SubMesh>;
  130706. /**
  130707. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  130708. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  130709. * @param maxCapacity defines the maximum size of each block (64 by default)
  130710. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  130711. * @returns the new octree
  130712. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  130713. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130714. */
  130715. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  130716. }
  130717. /**
  130718. * Defines the octree scene component responsible to manage any octrees
  130719. * in a given scene.
  130720. */
  130721. export class OctreeSceneComponent {
  130722. /**
  130723. * The component name help to identify the component in the list of scene components.
  130724. */
  130725. readonly name: string;
  130726. /**
  130727. * The scene the component belongs to.
  130728. */
  130729. scene: Scene;
  130730. /**
  130731. * Indicates if the meshes have been checked to make sure they are isEnabled()
  130732. */
  130733. readonly checksIsEnabled: boolean;
  130734. /**
  130735. * Creates a new instance of the component for the given scene
  130736. * @param scene Defines the scene to register the component in
  130737. */
  130738. constructor(scene: Scene);
  130739. /**
  130740. * Registers the component in a given scene
  130741. */
  130742. register(): void;
  130743. /**
  130744. * Return the list of active meshes
  130745. * @returns the list of active meshes
  130746. */
  130747. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  130748. /**
  130749. * Return the list of active sub meshes
  130750. * @param mesh The mesh to get the candidates sub meshes from
  130751. * @returns the list of active sub meshes
  130752. */
  130753. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  130754. private _tempRay;
  130755. /**
  130756. * Return the list of sub meshes intersecting with a given local ray
  130757. * @param mesh defines the mesh to find the submesh for
  130758. * @param localRay defines the ray in local space
  130759. * @returns the list of intersecting sub meshes
  130760. */
  130761. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  130762. /**
  130763. * Return the list of sub meshes colliding with a collider
  130764. * @param mesh defines the mesh to find the submesh for
  130765. * @param collider defines the collider to evaluate the collision against
  130766. * @returns the list of colliding sub meshes
  130767. */
  130768. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  130769. /**
  130770. * Rebuilds the elements related to this component in case of
  130771. * context lost for instance.
  130772. */
  130773. rebuild(): void;
  130774. /**
  130775. * Disposes the component and the associated ressources.
  130776. */
  130777. dispose(): void;
  130778. }
  130779. }
  130780. declare module BABYLON {
  130781. /**
  130782. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  130783. */
  130784. export class Gizmo implements IDisposable {
  130785. /** The utility layer the gizmo will be added to */
  130786. gizmoLayer: UtilityLayerRenderer;
  130787. /**
  130788. * The root mesh of the gizmo
  130789. */
  130790. _rootMesh: Mesh;
  130791. private _attachedMesh;
  130792. private _attachedNode;
  130793. /**
  130794. * Ratio for the scale of the gizmo (Default: 1)
  130795. */
  130796. protected _scaleRatio: number;
  130797. /**
  130798. * boolean updated by pointermove when a gizmo mesh is hovered
  130799. */
  130800. protected _isHovered: boolean;
  130801. /**
  130802. * Ratio for the scale of the gizmo (Default: 1)
  130803. */
  130804. set scaleRatio(value: number);
  130805. get scaleRatio(): number;
  130806. /**
  130807. * True when the mouse pointer is hovered a gizmo mesh
  130808. */
  130809. get isHovered(): boolean;
  130810. /**
  130811. * If a custom mesh has been set (Default: false)
  130812. */
  130813. protected _customMeshSet: boolean;
  130814. /**
  130815. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  130816. * * When set, interactions will be enabled
  130817. */
  130818. get attachedMesh(): Nullable<AbstractMesh>;
  130819. set attachedMesh(value: Nullable<AbstractMesh>);
  130820. /**
  130821. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  130822. * * When set, interactions will be enabled
  130823. */
  130824. get attachedNode(): Nullable<Node>;
  130825. set attachedNode(value: Nullable<Node>);
  130826. /**
  130827. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130828. * @param mesh The mesh to replace the default mesh of the gizmo
  130829. */
  130830. setCustomMesh(mesh: Mesh): void;
  130831. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  130832. /**
  130833. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  130834. */
  130835. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130836. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130837. /**
  130838. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  130839. */
  130840. updateGizmoPositionToMatchAttachedMesh: boolean;
  130841. /**
  130842. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  130843. */
  130844. updateScale: boolean;
  130845. protected _interactionsEnabled: boolean;
  130846. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130847. private _beforeRenderObserver;
  130848. private _tempQuaternion;
  130849. private _tempVector;
  130850. private _tempVector2;
  130851. private _tempMatrix1;
  130852. private _tempMatrix2;
  130853. private _rightHandtoLeftHandMatrix;
  130854. /**
  130855. * Creates a gizmo
  130856. * @param gizmoLayer The utility layer the gizmo will be added to
  130857. */
  130858. constructor(
  130859. /** The utility layer the gizmo will be added to */
  130860. gizmoLayer?: UtilityLayerRenderer);
  130861. /**
  130862. * Updates the gizmo to match the attached mesh's position/rotation
  130863. */
  130864. protected _update(): void;
  130865. /**
  130866. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  130867. * @param value Node, TransformNode or mesh
  130868. */
  130869. protected _matrixChanged(): void;
  130870. /**
  130871. * Disposes of the gizmo
  130872. */
  130873. dispose(): void;
  130874. }
  130875. }
  130876. declare module BABYLON {
  130877. /**
  130878. * Single plane drag gizmo
  130879. */
  130880. export class PlaneDragGizmo extends Gizmo {
  130881. /**
  130882. * Drag behavior responsible for the gizmos dragging interactions
  130883. */
  130884. dragBehavior: PointerDragBehavior;
  130885. private _pointerObserver;
  130886. /**
  130887. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130888. */
  130889. snapDistance: number;
  130890. /**
  130891. * Event that fires each time the gizmo snaps to a new location.
  130892. * * snapDistance is the the change in distance
  130893. */
  130894. onSnapObservable: Observable<{
  130895. snapDistance: number;
  130896. }>;
  130897. private _plane;
  130898. private _coloredMaterial;
  130899. private _hoverMaterial;
  130900. private _isEnabled;
  130901. private _parent;
  130902. /** @hidden */
  130903. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  130904. /** @hidden */
  130905. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130906. /**
  130907. * Creates a PlaneDragGizmo
  130908. * @param gizmoLayer The utility layer the gizmo will be added to
  130909. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  130910. * @param color The color of the gizmo
  130911. */
  130912. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  130913. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130914. /**
  130915. * If the gizmo is enabled
  130916. */
  130917. set isEnabled(value: boolean);
  130918. get isEnabled(): boolean;
  130919. /**
  130920. * Disposes of the gizmo
  130921. */
  130922. dispose(): void;
  130923. }
  130924. }
  130925. declare module BABYLON {
  130926. /**
  130927. * Gizmo that enables dragging a mesh along 3 axis
  130928. */
  130929. export class PositionGizmo extends Gizmo {
  130930. /**
  130931. * Internal gizmo used for interactions on the x axis
  130932. */
  130933. xGizmo: AxisDragGizmo;
  130934. /**
  130935. * Internal gizmo used for interactions on the y axis
  130936. */
  130937. yGizmo: AxisDragGizmo;
  130938. /**
  130939. * Internal gizmo used for interactions on the z axis
  130940. */
  130941. zGizmo: AxisDragGizmo;
  130942. /**
  130943. * Internal gizmo used for interactions on the yz plane
  130944. */
  130945. xPlaneGizmo: PlaneDragGizmo;
  130946. /**
  130947. * Internal gizmo used for interactions on the xz plane
  130948. */
  130949. yPlaneGizmo: PlaneDragGizmo;
  130950. /**
  130951. * Internal gizmo used for interactions on the xy plane
  130952. */
  130953. zPlaneGizmo: PlaneDragGizmo;
  130954. /**
  130955. * private variables
  130956. */
  130957. private _meshAttached;
  130958. private _nodeAttached;
  130959. private _snapDistance;
  130960. /** Fires an event when any of it's sub gizmos are dragged */
  130961. onDragStartObservable: Observable<unknown>;
  130962. /** Fires an event when any of it's sub gizmos are released from dragging */
  130963. onDragEndObservable: Observable<unknown>;
  130964. /**
  130965. * If set to true, planar drag is enabled
  130966. */
  130967. private _planarGizmoEnabled;
  130968. get attachedMesh(): Nullable<AbstractMesh>;
  130969. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130970. get attachedNode(): Nullable<Node>;
  130971. set attachedNode(node: Nullable<Node>);
  130972. /**
  130973. * True when the mouse pointer is hovering a gizmo mesh
  130974. */
  130975. get isHovered(): boolean;
  130976. /**
  130977. * Creates a PositionGizmo
  130978. * @param gizmoLayer The utility layer the gizmo will be added to
  130979. @param thickness display gizmo axis thickness
  130980. */
  130981. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  130982. /**
  130983. * If the planar drag gizmo is enabled
  130984. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  130985. */
  130986. set planarGizmoEnabled(value: boolean);
  130987. get planarGizmoEnabled(): boolean;
  130988. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130989. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130990. /**
  130991. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130992. */
  130993. set snapDistance(value: number);
  130994. get snapDistance(): number;
  130995. /**
  130996. * Ratio for the scale of the gizmo (Default: 1)
  130997. */
  130998. set scaleRatio(value: number);
  130999. get scaleRatio(): number;
  131000. /**
  131001. * Disposes of the gizmo
  131002. */
  131003. dispose(): void;
  131004. /**
  131005. * CustomMeshes are not supported by this gizmo
  131006. * @param mesh The mesh to replace the default mesh of the gizmo
  131007. */
  131008. setCustomMesh(mesh: Mesh): void;
  131009. }
  131010. }
  131011. declare module BABYLON {
  131012. /**
  131013. * Single axis drag gizmo
  131014. */
  131015. export class AxisDragGizmo extends Gizmo {
  131016. /**
  131017. * Drag behavior responsible for the gizmos dragging interactions
  131018. */
  131019. dragBehavior: PointerDragBehavior;
  131020. private _pointerObserver;
  131021. /**
  131022. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  131023. */
  131024. snapDistance: number;
  131025. /**
  131026. * Event that fires each time the gizmo snaps to a new location.
  131027. * * snapDistance is the the change in distance
  131028. */
  131029. onSnapObservable: Observable<{
  131030. snapDistance: number;
  131031. }>;
  131032. private _isEnabled;
  131033. private _parent;
  131034. private _arrow;
  131035. private _coloredMaterial;
  131036. private _hoverMaterial;
  131037. /** @hidden */
  131038. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  131039. /** @hidden */
  131040. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  131041. /**
  131042. * Creates an AxisDragGizmo
  131043. * @param gizmoLayer The utility layer the gizmo will be added to
  131044. * @param dragAxis The axis which the gizmo will be able to drag on
  131045. * @param color The color of the gizmo
  131046. * @param thickness display gizmo axis thickness
  131047. */
  131048. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  131049. protected _attachedNodeChanged(value: Nullable<Node>): void;
  131050. /**
  131051. * If the gizmo is enabled
  131052. */
  131053. set isEnabled(value: boolean);
  131054. get isEnabled(): boolean;
  131055. /**
  131056. * Disposes of the gizmo
  131057. */
  131058. dispose(): void;
  131059. }
  131060. }
  131061. declare module BABYLON.Debug {
  131062. /**
  131063. * The Axes viewer will show 3 axes in a specific point in space
  131064. */
  131065. export class AxesViewer {
  131066. private _xAxis;
  131067. private _yAxis;
  131068. private _zAxis;
  131069. private _scaleLinesFactor;
  131070. private _instanced;
  131071. /**
  131072. * Gets the hosting scene
  131073. */
  131074. scene: Nullable<Scene>;
  131075. /**
  131076. * Gets or sets a number used to scale line length
  131077. */
  131078. scaleLines: number;
  131079. /** Gets the node hierarchy used to render x-axis */
  131080. get xAxis(): TransformNode;
  131081. /** Gets the node hierarchy used to render y-axis */
  131082. get yAxis(): TransformNode;
  131083. /** Gets the node hierarchy used to render z-axis */
  131084. get zAxis(): TransformNode;
  131085. /**
  131086. * Creates a new AxesViewer
  131087. * @param scene defines the hosting scene
  131088. * @param scaleLines defines a number used to scale line length (1 by default)
  131089. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  131090. * @param xAxis defines the node hierarchy used to render the x-axis
  131091. * @param yAxis defines the node hierarchy used to render the y-axis
  131092. * @param zAxis defines the node hierarchy used to render the z-axis
  131093. */
  131094. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  131095. /**
  131096. * Force the viewer to update
  131097. * @param position defines the position of the viewer
  131098. * @param xaxis defines the x axis of the viewer
  131099. * @param yaxis defines the y axis of the viewer
  131100. * @param zaxis defines the z axis of the viewer
  131101. */
  131102. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  131103. /**
  131104. * Creates an instance of this axes viewer.
  131105. * @returns a new axes viewer with instanced meshes
  131106. */
  131107. createInstance(): AxesViewer;
  131108. /** Releases resources */
  131109. dispose(): void;
  131110. private static _SetRenderingGroupId;
  131111. }
  131112. }
  131113. declare module BABYLON.Debug {
  131114. /**
  131115. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  131116. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  131117. */
  131118. export class BoneAxesViewer extends AxesViewer {
  131119. /**
  131120. * Gets or sets the target mesh where to display the axes viewer
  131121. */
  131122. mesh: Nullable<Mesh>;
  131123. /**
  131124. * Gets or sets the target bone where to display the axes viewer
  131125. */
  131126. bone: Nullable<Bone>;
  131127. /** Gets current position */
  131128. pos: Vector3;
  131129. /** Gets direction of X axis */
  131130. xaxis: Vector3;
  131131. /** Gets direction of Y axis */
  131132. yaxis: Vector3;
  131133. /** Gets direction of Z axis */
  131134. zaxis: Vector3;
  131135. /**
  131136. * Creates a new BoneAxesViewer
  131137. * @param scene defines the hosting scene
  131138. * @param bone defines the target bone
  131139. * @param mesh defines the target mesh
  131140. * @param scaleLines defines a scaling factor for line length (1 by default)
  131141. */
  131142. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  131143. /**
  131144. * Force the viewer to update
  131145. */
  131146. update(): void;
  131147. /** Releases resources */
  131148. dispose(): void;
  131149. }
  131150. }
  131151. declare module BABYLON {
  131152. /**
  131153. * Interface used to define scene explorer extensibility option
  131154. */
  131155. export interface IExplorerExtensibilityOption {
  131156. /**
  131157. * Define the option label
  131158. */
  131159. label: string;
  131160. /**
  131161. * Defines the action to execute on click
  131162. */
  131163. action: (entity: any) => void;
  131164. }
  131165. /**
  131166. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  131167. */
  131168. export interface IExplorerExtensibilityGroup {
  131169. /**
  131170. * Defines a predicate to test if a given type mut be extended
  131171. */
  131172. predicate: (entity: any) => boolean;
  131173. /**
  131174. * Gets the list of options added to a type
  131175. */
  131176. entries: IExplorerExtensibilityOption[];
  131177. }
  131178. /**
  131179. * Interface used to define the options to use to create the Inspector
  131180. */
  131181. export interface IInspectorOptions {
  131182. /**
  131183. * Display in overlay mode (default: false)
  131184. */
  131185. overlay?: boolean;
  131186. /**
  131187. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  131188. */
  131189. globalRoot?: HTMLElement;
  131190. /**
  131191. * Display the Scene explorer
  131192. */
  131193. showExplorer?: boolean;
  131194. /**
  131195. * Display the property inspector
  131196. */
  131197. showInspector?: boolean;
  131198. /**
  131199. * Display in embed mode (both panes on the right)
  131200. */
  131201. embedMode?: boolean;
  131202. /**
  131203. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  131204. */
  131205. handleResize?: boolean;
  131206. /**
  131207. * Allow the panes to popup (default: true)
  131208. */
  131209. enablePopup?: boolean;
  131210. /**
  131211. * Allow the panes to be closed by users (default: true)
  131212. */
  131213. enableClose?: boolean;
  131214. /**
  131215. * Optional list of extensibility entries
  131216. */
  131217. explorerExtensibility?: IExplorerExtensibilityGroup[];
  131218. /**
  131219. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  131220. */
  131221. inspectorURL?: string;
  131222. /**
  131223. * Optional initial tab (default to DebugLayerTab.Properties)
  131224. */
  131225. initialTab?: DebugLayerTab;
  131226. }
  131227. interface Scene {
  131228. /**
  131229. * @hidden
  131230. * Backing field
  131231. */
  131232. _debugLayer: DebugLayer;
  131233. /**
  131234. * Gets the debug layer (aka Inspector) associated with the scene
  131235. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131236. */
  131237. debugLayer: DebugLayer;
  131238. }
  131239. /**
  131240. * Enum of inspector action tab
  131241. */
  131242. export enum DebugLayerTab {
  131243. /**
  131244. * Properties tag (default)
  131245. */
  131246. Properties = 0,
  131247. /**
  131248. * Debug tab
  131249. */
  131250. Debug = 1,
  131251. /**
  131252. * Statistics tab
  131253. */
  131254. Statistics = 2,
  131255. /**
  131256. * Tools tab
  131257. */
  131258. Tools = 3,
  131259. /**
  131260. * Settings tab
  131261. */
  131262. Settings = 4
  131263. }
  131264. /**
  131265. * The debug layer (aka Inspector) is the go to tool in order to better understand
  131266. * what is happening in your scene
  131267. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131268. */
  131269. export class DebugLayer {
  131270. /**
  131271. * Define the url to get the inspector script from.
  131272. * By default it uses the babylonjs CDN.
  131273. * @ignoreNaming
  131274. */
  131275. static InspectorURL: string;
  131276. private _scene;
  131277. private BJSINSPECTOR;
  131278. private _onPropertyChangedObservable?;
  131279. /**
  131280. * Observable triggered when a property is changed through the inspector.
  131281. */
  131282. get onPropertyChangedObservable(): any;
  131283. /**
  131284. * Instantiates a new debug layer.
  131285. * The debug layer (aka Inspector) is the go to tool in order to better understand
  131286. * what is happening in your scene
  131287. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131288. * @param scene Defines the scene to inspect
  131289. */
  131290. constructor(scene: Scene);
  131291. /** Creates the inspector window. */
  131292. private _createInspector;
  131293. /**
  131294. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  131295. * @param entity defines the entity to select
  131296. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  131297. */
  131298. select(entity: any, lineContainerTitles?: string | string[]): void;
  131299. /** Get the inspector from bundle or global */
  131300. private _getGlobalInspector;
  131301. /**
  131302. * Get if the inspector is visible or not.
  131303. * @returns true if visible otherwise, false
  131304. */
  131305. isVisible(): boolean;
  131306. /**
  131307. * Hide the inspector and close its window.
  131308. */
  131309. hide(): void;
  131310. /**
  131311. * Update the scene in the inspector
  131312. */
  131313. setAsActiveScene(): void;
  131314. /**
  131315. * Launch the debugLayer.
  131316. * @param config Define the configuration of the inspector
  131317. * @return a promise fulfilled when the debug layer is visible
  131318. */
  131319. show(config?: IInspectorOptions): Promise<DebugLayer>;
  131320. }
  131321. }
  131322. declare module BABYLON {
  131323. /**
  131324. * Class containing static functions to help procedurally build meshes
  131325. */
  131326. export class BoxBuilder {
  131327. /**
  131328. * Creates a box mesh
  131329. * * The parameter `size` sets the size (float) of each box side (default 1)
  131330. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  131331. * * 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)
  131332. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  131333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131336. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  131337. * @param name defines the name of the mesh
  131338. * @param options defines the options used to create the mesh
  131339. * @param scene defines the hosting scene
  131340. * @returns the box mesh
  131341. */
  131342. static CreateBox(name: string, options: {
  131343. size?: number;
  131344. width?: number;
  131345. height?: number;
  131346. depth?: number;
  131347. faceUV?: Vector4[];
  131348. faceColors?: Color4[];
  131349. sideOrientation?: number;
  131350. frontUVs?: Vector4;
  131351. backUVs?: Vector4;
  131352. wrap?: boolean;
  131353. topBaseAt?: number;
  131354. bottomBaseAt?: number;
  131355. updatable?: boolean;
  131356. }, scene?: Nullable<Scene>): Mesh;
  131357. }
  131358. }
  131359. declare module BABYLON.Debug {
  131360. /**
  131361. * Used to show the physics impostor around the specific mesh
  131362. */
  131363. export class PhysicsViewer {
  131364. /** @hidden */
  131365. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  131366. /** @hidden */
  131367. protected _meshes: Array<Nullable<AbstractMesh>>;
  131368. /** @hidden */
  131369. protected _scene: Nullable<Scene>;
  131370. /** @hidden */
  131371. protected _numMeshes: number;
  131372. /** @hidden */
  131373. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  131374. private _renderFunction;
  131375. private _utilityLayer;
  131376. private _debugBoxMesh;
  131377. private _debugSphereMesh;
  131378. private _debugCylinderMesh;
  131379. private _debugMaterial;
  131380. private _debugMeshMeshes;
  131381. /**
  131382. * Creates a new PhysicsViewer
  131383. * @param scene defines the hosting scene
  131384. */
  131385. constructor(scene: Scene);
  131386. /** @hidden */
  131387. protected _updateDebugMeshes(): void;
  131388. /**
  131389. * Renders a specified physic impostor
  131390. * @param impostor defines the impostor to render
  131391. * @param targetMesh defines the mesh represented by the impostor
  131392. * @returns the new debug mesh used to render the impostor
  131393. */
  131394. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  131395. /**
  131396. * Hides a specified physic impostor
  131397. * @param impostor defines the impostor to hide
  131398. */
  131399. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  131400. private _getDebugMaterial;
  131401. private _getDebugBoxMesh;
  131402. private _getDebugSphereMesh;
  131403. private _getDebugCylinderMesh;
  131404. private _getDebugMeshMesh;
  131405. private _getDebugMesh;
  131406. /** Releases all resources */
  131407. dispose(): void;
  131408. }
  131409. }
  131410. declare module BABYLON {
  131411. /**
  131412. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131413. * in order to better appreciate the issue one might have.
  131414. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131415. */
  131416. export class RayHelper {
  131417. /**
  131418. * Defines the ray we are currently tryin to visualize.
  131419. */
  131420. ray: Nullable<Ray>;
  131421. private _renderPoints;
  131422. private _renderLine;
  131423. private _renderFunction;
  131424. private _scene;
  131425. private _onAfterRenderObserver;
  131426. private _onAfterStepObserver;
  131427. private _attachedToMesh;
  131428. private _meshSpaceDirection;
  131429. private _meshSpaceOrigin;
  131430. /**
  131431. * Helper function to create a colored helper in a scene in one line.
  131432. * @param ray Defines the ray we are currently tryin to visualize
  131433. * @param scene Defines the scene the ray is used in
  131434. * @param color Defines the color we want to see the ray in
  131435. * @returns The newly created ray helper.
  131436. */
  131437. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  131438. /**
  131439. * Instantiate a new ray helper.
  131440. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131441. * in order to better appreciate the issue one might have.
  131442. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131443. * @param ray Defines the ray we are currently tryin to visualize
  131444. */
  131445. constructor(ray: Ray);
  131446. /**
  131447. * Shows the ray we are willing to debug.
  131448. * @param scene Defines the scene the ray needs to be rendered in
  131449. * @param color Defines the color the ray needs to be rendered in
  131450. */
  131451. show(scene: Scene, color?: Color3): void;
  131452. /**
  131453. * Hides the ray we are debugging.
  131454. */
  131455. hide(): void;
  131456. private _render;
  131457. /**
  131458. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  131459. * @param mesh Defines the mesh we want the helper attached to
  131460. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  131461. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  131462. * @param length Defines the length of the ray
  131463. */
  131464. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  131465. /**
  131466. * Detach the ray helper from the mesh it has previously been attached to.
  131467. */
  131468. detachFromMesh(): void;
  131469. private _updateToMesh;
  131470. /**
  131471. * Dispose the helper and release its associated resources.
  131472. */
  131473. dispose(): void;
  131474. }
  131475. }
  131476. declare module BABYLON {
  131477. /**
  131478. * Defines the options associated with the creation of a SkeletonViewer.
  131479. */
  131480. export interface ISkeletonViewerOptions {
  131481. /** Should the system pause animations before building the Viewer? */
  131482. pauseAnimations: boolean;
  131483. /** Should the system return the skeleton to rest before building? */
  131484. returnToRest: boolean;
  131485. /** public Display Mode of the Viewer */
  131486. displayMode: number;
  131487. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131488. displayOptions: ISkeletonViewerDisplayOptions;
  131489. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131490. computeBonesUsingShaders: boolean;
  131491. /** Flag ignore non weighted bones */
  131492. useAllBones: boolean;
  131493. }
  131494. /**
  131495. * Defines how to display the various bone meshes for the viewer.
  131496. */
  131497. export interface ISkeletonViewerDisplayOptions {
  131498. /** How far down to start tapering the bone spurs */
  131499. midStep?: number;
  131500. /** How big is the midStep? */
  131501. midStepFactor?: number;
  131502. /** Base for the Sphere Size */
  131503. sphereBaseSize?: number;
  131504. /** The ratio of the sphere to the longest bone in units */
  131505. sphereScaleUnit?: number;
  131506. /** Ratio for the Sphere Size */
  131507. sphereFactor?: number;
  131508. /** Whether a spur should attach its far end to the child bone position */
  131509. spurFollowsChild?: boolean;
  131510. /** Whether to show local axes or not */
  131511. showLocalAxes?: boolean;
  131512. /** Length of each local axis */
  131513. localAxesSize?: number;
  131514. }
  131515. /**
  131516. * Defines the constructor options for the BoneWeight Shader.
  131517. */
  131518. export interface IBoneWeightShaderOptions {
  131519. /** Skeleton to Map */
  131520. skeleton: Skeleton;
  131521. /** Colors for Uninfluenced bones */
  131522. colorBase?: Color3;
  131523. /** Colors for 0.0-0.25 Weight bones */
  131524. colorZero?: Color3;
  131525. /** Color for 0.25-0.5 Weight Influence */
  131526. colorQuarter?: Color3;
  131527. /** Color for 0.5-0.75 Weight Influence */
  131528. colorHalf?: Color3;
  131529. /** Color for 0.75-1 Weight Influence */
  131530. colorFull?: Color3;
  131531. /** Color for Zero Weight Influence */
  131532. targetBoneIndex?: number;
  131533. }
  131534. /**
  131535. * Simple structure of the gradient steps for the Color Map.
  131536. */
  131537. export interface ISkeletonMapShaderColorMapKnot {
  131538. /** Color of the Knot */
  131539. color: Color3;
  131540. /** Location of the Knot */
  131541. location: number;
  131542. }
  131543. /**
  131544. * Defines the constructor options for the SkeletonMap Shader.
  131545. */
  131546. export interface ISkeletonMapShaderOptions {
  131547. /** Skeleton to Map */
  131548. skeleton: Skeleton;
  131549. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  131550. colorMap?: ISkeletonMapShaderColorMapKnot[];
  131551. }
  131552. }
  131553. declare module BABYLON {
  131554. /**
  131555. * Class containing static functions to help procedurally build meshes
  131556. */
  131557. export class RibbonBuilder {
  131558. /**
  131559. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131560. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131561. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131562. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131563. * * 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
  131564. * * 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
  131565. * * 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
  131566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131567. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131568. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131569. * * 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
  131570. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131571. * * 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
  131572. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131574. * @param name defines the name of the mesh
  131575. * @param options defines the options used to create the mesh
  131576. * @param scene defines the hosting scene
  131577. * @returns the ribbon mesh
  131578. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131579. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131580. */
  131581. static CreateRibbon(name: string, options: {
  131582. pathArray: Vector3[][];
  131583. closeArray?: boolean;
  131584. closePath?: boolean;
  131585. offset?: number;
  131586. updatable?: boolean;
  131587. sideOrientation?: number;
  131588. frontUVs?: Vector4;
  131589. backUVs?: Vector4;
  131590. instance?: Mesh;
  131591. invertUV?: boolean;
  131592. uvs?: Vector2[];
  131593. colors?: Color4[];
  131594. }, scene?: Nullable<Scene>): Mesh;
  131595. }
  131596. }
  131597. declare module BABYLON {
  131598. /**
  131599. * Class containing static functions to help procedurally build meshes
  131600. */
  131601. export class ShapeBuilder {
  131602. /**
  131603. * 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.
  131604. * * 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.
  131605. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131606. * * 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.
  131607. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131608. * * 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
  131609. * * 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
  131610. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131612. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131613. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131615. * @param name defines the name of the mesh
  131616. * @param options defines the options used to create the mesh
  131617. * @param scene defines the hosting scene
  131618. * @returns the extruded shape mesh
  131619. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131620. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131621. */
  131622. static ExtrudeShape(name: string, options: {
  131623. shape: Vector3[];
  131624. path: Vector3[];
  131625. scale?: number;
  131626. rotation?: number;
  131627. cap?: number;
  131628. updatable?: boolean;
  131629. sideOrientation?: number;
  131630. frontUVs?: Vector4;
  131631. backUVs?: Vector4;
  131632. instance?: Mesh;
  131633. invertUV?: boolean;
  131634. }, scene?: Nullable<Scene>): Mesh;
  131635. /**
  131636. * Creates an custom extruded shape mesh.
  131637. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131638. * * 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.
  131639. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131640. * * 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
  131641. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131642. * * 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
  131643. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131644. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131645. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131646. * * 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
  131647. * * 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
  131648. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131651. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131653. * @param name defines the name of the mesh
  131654. * @param options defines the options used to create the mesh
  131655. * @param scene defines the hosting scene
  131656. * @returns the custom extruded shape mesh
  131657. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131658. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131659. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131660. */
  131661. static ExtrudeShapeCustom(name: string, options: {
  131662. shape: Vector3[];
  131663. path: Vector3[];
  131664. scaleFunction?: any;
  131665. rotationFunction?: any;
  131666. ribbonCloseArray?: boolean;
  131667. ribbonClosePath?: boolean;
  131668. cap?: number;
  131669. updatable?: boolean;
  131670. sideOrientation?: number;
  131671. frontUVs?: Vector4;
  131672. backUVs?: Vector4;
  131673. instance?: Mesh;
  131674. invertUV?: boolean;
  131675. }, scene?: Nullable<Scene>): Mesh;
  131676. private static _ExtrudeShapeGeneric;
  131677. }
  131678. }
  131679. declare module BABYLON.Debug {
  131680. /**
  131681. * Class used to render a debug view of a given skeleton
  131682. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  131683. */
  131684. export class SkeletonViewer {
  131685. /** defines the skeleton to render */
  131686. skeleton: Skeleton;
  131687. /** defines the mesh attached to the skeleton */
  131688. mesh: AbstractMesh;
  131689. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131690. autoUpdateBonesMatrices: boolean;
  131691. /** defines the rendering group id to use with the viewer */
  131692. renderingGroupId: number;
  131693. /** is the options for the viewer */
  131694. options: Partial<ISkeletonViewerOptions>;
  131695. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  131696. static readonly DISPLAY_LINES: number;
  131697. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  131698. static readonly DISPLAY_SPHERES: number;
  131699. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  131700. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  131701. /** public static method to create a BoneWeight Shader
  131702. * @param options The constructor options
  131703. * @param scene The scene that the shader is scoped to
  131704. * @returns The created ShaderMaterial
  131705. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  131706. */
  131707. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  131708. /** public static method to create a BoneWeight Shader
  131709. * @param options The constructor options
  131710. * @param scene The scene that the shader is scoped to
  131711. * @returns The created ShaderMaterial
  131712. */
  131713. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  131714. /** private static method to create a BoneWeight Shader
  131715. * @param size The size of the buffer to create (usually the bone count)
  131716. * @param colorMap The gradient data to generate
  131717. * @param scene The scene that the shader is scoped to
  131718. * @returns an Array of floats from the color gradient values
  131719. */
  131720. private static _CreateBoneMapColorBuffer;
  131721. /** If SkeletonViewer scene scope. */
  131722. private _scene;
  131723. /** Gets or sets the color used to render the skeleton */
  131724. color: Color3;
  131725. /** Array of the points of the skeleton fo the line view. */
  131726. private _debugLines;
  131727. /** The SkeletonViewers Mesh. */
  131728. private _debugMesh;
  131729. /** The local axes Meshes. */
  131730. private _localAxes;
  131731. /** If SkeletonViewer is enabled. */
  131732. private _isEnabled;
  131733. /** If SkeletonViewer is ready. */
  131734. private _ready;
  131735. /** SkeletonViewer render observable. */
  131736. private _obs;
  131737. /** The Utility Layer to render the gizmos in. */
  131738. private _utilityLayer;
  131739. private _boneIndices;
  131740. /** Gets the Scene. */
  131741. get scene(): Scene;
  131742. /** Gets the utilityLayer. */
  131743. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  131744. /** Checks Ready Status. */
  131745. get isReady(): Boolean;
  131746. /** Sets Ready Status. */
  131747. set ready(value: boolean);
  131748. /** Gets the debugMesh */
  131749. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  131750. /** Sets the debugMesh */
  131751. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  131752. /** Gets the displayMode */
  131753. get displayMode(): number;
  131754. /** Sets the displayMode */
  131755. set displayMode(value: number);
  131756. /**
  131757. * Creates a new SkeletonViewer
  131758. * @param skeleton defines the skeleton to render
  131759. * @param mesh defines the mesh attached to the skeleton
  131760. * @param scene defines the hosting scene
  131761. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  131762. * @param renderingGroupId defines the rendering group id to use with the viewer
  131763. * @param options All of the extra constructor options for the SkeletonViewer
  131764. */
  131765. constructor(
  131766. /** defines the skeleton to render */
  131767. skeleton: Skeleton,
  131768. /** defines the mesh attached to the skeleton */
  131769. mesh: AbstractMesh,
  131770. /** The Scene scope*/
  131771. scene: Scene,
  131772. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131773. autoUpdateBonesMatrices?: boolean,
  131774. /** defines the rendering group id to use with the viewer */
  131775. renderingGroupId?: number,
  131776. /** is the options for the viewer */
  131777. options?: Partial<ISkeletonViewerOptions>);
  131778. /** The Dynamic bindings for the update functions */
  131779. private _bindObs;
  131780. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  131781. update(): void;
  131782. /** Gets or sets a boolean indicating if the viewer is enabled */
  131783. set isEnabled(value: boolean);
  131784. get isEnabled(): boolean;
  131785. private _getBonePosition;
  131786. private _getLinesForBonesWithLength;
  131787. private _getLinesForBonesNoLength;
  131788. /** function to revert the mesh and scene back to the initial state. */
  131789. private _revert;
  131790. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  131791. private _getAbsoluteBindPoseToRef;
  131792. /** function to build and bind sphere joint points and spur bone representations. */
  131793. private _buildSpheresAndSpurs;
  131794. private _buildLocalAxes;
  131795. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  131796. private _displayLinesUpdate;
  131797. /** Changes the displayMode of the skeleton viewer
  131798. * @param mode The displayMode numerical value
  131799. */
  131800. changeDisplayMode(mode: number): void;
  131801. /** Sets a display option of the skeleton viewer
  131802. *
  131803. * | Option | Type | Default | Description |
  131804. * | ---------------- | ------- | ------- | ----------- |
  131805. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  131806. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  131807. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  131808. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  131809. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  131810. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  131811. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  131812. *
  131813. * @param option String of the option name
  131814. * @param value The numerical option value
  131815. */
  131816. changeDisplayOptions(option: string, value: number): void;
  131817. /** Release associated resources */
  131818. dispose(): void;
  131819. }
  131820. }
  131821. declare module BABYLON {
  131822. /**
  131823. * Enum for Device Types
  131824. */
  131825. export enum DeviceType {
  131826. /** Generic */
  131827. Generic = 0,
  131828. /** Keyboard */
  131829. Keyboard = 1,
  131830. /** Mouse */
  131831. Mouse = 2,
  131832. /** Touch Pointers */
  131833. Touch = 3,
  131834. /** PS4 Dual Shock */
  131835. DualShock = 4,
  131836. /** Xbox */
  131837. Xbox = 5,
  131838. /** Switch Controller */
  131839. Switch = 6
  131840. }
  131841. /**
  131842. * Enum for All Pointers (Touch/Mouse)
  131843. */
  131844. export enum PointerInput {
  131845. /** Horizontal Axis */
  131846. Horizontal = 0,
  131847. /** Vertical Axis */
  131848. Vertical = 1,
  131849. /** Left Click or Touch */
  131850. LeftClick = 2,
  131851. /** Middle Click */
  131852. MiddleClick = 3,
  131853. /** Right Click */
  131854. RightClick = 4,
  131855. /** Browser Back */
  131856. BrowserBack = 5,
  131857. /** Browser Forward */
  131858. BrowserForward = 6
  131859. }
  131860. /**
  131861. * Enum for Dual Shock Gamepad
  131862. */
  131863. export enum DualShockInput {
  131864. /** Cross */
  131865. Cross = 0,
  131866. /** Circle */
  131867. Circle = 1,
  131868. /** Square */
  131869. Square = 2,
  131870. /** Triangle */
  131871. Triangle = 3,
  131872. /** L1 */
  131873. L1 = 4,
  131874. /** R1 */
  131875. R1 = 5,
  131876. /** L2 */
  131877. L2 = 6,
  131878. /** R2 */
  131879. R2 = 7,
  131880. /** Share */
  131881. Share = 8,
  131882. /** Options */
  131883. Options = 9,
  131884. /** L3 */
  131885. L3 = 10,
  131886. /** R3 */
  131887. R3 = 11,
  131888. /** DPadUp */
  131889. DPadUp = 12,
  131890. /** DPadDown */
  131891. DPadDown = 13,
  131892. /** DPadLeft */
  131893. DPadLeft = 14,
  131894. /** DRight */
  131895. DPadRight = 15,
  131896. /** Home */
  131897. Home = 16,
  131898. /** TouchPad */
  131899. TouchPad = 17,
  131900. /** LStickXAxis */
  131901. LStickXAxis = 18,
  131902. /** LStickYAxis */
  131903. LStickYAxis = 19,
  131904. /** RStickXAxis */
  131905. RStickXAxis = 20,
  131906. /** RStickYAxis */
  131907. RStickYAxis = 21
  131908. }
  131909. /**
  131910. * Enum for Xbox Gamepad
  131911. */
  131912. export enum XboxInput {
  131913. /** A */
  131914. A = 0,
  131915. /** B */
  131916. B = 1,
  131917. /** X */
  131918. X = 2,
  131919. /** Y */
  131920. Y = 3,
  131921. /** LB */
  131922. LB = 4,
  131923. /** RB */
  131924. RB = 5,
  131925. /** LT */
  131926. LT = 6,
  131927. /** RT */
  131928. RT = 7,
  131929. /** Back */
  131930. Back = 8,
  131931. /** Start */
  131932. Start = 9,
  131933. /** LS */
  131934. LS = 10,
  131935. /** RS */
  131936. RS = 11,
  131937. /** DPadUp */
  131938. DPadUp = 12,
  131939. /** DPadDown */
  131940. DPadDown = 13,
  131941. /** DPadLeft */
  131942. DPadLeft = 14,
  131943. /** DRight */
  131944. DPadRight = 15,
  131945. /** Home */
  131946. Home = 16,
  131947. /** LStickXAxis */
  131948. LStickXAxis = 17,
  131949. /** LStickYAxis */
  131950. LStickYAxis = 18,
  131951. /** RStickXAxis */
  131952. RStickXAxis = 19,
  131953. /** RStickYAxis */
  131954. RStickYAxis = 20
  131955. }
  131956. /**
  131957. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  131958. */
  131959. export enum SwitchInput {
  131960. /** B */
  131961. B = 0,
  131962. /** A */
  131963. A = 1,
  131964. /** Y */
  131965. Y = 2,
  131966. /** X */
  131967. X = 3,
  131968. /** L */
  131969. L = 4,
  131970. /** R */
  131971. R = 5,
  131972. /** ZL */
  131973. ZL = 6,
  131974. /** ZR */
  131975. ZR = 7,
  131976. /** Minus */
  131977. Minus = 8,
  131978. /** Plus */
  131979. Plus = 9,
  131980. /** LS */
  131981. LS = 10,
  131982. /** RS */
  131983. RS = 11,
  131984. /** DPadUp */
  131985. DPadUp = 12,
  131986. /** DPadDown */
  131987. DPadDown = 13,
  131988. /** DPadLeft */
  131989. DPadLeft = 14,
  131990. /** DRight */
  131991. DPadRight = 15,
  131992. /** Home */
  131993. Home = 16,
  131994. /** Capture */
  131995. Capture = 17,
  131996. /** LStickXAxis */
  131997. LStickXAxis = 18,
  131998. /** LStickYAxis */
  131999. LStickYAxis = 19,
  132000. /** RStickXAxis */
  132001. RStickXAxis = 20,
  132002. /** RStickYAxis */
  132003. RStickYAxis = 21
  132004. }
  132005. }
  132006. declare module BABYLON {
  132007. /**
  132008. * This class will take all inputs from Keyboard, Pointer, and
  132009. * any Gamepads and provide a polling system that all devices
  132010. * will use. This class assumes that there will only be one
  132011. * pointer device and one keyboard.
  132012. */
  132013. export class DeviceInputSystem implements IDisposable {
  132014. /**
  132015. * Callback to be triggered when a device is connected
  132016. */
  132017. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  132018. /**
  132019. * Callback to be triggered when a device is disconnected
  132020. */
  132021. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  132022. /**
  132023. * Callback to be triggered when event driven input is updated
  132024. */
  132025. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  132026. private _inputs;
  132027. private _gamepads;
  132028. private _keyboardActive;
  132029. private _pointerActive;
  132030. private _elementToAttachTo;
  132031. private _keyboardDownEvent;
  132032. private _keyboardUpEvent;
  132033. private _pointerMoveEvent;
  132034. private _pointerDownEvent;
  132035. private _pointerUpEvent;
  132036. private _gamepadConnectedEvent;
  132037. private _gamepadDisconnectedEvent;
  132038. private static _MAX_KEYCODES;
  132039. private static _MAX_POINTER_INPUTS;
  132040. private constructor();
  132041. /**
  132042. * Creates a new DeviceInputSystem instance
  132043. * @param engine Engine to pull input element from
  132044. * @returns The new instance
  132045. */
  132046. static Create(engine: Engine): DeviceInputSystem;
  132047. /**
  132048. * Checks for current device input value, given an id and input index
  132049. * @param deviceName Id of connected device
  132050. * @param inputIndex Index of device input
  132051. * @returns Current value of input
  132052. */
  132053. /**
  132054. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  132055. * @param deviceType Enum specifiying device type
  132056. * @param deviceSlot "Slot" or index that device is referenced in
  132057. * @param inputIndex Id of input to be checked
  132058. * @returns Current value of input
  132059. */
  132060. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  132061. /**
  132062. * Dispose of all the eventlisteners
  132063. */
  132064. dispose(): void;
  132065. /**
  132066. * Add device and inputs to device array
  132067. * @param deviceType Enum specifiying device type
  132068. * @param deviceSlot "Slot" or index that device is referenced in
  132069. * @param numberOfInputs Number of input entries to create for given device
  132070. */
  132071. private _registerDevice;
  132072. /**
  132073. * Given a specific device name, remove that device from the device map
  132074. * @param deviceType Enum specifiying device type
  132075. * @param deviceSlot "Slot" or index that device is referenced in
  132076. */
  132077. private _unregisterDevice;
  132078. /**
  132079. * Handle all actions that come from keyboard interaction
  132080. */
  132081. private _handleKeyActions;
  132082. /**
  132083. * Handle all actions that come from pointer interaction
  132084. */
  132085. private _handlePointerActions;
  132086. /**
  132087. * Handle all actions that come from gamepad interaction
  132088. */
  132089. private _handleGamepadActions;
  132090. /**
  132091. * Update all non-event based devices with each frame
  132092. * @param deviceType Enum specifiying device type
  132093. * @param deviceSlot "Slot" or index that device is referenced in
  132094. * @param inputIndex Id of input to be checked
  132095. */
  132096. private _updateDevice;
  132097. /**
  132098. * Gets DeviceType from the device name
  132099. * @param deviceName Name of Device from DeviceInputSystem
  132100. * @returns DeviceType enum value
  132101. */
  132102. private _getGamepadDeviceType;
  132103. }
  132104. }
  132105. declare module BABYLON {
  132106. /**
  132107. * Type to handle enforcement of inputs
  132108. */
  132109. 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;
  132110. }
  132111. declare module BABYLON {
  132112. /**
  132113. * Class that handles all input for a specific device
  132114. */
  132115. export class DeviceSource<T extends DeviceType> {
  132116. /** Type of device */
  132117. readonly deviceType: DeviceType;
  132118. /** "Slot" or index that device is referenced in */
  132119. readonly deviceSlot: number;
  132120. /**
  132121. * Observable to handle device input changes per device
  132122. */
  132123. readonly onInputChangedObservable: Observable<{
  132124. inputIndex: DeviceInput<T>;
  132125. previousState: Nullable<number>;
  132126. currentState: Nullable<number>;
  132127. }>;
  132128. private readonly _deviceInputSystem;
  132129. /**
  132130. * Default Constructor
  132131. * @param deviceInputSystem Reference to DeviceInputSystem
  132132. * @param deviceType Type of device
  132133. * @param deviceSlot "Slot" or index that device is referenced in
  132134. */
  132135. constructor(deviceInputSystem: DeviceInputSystem,
  132136. /** Type of device */
  132137. deviceType: DeviceType,
  132138. /** "Slot" or index that device is referenced in */
  132139. deviceSlot?: number);
  132140. /**
  132141. * Get input for specific input
  132142. * @param inputIndex index of specific input on device
  132143. * @returns Input value from DeviceInputSystem
  132144. */
  132145. getInput(inputIndex: DeviceInput<T>): number;
  132146. }
  132147. /**
  132148. * Class to keep track of devices
  132149. */
  132150. export class DeviceSourceManager implements IDisposable {
  132151. /**
  132152. * Observable to be triggered when before a device is connected
  132153. */
  132154. readonly onBeforeDeviceConnectedObservable: Observable<{
  132155. deviceType: DeviceType;
  132156. deviceSlot: number;
  132157. }>;
  132158. /**
  132159. * Observable to be triggered when before a device is disconnected
  132160. */
  132161. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  132162. deviceType: DeviceType;
  132163. deviceSlot: number;
  132164. }>;
  132165. /**
  132166. * Observable to be triggered when after a device is connected
  132167. */
  132168. readonly onAfterDeviceConnectedObservable: Observable<{
  132169. deviceType: DeviceType;
  132170. deviceSlot: number;
  132171. }>;
  132172. /**
  132173. * Observable to be triggered when after a device is disconnected
  132174. */
  132175. readonly onAfterDeviceDisconnectedObservable: Observable<{
  132176. deviceType: DeviceType;
  132177. deviceSlot: number;
  132178. }>;
  132179. private readonly _devices;
  132180. private readonly _firstDevice;
  132181. private readonly _deviceInputSystem;
  132182. /**
  132183. * Default Constructor
  132184. * @param engine engine to pull input element from
  132185. */
  132186. constructor(engine: Engine);
  132187. /**
  132188. * Gets a DeviceSource, given a type and slot
  132189. * @param deviceType Enum specifying device type
  132190. * @param deviceSlot "Slot" or index that device is referenced in
  132191. * @returns DeviceSource object
  132192. */
  132193. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  132194. /**
  132195. * Gets an array of DeviceSource objects for a given device type
  132196. * @param deviceType Enum specifying device type
  132197. * @returns Array of DeviceSource objects
  132198. */
  132199. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  132200. /**
  132201. * Dispose of DeviceInputSystem and other parts
  132202. */
  132203. dispose(): void;
  132204. /**
  132205. * Function to add device name to device list
  132206. * @param deviceType Enum specifying device type
  132207. * @param deviceSlot "Slot" or index that device is referenced in
  132208. */
  132209. private _addDevice;
  132210. /**
  132211. * Function to remove device name to device list
  132212. * @param deviceType Enum specifying device type
  132213. * @param deviceSlot "Slot" or index that device is referenced in
  132214. */
  132215. private _removeDevice;
  132216. /**
  132217. * Updates array storing first connected device of each type
  132218. * @param type Type of Device
  132219. */
  132220. private _updateFirstDevices;
  132221. }
  132222. }
  132223. declare module BABYLON {
  132224. /**
  132225. * Options to create the null engine
  132226. */
  132227. export class NullEngineOptions {
  132228. /**
  132229. * Render width (Default: 512)
  132230. */
  132231. renderWidth: number;
  132232. /**
  132233. * Render height (Default: 256)
  132234. */
  132235. renderHeight: number;
  132236. /**
  132237. * Texture size (Default: 512)
  132238. */
  132239. textureSize: number;
  132240. /**
  132241. * If delta time between frames should be constant
  132242. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132243. */
  132244. deterministicLockstep: boolean;
  132245. /**
  132246. * Maximum about of steps between frames (Default: 4)
  132247. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132248. */
  132249. lockstepMaxSteps: number;
  132250. /**
  132251. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  132252. */
  132253. useHighPrecisionMatrix?: boolean;
  132254. }
  132255. /**
  132256. * The null engine class provides support for headless version of babylon.js.
  132257. * This can be used in server side scenario or for testing purposes
  132258. */
  132259. export class NullEngine extends Engine {
  132260. private _options;
  132261. /**
  132262. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  132263. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132264. * @returns true if engine is in deterministic lock step mode
  132265. */
  132266. isDeterministicLockStep(): boolean;
  132267. /**
  132268. * Gets the max steps when engine is running in deterministic lock step
  132269. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132270. * @returns the max steps
  132271. */
  132272. getLockstepMaxSteps(): number;
  132273. /**
  132274. * Gets the current hardware scaling level.
  132275. * By default the hardware scaling level is computed from the window device ratio.
  132276. * 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.
  132277. * @returns a number indicating the current hardware scaling level
  132278. */
  132279. getHardwareScalingLevel(): number;
  132280. constructor(options?: NullEngineOptions);
  132281. /**
  132282. * Creates a vertex buffer
  132283. * @param vertices the data for the vertex buffer
  132284. * @returns the new WebGL static buffer
  132285. */
  132286. createVertexBuffer(vertices: FloatArray): DataBuffer;
  132287. /**
  132288. * Creates a new index buffer
  132289. * @param indices defines the content of the index buffer
  132290. * @param updatable defines if the index buffer must be updatable
  132291. * @returns a new webGL buffer
  132292. */
  132293. createIndexBuffer(indices: IndicesArray): DataBuffer;
  132294. /**
  132295. * Clear the current render buffer or the current render target (if any is set up)
  132296. * @param color defines the color to use
  132297. * @param backBuffer defines if the back buffer must be cleared
  132298. * @param depth defines if the depth buffer must be cleared
  132299. * @param stencil defines if the stencil buffer must be cleared
  132300. */
  132301. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  132302. /**
  132303. * Gets the current render width
  132304. * @param useScreen defines if screen size must be used (or the current render target if any)
  132305. * @returns a number defining the current render width
  132306. */
  132307. getRenderWidth(useScreen?: boolean): number;
  132308. /**
  132309. * Gets the current render height
  132310. * @param useScreen defines if screen size must be used (or the current render target if any)
  132311. * @returns a number defining the current render height
  132312. */
  132313. getRenderHeight(useScreen?: boolean): number;
  132314. /**
  132315. * Set the WebGL's viewport
  132316. * @param viewport defines the viewport element to be used
  132317. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  132318. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  132319. */
  132320. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  132321. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  132322. /**
  132323. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  132324. * @param pipelineContext defines the pipeline context to use
  132325. * @param uniformsNames defines the list of uniform names
  132326. * @returns an array of webGL uniform locations
  132327. */
  132328. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  132329. /**
  132330. * Gets the lsit of active attributes for a given webGL program
  132331. * @param pipelineContext defines the pipeline context to use
  132332. * @param attributesNames defines the list of attribute names to get
  132333. * @returns an array of indices indicating the offset of each attribute
  132334. */
  132335. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  132336. /**
  132337. * Binds an effect to the webGL context
  132338. * @param effect defines the effect to bind
  132339. */
  132340. bindSamplers(effect: Effect): void;
  132341. /**
  132342. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  132343. * @param effect defines the effect to activate
  132344. */
  132345. enableEffect(effect: Effect): void;
  132346. /**
  132347. * Set various states to the webGL context
  132348. * @param culling defines backface culling state
  132349. * @param zOffset defines the value to apply to zOffset (0 by default)
  132350. * @param force defines if states must be applied even if cache is up to date
  132351. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  132352. */
  132353. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  132354. /**
  132355. * Set the value of an uniform to an array of int32
  132356. * @param uniform defines the webGL uniform location where to store the value
  132357. * @param array defines the array of int32 to store
  132358. * @returns true if value was set
  132359. */
  132360. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132361. /**
  132362. * Set the value of an uniform to an array of int32 (stored as vec2)
  132363. * @param uniform defines the webGL uniform location where to store the value
  132364. * @param array defines the array of int32 to store
  132365. * @returns true if value was set
  132366. */
  132367. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132368. /**
  132369. * Set the value of an uniform to an array of int32 (stored as vec3)
  132370. * @param uniform defines the webGL uniform location where to store the value
  132371. * @param array defines the array of int32 to store
  132372. * @returns true if value was set
  132373. */
  132374. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132375. /**
  132376. * Set the value of an uniform to an array of int32 (stored as vec4)
  132377. * @param uniform defines the webGL uniform location where to store the value
  132378. * @param array defines the array of int32 to store
  132379. * @returns true if value was set
  132380. */
  132381. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132382. /**
  132383. * Set the value of an uniform to an array of float32
  132384. * @param uniform defines the webGL uniform location where to store the value
  132385. * @param array defines the array of float32 to store
  132386. * @returns true if value was set
  132387. */
  132388. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132389. /**
  132390. * Set the value of an uniform to an array of float32 (stored as vec2)
  132391. * @param uniform defines the webGL uniform location where to store the value
  132392. * @param array defines the array of float32 to store
  132393. * @returns true if value was set
  132394. */
  132395. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132396. /**
  132397. * Set the value of an uniform to an array of float32 (stored as vec3)
  132398. * @param uniform defines the webGL uniform location where to store the value
  132399. * @param array defines the array of float32 to store
  132400. * @returns true if value was set
  132401. */
  132402. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132403. /**
  132404. * Set the value of an uniform to an array of float32 (stored as vec4)
  132405. * @param uniform defines the webGL uniform location where to store the value
  132406. * @param array defines the array of float32 to store
  132407. * @returns true if value was set
  132408. */
  132409. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132410. /**
  132411. * Set the value of an uniform to an array of number
  132412. * @param uniform defines the webGL uniform location where to store the value
  132413. * @param array defines the array of number to store
  132414. * @returns true if value was set
  132415. */
  132416. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  132417. /**
  132418. * Set the value of an uniform to an array of number (stored as vec2)
  132419. * @param uniform defines the webGL uniform location where to store the value
  132420. * @param array defines the array of number to store
  132421. * @returns true if value was set
  132422. */
  132423. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  132424. /**
  132425. * Set the value of an uniform to an array of number (stored as vec3)
  132426. * @param uniform defines the webGL uniform location where to store the value
  132427. * @param array defines the array of number to store
  132428. * @returns true if value was set
  132429. */
  132430. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  132431. /**
  132432. * Set the value of an uniform to an array of number (stored as vec4)
  132433. * @param uniform defines the webGL uniform location where to store the value
  132434. * @param array defines the array of number to store
  132435. * @returns true if value was set
  132436. */
  132437. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  132438. /**
  132439. * Set the value of an uniform to an array of float32 (stored as matrices)
  132440. * @param uniform defines the webGL uniform location where to store the value
  132441. * @param matrices defines the array of float32 to store
  132442. * @returns true if value was set
  132443. */
  132444. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  132445. /**
  132446. * Set the value of an uniform to a matrix (3x3)
  132447. * @param uniform defines the webGL uniform location where to store the value
  132448. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  132449. * @returns true if value was set
  132450. */
  132451. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  132452. /**
  132453. * Set the value of an uniform to a matrix (2x2)
  132454. * @param uniform defines the webGL uniform location where to store the value
  132455. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  132456. * @returns true if value was set
  132457. */
  132458. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  132459. /**
  132460. * Set the value of an uniform to a number (float)
  132461. * @param uniform defines the webGL uniform location where to store the value
  132462. * @param value defines the float number to store
  132463. * @returns true if value was set
  132464. */
  132465. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  132466. /**
  132467. * Set the value of an uniform to a vec2
  132468. * @param uniform defines the webGL uniform location where to store the value
  132469. * @param x defines the 1st component of the value
  132470. * @param y defines the 2nd component of the value
  132471. * @returns true if value was set
  132472. */
  132473. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  132474. /**
  132475. * Set the value of an uniform to a vec3
  132476. * @param uniform defines the webGL uniform location where to store the value
  132477. * @param x defines the 1st component of the value
  132478. * @param y defines the 2nd component of the value
  132479. * @param z defines the 3rd component of the value
  132480. * @returns true if value was set
  132481. */
  132482. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  132483. /**
  132484. * Set the value of an uniform to a boolean
  132485. * @param uniform defines the webGL uniform location where to store the value
  132486. * @param bool defines the boolean to store
  132487. * @returns true if value was set
  132488. */
  132489. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  132490. /**
  132491. * Set the value of an uniform to a vec4
  132492. * @param uniform defines the webGL uniform location where to store the value
  132493. * @param x defines the 1st component of the value
  132494. * @param y defines the 2nd component of the value
  132495. * @param z defines the 3rd component of the value
  132496. * @param w defines the 4th component of the value
  132497. * @returns true if value was set
  132498. */
  132499. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  132500. /**
  132501. * Sets the current alpha mode
  132502. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  132503. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  132504. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132505. */
  132506. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  132507. /**
  132508. * Bind webGl buffers directly to the webGL context
  132509. * @param vertexBuffers defines the vertex buffer to bind
  132510. * @param indexBuffer defines the index buffer to bind
  132511. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  132512. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  132513. * @param effect defines the effect associated with the vertex buffer
  132514. */
  132515. bindBuffers(vertexBuffers: {
  132516. [key: string]: VertexBuffer;
  132517. }, indexBuffer: DataBuffer, effect: Effect): void;
  132518. /**
  132519. * Force the entire cache to be cleared
  132520. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  132521. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  132522. */
  132523. wipeCaches(bruteForce?: boolean): void;
  132524. /**
  132525. * Send a draw order
  132526. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  132527. * @param indexStart defines the starting index
  132528. * @param indexCount defines the number of index to draw
  132529. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132530. */
  132531. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  132532. /**
  132533. * Draw a list of indexed primitives
  132534. * @param fillMode defines the primitive to use
  132535. * @param indexStart defines the starting index
  132536. * @param indexCount defines the number of index to draw
  132537. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132538. */
  132539. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  132540. /**
  132541. * Draw a list of unindexed primitives
  132542. * @param fillMode defines the primitive to use
  132543. * @param verticesStart defines the index of first vertex to draw
  132544. * @param verticesCount defines the count of vertices to draw
  132545. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132546. */
  132547. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  132548. /** @hidden */
  132549. _createTexture(): WebGLTexture;
  132550. /** @hidden */
  132551. _releaseTexture(texture: InternalTexture): void;
  132552. /**
  132553. * Usually called from Texture.ts.
  132554. * Passed information to create a WebGLTexture
  132555. * @param urlArg defines a value which contains one of the following:
  132556. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  132557. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  132558. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  132559. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  132560. * @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)
  132561. * @param scene needed for loading to the correct scene
  132562. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  132563. * @param onLoad optional callback to be called upon successful completion
  132564. * @param onError optional callback to be called upon failure
  132565. * @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
  132566. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  132567. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  132568. * @param forcedExtension defines the extension to use to pick the right loader
  132569. * @param mimeType defines an optional mime type
  132570. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132571. */
  132572. 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;
  132573. /**
  132574. * Creates a new render target texture
  132575. * @param size defines the size of the texture
  132576. * @param options defines the options used to create the texture
  132577. * @returns a new render target texture stored in an InternalTexture
  132578. */
  132579. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  132580. /**
  132581. * Update the sampling mode of a given texture
  132582. * @param samplingMode defines the required sampling mode
  132583. * @param texture defines the texture to update
  132584. */
  132585. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132586. /**
  132587. * Binds the frame buffer to the specified texture.
  132588. * @param texture The texture to render to or null for the default canvas
  132589. * @param faceIndex The face of the texture to render to in case of cube texture
  132590. * @param requiredWidth The width of the target to render to
  132591. * @param requiredHeight The height of the target to render to
  132592. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  132593. * @param lodLevel defines le lod level to bind to the frame buffer
  132594. */
  132595. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132596. /**
  132597. * Unbind the current render target texture from the webGL context
  132598. * @param texture defines the render target texture to unbind
  132599. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  132600. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  132601. */
  132602. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132603. /**
  132604. * Creates a dynamic vertex buffer
  132605. * @param vertices the data for the dynamic vertex buffer
  132606. * @returns the new WebGL dynamic buffer
  132607. */
  132608. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  132609. /**
  132610. * Update the content of a dynamic texture
  132611. * @param texture defines the texture to update
  132612. * @param canvas defines the canvas containing the source
  132613. * @param invertY defines if data must be stored with Y axis inverted
  132614. * @param premulAlpha defines if alpha is stored as premultiplied
  132615. * @param format defines the format of the data
  132616. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  132617. */
  132618. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  132619. /**
  132620. * Gets a boolean indicating if all created effects are ready
  132621. * @returns true if all effects are ready
  132622. */
  132623. areAllEffectsReady(): boolean;
  132624. /**
  132625. * @hidden
  132626. * Get the current error code of the webGL context
  132627. * @returns the error code
  132628. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  132629. */
  132630. getError(): number;
  132631. /** @hidden */
  132632. _getUnpackAlignement(): number;
  132633. /** @hidden */
  132634. _unpackFlipY(value: boolean): void;
  132635. /**
  132636. * Update a dynamic index buffer
  132637. * @param indexBuffer defines the target index buffer
  132638. * @param indices defines the data to update
  132639. * @param offset defines the offset in the target index buffer where update should start
  132640. */
  132641. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  132642. /**
  132643. * Updates a dynamic vertex buffer.
  132644. * @param vertexBuffer the vertex buffer to update
  132645. * @param vertices the data used to update the vertex buffer
  132646. * @param byteOffset the byte offset of the data (optional)
  132647. * @param byteLength the byte length of the data (optional)
  132648. */
  132649. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  132650. /** @hidden */
  132651. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  132652. /** @hidden */
  132653. _bindTexture(channel: number, texture: InternalTexture): void;
  132654. protected _deleteBuffer(buffer: WebGLBuffer): void;
  132655. /**
  132656. * 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
  132657. */
  132658. releaseEffects(): void;
  132659. displayLoadingUI(): void;
  132660. hideLoadingUI(): void;
  132661. /** @hidden */
  132662. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132663. /** @hidden */
  132664. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132665. /** @hidden */
  132666. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132667. /** @hidden */
  132668. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132669. }
  132670. }
  132671. declare module BABYLON {
  132672. /**
  132673. * @hidden
  132674. **/
  132675. export class _TimeToken {
  132676. _startTimeQuery: Nullable<WebGLQuery>;
  132677. _endTimeQuery: Nullable<WebGLQuery>;
  132678. _timeElapsedQuery: Nullable<WebGLQuery>;
  132679. _timeElapsedQueryEnded: boolean;
  132680. }
  132681. }
  132682. declare module BABYLON {
  132683. /** @hidden */
  132684. export class _OcclusionDataStorage {
  132685. /** @hidden */
  132686. occlusionInternalRetryCounter: number;
  132687. /** @hidden */
  132688. isOcclusionQueryInProgress: boolean;
  132689. /** @hidden */
  132690. isOccluded: boolean;
  132691. /** @hidden */
  132692. occlusionRetryCount: number;
  132693. /** @hidden */
  132694. occlusionType: number;
  132695. /** @hidden */
  132696. occlusionQueryAlgorithmType: number;
  132697. }
  132698. interface Engine {
  132699. /**
  132700. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  132701. * @return the new query
  132702. */
  132703. createQuery(): WebGLQuery;
  132704. /**
  132705. * Delete and release a webGL query
  132706. * @param query defines the query to delete
  132707. * @return the current engine
  132708. */
  132709. deleteQuery(query: WebGLQuery): Engine;
  132710. /**
  132711. * Check if a given query has resolved and got its value
  132712. * @param query defines the query to check
  132713. * @returns true if the query got its value
  132714. */
  132715. isQueryResultAvailable(query: WebGLQuery): boolean;
  132716. /**
  132717. * Gets the value of a given query
  132718. * @param query defines the query to check
  132719. * @returns the value of the query
  132720. */
  132721. getQueryResult(query: WebGLQuery): number;
  132722. /**
  132723. * Initiates an occlusion query
  132724. * @param algorithmType defines the algorithm to use
  132725. * @param query defines the query to use
  132726. * @returns the current engine
  132727. * @see https://doc.babylonjs.com/features/occlusionquery
  132728. */
  132729. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  132730. /**
  132731. * Ends an occlusion query
  132732. * @see https://doc.babylonjs.com/features/occlusionquery
  132733. * @param algorithmType defines the algorithm to use
  132734. * @returns the current engine
  132735. */
  132736. endOcclusionQuery(algorithmType: number): Engine;
  132737. /**
  132738. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  132739. * Please note that only one query can be issued at a time
  132740. * @returns a time token used to track the time span
  132741. */
  132742. startTimeQuery(): Nullable<_TimeToken>;
  132743. /**
  132744. * Ends a time query
  132745. * @param token defines the token used to measure the time span
  132746. * @returns the time spent (in ns)
  132747. */
  132748. endTimeQuery(token: _TimeToken): int;
  132749. /** @hidden */
  132750. _currentNonTimestampToken: Nullable<_TimeToken>;
  132751. /** @hidden */
  132752. _createTimeQuery(): WebGLQuery;
  132753. /** @hidden */
  132754. _deleteTimeQuery(query: WebGLQuery): void;
  132755. /** @hidden */
  132756. _getGlAlgorithmType(algorithmType: number): number;
  132757. /** @hidden */
  132758. _getTimeQueryResult(query: WebGLQuery): any;
  132759. /** @hidden */
  132760. _getTimeQueryAvailability(query: WebGLQuery): any;
  132761. }
  132762. interface AbstractMesh {
  132763. /**
  132764. * Backing filed
  132765. * @hidden
  132766. */
  132767. __occlusionDataStorage: _OcclusionDataStorage;
  132768. /**
  132769. * Access property
  132770. * @hidden
  132771. */
  132772. _occlusionDataStorage: _OcclusionDataStorage;
  132773. /**
  132774. * 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.
  132775. * The default value is -1 which means don't break the query and wait till the result
  132776. * @see https://doc.babylonjs.com/features/occlusionquery
  132777. */
  132778. occlusionRetryCount: number;
  132779. /**
  132780. * 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:
  132781. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  132782. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  132783. * * 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.
  132784. * @see https://doc.babylonjs.com/features/occlusionquery
  132785. */
  132786. occlusionType: number;
  132787. /**
  132788. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  132789. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  132790. * * 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.
  132791. * @see https://doc.babylonjs.com/features/occlusionquery
  132792. */
  132793. occlusionQueryAlgorithmType: number;
  132794. /**
  132795. * 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
  132796. * @see https://doc.babylonjs.com/features/occlusionquery
  132797. */
  132798. isOccluded: boolean;
  132799. /**
  132800. * Flag to check the progress status of the query
  132801. * @see https://doc.babylonjs.com/features/occlusionquery
  132802. */
  132803. isOcclusionQueryInProgress: boolean;
  132804. }
  132805. }
  132806. declare module BABYLON {
  132807. /** @hidden */
  132808. export var _forceTransformFeedbackToBundle: boolean;
  132809. interface Engine {
  132810. /**
  132811. * Creates a webGL transform feedback object
  132812. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  132813. * @returns the webGL transform feedback object
  132814. */
  132815. createTransformFeedback(): WebGLTransformFeedback;
  132816. /**
  132817. * Delete a webGL transform feedback object
  132818. * @param value defines the webGL transform feedback object to delete
  132819. */
  132820. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  132821. /**
  132822. * Bind a webGL transform feedback object to the webgl context
  132823. * @param value defines the webGL transform feedback object to bind
  132824. */
  132825. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  132826. /**
  132827. * Begins a transform feedback operation
  132828. * @param usePoints defines if points or triangles must be used
  132829. */
  132830. beginTransformFeedback(usePoints: boolean): void;
  132831. /**
  132832. * Ends a transform feedback operation
  132833. */
  132834. endTransformFeedback(): void;
  132835. /**
  132836. * Specify the varyings to use with transform feedback
  132837. * @param program defines the associated webGL program
  132838. * @param value defines the list of strings representing the varying names
  132839. */
  132840. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  132841. /**
  132842. * Bind a webGL buffer for a transform feedback operation
  132843. * @param value defines the webGL buffer to bind
  132844. */
  132845. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  132846. }
  132847. }
  132848. declare module BABYLON {
  132849. /**
  132850. * Class used to define an additional view for the engine
  132851. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132852. */
  132853. export class EngineView {
  132854. /** Defines the canvas where to render the view */
  132855. target: HTMLCanvasElement;
  132856. /** Defines an optional camera used to render the view (will use active camera else) */
  132857. camera?: Camera;
  132858. }
  132859. interface Engine {
  132860. /**
  132861. * Gets or sets the HTML element to use for attaching events
  132862. */
  132863. inputElement: Nullable<HTMLElement>;
  132864. /**
  132865. * Gets the current engine view
  132866. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132867. */
  132868. activeView: Nullable<EngineView>;
  132869. /** Gets or sets the list of views */
  132870. views: EngineView[];
  132871. /**
  132872. * Register a new child canvas
  132873. * @param canvas defines the canvas to register
  132874. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  132875. * @returns the associated view
  132876. */
  132877. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  132878. /**
  132879. * Remove a registered child canvas
  132880. * @param canvas defines the canvas to remove
  132881. * @returns the current engine
  132882. */
  132883. unRegisterView(canvas: HTMLCanvasElement): Engine;
  132884. }
  132885. }
  132886. declare module BABYLON {
  132887. interface Engine {
  132888. /** @hidden */
  132889. _excludedCompressedTextures: string[];
  132890. /** @hidden */
  132891. _textureFormatInUse: string;
  132892. /**
  132893. * Gets the list of texture formats supported
  132894. */
  132895. readonly texturesSupported: Array<string>;
  132896. /**
  132897. * Gets the texture format in use
  132898. */
  132899. readonly textureFormatInUse: Nullable<string>;
  132900. /**
  132901. * Set the compressed texture extensions or file names to skip.
  132902. *
  132903. * @param skippedFiles defines the list of those texture files you want to skip
  132904. * Example: [".dds", ".env", "myfile.png"]
  132905. */
  132906. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  132907. /**
  132908. * Set the compressed texture format to use, based on the formats you have, and the formats
  132909. * supported by the hardware / browser.
  132910. *
  132911. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  132912. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  132913. * to API arguments needed to compressed textures. This puts the burden on the container
  132914. * generator to house the arcane code for determining these for current & future formats.
  132915. *
  132916. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  132917. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  132918. *
  132919. * Note: The result of this call is not taken into account when a texture is base64.
  132920. *
  132921. * @param formatsAvailable defines the list of those format families you have created
  132922. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  132923. *
  132924. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  132925. * @returns The extension selected.
  132926. */
  132927. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  132928. }
  132929. }
  132930. declare module BABYLON {
  132931. /**
  132932. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  132933. */
  132934. export interface CubeMapInfo {
  132935. /**
  132936. * The pixel array for the front face.
  132937. * This is stored in format, left to right, up to down format.
  132938. */
  132939. front: Nullable<ArrayBufferView>;
  132940. /**
  132941. * The pixel array for the back face.
  132942. * This is stored in format, left to right, up to down format.
  132943. */
  132944. back: Nullable<ArrayBufferView>;
  132945. /**
  132946. * The pixel array for the left face.
  132947. * This is stored in format, left to right, up to down format.
  132948. */
  132949. left: Nullable<ArrayBufferView>;
  132950. /**
  132951. * The pixel array for the right face.
  132952. * This is stored in format, left to right, up to down format.
  132953. */
  132954. right: Nullable<ArrayBufferView>;
  132955. /**
  132956. * The pixel array for the up face.
  132957. * This is stored in format, left to right, up to down format.
  132958. */
  132959. up: Nullable<ArrayBufferView>;
  132960. /**
  132961. * The pixel array for the down face.
  132962. * This is stored in format, left to right, up to down format.
  132963. */
  132964. down: Nullable<ArrayBufferView>;
  132965. /**
  132966. * The size of the cubemap stored.
  132967. *
  132968. * Each faces will be size * size pixels.
  132969. */
  132970. size: number;
  132971. /**
  132972. * The format of the texture.
  132973. *
  132974. * RGBA, RGB.
  132975. */
  132976. format: number;
  132977. /**
  132978. * The type of the texture data.
  132979. *
  132980. * UNSIGNED_INT, FLOAT.
  132981. */
  132982. type: number;
  132983. /**
  132984. * Specifies whether the texture is in gamma space.
  132985. */
  132986. gammaSpace: boolean;
  132987. }
  132988. /**
  132989. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  132990. */
  132991. export class PanoramaToCubeMapTools {
  132992. private static FACE_LEFT;
  132993. private static FACE_RIGHT;
  132994. private static FACE_FRONT;
  132995. private static FACE_BACK;
  132996. private static FACE_DOWN;
  132997. private static FACE_UP;
  132998. /**
  132999. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  133000. *
  133001. * @param float32Array The source data.
  133002. * @param inputWidth The width of the input panorama.
  133003. * @param inputHeight The height of the input panorama.
  133004. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  133005. * @return The cubemap data
  133006. */
  133007. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  133008. private static CreateCubemapTexture;
  133009. private static CalcProjectionSpherical;
  133010. }
  133011. }
  133012. declare module BABYLON {
  133013. /**
  133014. * Helper class dealing with the extraction of spherical polynomial dataArray
  133015. * from a cube map.
  133016. */
  133017. export class CubeMapToSphericalPolynomialTools {
  133018. private static FileFaces;
  133019. /**
  133020. * Converts a texture to the according Spherical Polynomial data.
  133021. * This extracts the first 3 orders only as they are the only one used in the lighting.
  133022. *
  133023. * @param texture The texture to extract the information from.
  133024. * @return The Spherical Polynomial data.
  133025. */
  133026. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  133027. /**
  133028. * Converts a cubemap to the according Spherical Polynomial data.
  133029. * This extracts the first 3 orders only as they are the only one used in the lighting.
  133030. *
  133031. * @param cubeInfo The Cube map to extract the information from.
  133032. * @return The Spherical Polynomial data.
  133033. */
  133034. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  133035. }
  133036. }
  133037. declare module BABYLON {
  133038. interface BaseTexture {
  133039. /**
  133040. * Get the polynomial representation of the texture data.
  133041. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  133042. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  133043. */
  133044. sphericalPolynomial: Nullable<SphericalPolynomial>;
  133045. }
  133046. }
  133047. declare module BABYLON {
  133048. /** @hidden */
  133049. export var rgbdEncodePixelShader: {
  133050. name: string;
  133051. shader: string;
  133052. };
  133053. }
  133054. declare module BABYLON {
  133055. /** @hidden */
  133056. export var rgbdDecodePixelShader: {
  133057. name: string;
  133058. shader: string;
  133059. };
  133060. }
  133061. declare module BABYLON {
  133062. /**
  133063. * Raw texture data and descriptor sufficient for WebGL texture upload
  133064. */
  133065. export interface EnvironmentTextureInfo {
  133066. /**
  133067. * Version of the environment map
  133068. */
  133069. version: number;
  133070. /**
  133071. * Width of image
  133072. */
  133073. width: number;
  133074. /**
  133075. * Irradiance information stored in the file.
  133076. */
  133077. irradiance: any;
  133078. /**
  133079. * Specular information stored in the file.
  133080. */
  133081. specular: any;
  133082. }
  133083. /**
  133084. * Defines One Image in the file. It requires only the position in the file
  133085. * as well as the length.
  133086. */
  133087. interface BufferImageData {
  133088. /**
  133089. * Length of the image data.
  133090. */
  133091. length: number;
  133092. /**
  133093. * Position of the data from the null terminator delimiting the end of the JSON.
  133094. */
  133095. position: number;
  133096. }
  133097. /**
  133098. * Defines the specular data enclosed in the file.
  133099. * This corresponds to the version 1 of the data.
  133100. */
  133101. export interface EnvironmentTextureSpecularInfoV1 {
  133102. /**
  133103. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  133104. */
  133105. specularDataPosition?: number;
  133106. /**
  133107. * This contains all the images data needed to reconstruct the cubemap.
  133108. */
  133109. mipmaps: Array<BufferImageData>;
  133110. /**
  133111. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  133112. */
  133113. lodGenerationScale: number;
  133114. }
  133115. /**
  133116. * Sets of helpers addressing the serialization and deserialization of environment texture
  133117. * stored in a BabylonJS env file.
  133118. * Those files are usually stored as .env files.
  133119. */
  133120. export class EnvironmentTextureTools {
  133121. /**
  133122. * Magic number identifying the env file.
  133123. */
  133124. private static _MagicBytes;
  133125. /**
  133126. * Gets the environment info from an env file.
  133127. * @param data The array buffer containing the .env bytes.
  133128. * @returns the environment file info (the json header) if successfully parsed.
  133129. */
  133130. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  133131. /**
  133132. * Creates an environment texture from a loaded cube texture.
  133133. * @param texture defines the cube texture to convert in env file
  133134. * @return a promise containing the environment data if succesfull.
  133135. */
  133136. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  133137. /**
  133138. * Creates a JSON representation of the spherical data.
  133139. * @param texture defines the texture containing the polynomials
  133140. * @return the JSON representation of the spherical info
  133141. */
  133142. private static _CreateEnvTextureIrradiance;
  133143. /**
  133144. * Creates the ArrayBufferViews used for initializing environment texture image data.
  133145. * @param data the image data
  133146. * @param info parameters that determine what views will be created for accessing the underlying buffer
  133147. * @return the views described by info providing access to the underlying buffer
  133148. */
  133149. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  133150. /**
  133151. * Uploads the texture info contained in the env file to the GPU.
  133152. * @param texture defines the internal texture to upload to
  133153. * @param data defines the data to load
  133154. * @param info defines the texture info retrieved through the GetEnvInfo method
  133155. * @returns a promise
  133156. */
  133157. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  133158. private static _OnImageReadyAsync;
  133159. /**
  133160. * Uploads the levels of image data to the GPU.
  133161. * @param texture defines the internal texture to upload to
  133162. * @param imageData defines the array buffer views of image data [mipmap][face]
  133163. * @returns a promise
  133164. */
  133165. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  133166. /**
  133167. * Uploads spherical polynomials information to the texture.
  133168. * @param texture defines the texture we are trying to upload the information to
  133169. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  133170. */
  133171. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  133172. /** @hidden */
  133173. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  133174. }
  133175. }
  133176. declare module BABYLON {
  133177. /**
  133178. * Class used to inline functions in shader code
  133179. */
  133180. export class ShaderCodeInliner {
  133181. private static readonly _RegexpFindFunctionNameAndType;
  133182. private _sourceCode;
  133183. private _functionDescr;
  133184. private _numMaxIterations;
  133185. /** Gets or sets the token used to mark the functions to inline */
  133186. inlineToken: string;
  133187. /** Gets or sets the debug mode */
  133188. debug: boolean;
  133189. /** Gets the code after the inlining process */
  133190. get code(): string;
  133191. /**
  133192. * Initializes the inliner
  133193. * @param sourceCode shader code source to inline
  133194. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  133195. */
  133196. constructor(sourceCode: string, numMaxIterations?: number);
  133197. /**
  133198. * Start the processing of the shader code
  133199. */
  133200. processCode(): void;
  133201. private _collectFunctions;
  133202. private _processInlining;
  133203. private _extractBetweenMarkers;
  133204. private _skipWhitespaces;
  133205. private _removeComments;
  133206. private _replaceFunctionCallsByCode;
  133207. private _findBackward;
  133208. private _escapeRegExp;
  133209. private _replaceNames;
  133210. }
  133211. }
  133212. declare module BABYLON {
  133213. /**
  133214. * Container for accessors for natively-stored mesh data buffers.
  133215. */
  133216. class NativeDataBuffer extends DataBuffer {
  133217. /**
  133218. * Accessor value used to identify/retrieve a natively-stored index buffer.
  133219. */
  133220. nativeIndexBuffer?: any;
  133221. /**
  133222. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  133223. */
  133224. nativeVertexBuffer?: any;
  133225. }
  133226. /** @hidden */
  133227. class NativeTexture extends InternalTexture {
  133228. getInternalTexture(): InternalTexture;
  133229. getViewCount(): number;
  133230. }
  133231. /** @hidden */
  133232. export class NativeEngine extends Engine {
  133233. private readonly _native;
  133234. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  133235. private readonly INVALID_HANDLE;
  133236. private _boundBuffersVertexArray;
  133237. private _currentDepthTest;
  133238. getHardwareScalingLevel(): number;
  133239. constructor();
  133240. dispose(): void;
  133241. /**
  133242. * Can be used to override the current requestAnimationFrame requester.
  133243. * @hidden
  133244. */
  133245. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  133246. /**
  133247. * Override default engine behavior.
  133248. * @param color
  133249. * @param backBuffer
  133250. * @param depth
  133251. * @param stencil
  133252. */
  133253. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  133254. /**
  133255. * Gets host document
  133256. * @returns the host document object
  133257. */
  133258. getHostDocument(): Nullable<Document>;
  133259. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  133260. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  133261. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  133262. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  133263. [key: string]: VertexBuffer;
  133264. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  133265. bindBuffers(vertexBuffers: {
  133266. [key: string]: VertexBuffer;
  133267. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  133268. recordVertexArrayObject(vertexBuffers: {
  133269. [key: string]: VertexBuffer;
  133270. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  133271. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  133272. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  133273. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  133274. /**
  133275. * Draw a list of indexed primitives
  133276. * @param fillMode defines the primitive to use
  133277. * @param indexStart defines the starting index
  133278. * @param indexCount defines the number of index to draw
  133279. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  133280. */
  133281. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  133282. /**
  133283. * Draw a list of unindexed primitives
  133284. * @param fillMode defines the primitive to use
  133285. * @param verticesStart defines the index of first vertex to draw
  133286. * @param verticesCount defines the count of vertices to draw
  133287. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  133288. */
  133289. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  133290. createPipelineContext(): IPipelineContext;
  133291. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  133292. /** @hidden */
  133293. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  133294. /** @hidden */
  133295. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  133296. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  133297. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  133298. protected _setProgram(program: WebGLProgram): void;
  133299. _releaseEffect(effect: Effect): void;
  133300. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  133301. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  133302. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  133303. bindSamplers(effect: Effect): void;
  133304. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  133305. getRenderWidth(useScreen?: boolean): number;
  133306. getRenderHeight(useScreen?: boolean): number;
  133307. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  133308. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  133309. /**
  133310. * Set the z offset to apply to current rendering
  133311. * @param value defines the offset to apply
  133312. */
  133313. setZOffset(value: number): void;
  133314. /**
  133315. * Gets the current value of the zOffset
  133316. * @returns the current zOffset state
  133317. */
  133318. getZOffset(): number;
  133319. /**
  133320. * Enable or disable depth buffering
  133321. * @param enable defines the state to set
  133322. */
  133323. setDepthBuffer(enable: boolean): void;
  133324. /**
  133325. * Gets a boolean indicating if depth writing is enabled
  133326. * @returns the current depth writing state
  133327. */
  133328. getDepthWrite(): boolean;
  133329. setDepthFunctionToGreater(): void;
  133330. setDepthFunctionToGreaterOrEqual(): void;
  133331. setDepthFunctionToLess(): void;
  133332. setDepthFunctionToLessOrEqual(): void;
  133333. /**
  133334. * Enable or disable depth writing
  133335. * @param enable defines the state to set
  133336. */
  133337. setDepthWrite(enable: boolean): void;
  133338. /**
  133339. * Enable or disable color writing
  133340. * @param enable defines the state to set
  133341. */
  133342. setColorWrite(enable: boolean): void;
  133343. /**
  133344. * Gets a boolean indicating if color writing is enabled
  133345. * @returns the current color writing state
  133346. */
  133347. getColorWrite(): boolean;
  133348. /**
  133349. * Sets alpha constants used by some alpha blending modes
  133350. * @param r defines the red component
  133351. * @param g defines the green component
  133352. * @param b defines the blue component
  133353. * @param a defines the alpha component
  133354. */
  133355. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  133356. /**
  133357. * Sets the current alpha mode
  133358. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  133359. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  133360. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  133361. */
  133362. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  133363. /**
  133364. * Gets the current alpha mode
  133365. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  133366. * @returns the current alpha mode
  133367. */
  133368. getAlphaMode(): number;
  133369. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  133370. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133371. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133372. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133373. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133374. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133375. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133376. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133377. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133378. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  133379. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  133380. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  133381. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  133382. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  133383. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  133384. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  133385. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  133386. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  133387. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  133388. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  133389. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  133390. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  133391. wipeCaches(bruteForce?: boolean): void;
  133392. _createTexture(): WebGLTexture;
  133393. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  133394. /**
  133395. * Usually called from Texture.ts.
  133396. * Passed information to create a WebGLTexture
  133397. * @param url defines a value which contains one of the following:
  133398. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  133399. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  133400. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  133401. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  133402. * @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)
  133403. * @param scene needed for loading to the correct scene
  133404. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  133405. * @param onLoad optional callback to be called upon successful completion
  133406. * @param onError optional callback to be called upon failure
  133407. * @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
  133408. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  133409. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  133410. * @param forcedExtension defines the extension to use to pick the right loader
  133411. * @param mimeType defines an optional mime type
  133412. * @returns a InternalTexture for assignment back into BABYLON.Texture
  133413. */
  133414. 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;
  133415. /**
  133416. * Creates a cube texture
  133417. * @param rootUrl defines the url where the files to load is located
  133418. * @param scene defines the current scene
  133419. * @param files defines the list of files to load (1 per face)
  133420. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  133421. * @param onLoad defines an optional callback raised when the texture is loaded
  133422. * @param onError defines an optional callback raised if there is an issue to load the texture
  133423. * @param format defines the format of the data
  133424. * @param forcedExtension defines the extension to use to pick the right loader
  133425. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  133426. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  133427. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  133428. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  133429. * @returns the cube texture as an InternalTexture
  133430. */
  133431. 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;
  133432. private _getSamplingFilter;
  133433. private static _GetNativeTextureFormat;
  133434. createRenderTargetTexture(size: number | {
  133435. width: number;
  133436. height: number;
  133437. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  133438. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  133439. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  133440. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  133441. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  133442. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  133443. /**
  133444. * Updates a dynamic vertex buffer.
  133445. * @param vertexBuffer the vertex buffer to update
  133446. * @param data the data used to update the vertex buffer
  133447. * @param byteOffset the byte offset of the data (optional)
  133448. * @param byteLength the byte length of the data (optional)
  133449. */
  133450. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  133451. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  133452. private _updateAnisotropicLevel;
  133453. private _getAddressMode;
  133454. /** @hidden */
  133455. _bindTexture(channel: number, texture: InternalTexture): void;
  133456. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  133457. releaseEffects(): void;
  133458. /** @hidden */
  133459. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133460. /** @hidden */
  133461. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133462. /** @hidden */
  133463. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133464. /** @hidden */
  133465. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  133466. }
  133467. }
  133468. declare module BABYLON {
  133469. /**
  133470. * Gather the list of clipboard event types as constants.
  133471. */
  133472. export class ClipboardEventTypes {
  133473. /**
  133474. * The clipboard event is fired when a copy command is active (pressed).
  133475. */
  133476. static readonly COPY: number;
  133477. /**
  133478. * The clipboard event is fired when a cut command is active (pressed).
  133479. */
  133480. static readonly CUT: number;
  133481. /**
  133482. * The clipboard event is fired when a paste command is active (pressed).
  133483. */
  133484. static readonly PASTE: number;
  133485. }
  133486. /**
  133487. * This class is used to store clipboard related info for the onClipboardObservable event.
  133488. */
  133489. export class ClipboardInfo {
  133490. /**
  133491. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133492. */
  133493. type: number;
  133494. /**
  133495. * Defines the related dom event
  133496. */
  133497. event: ClipboardEvent;
  133498. /**
  133499. *Creates an instance of ClipboardInfo.
  133500. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  133501. * @param event Defines the related dom event
  133502. */
  133503. constructor(
  133504. /**
  133505. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133506. */
  133507. type: number,
  133508. /**
  133509. * Defines the related dom event
  133510. */
  133511. event: ClipboardEvent);
  133512. /**
  133513. * Get the clipboard event's type from the keycode.
  133514. * @param keyCode Defines the keyCode for the current keyboard event.
  133515. * @return {number}
  133516. */
  133517. static GetTypeFromCharacter(keyCode: number): number;
  133518. }
  133519. }
  133520. declare module BABYLON {
  133521. /**
  133522. * Google Daydream controller
  133523. */
  133524. export class DaydreamController extends WebVRController {
  133525. /**
  133526. * Base Url for the controller model.
  133527. */
  133528. static MODEL_BASE_URL: string;
  133529. /**
  133530. * File name for the controller model.
  133531. */
  133532. static MODEL_FILENAME: string;
  133533. /**
  133534. * Gamepad Id prefix used to identify Daydream Controller.
  133535. */
  133536. static readonly GAMEPAD_ID_PREFIX: string;
  133537. /**
  133538. * Creates a new DaydreamController from a gamepad
  133539. * @param vrGamepad the gamepad that the controller should be created from
  133540. */
  133541. constructor(vrGamepad: any);
  133542. /**
  133543. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133544. * @param scene scene in which to add meshes
  133545. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133546. */
  133547. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133548. /**
  133549. * Called once for each button that changed state since the last frame
  133550. * @param buttonIdx Which button index changed
  133551. * @param state New state of the button
  133552. * @param changes Which properties on the state changed since last frame
  133553. */
  133554. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133555. }
  133556. }
  133557. declare module BABYLON {
  133558. /**
  133559. * Gear VR Controller
  133560. */
  133561. export class GearVRController extends WebVRController {
  133562. /**
  133563. * Base Url for the controller model.
  133564. */
  133565. static MODEL_BASE_URL: string;
  133566. /**
  133567. * File name for the controller model.
  133568. */
  133569. static MODEL_FILENAME: string;
  133570. /**
  133571. * Gamepad Id prefix used to identify this controller.
  133572. */
  133573. static readonly GAMEPAD_ID_PREFIX: string;
  133574. private readonly _buttonIndexToObservableNameMap;
  133575. /**
  133576. * Creates a new GearVRController from a gamepad
  133577. * @param vrGamepad the gamepad that the controller should be created from
  133578. */
  133579. constructor(vrGamepad: any);
  133580. /**
  133581. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133582. * @param scene scene in which to add meshes
  133583. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133584. */
  133585. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133586. /**
  133587. * Called once for each button that changed state since the last frame
  133588. * @param buttonIdx Which button index changed
  133589. * @param state New state of the button
  133590. * @param changes Which properties on the state changed since last frame
  133591. */
  133592. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133593. }
  133594. }
  133595. declare module BABYLON {
  133596. /**
  133597. * Generic Controller
  133598. */
  133599. export class GenericController extends WebVRController {
  133600. /**
  133601. * Base Url for the controller model.
  133602. */
  133603. static readonly MODEL_BASE_URL: string;
  133604. /**
  133605. * File name for the controller model.
  133606. */
  133607. static readonly MODEL_FILENAME: string;
  133608. /**
  133609. * Creates a new GenericController from a gamepad
  133610. * @param vrGamepad the gamepad that the controller should be created from
  133611. */
  133612. constructor(vrGamepad: any);
  133613. /**
  133614. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133615. * @param scene scene in which to add meshes
  133616. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133617. */
  133618. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133619. /**
  133620. * Called once for each button that changed state since the last frame
  133621. * @param buttonIdx Which button index changed
  133622. * @param state New state of the button
  133623. * @param changes Which properties on the state changed since last frame
  133624. */
  133625. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133626. }
  133627. }
  133628. declare module BABYLON {
  133629. /**
  133630. * Oculus Touch Controller
  133631. */
  133632. export class OculusTouchController extends WebVRController {
  133633. /**
  133634. * Base Url for the controller model.
  133635. */
  133636. static MODEL_BASE_URL: string;
  133637. /**
  133638. * File name for the left controller model.
  133639. */
  133640. static MODEL_LEFT_FILENAME: string;
  133641. /**
  133642. * File name for the right controller model.
  133643. */
  133644. static MODEL_RIGHT_FILENAME: string;
  133645. /**
  133646. * Base Url for the Quest controller model.
  133647. */
  133648. static QUEST_MODEL_BASE_URL: string;
  133649. /**
  133650. * @hidden
  133651. * If the controllers are running on a device that needs the updated Quest controller models
  133652. */
  133653. static _IsQuest: boolean;
  133654. /**
  133655. * Fired when the secondary trigger on this controller is modified
  133656. */
  133657. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  133658. /**
  133659. * Fired when the thumb rest on this controller is modified
  133660. */
  133661. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  133662. /**
  133663. * Creates a new OculusTouchController from a gamepad
  133664. * @param vrGamepad the gamepad that the controller should be created from
  133665. */
  133666. constructor(vrGamepad: any);
  133667. /**
  133668. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133669. * @param scene scene in which to add meshes
  133670. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133671. */
  133672. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133673. /**
  133674. * Fired when the A button on this controller is modified
  133675. */
  133676. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133677. /**
  133678. * Fired when the B button on this controller is modified
  133679. */
  133680. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133681. /**
  133682. * Fired when the X button on this controller is modified
  133683. */
  133684. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133685. /**
  133686. * Fired when the Y button on this controller is modified
  133687. */
  133688. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133689. /**
  133690. * Called once for each button that changed state since the last frame
  133691. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  133692. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  133693. * 2) secondary trigger (same)
  133694. * 3) A (right) X (left), touch, pressed = value
  133695. * 4) B / Y
  133696. * 5) thumb rest
  133697. * @param buttonIdx Which button index changed
  133698. * @param state New state of the button
  133699. * @param changes Which properties on the state changed since last frame
  133700. */
  133701. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133702. }
  133703. }
  133704. declare module BABYLON {
  133705. /**
  133706. * Vive Controller
  133707. */
  133708. export class ViveController extends WebVRController {
  133709. /**
  133710. * Base Url for the controller model.
  133711. */
  133712. static MODEL_BASE_URL: string;
  133713. /**
  133714. * File name for the controller model.
  133715. */
  133716. static MODEL_FILENAME: string;
  133717. /**
  133718. * Creates a new ViveController from a gamepad
  133719. * @param vrGamepad the gamepad that the controller should be created from
  133720. */
  133721. constructor(vrGamepad: any);
  133722. /**
  133723. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133724. * @param scene scene in which to add meshes
  133725. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133726. */
  133727. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133728. /**
  133729. * Fired when the left button on this controller is modified
  133730. */
  133731. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133732. /**
  133733. * Fired when the right button on this controller is modified
  133734. */
  133735. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133736. /**
  133737. * Fired when the menu button on this controller is modified
  133738. */
  133739. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133740. /**
  133741. * Called once for each button that changed state since the last frame
  133742. * Vive mapping:
  133743. * 0: touchpad
  133744. * 1: trigger
  133745. * 2: left AND right buttons
  133746. * 3: menu button
  133747. * @param buttonIdx Which button index changed
  133748. * @param state New state of the button
  133749. * @param changes Which properties on the state changed since last frame
  133750. */
  133751. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133752. }
  133753. }
  133754. declare module BABYLON {
  133755. /**
  133756. * Defines the WindowsMotionController object that the state of the windows motion controller
  133757. */
  133758. export class WindowsMotionController extends WebVRController {
  133759. /**
  133760. * The base url used to load the left and right controller models
  133761. */
  133762. static MODEL_BASE_URL: string;
  133763. /**
  133764. * The name of the left controller model file
  133765. */
  133766. static MODEL_LEFT_FILENAME: string;
  133767. /**
  133768. * The name of the right controller model file
  133769. */
  133770. static MODEL_RIGHT_FILENAME: string;
  133771. /**
  133772. * The controller name prefix for this controller type
  133773. */
  133774. static readonly GAMEPAD_ID_PREFIX: string;
  133775. /**
  133776. * The controller id pattern for this controller type
  133777. */
  133778. private static readonly GAMEPAD_ID_PATTERN;
  133779. private _loadedMeshInfo;
  133780. protected readonly _mapping: {
  133781. buttons: string[];
  133782. buttonMeshNames: {
  133783. trigger: string;
  133784. menu: string;
  133785. grip: string;
  133786. thumbstick: string;
  133787. trackpad: string;
  133788. };
  133789. buttonObservableNames: {
  133790. trigger: string;
  133791. menu: string;
  133792. grip: string;
  133793. thumbstick: string;
  133794. trackpad: string;
  133795. };
  133796. axisMeshNames: string[];
  133797. pointingPoseMeshName: string;
  133798. };
  133799. /**
  133800. * Fired when the trackpad on this controller is clicked
  133801. */
  133802. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133803. /**
  133804. * Fired when the trackpad on this controller is modified
  133805. */
  133806. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133807. /**
  133808. * The current x and y values of this controller's trackpad
  133809. */
  133810. trackpad: StickValues;
  133811. /**
  133812. * Creates a new WindowsMotionController from a gamepad
  133813. * @param vrGamepad the gamepad that the controller should be created from
  133814. */
  133815. constructor(vrGamepad: any);
  133816. /**
  133817. * Fired when the trigger on this controller is modified
  133818. */
  133819. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133820. /**
  133821. * Fired when the menu button on this controller is modified
  133822. */
  133823. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133824. /**
  133825. * Fired when the grip button on this controller is modified
  133826. */
  133827. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133828. /**
  133829. * Fired when the thumbstick button on this controller is modified
  133830. */
  133831. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133832. /**
  133833. * Fired when the touchpad button on this controller is modified
  133834. */
  133835. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133836. /**
  133837. * Fired when the touchpad values on this controller are modified
  133838. */
  133839. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  133840. protected _updateTrackpad(): void;
  133841. /**
  133842. * Called once per frame by the engine.
  133843. */
  133844. update(): void;
  133845. /**
  133846. * Called once for each button that changed state since the last frame
  133847. * @param buttonIdx Which button index changed
  133848. * @param state New state of the button
  133849. * @param changes Which properties on the state changed since last frame
  133850. */
  133851. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133852. /**
  133853. * Moves the buttons on the controller mesh based on their current state
  133854. * @param buttonName the name of the button to move
  133855. * @param buttonValue the value of the button which determines the buttons new position
  133856. */
  133857. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  133858. /**
  133859. * Moves the axis on the controller mesh based on its current state
  133860. * @param axis the index of the axis
  133861. * @param axisValue the value of the axis which determines the meshes new position
  133862. * @hidden
  133863. */
  133864. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  133865. /**
  133866. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133867. * @param scene scene in which to add meshes
  133868. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133869. */
  133870. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  133871. /**
  133872. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  133873. * can be transformed by button presses and axes values, based on this._mapping.
  133874. *
  133875. * @param scene scene in which the meshes exist
  133876. * @param meshes list of meshes that make up the controller model to process
  133877. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  133878. */
  133879. private processModel;
  133880. private createMeshInfo;
  133881. /**
  133882. * Gets the ray of the controller in the direction the controller is pointing
  133883. * @param length the length the resulting ray should be
  133884. * @returns a ray in the direction the controller is pointing
  133885. */
  133886. getForwardRay(length?: number): Ray;
  133887. /**
  133888. * Disposes of the controller
  133889. */
  133890. dispose(): void;
  133891. }
  133892. /**
  133893. * This class represents a new windows motion controller in XR.
  133894. */
  133895. export class XRWindowsMotionController extends WindowsMotionController {
  133896. /**
  133897. * Changing the original WIndowsMotionController mapping to fir the new mapping
  133898. */
  133899. protected readonly _mapping: {
  133900. buttons: string[];
  133901. buttonMeshNames: {
  133902. trigger: string;
  133903. menu: string;
  133904. grip: string;
  133905. thumbstick: string;
  133906. trackpad: string;
  133907. };
  133908. buttonObservableNames: {
  133909. trigger: string;
  133910. menu: string;
  133911. grip: string;
  133912. thumbstick: string;
  133913. trackpad: string;
  133914. };
  133915. axisMeshNames: string[];
  133916. pointingPoseMeshName: string;
  133917. };
  133918. /**
  133919. * Construct a new XR-Based windows motion controller
  133920. *
  133921. * @param gamepadInfo the gamepad object from the browser
  133922. */
  133923. constructor(gamepadInfo: any);
  133924. /**
  133925. * holds the thumbstick values (X,Y)
  133926. */
  133927. thumbstickValues: StickValues;
  133928. /**
  133929. * Fired when the thumbstick on this controller is clicked
  133930. */
  133931. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  133932. /**
  133933. * Fired when the thumbstick on this controller is modified
  133934. */
  133935. onThumbstickValuesChangedObservable: Observable<StickValues>;
  133936. /**
  133937. * Fired when the touchpad button on this controller is modified
  133938. */
  133939. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133940. /**
  133941. * Fired when the touchpad values on this controller are modified
  133942. */
  133943. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133944. /**
  133945. * Fired when the thumbstick button on this controller is modified
  133946. * here to prevent breaking changes
  133947. */
  133948. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133949. /**
  133950. * updating the thumbstick(!) and not the trackpad.
  133951. * This is named this way due to the difference between WebVR and XR and to avoid
  133952. * changing the parent class.
  133953. */
  133954. protected _updateTrackpad(): void;
  133955. /**
  133956. * Disposes the class with joy
  133957. */
  133958. dispose(): void;
  133959. }
  133960. }
  133961. declare module BABYLON {
  133962. /**
  133963. * Class containing static functions to help procedurally build meshes
  133964. */
  133965. export class PolyhedronBuilder {
  133966. /**
  133967. * Creates a polyhedron mesh
  133968. * * 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
  133969. * * The parameter `size` (positive float, default 1) sets the polygon size
  133970. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  133971. * * 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`
  133972. * * 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
  133973. * * 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)`)
  133974. * * 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
  133975. * * 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
  133976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133977. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133979. * @param name defines the name of the mesh
  133980. * @param options defines the options used to create the mesh
  133981. * @param scene defines the hosting scene
  133982. * @returns the polyhedron mesh
  133983. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  133984. */
  133985. static CreatePolyhedron(name: string, options: {
  133986. type?: number;
  133987. size?: number;
  133988. sizeX?: number;
  133989. sizeY?: number;
  133990. sizeZ?: number;
  133991. custom?: any;
  133992. faceUV?: Vector4[];
  133993. faceColors?: Color4[];
  133994. flat?: boolean;
  133995. updatable?: boolean;
  133996. sideOrientation?: number;
  133997. frontUVs?: Vector4;
  133998. backUVs?: Vector4;
  133999. }, scene?: Nullable<Scene>): Mesh;
  134000. }
  134001. }
  134002. declare module BABYLON {
  134003. /**
  134004. * Gizmo that enables scaling a mesh along 3 axis
  134005. */
  134006. export class ScaleGizmo extends Gizmo {
  134007. /**
  134008. * Internal gizmo used for interactions on the x axis
  134009. */
  134010. xGizmo: AxisScaleGizmo;
  134011. /**
  134012. * Internal gizmo used for interactions on the y axis
  134013. */
  134014. yGizmo: AxisScaleGizmo;
  134015. /**
  134016. * Internal gizmo used for interactions on the z axis
  134017. */
  134018. zGizmo: AxisScaleGizmo;
  134019. /**
  134020. * Internal gizmo used to scale all axis equally
  134021. */
  134022. uniformScaleGizmo: AxisScaleGizmo;
  134023. private _meshAttached;
  134024. private _nodeAttached;
  134025. private _snapDistance;
  134026. private _uniformScalingMesh;
  134027. private _octahedron;
  134028. private _sensitivity;
  134029. /** Fires an event when any of it's sub gizmos are dragged */
  134030. onDragStartObservable: Observable<unknown>;
  134031. /** Fires an event when any of it's sub gizmos are released from dragging */
  134032. onDragEndObservable: Observable<unknown>;
  134033. get attachedMesh(): Nullable<AbstractMesh>;
  134034. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134035. get attachedNode(): Nullable<Node>;
  134036. set attachedNode(node: Nullable<Node>);
  134037. /**
  134038. * True when the mouse pointer is hovering a gizmo mesh
  134039. */
  134040. get isHovered(): boolean;
  134041. /**
  134042. * Creates a ScaleGizmo
  134043. * @param gizmoLayer The utility layer the gizmo will be added to
  134044. * @param thickness display gizmo axis thickness
  134045. */
  134046. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  134047. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134048. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134049. /**
  134050. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134051. */
  134052. set snapDistance(value: number);
  134053. get snapDistance(): number;
  134054. /**
  134055. * Ratio for the scale of the gizmo (Default: 1)
  134056. */
  134057. set scaleRatio(value: number);
  134058. get scaleRatio(): number;
  134059. /**
  134060. * Sensitivity factor for dragging (Default: 1)
  134061. */
  134062. set sensitivity(value: number);
  134063. get sensitivity(): number;
  134064. /**
  134065. * Disposes of the gizmo
  134066. */
  134067. dispose(): void;
  134068. }
  134069. }
  134070. declare module BABYLON {
  134071. /**
  134072. * Single axis scale gizmo
  134073. */
  134074. export class AxisScaleGizmo extends Gizmo {
  134075. /**
  134076. * Drag behavior responsible for the gizmos dragging interactions
  134077. */
  134078. dragBehavior: PointerDragBehavior;
  134079. private _pointerObserver;
  134080. /**
  134081. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134082. */
  134083. snapDistance: number;
  134084. /**
  134085. * Event that fires each time the gizmo snaps to a new location.
  134086. * * snapDistance is the the change in distance
  134087. */
  134088. onSnapObservable: Observable<{
  134089. snapDistance: number;
  134090. }>;
  134091. /**
  134092. * If the scaling operation should be done on all axis (default: false)
  134093. */
  134094. uniformScaling: boolean;
  134095. /**
  134096. * Custom sensitivity value for the drag strength
  134097. */
  134098. sensitivity: number;
  134099. private _isEnabled;
  134100. private _parent;
  134101. private _arrow;
  134102. private _coloredMaterial;
  134103. private _hoverMaterial;
  134104. /**
  134105. * Creates an AxisScaleGizmo
  134106. * @param gizmoLayer The utility layer the gizmo will be added to
  134107. * @param dragAxis The axis which the gizmo will be able to scale on
  134108. * @param color The color of the gizmo
  134109. * @param thickness display gizmo axis thickness
  134110. */
  134111. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  134112. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134113. /**
  134114. * If the gizmo is enabled
  134115. */
  134116. set isEnabled(value: boolean);
  134117. get isEnabled(): boolean;
  134118. /**
  134119. * Disposes of the gizmo
  134120. */
  134121. dispose(): void;
  134122. /**
  134123. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  134124. * @param mesh The mesh to replace the default mesh of the gizmo
  134125. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  134126. */
  134127. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  134128. }
  134129. }
  134130. declare module BABYLON {
  134131. /**
  134132. * Bounding box gizmo
  134133. */
  134134. export class BoundingBoxGizmo extends Gizmo {
  134135. private _lineBoundingBox;
  134136. private _rotateSpheresParent;
  134137. private _scaleBoxesParent;
  134138. private _boundingDimensions;
  134139. private _renderObserver;
  134140. private _pointerObserver;
  134141. private _scaleDragSpeed;
  134142. private _tmpQuaternion;
  134143. private _tmpVector;
  134144. private _tmpRotationMatrix;
  134145. /**
  134146. * 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)
  134147. */
  134148. ignoreChildren: boolean;
  134149. /**
  134150. * 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)
  134151. */
  134152. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  134153. /**
  134154. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  134155. */
  134156. rotationSphereSize: number;
  134157. /**
  134158. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  134159. */
  134160. scaleBoxSize: number;
  134161. /**
  134162. * 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)
  134163. */
  134164. fixedDragMeshScreenSize: boolean;
  134165. /**
  134166. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  134167. */
  134168. fixedDragMeshScreenSizeDistanceFactor: number;
  134169. /**
  134170. * Fired when a rotation sphere or scale box is dragged
  134171. */
  134172. onDragStartObservable: Observable<{}>;
  134173. /**
  134174. * Fired when a scale box is dragged
  134175. */
  134176. onScaleBoxDragObservable: Observable<{}>;
  134177. /**
  134178. * Fired when a scale box drag is ended
  134179. */
  134180. onScaleBoxDragEndObservable: Observable<{}>;
  134181. /**
  134182. * Fired when a rotation sphere is dragged
  134183. */
  134184. onRotationSphereDragObservable: Observable<{}>;
  134185. /**
  134186. * Fired when a rotation sphere drag is ended
  134187. */
  134188. onRotationSphereDragEndObservable: Observable<{}>;
  134189. /**
  134190. * 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)
  134191. */
  134192. scalePivot: Nullable<Vector3>;
  134193. /**
  134194. * Mesh used as a pivot to rotate the attached node
  134195. */
  134196. private _anchorMesh;
  134197. private _existingMeshScale;
  134198. private _dragMesh;
  134199. private pointerDragBehavior;
  134200. private coloredMaterial;
  134201. private hoverColoredMaterial;
  134202. /**
  134203. * Sets the color of the bounding box gizmo
  134204. * @param color the color to set
  134205. */
  134206. setColor(color: Color3): void;
  134207. /**
  134208. * Creates an BoundingBoxGizmo
  134209. * @param gizmoLayer The utility layer the gizmo will be added to
  134210. * @param color The color of the gizmo
  134211. */
  134212. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  134213. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  134214. private _selectNode;
  134215. /**
  134216. * Updates the bounding box information for the Gizmo
  134217. */
  134218. updateBoundingBox(): void;
  134219. private _updateRotationSpheres;
  134220. private _updateScaleBoxes;
  134221. /**
  134222. * Enables rotation on the specified axis and disables rotation on the others
  134223. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  134224. */
  134225. setEnabledRotationAxis(axis: string): void;
  134226. /**
  134227. * Enables/disables scaling
  134228. * @param enable if scaling should be enabled
  134229. * @param homogeneousScaling defines if scaling should only be homogeneous
  134230. */
  134231. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  134232. private _updateDummy;
  134233. /**
  134234. * Enables a pointer drag behavior on the bounding box of the gizmo
  134235. */
  134236. enableDragBehavior(): void;
  134237. /**
  134238. * Disposes of the gizmo
  134239. */
  134240. dispose(): void;
  134241. /**
  134242. * 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)
  134243. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  134244. * @returns the bounding box mesh with the passed in mesh as a child
  134245. */
  134246. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  134247. /**
  134248. * CustomMeshes are not supported by this gizmo
  134249. * @param mesh The mesh to replace the default mesh of the gizmo
  134250. */
  134251. setCustomMesh(mesh: Mesh): void;
  134252. }
  134253. }
  134254. declare module BABYLON {
  134255. /**
  134256. * Single plane rotation gizmo
  134257. */
  134258. export class PlaneRotationGizmo extends Gizmo {
  134259. /**
  134260. * Drag behavior responsible for the gizmos dragging interactions
  134261. */
  134262. dragBehavior: PointerDragBehavior;
  134263. private _pointerObserver;
  134264. /**
  134265. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  134266. */
  134267. snapDistance: number;
  134268. /**
  134269. * Event that fires each time the gizmo snaps to a new location.
  134270. * * snapDistance is the the change in distance
  134271. */
  134272. onSnapObservable: Observable<{
  134273. snapDistance: number;
  134274. }>;
  134275. private _isEnabled;
  134276. private _parent;
  134277. /**
  134278. * Creates a PlaneRotationGizmo
  134279. * @param gizmoLayer The utility layer the gizmo will be added to
  134280. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  134281. * @param color The color of the gizmo
  134282. * @param tessellation Amount of tessellation to be used when creating rotation circles
  134283. * @param useEulerRotation Use and update Euler angle instead of quaternion
  134284. * @param thickness display gizmo axis thickness
  134285. */
  134286. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  134287. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134288. /**
  134289. * If the gizmo is enabled
  134290. */
  134291. set isEnabled(value: boolean);
  134292. get isEnabled(): boolean;
  134293. /**
  134294. * Disposes of the gizmo
  134295. */
  134296. dispose(): void;
  134297. }
  134298. }
  134299. declare module BABYLON {
  134300. /**
  134301. * Gizmo that enables rotating a mesh along 3 axis
  134302. */
  134303. export class RotationGizmo extends Gizmo {
  134304. /**
  134305. * Internal gizmo used for interactions on the x axis
  134306. */
  134307. xGizmo: PlaneRotationGizmo;
  134308. /**
  134309. * Internal gizmo used for interactions on the y axis
  134310. */
  134311. yGizmo: PlaneRotationGizmo;
  134312. /**
  134313. * Internal gizmo used for interactions on the z axis
  134314. */
  134315. zGizmo: PlaneRotationGizmo;
  134316. /** Fires an event when any of it's sub gizmos are dragged */
  134317. onDragStartObservable: Observable<unknown>;
  134318. /** Fires an event when any of it's sub gizmos are released from dragging */
  134319. onDragEndObservable: Observable<unknown>;
  134320. private _meshAttached;
  134321. private _nodeAttached;
  134322. get attachedMesh(): Nullable<AbstractMesh>;
  134323. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134324. get attachedNode(): Nullable<Node>;
  134325. set attachedNode(node: Nullable<Node>);
  134326. /**
  134327. * True when the mouse pointer is hovering a gizmo mesh
  134328. */
  134329. get isHovered(): boolean;
  134330. /**
  134331. * Creates a RotationGizmo
  134332. * @param gizmoLayer The utility layer the gizmo will be added to
  134333. * @param tessellation Amount of tessellation to be used when creating rotation circles
  134334. * @param useEulerRotation Use and update Euler angle instead of quaternion
  134335. * @param thickness display gizmo axis thickness
  134336. */
  134337. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  134338. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134339. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134340. /**
  134341. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134342. */
  134343. set snapDistance(value: number);
  134344. get snapDistance(): number;
  134345. /**
  134346. * Ratio for the scale of the gizmo (Default: 1)
  134347. */
  134348. set scaleRatio(value: number);
  134349. get scaleRatio(): number;
  134350. /**
  134351. * Disposes of the gizmo
  134352. */
  134353. dispose(): void;
  134354. /**
  134355. * CustomMeshes are not supported by this gizmo
  134356. * @param mesh The mesh to replace the default mesh of the gizmo
  134357. */
  134358. setCustomMesh(mesh: Mesh): void;
  134359. }
  134360. }
  134361. declare module BABYLON {
  134362. /**
  134363. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  134364. */
  134365. export class GizmoManager implements IDisposable {
  134366. private scene;
  134367. /**
  134368. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  134369. */
  134370. gizmos: {
  134371. positionGizmo: Nullable<PositionGizmo>;
  134372. rotationGizmo: Nullable<RotationGizmo>;
  134373. scaleGizmo: Nullable<ScaleGizmo>;
  134374. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  134375. };
  134376. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  134377. clearGizmoOnEmptyPointerEvent: boolean;
  134378. /** Fires an event when the manager is attached to a mesh */
  134379. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  134380. /** Fires an event when the manager is attached to a node */
  134381. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  134382. private _gizmosEnabled;
  134383. private _pointerObserver;
  134384. private _attachedMesh;
  134385. private _attachedNode;
  134386. private _boundingBoxColor;
  134387. private _defaultUtilityLayer;
  134388. private _defaultKeepDepthUtilityLayer;
  134389. private _thickness;
  134390. /**
  134391. * When bounding box gizmo is enabled, this can be used to track drag/end events
  134392. */
  134393. boundingBoxDragBehavior: SixDofDragBehavior;
  134394. /**
  134395. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  134396. */
  134397. attachableMeshes: Nullable<Array<AbstractMesh>>;
  134398. /**
  134399. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  134400. */
  134401. attachableNodes: Nullable<Array<Node>>;
  134402. /**
  134403. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  134404. */
  134405. usePointerToAttachGizmos: boolean;
  134406. /**
  134407. * Utility layer that the bounding box gizmo belongs to
  134408. */
  134409. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  134410. /**
  134411. * Utility layer that all gizmos besides bounding box belong to
  134412. */
  134413. get utilityLayer(): UtilityLayerRenderer;
  134414. /**
  134415. * True when the mouse pointer is hovering a gizmo mesh
  134416. */
  134417. get isHovered(): boolean;
  134418. /**
  134419. * Instatiates a gizmo manager
  134420. * @param scene the scene to overlay the gizmos on top of
  134421. * @param thickness display gizmo axis thickness
  134422. */
  134423. constructor(scene: Scene, thickness?: number);
  134424. /**
  134425. * Attaches a set of gizmos to the specified mesh
  134426. * @param mesh The mesh the gizmo's should be attached to
  134427. */
  134428. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  134429. /**
  134430. * Attaches a set of gizmos to the specified node
  134431. * @param node The node the gizmo's should be attached to
  134432. */
  134433. attachToNode(node: Nullable<Node>): void;
  134434. /**
  134435. * If the position gizmo is enabled
  134436. */
  134437. set positionGizmoEnabled(value: boolean);
  134438. get positionGizmoEnabled(): boolean;
  134439. /**
  134440. * If the rotation gizmo is enabled
  134441. */
  134442. set rotationGizmoEnabled(value: boolean);
  134443. get rotationGizmoEnabled(): boolean;
  134444. /**
  134445. * If the scale gizmo is enabled
  134446. */
  134447. set scaleGizmoEnabled(value: boolean);
  134448. get scaleGizmoEnabled(): boolean;
  134449. /**
  134450. * If the boundingBox gizmo is enabled
  134451. */
  134452. set boundingBoxGizmoEnabled(value: boolean);
  134453. get boundingBoxGizmoEnabled(): boolean;
  134454. /**
  134455. * Disposes of the gizmo manager
  134456. */
  134457. dispose(): void;
  134458. }
  134459. }
  134460. declare module BABYLON {
  134461. /**
  134462. * A directional light is defined by a direction (what a surprise!).
  134463. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  134464. * 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.
  134465. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134466. */
  134467. export class DirectionalLight extends ShadowLight {
  134468. private _shadowFrustumSize;
  134469. /**
  134470. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  134471. */
  134472. get shadowFrustumSize(): number;
  134473. /**
  134474. * Specifies a fix frustum size for the shadow generation.
  134475. */
  134476. set shadowFrustumSize(value: number);
  134477. private _shadowOrthoScale;
  134478. /**
  134479. * Gets the shadow projection scale against the optimal computed one.
  134480. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134481. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134482. */
  134483. get shadowOrthoScale(): number;
  134484. /**
  134485. * Sets the shadow projection scale against the optimal computed one.
  134486. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134487. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134488. */
  134489. set shadowOrthoScale(value: number);
  134490. /**
  134491. * Automatically compute the projection matrix to best fit (including all the casters)
  134492. * on each frame.
  134493. */
  134494. autoUpdateExtends: boolean;
  134495. /**
  134496. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  134497. * on each frame. autoUpdateExtends must be set to true for this to work
  134498. */
  134499. autoCalcShadowZBounds: boolean;
  134500. private _orthoLeft;
  134501. private _orthoRight;
  134502. private _orthoTop;
  134503. private _orthoBottom;
  134504. /**
  134505. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  134506. * The directional light is emitted from everywhere in the given direction.
  134507. * It can cast shadows.
  134508. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134509. * @param name The friendly name of the light
  134510. * @param direction The direction of the light
  134511. * @param scene The scene the light belongs to
  134512. */
  134513. constructor(name: string, direction: Vector3, scene: Scene);
  134514. /**
  134515. * Returns the string "DirectionalLight".
  134516. * @return The class name
  134517. */
  134518. getClassName(): string;
  134519. /**
  134520. * Returns the integer 1.
  134521. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134522. */
  134523. getTypeID(): number;
  134524. /**
  134525. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  134526. * Returns the DirectionalLight Shadow projection matrix.
  134527. */
  134528. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134529. /**
  134530. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  134531. * Returns the DirectionalLight Shadow projection matrix.
  134532. */
  134533. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  134534. /**
  134535. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  134536. * Returns the DirectionalLight Shadow projection matrix.
  134537. */
  134538. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134539. protected _buildUniformLayout(): void;
  134540. /**
  134541. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  134542. * @param effect The effect to update
  134543. * @param lightIndex The index of the light in the effect to update
  134544. * @returns The directional light
  134545. */
  134546. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  134547. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  134548. /**
  134549. * Gets the minZ used for shadow according to both the scene and the light.
  134550. *
  134551. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134552. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134553. * @param activeCamera The camera we are returning the min for
  134554. * @returns the depth min z
  134555. */
  134556. getDepthMinZ(activeCamera: Camera): number;
  134557. /**
  134558. * Gets the maxZ used for shadow according to both the scene and the light.
  134559. *
  134560. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134561. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134562. * @param activeCamera The camera we are returning the max for
  134563. * @returns the depth max z
  134564. */
  134565. getDepthMaxZ(activeCamera: Camera): number;
  134566. /**
  134567. * Prepares the list of defines specific to the light type.
  134568. * @param defines the list of defines
  134569. * @param lightIndex defines the index of the light for the effect
  134570. */
  134571. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134572. }
  134573. }
  134574. declare module BABYLON {
  134575. /**
  134576. * Class containing static functions to help procedurally build meshes
  134577. */
  134578. export class HemisphereBuilder {
  134579. /**
  134580. * Creates a hemisphere mesh
  134581. * @param name defines the name of the mesh
  134582. * @param options defines the options used to create the mesh
  134583. * @param scene defines the hosting scene
  134584. * @returns the hemisphere mesh
  134585. */
  134586. static CreateHemisphere(name: string, options: {
  134587. segments?: number;
  134588. diameter?: number;
  134589. sideOrientation?: number;
  134590. }, scene: any): Mesh;
  134591. }
  134592. }
  134593. declare module BABYLON {
  134594. /**
  134595. * A spot light is defined by a position, a direction, an angle, and an exponent.
  134596. * These values define a cone of light starting from the position, emitting toward the direction.
  134597. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  134598. * and the exponent defines the speed of the decay of the light with distance (reach).
  134599. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134600. */
  134601. export class SpotLight extends ShadowLight {
  134602. private _angle;
  134603. private _innerAngle;
  134604. private _cosHalfAngle;
  134605. private _lightAngleScale;
  134606. private _lightAngleOffset;
  134607. /**
  134608. * Gets the cone angle of the spot light in Radians.
  134609. */
  134610. get angle(): number;
  134611. /**
  134612. * Sets the cone angle of the spot light in Radians.
  134613. */
  134614. set angle(value: number);
  134615. /**
  134616. * Only used in gltf falloff mode, this defines the angle where
  134617. * the directional falloff will start before cutting at angle which could be seen
  134618. * as outer angle.
  134619. */
  134620. get innerAngle(): number;
  134621. /**
  134622. * Only used in gltf falloff mode, this defines the angle where
  134623. * the directional falloff will start before cutting at angle which could be seen
  134624. * as outer angle.
  134625. */
  134626. set innerAngle(value: number);
  134627. private _shadowAngleScale;
  134628. /**
  134629. * Allows scaling the angle of the light for shadow generation only.
  134630. */
  134631. get shadowAngleScale(): number;
  134632. /**
  134633. * Allows scaling the angle of the light for shadow generation only.
  134634. */
  134635. set shadowAngleScale(value: number);
  134636. /**
  134637. * The light decay speed with the distance from the emission spot.
  134638. */
  134639. exponent: number;
  134640. private _projectionTextureMatrix;
  134641. /**
  134642. * Allows reading the projecton texture
  134643. */
  134644. get projectionTextureMatrix(): Matrix;
  134645. protected _projectionTextureLightNear: number;
  134646. /**
  134647. * Gets the near clip of the Spotlight for texture projection.
  134648. */
  134649. get projectionTextureLightNear(): number;
  134650. /**
  134651. * Sets the near clip of the Spotlight for texture projection.
  134652. */
  134653. set projectionTextureLightNear(value: number);
  134654. protected _projectionTextureLightFar: number;
  134655. /**
  134656. * Gets the far clip of the Spotlight for texture projection.
  134657. */
  134658. get projectionTextureLightFar(): number;
  134659. /**
  134660. * Sets the far clip of the Spotlight for texture projection.
  134661. */
  134662. set projectionTextureLightFar(value: number);
  134663. protected _projectionTextureUpDirection: Vector3;
  134664. /**
  134665. * Gets the Up vector of the Spotlight for texture projection.
  134666. */
  134667. get projectionTextureUpDirection(): Vector3;
  134668. /**
  134669. * Sets the Up vector of the Spotlight for texture projection.
  134670. */
  134671. set projectionTextureUpDirection(value: Vector3);
  134672. private _projectionTexture;
  134673. /**
  134674. * Gets the projection texture of the light.
  134675. */
  134676. get projectionTexture(): Nullable<BaseTexture>;
  134677. /**
  134678. * Sets the projection texture of the light.
  134679. */
  134680. set projectionTexture(value: Nullable<BaseTexture>);
  134681. private _projectionTextureViewLightDirty;
  134682. private _projectionTextureProjectionLightDirty;
  134683. private _projectionTextureDirty;
  134684. private _projectionTextureViewTargetVector;
  134685. private _projectionTextureViewLightMatrix;
  134686. private _projectionTextureProjectionLightMatrix;
  134687. private _projectionTextureScalingMatrix;
  134688. /**
  134689. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  134690. * It can cast shadows.
  134691. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134692. * @param name The light friendly name
  134693. * @param position The position of the spot light in the scene
  134694. * @param direction The direction of the light in the scene
  134695. * @param angle The cone angle of the light in Radians
  134696. * @param exponent The light decay speed with the distance from the emission spot
  134697. * @param scene The scene the lights belongs to
  134698. */
  134699. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  134700. /**
  134701. * Returns the string "SpotLight".
  134702. * @returns the class name
  134703. */
  134704. getClassName(): string;
  134705. /**
  134706. * Returns the integer 2.
  134707. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134708. */
  134709. getTypeID(): number;
  134710. /**
  134711. * Overrides the direction setter to recompute the projection texture view light Matrix.
  134712. */
  134713. protected _setDirection(value: Vector3): void;
  134714. /**
  134715. * Overrides the position setter to recompute the projection texture view light Matrix.
  134716. */
  134717. protected _setPosition(value: Vector3): void;
  134718. /**
  134719. * 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.
  134720. * Returns the SpotLight.
  134721. */
  134722. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134723. protected _computeProjectionTextureViewLightMatrix(): void;
  134724. protected _computeProjectionTextureProjectionLightMatrix(): void;
  134725. /**
  134726. * Main function for light texture projection matrix computing.
  134727. */
  134728. protected _computeProjectionTextureMatrix(): void;
  134729. protected _buildUniformLayout(): void;
  134730. private _computeAngleValues;
  134731. /**
  134732. * Sets the passed Effect "effect" with the Light textures.
  134733. * @param effect The effect to update
  134734. * @param lightIndex The index of the light in the effect to update
  134735. * @returns The light
  134736. */
  134737. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  134738. /**
  134739. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  134740. * @param effect The effect to update
  134741. * @param lightIndex The index of the light in the effect to update
  134742. * @returns The spot light
  134743. */
  134744. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  134745. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  134746. /**
  134747. * Disposes the light and the associated resources.
  134748. */
  134749. dispose(): void;
  134750. /**
  134751. * Prepares the list of defines specific to the light type.
  134752. * @param defines the list of defines
  134753. * @param lightIndex defines the index of the light for the effect
  134754. */
  134755. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134756. }
  134757. }
  134758. declare module BABYLON {
  134759. /**
  134760. * Gizmo that enables viewing a light
  134761. */
  134762. export class LightGizmo extends Gizmo {
  134763. private _lightMesh;
  134764. private _material;
  134765. private _cachedPosition;
  134766. private _cachedForward;
  134767. private _attachedMeshParent;
  134768. private _pointerObserver;
  134769. /**
  134770. * Event that fires each time the gizmo is clicked
  134771. */
  134772. onClickedObservable: Observable<Light>;
  134773. /**
  134774. * Creates a LightGizmo
  134775. * @param gizmoLayer The utility layer the gizmo will be added to
  134776. */
  134777. constructor(gizmoLayer?: UtilityLayerRenderer);
  134778. private _light;
  134779. /**
  134780. * The light that the gizmo is attached to
  134781. */
  134782. set light(light: Nullable<Light>);
  134783. get light(): Nullable<Light>;
  134784. /**
  134785. * Gets the material used to render the light gizmo
  134786. */
  134787. get material(): StandardMaterial;
  134788. /**
  134789. * @hidden
  134790. * Updates the gizmo to match the attached mesh's position/rotation
  134791. */
  134792. protected _update(): void;
  134793. private static _Scale;
  134794. /**
  134795. * Creates the lines for a light mesh
  134796. */
  134797. private static _CreateLightLines;
  134798. /**
  134799. * Disposes of the light gizmo
  134800. */
  134801. dispose(): void;
  134802. private static _CreateHemisphericLightMesh;
  134803. private static _CreatePointLightMesh;
  134804. private static _CreateSpotLightMesh;
  134805. private static _CreateDirectionalLightMesh;
  134806. }
  134807. }
  134808. declare module BABYLON {
  134809. /**
  134810. * Gizmo that enables viewing a camera
  134811. */
  134812. export class CameraGizmo extends Gizmo {
  134813. private _cameraMesh;
  134814. private _cameraLinesMesh;
  134815. private _material;
  134816. private _pointerObserver;
  134817. /**
  134818. * Event that fires each time the gizmo is clicked
  134819. */
  134820. onClickedObservable: Observable<Camera>;
  134821. /**
  134822. * Creates a CameraGizmo
  134823. * @param gizmoLayer The utility layer the gizmo will be added to
  134824. */
  134825. constructor(gizmoLayer?: UtilityLayerRenderer);
  134826. private _camera;
  134827. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  134828. get displayFrustum(): boolean;
  134829. set displayFrustum(value: boolean);
  134830. /**
  134831. * The camera that the gizmo is attached to
  134832. */
  134833. set camera(camera: Nullable<Camera>);
  134834. get camera(): Nullable<Camera>;
  134835. /**
  134836. * Gets the material used to render the camera gizmo
  134837. */
  134838. get material(): StandardMaterial;
  134839. /**
  134840. * @hidden
  134841. * Updates the gizmo to match the attached mesh's position/rotation
  134842. */
  134843. protected _update(): void;
  134844. private static _Scale;
  134845. private _invProjection;
  134846. /**
  134847. * Disposes of the camera gizmo
  134848. */
  134849. dispose(): void;
  134850. private static _CreateCameraMesh;
  134851. private static _CreateCameraFrustum;
  134852. }
  134853. }
  134854. declare module BABYLON {
  134855. /** @hidden */
  134856. export var backgroundFragmentDeclaration: {
  134857. name: string;
  134858. shader: string;
  134859. };
  134860. }
  134861. declare module BABYLON {
  134862. /** @hidden */
  134863. export var backgroundUboDeclaration: {
  134864. name: string;
  134865. shader: string;
  134866. };
  134867. }
  134868. declare module BABYLON {
  134869. /** @hidden */
  134870. export var backgroundPixelShader: {
  134871. name: string;
  134872. shader: string;
  134873. };
  134874. }
  134875. declare module BABYLON {
  134876. /** @hidden */
  134877. export var backgroundVertexDeclaration: {
  134878. name: string;
  134879. shader: string;
  134880. };
  134881. }
  134882. declare module BABYLON {
  134883. /** @hidden */
  134884. export var backgroundVertexShader: {
  134885. name: string;
  134886. shader: string;
  134887. };
  134888. }
  134889. declare module BABYLON {
  134890. /**
  134891. * Background material used to create an efficient environement around your scene.
  134892. */
  134893. export class BackgroundMaterial extends PushMaterial {
  134894. /**
  134895. * Standard reflectance value at parallel view angle.
  134896. */
  134897. static StandardReflectance0: number;
  134898. /**
  134899. * Standard reflectance value at grazing angle.
  134900. */
  134901. static StandardReflectance90: number;
  134902. protected _primaryColor: Color3;
  134903. /**
  134904. * Key light Color (multiply against the environement texture)
  134905. */
  134906. primaryColor: Color3;
  134907. protected __perceptualColor: Nullable<Color3>;
  134908. /**
  134909. * Experimental Internal Use Only.
  134910. *
  134911. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  134912. * This acts as a helper to set the primary color to a more "human friendly" value.
  134913. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  134914. * output color as close as possible from the chosen value.
  134915. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  134916. * part of lighting setup.)
  134917. */
  134918. get _perceptualColor(): Nullable<Color3>;
  134919. set _perceptualColor(value: Nullable<Color3>);
  134920. protected _primaryColorShadowLevel: float;
  134921. /**
  134922. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  134923. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  134924. */
  134925. get primaryColorShadowLevel(): float;
  134926. set primaryColorShadowLevel(value: float);
  134927. protected _primaryColorHighlightLevel: float;
  134928. /**
  134929. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  134930. * The primary color is used at the level chosen to define what the white area would look.
  134931. */
  134932. get primaryColorHighlightLevel(): float;
  134933. set primaryColorHighlightLevel(value: float);
  134934. protected _reflectionTexture: Nullable<BaseTexture>;
  134935. /**
  134936. * Reflection Texture used in the material.
  134937. * Should be author in a specific way for the best result (refer to the documentation).
  134938. */
  134939. reflectionTexture: Nullable<BaseTexture>;
  134940. protected _reflectionBlur: float;
  134941. /**
  134942. * Reflection Texture level of blur.
  134943. *
  134944. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  134945. * texture twice.
  134946. */
  134947. reflectionBlur: float;
  134948. protected _diffuseTexture: Nullable<BaseTexture>;
  134949. /**
  134950. * Diffuse Texture used in the material.
  134951. * Should be author in a specific way for the best result (refer to the documentation).
  134952. */
  134953. diffuseTexture: Nullable<BaseTexture>;
  134954. protected _shadowLights: Nullable<IShadowLight[]>;
  134955. /**
  134956. * Specify the list of lights casting shadow on the material.
  134957. * All scene shadow lights will be included if null.
  134958. */
  134959. shadowLights: Nullable<IShadowLight[]>;
  134960. protected _shadowLevel: float;
  134961. /**
  134962. * Helps adjusting the shadow to a softer level if required.
  134963. * 0 means black shadows and 1 means no shadows.
  134964. */
  134965. shadowLevel: float;
  134966. protected _sceneCenter: Vector3;
  134967. /**
  134968. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  134969. * It is usually zero but might be interesting to modify according to your setup.
  134970. */
  134971. sceneCenter: Vector3;
  134972. protected _opacityFresnel: boolean;
  134973. /**
  134974. * This helps specifying that the material is falling off to the sky box at grazing angle.
  134975. * This helps ensuring a nice transition when the camera goes under the ground.
  134976. */
  134977. opacityFresnel: boolean;
  134978. protected _reflectionFresnel: boolean;
  134979. /**
  134980. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  134981. * This helps adding a mirror texture on the ground.
  134982. */
  134983. reflectionFresnel: boolean;
  134984. protected _reflectionFalloffDistance: number;
  134985. /**
  134986. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  134987. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  134988. */
  134989. reflectionFalloffDistance: number;
  134990. protected _reflectionAmount: number;
  134991. /**
  134992. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  134993. */
  134994. reflectionAmount: number;
  134995. protected _reflectionReflectance0: number;
  134996. /**
  134997. * This specifies the weight of the reflection at grazing angle.
  134998. */
  134999. reflectionReflectance0: number;
  135000. protected _reflectionReflectance90: number;
  135001. /**
  135002. * This specifies the weight of the reflection at a perpendicular point of view.
  135003. */
  135004. reflectionReflectance90: number;
  135005. /**
  135006. * Sets the reflection reflectance fresnel values according to the default standard
  135007. * empirically know to work well :-)
  135008. */
  135009. set reflectionStandardFresnelWeight(value: number);
  135010. protected _useRGBColor: boolean;
  135011. /**
  135012. * Helps to directly use the maps channels instead of their level.
  135013. */
  135014. useRGBColor: boolean;
  135015. protected _enableNoise: boolean;
  135016. /**
  135017. * This helps reducing the banding effect that could occur on the background.
  135018. */
  135019. enableNoise: boolean;
  135020. /**
  135021. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  135022. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  135023. * Recommended to be keep at 1.0 except for special cases.
  135024. */
  135025. get fovMultiplier(): number;
  135026. set fovMultiplier(value: number);
  135027. private _fovMultiplier;
  135028. /**
  135029. * Enable the FOV adjustment feature controlled by fovMultiplier.
  135030. */
  135031. useEquirectangularFOV: boolean;
  135032. private _maxSimultaneousLights;
  135033. /**
  135034. * Number of Simultaneous lights allowed on the material.
  135035. */
  135036. maxSimultaneousLights: int;
  135037. private _shadowOnly;
  135038. /**
  135039. * Make the material only render shadows
  135040. */
  135041. shadowOnly: boolean;
  135042. /**
  135043. * Default configuration related to image processing available in the Background Material.
  135044. */
  135045. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  135046. /**
  135047. * Keep track of the image processing observer to allow dispose and replace.
  135048. */
  135049. private _imageProcessingObserver;
  135050. /**
  135051. * Attaches a new image processing configuration to the PBR Material.
  135052. * @param configuration (if null the scene configuration will be use)
  135053. */
  135054. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  135055. /**
  135056. * Gets the image processing configuration used either in this material.
  135057. */
  135058. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  135059. /**
  135060. * Sets the Default image processing configuration used either in the this material.
  135061. *
  135062. * If sets to null, the scene one is in use.
  135063. */
  135064. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  135065. /**
  135066. * Gets wether the color curves effect is enabled.
  135067. */
  135068. get cameraColorCurvesEnabled(): boolean;
  135069. /**
  135070. * Sets wether the color curves effect is enabled.
  135071. */
  135072. set cameraColorCurvesEnabled(value: boolean);
  135073. /**
  135074. * Gets wether the color grading effect is enabled.
  135075. */
  135076. get cameraColorGradingEnabled(): boolean;
  135077. /**
  135078. * Gets wether the color grading effect is enabled.
  135079. */
  135080. set cameraColorGradingEnabled(value: boolean);
  135081. /**
  135082. * Gets wether tonemapping is enabled or not.
  135083. */
  135084. get cameraToneMappingEnabled(): boolean;
  135085. /**
  135086. * Sets wether tonemapping is enabled or not
  135087. */
  135088. set cameraToneMappingEnabled(value: boolean);
  135089. /**
  135090. * The camera exposure used on this material.
  135091. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135092. * This corresponds to a photographic exposure.
  135093. */
  135094. get cameraExposure(): float;
  135095. /**
  135096. * The camera exposure used on this material.
  135097. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135098. * This corresponds to a photographic exposure.
  135099. */
  135100. set cameraExposure(value: float);
  135101. /**
  135102. * Gets The camera contrast used on this material.
  135103. */
  135104. get cameraContrast(): float;
  135105. /**
  135106. * Sets The camera contrast used on this material.
  135107. */
  135108. set cameraContrast(value: float);
  135109. /**
  135110. * Gets the Color Grading 2D Lookup Texture.
  135111. */
  135112. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  135113. /**
  135114. * Sets the Color Grading 2D Lookup Texture.
  135115. */
  135116. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  135117. /**
  135118. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135119. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135120. * 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;
  135121. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135122. */
  135123. get cameraColorCurves(): Nullable<ColorCurves>;
  135124. /**
  135125. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135126. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135127. * 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;
  135128. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135129. */
  135130. set cameraColorCurves(value: Nullable<ColorCurves>);
  135131. /**
  135132. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  135133. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  135134. */
  135135. switchToBGR: boolean;
  135136. private _renderTargets;
  135137. private _reflectionControls;
  135138. private _white;
  135139. private _primaryShadowColor;
  135140. private _primaryHighlightColor;
  135141. /**
  135142. * Instantiates a Background Material in the given scene
  135143. * @param name The friendly name of the material
  135144. * @param scene The scene to add the material to
  135145. */
  135146. constructor(name: string, scene: Scene);
  135147. /**
  135148. * Gets a boolean indicating that current material needs to register RTT
  135149. */
  135150. get hasRenderTargetTextures(): boolean;
  135151. /**
  135152. * The entire material has been created in order to prevent overdraw.
  135153. * @returns false
  135154. */
  135155. needAlphaTesting(): boolean;
  135156. /**
  135157. * The entire material has been created in order to prevent overdraw.
  135158. * @returns true if blending is enable
  135159. */
  135160. needAlphaBlending(): boolean;
  135161. /**
  135162. * Checks wether the material is ready to be rendered for a given mesh.
  135163. * @param mesh The mesh to render
  135164. * @param subMesh The submesh to check against
  135165. * @param useInstances Specify wether or not the material is used with instances
  135166. * @returns true if all the dependencies are ready (Textures, Effects...)
  135167. */
  135168. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  135169. /**
  135170. * Compute the primary color according to the chosen perceptual color.
  135171. */
  135172. private _computePrimaryColorFromPerceptualColor;
  135173. /**
  135174. * Compute the highlights and shadow colors according to their chosen levels.
  135175. */
  135176. private _computePrimaryColors;
  135177. /**
  135178. * Build the uniform buffer used in the material.
  135179. */
  135180. buildUniformLayout(): void;
  135181. /**
  135182. * Unbind the material.
  135183. */
  135184. unbind(): void;
  135185. /**
  135186. * Bind only the world matrix to the material.
  135187. * @param world The world matrix to bind.
  135188. */
  135189. bindOnlyWorldMatrix(world: Matrix): void;
  135190. /**
  135191. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  135192. * @param world The world matrix to bind.
  135193. * @param subMesh The submesh to bind for.
  135194. */
  135195. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  135196. /**
  135197. * Checks to see if a texture is used in the material.
  135198. * @param texture - Base texture to use.
  135199. * @returns - Boolean specifying if a texture is used in the material.
  135200. */
  135201. hasTexture(texture: BaseTexture): boolean;
  135202. /**
  135203. * Dispose the material.
  135204. * @param forceDisposeEffect Force disposal of the associated effect.
  135205. * @param forceDisposeTextures Force disposal of the associated textures.
  135206. */
  135207. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  135208. /**
  135209. * Clones the material.
  135210. * @param name The cloned name.
  135211. * @returns The cloned material.
  135212. */
  135213. clone(name: string): BackgroundMaterial;
  135214. /**
  135215. * Serializes the current material to its JSON representation.
  135216. * @returns The JSON representation.
  135217. */
  135218. serialize(): any;
  135219. /**
  135220. * Gets the class name of the material
  135221. * @returns "BackgroundMaterial"
  135222. */
  135223. getClassName(): string;
  135224. /**
  135225. * Parse a JSON input to create back a background material.
  135226. * @param source The JSON data to parse
  135227. * @param scene The scene to create the parsed material in
  135228. * @param rootUrl The root url of the assets the material depends upon
  135229. * @returns the instantiated BackgroundMaterial.
  135230. */
  135231. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  135232. }
  135233. }
  135234. declare module BABYLON {
  135235. /**
  135236. * Represents the different options available during the creation of
  135237. * a Environment helper.
  135238. *
  135239. * This can control the default ground, skybox and image processing setup of your scene.
  135240. */
  135241. export interface IEnvironmentHelperOptions {
  135242. /**
  135243. * Specifies whether or not to create a ground.
  135244. * True by default.
  135245. */
  135246. createGround: boolean;
  135247. /**
  135248. * Specifies the ground size.
  135249. * 15 by default.
  135250. */
  135251. groundSize: number;
  135252. /**
  135253. * The texture used on the ground for the main color.
  135254. * Comes from the BabylonJS CDN by default.
  135255. *
  135256. * Remarks: Can be either a texture or a url.
  135257. */
  135258. groundTexture: string | BaseTexture;
  135259. /**
  135260. * The color mixed in the ground texture by default.
  135261. * BabylonJS clearColor by default.
  135262. */
  135263. groundColor: Color3;
  135264. /**
  135265. * Specifies the ground opacity.
  135266. * 1 by default.
  135267. */
  135268. groundOpacity: number;
  135269. /**
  135270. * Enables the ground to receive shadows.
  135271. * True by default.
  135272. */
  135273. enableGroundShadow: boolean;
  135274. /**
  135275. * Helps preventing the shadow to be fully black on the ground.
  135276. * 0.5 by default.
  135277. */
  135278. groundShadowLevel: number;
  135279. /**
  135280. * Creates a mirror texture attach to the ground.
  135281. * false by default.
  135282. */
  135283. enableGroundMirror: boolean;
  135284. /**
  135285. * Specifies the ground mirror size ratio.
  135286. * 0.3 by default as the default kernel is 64.
  135287. */
  135288. groundMirrorSizeRatio: number;
  135289. /**
  135290. * Specifies the ground mirror blur kernel size.
  135291. * 64 by default.
  135292. */
  135293. groundMirrorBlurKernel: number;
  135294. /**
  135295. * Specifies the ground mirror visibility amount.
  135296. * 1 by default
  135297. */
  135298. groundMirrorAmount: number;
  135299. /**
  135300. * Specifies the ground mirror reflectance weight.
  135301. * This uses the standard weight of the background material to setup the fresnel effect
  135302. * of the mirror.
  135303. * 1 by default.
  135304. */
  135305. groundMirrorFresnelWeight: number;
  135306. /**
  135307. * Specifies the ground mirror Falloff distance.
  135308. * This can helps reducing the size of the reflection.
  135309. * 0 by Default.
  135310. */
  135311. groundMirrorFallOffDistance: number;
  135312. /**
  135313. * Specifies the ground mirror texture type.
  135314. * Unsigned Int by Default.
  135315. */
  135316. groundMirrorTextureType: number;
  135317. /**
  135318. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  135319. * the shown objects.
  135320. */
  135321. groundYBias: number;
  135322. /**
  135323. * Specifies whether or not to create a skybox.
  135324. * True by default.
  135325. */
  135326. createSkybox: boolean;
  135327. /**
  135328. * Specifies the skybox size.
  135329. * 20 by default.
  135330. */
  135331. skyboxSize: number;
  135332. /**
  135333. * The texture used on the skybox for the main color.
  135334. * Comes from the BabylonJS CDN by default.
  135335. *
  135336. * Remarks: Can be either a texture or a url.
  135337. */
  135338. skyboxTexture: string | BaseTexture;
  135339. /**
  135340. * The color mixed in the skybox texture by default.
  135341. * BabylonJS clearColor by default.
  135342. */
  135343. skyboxColor: Color3;
  135344. /**
  135345. * The background rotation around the Y axis of the scene.
  135346. * This helps aligning the key lights of your scene with the background.
  135347. * 0 by default.
  135348. */
  135349. backgroundYRotation: number;
  135350. /**
  135351. * Compute automatically the size of the elements to best fit with the scene.
  135352. */
  135353. sizeAuto: boolean;
  135354. /**
  135355. * Default position of the rootMesh if autoSize is not true.
  135356. */
  135357. rootPosition: Vector3;
  135358. /**
  135359. * Sets up the image processing in the scene.
  135360. * true by default.
  135361. */
  135362. setupImageProcessing: boolean;
  135363. /**
  135364. * The texture used as your environment texture in the scene.
  135365. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  135366. *
  135367. * Remarks: Can be either a texture or a url.
  135368. */
  135369. environmentTexture: string | BaseTexture;
  135370. /**
  135371. * The value of the exposure to apply to the scene.
  135372. * 0.6 by default if setupImageProcessing is true.
  135373. */
  135374. cameraExposure: number;
  135375. /**
  135376. * The value of the contrast to apply to the scene.
  135377. * 1.6 by default if setupImageProcessing is true.
  135378. */
  135379. cameraContrast: number;
  135380. /**
  135381. * Specifies whether or not tonemapping should be enabled in the scene.
  135382. * true by default if setupImageProcessing is true.
  135383. */
  135384. toneMappingEnabled: boolean;
  135385. }
  135386. /**
  135387. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  135388. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  135389. * It also helps with the default setup of your imageProcessing configuration.
  135390. */
  135391. export class EnvironmentHelper {
  135392. /**
  135393. * Default ground texture URL.
  135394. */
  135395. private static _groundTextureCDNUrl;
  135396. /**
  135397. * Default skybox texture URL.
  135398. */
  135399. private static _skyboxTextureCDNUrl;
  135400. /**
  135401. * Default environment texture URL.
  135402. */
  135403. private static _environmentTextureCDNUrl;
  135404. /**
  135405. * Creates the default options for the helper.
  135406. */
  135407. private static _getDefaultOptions;
  135408. private _rootMesh;
  135409. /**
  135410. * Gets the root mesh created by the helper.
  135411. */
  135412. get rootMesh(): Mesh;
  135413. private _skybox;
  135414. /**
  135415. * Gets the skybox created by the helper.
  135416. */
  135417. get skybox(): Nullable<Mesh>;
  135418. private _skyboxTexture;
  135419. /**
  135420. * Gets the skybox texture created by the helper.
  135421. */
  135422. get skyboxTexture(): Nullable<BaseTexture>;
  135423. private _skyboxMaterial;
  135424. /**
  135425. * Gets the skybox material created by the helper.
  135426. */
  135427. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  135428. private _ground;
  135429. /**
  135430. * Gets the ground mesh created by the helper.
  135431. */
  135432. get ground(): Nullable<Mesh>;
  135433. private _groundTexture;
  135434. /**
  135435. * Gets the ground texture created by the helper.
  135436. */
  135437. get groundTexture(): Nullable<BaseTexture>;
  135438. private _groundMirror;
  135439. /**
  135440. * Gets the ground mirror created by the helper.
  135441. */
  135442. get groundMirror(): Nullable<MirrorTexture>;
  135443. /**
  135444. * Gets the ground mirror render list to helps pushing the meshes
  135445. * you wish in the ground reflection.
  135446. */
  135447. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  135448. private _groundMaterial;
  135449. /**
  135450. * Gets the ground material created by the helper.
  135451. */
  135452. get groundMaterial(): Nullable<BackgroundMaterial>;
  135453. /**
  135454. * Stores the creation options.
  135455. */
  135456. private readonly _scene;
  135457. private _options;
  135458. /**
  135459. * This observable will be notified with any error during the creation of the environment,
  135460. * mainly texture creation errors.
  135461. */
  135462. onErrorObservable: Observable<{
  135463. message?: string;
  135464. exception?: any;
  135465. }>;
  135466. /**
  135467. * constructor
  135468. * @param options Defines the options we want to customize the helper
  135469. * @param scene The scene to add the material to
  135470. */
  135471. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  135472. /**
  135473. * Updates the background according to the new options
  135474. * @param options
  135475. */
  135476. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  135477. /**
  135478. * Sets the primary color of all the available elements.
  135479. * @param color the main color to affect to the ground and the background
  135480. */
  135481. setMainColor(color: Color3): void;
  135482. /**
  135483. * Setup the image processing according to the specified options.
  135484. */
  135485. private _setupImageProcessing;
  135486. /**
  135487. * Setup the environment texture according to the specified options.
  135488. */
  135489. private _setupEnvironmentTexture;
  135490. /**
  135491. * Setup the background according to the specified options.
  135492. */
  135493. private _setupBackground;
  135494. /**
  135495. * Get the scene sizes according to the setup.
  135496. */
  135497. private _getSceneSize;
  135498. /**
  135499. * Setup the ground according to the specified options.
  135500. */
  135501. private _setupGround;
  135502. /**
  135503. * Setup the ground material according to the specified options.
  135504. */
  135505. private _setupGroundMaterial;
  135506. /**
  135507. * Setup the ground diffuse texture according to the specified options.
  135508. */
  135509. private _setupGroundDiffuseTexture;
  135510. /**
  135511. * Setup the ground mirror texture according to the specified options.
  135512. */
  135513. private _setupGroundMirrorTexture;
  135514. /**
  135515. * Setup the ground to receive the mirror texture.
  135516. */
  135517. private _setupMirrorInGroundMaterial;
  135518. /**
  135519. * Setup the skybox according to the specified options.
  135520. */
  135521. private _setupSkybox;
  135522. /**
  135523. * Setup the skybox material according to the specified options.
  135524. */
  135525. private _setupSkyboxMaterial;
  135526. /**
  135527. * Setup the skybox reflection texture according to the specified options.
  135528. */
  135529. private _setupSkyboxReflectionTexture;
  135530. private _errorHandler;
  135531. /**
  135532. * Dispose all the elements created by the Helper.
  135533. */
  135534. dispose(): void;
  135535. }
  135536. }
  135537. declare module BABYLON {
  135538. /**
  135539. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  135540. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  135541. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135542. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135543. */
  135544. export abstract class TextureDome<T extends Texture> extends TransformNode {
  135545. protected onError: Nullable<(message?: string, exception?: any) => void>;
  135546. /**
  135547. * Define the source as a Monoscopic panoramic 360/180.
  135548. */
  135549. static readonly MODE_MONOSCOPIC: number;
  135550. /**
  135551. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  135552. */
  135553. static readonly MODE_TOPBOTTOM: number;
  135554. /**
  135555. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  135556. */
  135557. static readonly MODE_SIDEBYSIDE: number;
  135558. private _halfDome;
  135559. protected _useDirectMapping: boolean;
  135560. /**
  135561. * The texture being displayed on the sphere
  135562. */
  135563. protected _texture: T;
  135564. /**
  135565. * Gets the texture being displayed on the sphere
  135566. */
  135567. get texture(): T;
  135568. /**
  135569. * Sets the texture being displayed on the sphere
  135570. */
  135571. set texture(newTexture: T);
  135572. /**
  135573. * The skybox material
  135574. */
  135575. protected _material: BackgroundMaterial;
  135576. /**
  135577. * The surface used for the dome
  135578. */
  135579. protected _mesh: Mesh;
  135580. /**
  135581. * Gets the mesh used for the dome.
  135582. */
  135583. get mesh(): Mesh;
  135584. /**
  135585. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  135586. */
  135587. private _halfDomeMask;
  135588. /**
  135589. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  135590. * Also see the options.resolution property.
  135591. */
  135592. get fovMultiplier(): number;
  135593. set fovMultiplier(value: number);
  135594. protected _textureMode: number;
  135595. /**
  135596. * Gets or set the current texture mode for the texture. It can be:
  135597. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135598. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135599. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135600. */
  135601. get textureMode(): number;
  135602. /**
  135603. * Sets the current texture mode for the texture. It can be:
  135604. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135605. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135606. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135607. */
  135608. set textureMode(value: number);
  135609. /**
  135610. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  135611. */
  135612. get halfDome(): boolean;
  135613. /**
  135614. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  135615. */
  135616. set halfDome(enabled: boolean);
  135617. /**
  135618. * Oberserver used in Stereoscopic VR Mode.
  135619. */
  135620. private _onBeforeCameraRenderObserver;
  135621. /**
  135622. * Observable raised when an error occured while loading the 360 image
  135623. */
  135624. onLoadErrorObservable: Observable<string>;
  135625. /**
  135626. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  135627. * @param name Element's name, child elements will append suffixes for their own names.
  135628. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  135629. * @param options An object containing optional or exposed sub element properties
  135630. */
  135631. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  135632. resolution?: number;
  135633. clickToPlay?: boolean;
  135634. autoPlay?: boolean;
  135635. loop?: boolean;
  135636. size?: number;
  135637. poster?: string;
  135638. faceForward?: boolean;
  135639. useDirectMapping?: boolean;
  135640. halfDomeMode?: boolean;
  135641. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  135642. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  135643. protected _changeTextureMode(value: number): void;
  135644. /**
  135645. * Releases resources associated with this node.
  135646. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  135647. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  135648. */
  135649. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  135650. }
  135651. }
  135652. declare module BABYLON {
  135653. /**
  135654. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  135655. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  135656. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135657. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135658. */
  135659. export class PhotoDome extends TextureDome<Texture> {
  135660. /**
  135661. * Define the image as a Monoscopic panoramic 360 image.
  135662. */
  135663. static readonly MODE_MONOSCOPIC: number;
  135664. /**
  135665. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  135666. */
  135667. static readonly MODE_TOPBOTTOM: number;
  135668. /**
  135669. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  135670. */
  135671. static readonly MODE_SIDEBYSIDE: number;
  135672. /**
  135673. * Gets or sets the texture being displayed on the sphere
  135674. */
  135675. get photoTexture(): Texture;
  135676. /**
  135677. * sets the texture being displayed on the sphere
  135678. */
  135679. set photoTexture(value: Texture);
  135680. /**
  135681. * Gets the current video mode for the video. It can be:
  135682. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135683. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135684. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135685. */
  135686. get imageMode(): number;
  135687. /**
  135688. * Sets the current video mode for the video. It can be:
  135689. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135690. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135691. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135692. */
  135693. set imageMode(value: number);
  135694. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  135695. }
  135696. }
  135697. declare module BABYLON {
  135698. /**
  135699. * Class used to host RGBD texture specific utilities
  135700. */
  135701. export class RGBDTextureTools {
  135702. /**
  135703. * Expand the RGBD Texture from RGBD to Half Float if possible.
  135704. * @param texture the texture to expand.
  135705. */
  135706. static ExpandRGBDTexture(texture: Texture): void;
  135707. }
  135708. }
  135709. declare module BABYLON {
  135710. /**
  135711. * Class used to host texture specific utilities
  135712. */
  135713. export class BRDFTextureTools {
  135714. /**
  135715. * Prevents texture cache collision
  135716. */
  135717. private static _instanceNumber;
  135718. /**
  135719. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  135720. * @param scene defines the hosting scene
  135721. * @returns the environment BRDF texture
  135722. */
  135723. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  135724. private static _environmentBRDFBase64Texture;
  135725. }
  135726. }
  135727. declare module BABYLON {
  135728. /**
  135729. * @hidden
  135730. */
  135731. export interface IMaterialClearCoatDefines {
  135732. CLEARCOAT: boolean;
  135733. CLEARCOAT_DEFAULTIOR: boolean;
  135734. CLEARCOAT_TEXTURE: boolean;
  135735. CLEARCOAT_TEXTUREDIRECTUV: number;
  135736. CLEARCOAT_BUMP: boolean;
  135737. CLEARCOAT_BUMPDIRECTUV: number;
  135738. CLEARCOAT_REMAP_F0: boolean;
  135739. CLEARCOAT_TINT: boolean;
  135740. CLEARCOAT_TINT_TEXTURE: boolean;
  135741. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  135742. /** @hidden */
  135743. _areTexturesDirty: boolean;
  135744. }
  135745. /**
  135746. * Define the code related to the clear coat parameters of the pbr material.
  135747. */
  135748. export class PBRClearCoatConfiguration {
  135749. /**
  135750. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135751. * The default fits with a polyurethane material.
  135752. */
  135753. private static readonly _DefaultIndexOfRefraction;
  135754. private _isEnabled;
  135755. /**
  135756. * Defines if the clear coat is enabled in the material.
  135757. */
  135758. isEnabled: boolean;
  135759. /**
  135760. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  135761. */
  135762. intensity: number;
  135763. /**
  135764. * Defines the clear coat layer roughness.
  135765. */
  135766. roughness: number;
  135767. private _indexOfRefraction;
  135768. /**
  135769. * Defines the index of refraction of the clear coat.
  135770. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135771. * The default fits with a polyurethane material.
  135772. * Changing the default value is more performance intensive.
  135773. */
  135774. indexOfRefraction: number;
  135775. private _texture;
  135776. /**
  135777. * Stores the clear coat values in a texture.
  135778. */
  135779. texture: Nullable<BaseTexture>;
  135780. private _remapF0OnInterfaceChange;
  135781. /**
  135782. * Defines if the F0 value should be remapped to account for the interface change in the material.
  135783. */
  135784. remapF0OnInterfaceChange: boolean;
  135785. private _bumpTexture;
  135786. /**
  135787. * Define the clear coat specific bump texture.
  135788. */
  135789. bumpTexture: Nullable<BaseTexture>;
  135790. private _isTintEnabled;
  135791. /**
  135792. * Defines if the clear coat tint is enabled in the material.
  135793. */
  135794. isTintEnabled: boolean;
  135795. /**
  135796. * Defines the clear coat tint of the material.
  135797. * This is only use if tint is enabled
  135798. */
  135799. tintColor: Color3;
  135800. /**
  135801. * Defines the distance at which the tint color should be found in the
  135802. * clear coat media.
  135803. * This is only use if tint is enabled
  135804. */
  135805. tintColorAtDistance: number;
  135806. /**
  135807. * Defines the clear coat layer thickness.
  135808. * This is only use if tint is enabled
  135809. */
  135810. tintThickness: number;
  135811. private _tintTexture;
  135812. /**
  135813. * Stores the clear tint values in a texture.
  135814. * rgb is tint
  135815. * a is a thickness factor
  135816. */
  135817. tintTexture: Nullable<BaseTexture>;
  135818. /** @hidden */
  135819. private _internalMarkAllSubMeshesAsTexturesDirty;
  135820. /** @hidden */
  135821. _markAllSubMeshesAsTexturesDirty(): void;
  135822. /**
  135823. * Instantiate a new istance of clear coat configuration.
  135824. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135825. */
  135826. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135827. /**
  135828. * Gets wehter the submesh is ready to be used or not.
  135829. * @param defines the list of "defines" to update.
  135830. * @param scene defines the scene the material belongs to.
  135831. * @param engine defines the engine the material belongs to.
  135832. * @param disableBumpMap defines wether the material disables bump or not.
  135833. * @returns - boolean indicating that the submesh is ready or not.
  135834. */
  135835. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  135836. /**
  135837. * Checks to see if a texture is used in the material.
  135838. * @param defines the list of "defines" to update.
  135839. * @param scene defines the scene to the material belongs to.
  135840. */
  135841. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  135842. /**
  135843. * Binds the material data.
  135844. * @param uniformBuffer defines the Uniform buffer to fill in.
  135845. * @param scene defines the scene the material belongs to.
  135846. * @param engine defines the engine the material belongs to.
  135847. * @param disableBumpMap defines wether the material disables bump or not.
  135848. * @param isFrozen defines wether the material is frozen or not.
  135849. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  135850. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  135851. */
  135852. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  135853. /**
  135854. * Checks to see if a texture is used in the material.
  135855. * @param texture - Base texture to use.
  135856. * @returns - Boolean specifying if a texture is used in the material.
  135857. */
  135858. hasTexture(texture: BaseTexture): boolean;
  135859. /**
  135860. * Returns an array of the actively used textures.
  135861. * @param activeTextures Array of BaseTextures
  135862. */
  135863. getActiveTextures(activeTextures: BaseTexture[]): void;
  135864. /**
  135865. * Returns the animatable textures.
  135866. * @param animatables Array of animatable textures.
  135867. */
  135868. getAnimatables(animatables: IAnimatable[]): void;
  135869. /**
  135870. * Disposes the resources of the material.
  135871. * @param forceDisposeTextures - Forces the disposal of all textures.
  135872. */
  135873. dispose(forceDisposeTextures?: boolean): void;
  135874. /**
  135875. * Get the current class name of the texture useful for serialization or dynamic coding.
  135876. * @returns "PBRClearCoatConfiguration"
  135877. */
  135878. getClassName(): string;
  135879. /**
  135880. * Add fallbacks to the effect fallbacks list.
  135881. * @param defines defines the Base texture to use.
  135882. * @param fallbacks defines the current fallback list.
  135883. * @param currentRank defines the current fallback rank.
  135884. * @returns the new fallback rank.
  135885. */
  135886. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135887. /**
  135888. * Add the required uniforms to the current list.
  135889. * @param uniforms defines the current uniform list.
  135890. */
  135891. static AddUniforms(uniforms: string[]): void;
  135892. /**
  135893. * Add the required samplers to the current list.
  135894. * @param samplers defines the current sampler list.
  135895. */
  135896. static AddSamplers(samplers: string[]): void;
  135897. /**
  135898. * Add the required uniforms to the current buffer.
  135899. * @param uniformBuffer defines the current uniform buffer.
  135900. */
  135901. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135902. /**
  135903. * Makes a duplicate of the current configuration into another one.
  135904. * @param clearCoatConfiguration define the config where to copy the info
  135905. */
  135906. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  135907. /**
  135908. * Serializes this clear coat configuration.
  135909. * @returns - An object with the serialized config.
  135910. */
  135911. serialize(): any;
  135912. /**
  135913. * Parses a anisotropy Configuration from a serialized object.
  135914. * @param source - Serialized object.
  135915. * @param scene Defines the scene we are parsing for
  135916. * @param rootUrl Defines the rootUrl to load from
  135917. */
  135918. parse(source: any, scene: Scene, rootUrl: string): void;
  135919. }
  135920. }
  135921. declare module BABYLON {
  135922. /**
  135923. * @hidden
  135924. */
  135925. export interface IMaterialAnisotropicDefines {
  135926. ANISOTROPIC: boolean;
  135927. ANISOTROPIC_TEXTURE: boolean;
  135928. ANISOTROPIC_TEXTUREDIRECTUV: number;
  135929. MAINUV1: boolean;
  135930. _areTexturesDirty: boolean;
  135931. _needUVs: boolean;
  135932. }
  135933. /**
  135934. * Define the code related to the anisotropic parameters of the pbr material.
  135935. */
  135936. export class PBRAnisotropicConfiguration {
  135937. private _isEnabled;
  135938. /**
  135939. * Defines if the anisotropy is enabled in the material.
  135940. */
  135941. isEnabled: boolean;
  135942. /**
  135943. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  135944. */
  135945. intensity: number;
  135946. /**
  135947. * Defines if the effect is along the tangents, bitangents or in between.
  135948. * By default, the effect is "strectching" the highlights along the tangents.
  135949. */
  135950. direction: Vector2;
  135951. private _texture;
  135952. /**
  135953. * Stores the anisotropy values in a texture.
  135954. * rg is direction (like normal from -1 to 1)
  135955. * b is a intensity
  135956. */
  135957. texture: Nullable<BaseTexture>;
  135958. /** @hidden */
  135959. private _internalMarkAllSubMeshesAsTexturesDirty;
  135960. /** @hidden */
  135961. _markAllSubMeshesAsTexturesDirty(): void;
  135962. /**
  135963. * Instantiate a new istance of anisotropy configuration.
  135964. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135965. */
  135966. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135967. /**
  135968. * Specifies that the submesh is ready to be used.
  135969. * @param defines the list of "defines" to update.
  135970. * @param scene defines the scene the material belongs to.
  135971. * @returns - boolean indicating that the submesh is ready or not.
  135972. */
  135973. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  135974. /**
  135975. * Checks to see if a texture is used in the material.
  135976. * @param defines the list of "defines" to update.
  135977. * @param mesh the mesh we are preparing the defines for.
  135978. * @param scene defines the scene the material belongs to.
  135979. */
  135980. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  135981. /**
  135982. * Binds the material data.
  135983. * @param uniformBuffer defines the Uniform buffer to fill in.
  135984. * @param scene defines the scene the material belongs to.
  135985. * @param isFrozen defines wether the material is frozen or not.
  135986. */
  135987. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  135988. /**
  135989. * Checks to see if a texture is used in the material.
  135990. * @param texture - Base texture to use.
  135991. * @returns - Boolean specifying if a texture is used in the material.
  135992. */
  135993. hasTexture(texture: BaseTexture): boolean;
  135994. /**
  135995. * Returns an array of the actively used textures.
  135996. * @param activeTextures Array of BaseTextures
  135997. */
  135998. getActiveTextures(activeTextures: BaseTexture[]): void;
  135999. /**
  136000. * Returns the animatable textures.
  136001. * @param animatables Array of animatable textures.
  136002. */
  136003. getAnimatables(animatables: IAnimatable[]): void;
  136004. /**
  136005. * Disposes the resources of the material.
  136006. * @param forceDisposeTextures - Forces the disposal of all textures.
  136007. */
  136008. dispose(forceDisposeTextures?: boolean): void;
  136009. /**
  136010. * Get the current class name of the texture useful for serialization or dynamic coding.
  136011. * @returns "PBRAnisotropicConfiguration"
  136012. */
  136013. getClassName(): string;
  136014. /**
  136015. * Add fallbacks to the effect fallbacks list.
  136016. * @param defines defines the Base texture to use.
  136017. * @param fallbacks defines the current fallback list.
  136018. * @param currentRank defines the current fallback rank.
  136019. * @returns the new fallback rank.
  136020. */
  136021. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136022. /**
  136023. * Add the required uniforms to the current list.
  136024. * @param uniforms defines the current uniform list.
  136025. */
  136026. static AddUniforms(uniforms: string[]): void;
  136027. /**
  136028. * Add the required uniforms to the current buffer.
  136029. * @param uniformBuffer defines the current uniform buffer.
  136030. */
  136031. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136032. /**
  136033. * Add the required samplers to the current list.
  136034. * @param samplers defines the current sampler list.
  136035. */
  136036. static AddSamplers(samplers: string[]): void;
  136037. /**
  136038. * Makes a duplicate of the current configuration into another one.
  136039. * @param anisotropicConfiguration define the config where to copy the info
  136040. */
  136041. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  136042. /**
  136043. * Serializes this anisotropy configuration.
  136044. * @returns - An object with the serialized config.
  136045. */
  136046. serialize(): any;
  136047. /**
  136048. * Parses a anisotropy Configuration from a serialized object.
  136049. * @param source - Serialized object.
  136050. * @param scene Defines the scene we are parsing for
  136051. * @param rootUrl Defines the rootUrl to load from
  136052. */
  136053. parse(source: any, scene: Scene, rootUrl: string): void;
  136054. }
  136055. }
  136056. declare module BABYLON {
  136057. /**
  136058. * @hidden
  136059. */
  136060. export interface IMaterialBRDFDefines {
  136061. BRDF_V_HEIGHT_CORRELATED: boolean;
  136062. MS_BRDF_ENERGY_CONSERVATION: boolean;
  136063. SPHERICAL_HARMONICS: boolean;
  136064. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  136065. /** @hidden */
  136066. _areMiscDirty: boolean;
  136067. }
  136068. /**
  136069. * Define the code related to the BRDF parameters of the pbr material.
  136070. */
  136071. export class PBRBRDFConfiguration {
  136072. /**
  136073. * Default value used for the energy conservation.
  136074. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  136075. */
  136076. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  136077. /**
  136078. * Default value used for the Smith Visibility Height Correlated mode.
  136079. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  136080. */
  136081. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  136082. /**
  136083. * Default value used for the IBL diffuse part.
  136084. * This can help switching back to the polynomials mode globally which is a tiny bit
  136085. * less GPU intensive at the drawback of a lower quality.
  136086. */
  136087. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  136088. /**
  136089. * Default value used for activating energy conservation for the specular workflow.
  136090. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  136091. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  136092. */
  136093. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  136094. private _useEnergyConservation;
  136095. /**
  136096. * Defines if the material uses energy conservation.
  136097. */
  136098. useEnergyConservation: boolean;
  136099. private _useSmithVisibilityHeightCorrelated;
  136100. /**
  136101. * LEGACY Mode set to false
  136102. * Defines if the material uses height smith correlated visibility term.
  136103. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  136104. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  136105. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  136106. * Not relying on height correlated will also disable energy conservation.
  136107. */
  136108. useSmithVisibilityHeightCorrelated: boolean;
  136109. private _useSphericalHarmonics;
  136110. /**
  136111. * LEGACY Mode set to false
  136112. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  136113. * diffuse part of the IBL.
  136114. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  136115. * to the ground truth.
  136116. */
  136117. useSphericalHarmonics: boolean;
  136118. private _useSpecularGlossinessInputEnergyConservation;
  136119. /**
  136120. * Defines if the material uses energy conservation, when the specular workflow is active.
  136121. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  136122. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  136123. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  136124. */
  136125. useSpecularGlossinessInputEnergyConservation: boolean;
  136126. /** @hidden */
  136127. private _internalMarkAllSubMeshesAsMiscDirty;
  136128. /** @hidden */
  136129. _markAllSubMeshesAsMiscDirty(): void;
  136130. /**
  136131. * Instantiate a new istance of clear coat configuration.
  136132. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  136133. */
  136134. constructor(markAllSubMeshesAsMiscDirty: () => void);
  136135. /**
  136136. * Checks to see if a texture is used in the material.
  136137. * @param defines the list of "defines" to update.
  136138. */
  136139. prepareDefines(defines: IMaterialBRDFDefines): void;
  136140. /**
  136141. * Get the current class name of the texture useful for serialization or dynamic coding.
  136142. * @returns "PBRClearCoatConfiguration"
  136143. */
  136144. getClassName(): string;
  136145. /**
  136146. * Makes a duplicate of the current configuration into another one.
  136147. * @param brdfConfiguration define the config where to copy the info
  136148. */
  136149. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  136150. /**
  136151. * Serializes this BRDF configuration.
  136152. * @returns - An object with the serialized config.
  136153. */
  136154. serialize(): any;
  136155. /**
  136156. * Parses a anisotropy Configuration from a serialized object.
  136157. * @param source - Serialized object.
  136158. * @param scene Defines the scene we are parsing for
  136159. * @param rootUrl Defines the rootUrl to load from
  136160. */
  136161. parse(source: any, scene: Scene, rootUrl: string): void;
  136162. }
  136163. }
  136164. declare module BABYLON {
  136165. /**
  136166. * @hidden
  136167. */
  136168. export interface IMaterialSheenDefines {
  136169. SHEEN: boolean;
  136170. SHEEN_TEXTURE: boolean;
  136171. SHEEN_TEXTUREDIRECTUV: number;
  136172. SHEEN_LINKWITHALBEDO: boolean;
  136173. SHEEN_ROUGHNESS: boolean;
  136174. SHEEN_ALBEDOSCALING: boolean;
  136175. /** @hidden */
  136176. _areTexturesDirty: boolean;
  136177. }
  136178. /**
  136179. * Define the code related to the Sheen parameters of the pbr material.
  136180. */
  136181. export class PBRSheenConfiguration {
  136182. private _isEnabled;
  136183. /**
  136184. * Defines if the material uses sheen.
  136185. */
  136186. isEnabled: boolean;
  136187. private _linkSheenWithAlbedo;
  136188. /**
  136189. * Defines if the sheen is linked to the sheen color.
  136190. */
  136191. linkSheenWithAlbedo: boolean;
  136192. /**
  136193. * Defines the sheen intensity.
  136194. */
  136195. intensity: number;
  136196. /**
  136197. * Defines the sheen color.
  136198. */
  136199. color: Color3;
  136200. private _texture;
  136201. /**
  136202. * Stores the sheen tint values in a texture.
  136203. * rgb is tint
  136204. * a is a intensity or roughness if roughness has been defined
  136205. */
  136206. texture: Nullable<BaseTexture>;
  136207. private _roughness;
  136208. /**
  136209. * Defines the sheen roughness.
  136210. * It is not taken into account if linkSheenWithAlbedo is true.
  136211. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  136212. */
  136213. roughness: Nullable<number>;
  136214. private _albedoScaling;
  136215. /**
  136216. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  136217. * It allows the strength of the sheen effect to not depend on the base color of the material,
  136218. * making it easier to setup and tweak the effect
  136219. */
  136220. albedoScaling: boolean;
  136221. /** @hidden */
  136222. private _internalMarkAllSubMeshesAsTexturesDirty;
  136223. /** @hidden */
  136224. _markAllSubMeshesAsTexturesDirty(): void;
  136225. /**
  136226. * Instantiate a new istance of clear coat configuration.
  136227. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136228. */
  136229. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  136230. /**
  136231. * Specifies that the submesh is ready to be used.
  136232. * @param defines the list of "defines" to update.
  136233. * @param scene defines the scene the material belongs to.
  136234. * @returns - boolean indicating that the submesh is ready or not.
  136235. */
  136236. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  136237. /**
  136238. * Checks to see if a texture is used in the material.
  136239. * @param defines the list of "defines" to update.
  136240. * @param scene defines the scene the material belongs to.
  136241. */
  136242. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  136243. /**
  136244. * Binds the material data.
  136245. * @param uniformBuffer defines the Uniform buffer to fill in.
  136246. * @param scene defines the scene the material belongs to.
  136247. * @param isFrozen defines wether the material is frozen or not.
  136248. */
  136249. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  136250. /**
  136251. * Checks to see if a texture is used in the material.
  136252. * @param texture - Base texture to use.
  136253. * @returns - Boolean specifying if a texture is used in the material.
  136254. */
  136255. hasTexture(texture: BaseTexture): boolean;
  136256. /**
  136257. * Returns an array of the actively used textures.
  136258. * @param activeTextures Array of BaseTextures
  136259. */
  136260. getActiveTextures(activeTextures: BaseTexture[]): void;
  136261. /**
  136262. * Returns the animatable textures.
  136263. * @param animatables Array of animatable textures.
  136264. */
  136265. getAnimatables(animatables: IAnimatable[]): void;
  136266. /**
  136267. * Disposes the resources of the material.
  136268. * @param forceDisposeTextures - Forces the disposal of all textures.
  136269. */
  136270. dispose(forceDisposeTextures?: boolean): void;
  136271. /**
  136272. * Get the current class name of the texture useful for serialization or dynamic coding.
  136273. * @returns "PBRSheenConfiguration"
  136274. */
  136275. getClassName(): string;
  136276. /**
  136277. * Add fallbacks to the effect fallbacks list.
  136278. * @param defines defines the Base texture to use.
  136279. * @param fallbacks defines the current fallback list.
  136280. * @param currentRank defines the current fallback rank.
  136281. * @returns the new fallback rank.
  136282. */
  136283. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136284. /**
  136285. * Add the required uniforms to the current list.
  136286. * @param uniforms defines the current uniform list.
  136287. */
  136288. static AddUniforms(uniforms: string[]): void;
  136289. /**
  136290. * Add the required uniforms to the current buffer.
  136291. * @param uniformBuffer defines the current uniform buffer.
  136292. */
  136293. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136294. /**
  136295. * Add the required samplers to the current list.
  136296. * @param samplers defines the current sampler list.
  136297. */
  136298. static AddSamplers(samplers: string[]): void;
  136299. /**
  136300. * Makes a duplicate of the current configuration into another one.
  136301. * @param sheenConfiguration define the config where to copy the info
  136302. */
  136303. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  136304. /**
  136305. * Serializes this BRDF configuration.
  136306. * @returns - An object with the serialized config.
  136307. */
  136308. serialize(): any;
  136309. /**
  136310. * Parses a anisotropy Configuration from a serialized object.
  136311. * @param source - Serialized object.
  136312. * @param scene Defines the scene we are parsing for
  136313. * @param rootUrl Defines the rootUrl to load from
  136314. */
  136315. parse(source: any, scene: Scene, rootUrl: string): void;
  136316. }
  136317. }
  136318. declare module BABYLON {
  136319. /**
  136320. * @hidden
  136321. */
  136322. export interface IMaterialSubSurfaceDefines {
  136323. SUBSURFACE: boolean;
  136324. SS_REFRACTION: boolean;
  136325. SS_TRANSLUCENCY: boolean;
  136326. SS_SCATTERING: boolean;
  136327. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136328. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136329. SS_REFRACTIONMAP_3D: boolean;
  136330. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136331. SS_LODINREFRACTIONALPHA: boolean;
  136332. SS_GAMMAREFRACTION: boolean;
  136333. SS_RGBDREFRACTION: boolean;
  136334. SS_LINEARSPECULARREFRACTION: boolean;
  136335. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136336. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136337. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136338. /** @hidden */
  136339. _areTexturesDirty: boolean;
  136340. }
  136341. /**
  136342. * Define the code related to the sub surface parameters of the pbr material.
  136343. */
  136344. export class PBRSubSurfaceConfiguration {
  136345. private _isRefractionEnabled;
  136346. /**
  136347. * Defines if the refraction is enabled in the material.
  136348. */
  136349. isRefractionEnabled: boolean;
  136350. private _isTranslucencyEnabled;
  136351. /**
  136352. * Defines if the translucency is enabled in the material.
  136353. */
  136354. isTranslucencyEnabled: boolean;
  136355. private _isScatteringEnabled;
  136356. /**
  136357. * Defines if the sub surface scattering is enabled in the material.
  136358. */
  136359. isScatteringEnabled: boolean;
  136360. private _scatteringDiffusionProfileIndex;
  136361. /**
  136362. * Diffusion profile for subsurface scattering.
  136363. * Useful for better scattering in the skins or foliages.
  136364. */
  136365. get scatteringDiffusionProfile(): Nullable<Color3>;
  136366. set scatteringDiffusionProfile(c: Nullable<Color3>);
  136367. /**
  136368. * Defines the refraction intensity of the material.
  136369. * The refraction when enabled replaces the Diffuse part of the material.
  136370. * The intensity helps transitionning between diffuse and refraction.
  136371. */
  136372. refractionIntensity: number;
  136373. /**
  136374. * Defines the translucency intensity of the material.
  136375. * When translucency has been enabled, this defines how much of the "translucency"
  136376. * is addded to the diffuse part of the material.
  136377. */
  136378. translucencyIntensity: number;
  136379. /**
  136380. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  136381. */
  136382. useAlbedoToTintRefraction: boolean;
  136383. private _thicknessTexture;
  136384. /**
  136385. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  136386. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  136387. * 0 would mean minimumThickness
  136388. * 1 would mean maximumThickness
  136389. * The other channels might be use as a mask to vary the different effects intensity.
  136390. */
  136391. thicknessTexture: Nullable<BaseTexture>;
  136392. private _refractionTexture;
  136393. /**
  136394. * Defines the texture to use for refraction.
  136395. */
  136396. refractionTexture: Nullable<BaseTexture>;
  136397. private _indexOfRefraction;
  136398. /**
  136399. * Index of refraction of the material base layer.
  136400. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136401. *
  136402. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  136403. *
  136404. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  136405. */
  136406. indexOfRefraction: number;
  136407. private _volumeIndexOfRefraction;
  136408. /**
  136409. * Index of refraction of the material's volume.
  136410. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136411. *
  136412. * This ONLY impacts refraction. If not provided or given a non-valid value,
  136413. * the volume will use the same IOR as the surface.
  136414. */
  136415. get volumeIndexOfRefraction(): number;
  136416. set volumeIndexOfRefraction(value: number);
  136417. private _invertRefractionY;
  136418. /**
  136419. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  136420. */
  136421. invertRefractionY: boolean;
  136422. private _linkRefractionWithTransparency;
  136423. /**
  136424. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  136425. * Materials half opaque for instance using refraction could benefit from this control.
  136426. */
  136427. linkRefractionWithTransparency: boolean;
  136428. /**
  136429. * Defines the minimum thickness stored in the thickness map.
  136430. * If no thickness map is defined, this value will be used to simulate thickness.
  136431. */
  136432. minimumThickness: number;
  136433. /**
  136434. * Defines the maximum thickness stored in the thickness map.
  136435. */
  136436. maximumThickness: number;
  136437. /**
  136438. * Defines the volume tint of the material.
  136439. * This is used for both translucency and scattering.
  136440. */
  136441. tintColor: Color3;
  136442. /**
  136443. * Defines the distance at which the tint color should be found in the media.
  136444. * This is used for refraction only.
  136445. */
  136446. tintColorAtDistance: number;
  136447. /**
  136448. * Defines how far each channel transmit through the media.
  136449. * It is defined as a color to simplify it selection.
  136450. */
  136451. diffusionDistance: Color3;
  136452. private _useMaskFromThicknessTexture;
  136453. /**
  136454. * Stores the intensity of the different subsurface effects in the thickness texture.
  136455. * * the green channel is the translucency intensity.
  136456. * * the blue channel is the scattering intensity.
  136457. * * the alpha channel is the refraction intensity.
  136458. */
  136459. useMaskFromThicknessTexture: boolean;
  136460. private _scene;
  136461. /** @hidden */
  136462. private _internalMarkAllSubMeshesAsTexturesDirty;
  136463. private _internalMarkScenePrePassDirty;
  136464. /** @hidden */
  136465. _markAllSubMeshesAsTexturesDirty(): void;
  136466. /** @hidden */
  136467. _markScenePrePassDirty(): void;
  136468. /**
  136469. * Instantiate a new istance of sub surface configuration.
  136470. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136471. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  136472. * @param scene The scene
  136473. */
  136474. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  136475. /**
  136476. * Gets wehter the submesh is ready to be used or not.
  136477. * @param defines the list of "defines" to update.
  136478. * @param scene defines the scene the material belongs to.
  136479. * @returns - boolean indicating that the submesh is ready or not.
  136480. */
  136481. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  136482. /**
  136483. * Checks to see if a texture is used in the material.
  136484. * @param defines the list of "defines" to update.
  136485. * @param scene defines the scene to the material belongs to.
  136486. */
  136487. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  136488. /**
  136489. * Binds the material data.
  136490. * @param uniformBuffer defines the Uniform buffer to fill in.
  136491. * @param scene defines the scene the material belongs to.
  136492. * @param engine defines the engine the material belongs to.
  136493. * @param isFrozen defines whether the material is frozen or not.
  136494. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  136495. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  136496. */
  136497. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  136498. /**
  136499. * Unbinds the material from the mesh.
  136500. * @param activeEffect defines the effect that should be unbound from.
  136501. * @returns true if unbound, otherwise false
  136502. */
  136503. unbind(activeEffect: Effect): boolean;
  136504. /**
  136505. * Returns the texture used for refraction or null if none is used.
  136506. * @param scene defines the scene the material belongs to.
  136507. * @returns - Refraction texture if present. If no refraction texture and refraction
  136508. * is linked with transparency, returns environment texture. Otherwise, returns null.
  136509. */
  136510. private _getRefractionTexture;
  136511. /**
  136512. * Returns true if alpha blending should be disabled.
  136513. */
  136514. get disableAlphaBlending(): boolean;
  136515. /**
  136516. * Fills the list of render target textures.
  136517. * @param renderTargets the list of render targets to update
  136518. */
  136519. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  136520. /**
  136521. * Checks to see if a texture is used in the material.
  136522. * @param texture - Base texture to use.
  136523. * @returns - Boolean specifying if a texture is used in the material.
  136524. */
  136525. hasTexture(texture: BaseTexture): boolean;
  136526. /**
  136527. * Gets a boolean indicating that current material needs to register RTT
  136528. * @returns true if this uses a render target otherwise false.
  136529. */
  136530. hasRenderTargetTextures(): boolean;
  136531. /**
  136532. * Returns an array of the actively used textures.
  136533. * @param activeTextures Array of BaseTextures
  136534. */
  136535. getActiveTextures(activeTextures: BaseTexture[]): void;
  136536. /**
  136537. * Returns the animatable textures.
  136538. * @param animatables Array of animatable textures.
  136539. */
  136540. getAnimatables(animatables: IAnimatable[]): void;
  136541. /**
  136542. * Disposes the resources of the material.
  136543. * @param forceDisposeTextures - Forces the disposal of all textures.
  136544. */
  136545. dispose(forceDisposeTextures?: boolean): void;
  136546. /**
  136547. * Get the current class name of the texture useful for serialization or dynamic coding.
  136548. * @returns "PBRSubSurfaceConfiguration"
  136549. */
  136550. getClassName(): string;
  136551. /**
  136552. * Add fallbacks to the effect fallbacks list.
  136553. * @param defines defines the Base texture to use.
  136554. * @param fallbacks defines the current fallback list.
  136555. * @param currentRank defines the current fallback rank.
  136556. * @returns the new fallback rank.
  136557. */
  136558. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136559. /**
  136560. * Add the required uniforms to the current list.
  136561. * @param uniforms defines the current uniform list.
  136562. */
  136563. static AddUniforms(uniforms: string[]): void;
  136564. /**
  136565. * Add the required samplers to the current list.
  136566. * @param samplers defines the current sampler list.
  136567. */
  136568. static AddSamplers(samplers: string[]): void;
  136569. /**
  136570. * Add the required uniforms to the current buffer.
  136571. * @param uniformBuffer defines the current uniform buffer.
  136572. */
  136573. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136574. /**
  136575. * Makes a duplicate of the current configuration into another one.
  136576. * @param configuration define the config where to copy the info
  136577. */
  136578. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  136579. /**
  136580. * Serializes this Sub Surface configuration.
  136581. * @returns - An object with the serialized config.
  136582. */
  136583. serialize(): any;
  136584. /**
  136585. * Parses a anisotropy Configuration from a serialized object.
  136586. * @param source - Serialized object.
  136587. * @param scene Defines the scene we are parsing for
  136588. * @param rootUrl Defines the rootUrl to load from
  136589. */
  136590. parse(source: any, scene: Scene, rootUrl: string): void;
  136591. }
  136592. }
  136593. declare module BABYLON {
  136594. /** @hidden */
  136595. export var pbrFragmentDeclaration: {
  136596. name: string;
  136597. shader: string;
  136598. };
  136599. }
  136600. declare module BABYLON {
  136601. /** @hidden */
  136602. export var pbrUboDeclaration: {
  136603. name: string;
  136604. shader: string;
  136605. };
  136606. }
  136607. declare module BABYLON {
  136608. /** @hidden */
  136609. export var pbrFragmentExtraDeclaration: {
  136610. name: string;
  136611. shader: string;
  136612. };
  136613. }
  136614. declare module BABYLON {
  136615. /** @hidden */
  136616. export var pbrFragmentSamplersDeclaration: {
  136617. name: string;
  136618. shader: string;
  136619. };
  136620. }
  136621. declare module BABYLON {
  136622. /** @hidden */
  136623. export var subSurfaceScatteringFunctions: {
  136624. name: string;
  136625. shader: string;
  136626. };
  136627. }
  136628. declare module BABYLON {
  136629. /** @hidden */
  136630. export var importanceSampling: {
  136631. name: string;
  136632. shader: string;
  136633. };
  136634. }
  136635. declare module BABYLON {
  136636. /** @hidden */
  136637. export var pbrHelperFunctions: {
  136638. name: string;
  136639. shader: string;
  136640. };
  136641. }
  136642. declare module BABYLON {
  136643. /** @hidden */
  136644. export var harmonicsFunctions: {
  136645. name: string;
  136646. shader: string;
  136647. };
  136648. }
  136649. declare module BABYLON {
  136650. /** @hidden */
  136651. export var pbrDirectLightingSetupFunctions: {
  136652. name: string;
  136653. shader: string;
  136654. };
  136655. }
  136656. declare module BABYLON {
  136657. /** @hidden */
  136658. export var pbrDirectLightingFalloffFunctions: {
  136659. name: string;
  136660. shader: string;
  136661. };
  136662. }
  136663. declare module BABYLON {
  136664. /** @hidden */
  136665. export var pbrBRDFFunctions: {
  136666. name: string;
  136667. shader: string;
  136668. };
  136669. }
  136670. declare module BABYLON {
  136671. /** @hidden */
  136672. export var hdrFilteringFunctions: {
  136673. name: string;
  136674. shader: string;
  136675. };
  136676. }
  136677. declare module BABYLON {
  136678. /** @hidden */
  136679. export var pbrDirectLightingFunctions: {
  136680. name: string;
  136681. shader: string;
  136682. };
  136683. }
  136684. declare module BABYLON {
  136685. /** @hidden */
  136686. export var pbrIBLFunctions: {
  136687. name: string;
  136688. shader: string;
  136689. };
  136690. }
  136691. declare module BABYLON {
  136692. /** @hidden */
  136693. export var pbrBlockAlbedoOpacity: {
  136694. name: string;
  136695. shader: string;
  136696. };
  136697. }
  136698. declare module BABYLON {
  136699. /** @hidden */
  136700. export var pbrBlockReflectivity: {
  136701. name: string;
  136702. shader: string;
  136703. };
  136704. }
  136705. declare module BABYLON {
  136706. /** @hidden */
  136707. export var pbrBlockAmbientOcclusion: {
  136708. name: string;
  136709. shader: string;
  136710. };
  136711. }
  136712. declare module BABYLON {
  136713. /** @hidden */
  136714. export var pbrBlockAlphaFresnel: {
  136715. name: string;
  136716. shader: string;
  136717. };
  136718. }
  136719. declare module BABYLON {
  136720. /** @hidden */
  136721. export var pbrBlockAnisotropic: {
  136722. name: string;
  136723. shader: string;
  136724. };
  136725. }
  136726. declare module BABYLON {
  136727. /** @hidden */
  136728. export var pbrBlockReflection: {
  136729. name: string;
  136730. shader: string;
  136731. };
  136732. }
  136733. declare module BABYLON {
  136734. /** @hidden */
  136735. export var pbrBlockSheen: {
  136736. name: string;
  136737. shader: string;
  136738. };
  136739. }
  136740. declare module BABYLON {
  136741. /** @hidden */
  136742. export var pbrBlockClearcoat: {
  136743. name: string;
  136744. shader: string;
  136745. };
  136746. }
  136747. declare module BABYLON {
  136748. /** @hidden */
  136749. export var pbrBlockSubSurface: {
  136750. name: string;
  136751. shader: string;
  136752. };
  136753. }
  136754. declare module BABYLON {
  136755. /** @hidden */
  136756. export var pbrBlockNormalGeometric: {
  136757. name: string;
  136758. shader: string;
  136759. };
  136760. }
  136761. declare module BABYLON {
  136762. /** @hidden */
  136763. export var pbrBlockNormalFinal: {
  136764. name: string;
  136765. shader: string;
  136766. };
  136767. }
  136768. declare module BABYLON {
  136769. /** @hidden */
  136770. export var pbrBlockLightmapInit: {
  136771. name: string;
  136772. shader: string;
  136773. };
  136774. }
  136775. declare module BABYLON {
  136776. /** @hidden */
  136777. export var pbrBlockGeometryInfo: {
  136778. name: string;
  136779. shader: string;
  136780. };
  136781. }
  136782. declare module BABYLON {
  136783. /** @hidden */
  136784. export var pbrBlockReflectance0: {
  136785. name: string;
  136786. shader: string;
  136787. };
  136788. }
  136789. declare module BABYLON {
  136790. /** @hidden */
  136791. export var pbrBlockReflectance: {
  136792. name: string;
  136793. shader: string;
  136794. };
  136795. }
  136796. declare module BABYLON {
  136797. /** @hidden */
  136798. export var pbrBlockDirectLighting: {
  136799. name: string;
  136800. shader: string;
  136801. };
  136802. }
  136803. declare module BABYLON {
  136804. /** @hidden */
  136805. export var pbrBlockFinalLitComponents: {
  136806. name: string;
  136807. shader: string;
  136808. };
  136809. }
  136810. declare module BABYLON {
  136811. /** @hidden */
  136812. export var pbrBlockFinalUnlitComponents: {
  136813. name: string;
  136814. shader: string;
  136815. };
  136816. }
  136817. declare module BABYLON {
  136818. /** @hidden */
  136819. export var pbrBlockFinalColorComposition: {
  136820. name: string;
  136821. shader: string;
  136822. };
  136823. }
  136824. declare module BABYLON {
  136825. /** @hidden */
  136826. export var pbrBlockImageProcessing: {
  136827. name: string;
  136828. shader: string;
  136829. };
  136830. }
  136831. declare module BABYLON {
  136832. /** @hidden */
  136833. export var pbrDebug: {
  136834. name: string;
  136835. shader: string;
  136836. };
  136837. }
  136838. declare module BABYLON {
  136839. /** @hidden */
  136840. export var pbrPixelShader: {
  136841. name: string;
  136842. shader: string;
  136843. };
  136844. }
  136845. declare module BABYLON {
  136846. /** @hidden */
  136847. export var pbrVertexDeclaration: {
  136848. name: string;
  136849. shader: string;
  136850. };
  136851. }
  136852. declare module BABYLON {
  136853. /** @hidden */
  136854. export var pbrVertexShader: {
  136855. name: string;
  136856. shader: string;
  136857. };
  136858. }
  136859. declare module BABYLON {
  136860. /**
  136861. * Manages the defines for the PBR Material.
  136862. * @hidden
  136863. */
  136864. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  136865. PBR: boolean;
  136866. NUM_SAMPLES: string;
  136867. REALTIME_FILTERING: boolean;
  136868. MAINUV1: boolean;
  136869. MAINUV2: boolean;
  136870. UV1: boolean;
  136871. UV2: boolean;
  136872. ALBEDO: boolean;
  136873. GAMMAALBEDO: boolean;
  136874. ALBEDODIRECTUV: number;
  136875. VERTEXCOLOR: boolean;
  136876. DETAIL: boolean;
  136877. DETAILDIRECTUV: number;
  136878. DETAIL_NORMALBLENDMETHOD: number;
  136879. AMBIENT: boolean;
  136880. AMBIENTDIRECTUV: number;
  136881. AMBIENTINGRAYSCALE: boolean;
  136882. OPACITY: boolean;
  136883. VERTEXALPHA: boolean;
  136884. OPACITYDIRECTUV: number;
  136885. OPACITYRGB: boolean;
  136886. ALPHATEST: boolean;
  136887. DEPTHPREPASS: boolean;
  136888. ALPHABLEND: boolean;
  136889. ALPHAFROMALBEDO: boolean;
  136890. ALPHATESTVALUE: string;
  136891. SPECULAROVERALPHA: boolean;
  136892. RADIANCEOVERALPHA: boolean;
  136893. ALPHAFRESNEL: boolean;
  136894. LINEARALPHAFRESNEL: boolean;
  136895. PREMULTIPLYALPHA: boolean;
  136896. EMISSIVE: boolean;
  136897. EMISSIVEDIRECTUV: number;
  136898. REFLECTIVITY: boolean;
  136899. REFLECTIVITYDIRECTUV: number;
  136900. SPECULARTERM: boolean;
  136901. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  136902. MICROSURFACEAUTOMATIC: boolean;
  136903. LODBASEDMICROSFURACE: boolean;
  136904. MICROSURFACEMAP: boolean;
  136905. MICROSURFACEMAPDIRECTUV: number;
  136906. METALLICWORKFLOW: boolean;
  136907. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  136908. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  136909. METALLNESSSTOREINMETALMAPBLUE: boolean;
  136910. AOSTOREINMETALMAPRED: boolean;
  136911. METALLIC_REFLECTANCE: boolean;
  136912. METALLIC_REFLECTANCEDIRECTUV: number;
  136913. ENVIRONMENTBRDF: boolean;
  136914. ENVIRONMENTBRDF_RGBD: boolean;
  136915. NORMAL: boolean;
  136916. TANGENT: boolean;
  136917. BUMP: boolean;
  136918. BUMPDIRECTUV: number;
  136919. OBJECTSPACE_NORMALMAP: boolean;
  136920. PARALLAX: boolean;
  136921. PARALLAXOCCLUSION: boolean;
  136922. NORMALXYSCALE: boolean;
  136923. LIGHTMAP: boolean;
  136924. LIGHTMAPDIRECTUV: number;
  136925. USELIGHTMAPASSHADOWMAP: boolean;
  136926. GAMMALIGHTMAP: boolean;
  136927. RGBDLIGHTMAP: boolean;
  136928. REFLECTION: boolean;
  136929. REFLECTIONMAP_3D: boolean;
  136930. REFLECTIONMAP_SPHERICAL: boolean;
  136931. REFLECTIONMAP_PLANAR: boolean;
  136932. REFLECTIONMAP_CUBIC: boolean;
  136933. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  136934. REFLECTIONMAP_PROJECTION: boolean;
  136935. REFLECTIONMAP_SKYBOX: boolean;
  136936. REFLECTIONMAP_EXPLICIT: boolean;
  136937. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  136938. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  136939. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  136940. INVERTCUBICMAP: boolean;
  136941. USESPHERICALFROMREFLECTIONMAP: boolean;
  136942. USEIRRADIANCEMAP: boolean;
  136943. SPHERICAL_HARMONICS: boolean;
  136944. USESPHERICALINVERTEX: boolean;
  136945. REFLECTIONMAP_OPPOSITEZ: boolean;
  136946. LODINREFLECTIONALPHA: boolean;
  136947. GAMMAREFLECTION: boolean;
  136948. RGBDREFLECTION: boolean;
  136949. LINEARSPECULARREFLECTION: boolean;
  136950. RADIANCEOCCLUSION: boolean;
  136951. HORIZONOCCLUSION: boolean;
  136952. INSTANCES: boolean;
  136953. THIN_INSTANCES: boolean;
  136954. PREPASS: boolean;
  136955. PREPASS_IRRADIANCE: boolean;
  136956. PREPASS_IRRADIANCE_INDEX: number;
  136957. PREPASS_ALBEDO: boolean;
  136958. PREPASS_ALBEDO_INDEX: number;
  136959. PREPASS_DEPTHNORMAL: boolean;
  136960. PREPASS_DEPTHNORMAL_INDEX: number;
  136961. SCENE_MRT_COUNT: number;
  136962. NUM_BONE_INFLUENCERS: number;
  136963. BonesPerMesh: number;
  136964. BONETEXTURE: boolean;
  136965. NONUNIFORMSCALING: boolean;
  136966. MORPHTARGETS: boolean;
  136967. MORPHTARGETS_NORMAL: boolean;
  136968. MORPHTARGETS_TANGENT: boolean;
  136969. MORPHTARGETS_UV: boolean;
  136970. NUM_MORPH_INFLUENCERS: number;
  136971. IMAGEPROCESSING: boolean;
  136972. VIGNETTE: boolean;
  136973. VIGNETTEBLENDMODEMULTIPLY: boolean;
  136974. VIGNETTEBLENDMODEOPAQUE: boolean;
  136975. TONEMAPPING: boolean;
  136976. TONEMAPPING_ACES: boolean;
  136977. CONTRAST: boolean;
  136978. COLORCURVES: boolean;
  136979. COLORGRADING: boolean;
  136980. COLORGRADING3D: boolean;
  136981. SAMPLER3DGREENDEPTH: boolean;
  136982. SAMPLER3DBGRMAP: boolean;
  136983. IMAGEPROCESSINGPOSTPROCESS: boolean;
  136984. EXPOSURE: boolean;
  136985. MULTIVIEW: boolean;
  136986. USEPHYSICALLIGHTFALLOFF: boolean;
  136987. USEGLTFLIGHTFALLOFF: boolean;
  136988. TWOSIDEDLIGHTING: boolean;
  136989. SHADOWFLOAT: boolean;
  136990. CLIPPLANE: boolean;
  136991. CLIPPLANE2: boolean;
  136992. CLIPPLANE3: boolean;
  136993. CLIPPLANE4: boolean;
  136994. CLIPPLANE5: boolean;
  136995. CLIPPLANE6: boolean;
  136996. POINTSIZE: boolean;
  136997. FOG: boolean;
  136998. LOGARITHMICDEPTH: boolean;
  136999. FORCENORMALFORWARD: boolean;
  137000. SPECULARAA: boolean;
  137001. CLEARCOAT: boolean;
  137002. CLEARCOAT_DEFAULTIOR: boolean;
  137003. CLEARCOAT_TEXTURE: boolean;
  137004. CLEARCOAT_TEXTUREDIRECTUV: number;
  137005. CLEARCOAT_BUMP: boolean;
  137006. CLEARCOAT_BUMPDIRECTUV: number;
  137007. CLEARCOAT_REMAP_F0: boolean;
  137008. CLEARCOAT_TINT: boolean;
  137009. CLEARCOAT_TINT_TEXTURE: boolean;
  137010. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  137011. ANISOTROPIC: boolean;
  137012. ANISOTROPIC_TEXTURE: boolean;
  137013. ANISOTROPIC_TEXTUREDIRECTUV: number;
  137014. BRDF_V_HEIGHT_CORRELATED: boolean;
  137015. MS_BRDF_ENERGY_CONSERVATION: boolean;
  137016. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  137017. SHEEN: boolean;
  137018. SHEEN_TEXTURE: boolean;
  137019. SHEEN_TEXTUREDIRECTUV: number;
  137020. SHEEN_LINKWITHALBEDO: boolean;
  137021. SHEEN_ROUGHNESS: boolean;
  137022. SHEEN_ALBEDOSCALING: boolean;
  137023. SUBSURFACE: boolean;
  137024. SS_REFRACTION: boolean;
  137025. SS_TRANSLUCENCY: boolean;
  137026. SS_SCATTERING: boolean;
  137027. SS_THICKNESSANDMASK_TEXTURE: boolean;
  137028. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  137029. SS_REFRACTIONMAP_3D: boolean;
  137030. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  137031. SS_LODINREFRACTIONALPHA: boolean;
  137032. SS_GAMMAREFRACTION: boolean;
  137033. SS_RGBDREFRACTION: boolean;
  137034. SS_LINEARSPECULARREFRACTION: boolean;
  137035. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  137036. SS_ALBEDOFORREFRACTIONTINT: boolean;
  137037. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  137038. UNLIT: boolean;
  137039. DEBUGMODE: number;
  137040. /**
  137041. * Initializes the PBR Material defines.
  137042. */
  137043. constructor();
  137044. /**
  137045. * Resets the PBR Material defines.
  137046. */
  137047. reset(): void;
  137048. }
  137049. /**
  137050. * The Physically based material base class of BJS.
  137051. *
  137052. * This offers the main features of a standard PBR material.
  137053. * For more information, please refer to the documentation :
  137054. * https://doc.babylonjs.com/how_to/physically_based_rendering
  137055. */
  137056. export abstract class PBRBaseMaterial extends PushMaterial {
  137057. /**
  137058. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  137059. */
  137060. static readonly PBRMATERIAL_OPAQUE: number;
  137061. /**
  137062. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  137063. */
  137064. static readonly PBRMATERIAL_ALPHATEST: number;
  137065. /**
  137066. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137067. */
  137068. static readonly PBRMATERIAL_ALPHABLEND: number;
  137069. /**
  137070. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137071. * They are also discarded below the alpha cutoff threshold to improve performances.
  137072. */
  137073. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  137074. /**
  137075. * Defines the default value of how much AO map is occluding the analytical lights
  137076. * (point spot...).
  137077. */
  137078. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  137079. /**
  137080. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  137081. */
  137082. static readonly LIGHTFALLOFF_PHYSICAL: number;
  137083. /**
  137084. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  137085. * to enhance interoperability with other engines.
  137086. */
  137087. static readonly LIGHTFALLOFF_GLTF: number;
  137088. /**
  137089. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  137090. * to enhance interoperability with other materials.
  137091. */
  137092. static readonly LIGHTFALLOFF_STANDARD: number;
  137093. /**
  137094. * Intensity of the direct lights e.g. the four lights available in your scene.
  137095. * This impacts both the direct diffuse and specular highlights.
  137096. */
  137097. protected _directIntensity: number;
  137098. /**
  137099. * Intensity of the emissive part of the material.
  137100. * This helps controlling the emissive effect without modifying the emissive color.
  137101. */
  137102. protected _emissiveIntensity: number;
  137103. /**
  137104. * Intensity of the environment e.g. how much the environment will light the object
  137105. * either through harmonics for rough material or through the refelction for shiny ones.
  137106. */
  137107. protected _environmentIntensity: number;
  137108. /**
  137109. * This is a special control allowing the reduction of the specular highlights coming from the
  137110. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137111. */
  137112. protected _specularIntensity: number;
  137113. /**
  137114. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  137115. */
  137116. private _lightingInfos;
  137117. /**
  137118. * Debug Control allowing disabling the bump map on this material.
  137119. */
  137120. protected _disableBumpMap: boolean;
  137121. /**
  137122. * AKA Diffuse Texture in standard nomenclature.
  137123. */
  137124. protected _albedoTexture: Nullable<BaseTexture>;
  137125. /**
  137126. * AKA Occlusion Texture in other nomenclature.
  137127. */
  137128. protected _ambientTexture: Nullable<BaseTexture>;
  137129. /**
  137130. * AKA Occlusion Texture Intensity in other nomenclature.
  137131. */
  137132. protected _ambientTextureStrength: number;
  137133. /**
  137134. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137135. * 1 means it completely occludes it
  137136. * 0 mean it has no impact
  137137. */
  137138. protected _ambientTextureImpactOnAnalyticalLights: number;
  137139. /**
  137140. * Stores the alpha values in a texture.
  137141. */
  137142. protected _opacityTexture: Nullable<BaseTexture>;
  137143. /**
  137144. * Stores the reflection values in a texture.
  137145. */
  137146. protected _reflectionTexture: Nullable<BaseTexture>;
  137147. /**
  137148. * Stores the emissive values in a texture.
  137149. */
  137150. protected _emissiveTexture: Nullable<BaseTexture>;
  137151. /**
  137152. * AKA Specular texture in other nomenclature.
  137153. */
  137154. protected _reflectivityTexture: Nullable<BaseTexture>;
  137155. /**
  137156. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137157. */
  137158. protected _metallicTexture: Nullable<BaseTexture>;
  137159. /**
  137160. * Specifies the metallic scalar of the metallic/roughness workflow.
  137161. * Can also be used to scale the metalness values of the metallic texture.
  137162. */
  137163. protected _metallic: Nullable<number>;
  137164. /**
  137165. * Specifies the roughness scalar of the metallic/roughness workflow.
  137166. * Can also be used to scale the roughness values of the metallic texture.
  137167. */
  137168. protected _roughness: Nullable<number>;
  137169. /**
  137170. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137171. * By default the indexOfrefraction is used to compute F0;
  137172. *
  137173. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137174. *
  137175. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137176. * F90 = metallicReflectanceColor;
  137177. */
  137178. protected _metallicF0Factor: number;
  137179. /**
  137180. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137181. * By default the F90 is always 1;
  137182. *
  137183. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137184. *
  137185. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137186. * F90 = metallicReflectanceColor;
  137187. */
  137188. protected _metallicReflectanceColor: Color3;
  137189. /**
  137190. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137191. * This is multiply against the scalar values defined in the material.
  137192. */
  137193. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  137194. /**
  137195. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137196. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137197. */
  137198. protected _microSurfaceTexture: Nullable<BaseTexture>;
  137199. /**
  137200. * Stores surface normal data used to displace a mesh in a texture.
  137201. */
  137202. protected _bumpTexture: Nullable<BaseTexture>;
  137203. /**
  137204. * Stores the pre-calculated light information of a mesh in a texture.
  137205. */
  137206. protected _lightmapTexture: Nullable<BaseTexture>;
  137207. /**
  137208. * The color of a material in ambient lighting.
  137209. */
  137210. protected _ambientColor: Color3;
  137211. /**
  137212. * AKA Diffuse Color in other nomenclature.
  137213. */
  137214. protected _albedoColor: Color3;
  137215. /**
  137216. * AKA Specular Color in other nomenclature.
  137217. */
  137218. protected _reflectivityColor: Color3;
  137219. /**
  137220. * The color applied when light is reflected from a material.
  137221. */
  137222. protected _reflectionColor: Color3;
  137223. /**
  137224. * The color applied when light is emitted from a material.
  137225. */
  137226. protected _emissiveColor: Color3;
  137227. /**
  137228. * AKA Glossiness in other nomenclature.
  137229. */
  137230. protected _microSurface: number;
  137231. /**
  137232. * Specifies that the material will use the light map as a show map.
  137233. */
  137234. protected _useLightmapAsShadowmap: boolean;
  137235. /**
  137236. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137237. * makes the reflect vector face the model (under horizon).
  137238. */
  137239. protected _useHorizonOcclusion: boolean;
  137240. /**
  137241. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137242. * too much the area relying on ambient texture to define their ambient occlusion.
  137243. */
  137244. protected _useRadianceOcclusion: boolean;
  137245. /**
  137246. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137247. */
  137248. protected _useAlphaFromAlbedoTexture: boolean;
  137249. /**
  137250. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  137251. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137252. */
  137253. protected _useSpecularOverAlpha: boolean;
  137254. /**
  137255. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137256. */
  137257. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137258. /**
  137259. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137260. */
  137261. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  137262. /**
  137263. * Specifies if the metallic texture contains the roughness information in its green channel.
  137264. */
  137265. protected _useRoughnessFromMetallicTextureGreen: boolean;
  137266. /**
  137267. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137268. */
  137269. protected _useMetallnessFromMetallicTextureBlue: boolean;
  137270. /**
  137271. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137272. */
  137273. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  137274. /**
  137275. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137276. */
  137277. protected _useAmbientInGrayScale: boolean;
  137278. /**
  137279. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137280. * The material will try to infer what glossiness each pixel should be.
  137281. */
  137282. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  137283. /**
  137284. * Defines the falloff type used in this material.
  137285. * It by default is Physical.
  137286. */
  137287. protected _lightFalloff: number;
  137288. /**
  137289. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137290. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137291. */
  137292. protected _useRadianceOverAlpha: boolean;
  137293. /**
  137294. * Allows using an object space normal map (instead of tangent space).
  137295. */
  137296. protected _useObjectSpaceNormalMap: boolean;
  137297. /**
  137298. * Allows using the bump map in parallax mode.
  137299. */
  137300. protected _useParallax: boolean;
  137301. /**
  137302. * Allows using the bump map in parallax occlusion mode.
  137303. */
  137304. protected _useParallaxOcclusion: boolean;
  137305. /**
  137306. * Controls the scale bias of the parallax mode.
  137307. */
  137308. protected _parallaxScaleBias: number;
  137309. /**
  137310. * If sets to true, disables all the lights affecting the material.
  137311. */
  137312. protected _disableLighting: boolean;
  137313. /**
  137314. * Number of Simultaneous lights allowed on the material.
  137315. */
  137316. protected _maxSimultaneousLights: number;
  137317. /**
  137318. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  137319. */
  137320. protected _invertNormalMapX: boolean;
  137321. /**
  137322. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  137323. */
  137324. protected _invertNormalMapY: boolean;
  137325. /**
  137326. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137327. */
  137328. protected _twoSidedLighting: boolean;
  137329. /**
  137330. * Defines the alpha limits in alpha test mode.
  137331. */
  137332. protected _alphaCutOff: number;
  137333. /**
  137334. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137335. */
  137336. protected _forceAlphaTest: boolean;
  137337. /**
  137338. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137339. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137340. */
  137341. protected _useAlphaFresnel: boolean;
  137342. /**
  137343. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137344. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137345. */
  137346. protected _useLinearAlphaFresnel: boolean;
  137347. /**
  137348. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  137349. * from cos thetav and roughness:
  137350. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  137351. */
  137352. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  137353. /**
  137354. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137355. */
  137356. protected _forceIrradianceInFragment: boolean;
  137357. private _realTimeFiltering;
  137358. /**
  137359. * Enables realtime filtering on the texture.
  137360. */
  137361. get realTimeFiltering(): boolean;
  137362. set realTimeFiltering(b: boolean);
  137363. private _realTimeFilteringQuality;
  137364. /**
  137365. * Quality switch for realtime filtering
  137366. */
  137367. get realTimeFilteringQuality(): number;
  137368. set realTimeFilteringQuality(n: number);
  137369. /**
  137370. * Can this material render to several textures at once
  137371. */
  137372. get canRenderToMRT(): boolean;
  137373. /**
  137374. * Force normal to face away from face.
  137375. */
  137376. protected _forceNormalForward: boolean;
  137377. /**
  137378. * Enables specular anti aliasing in the PBR shader.
  137379. * It will both interacts on the Geometry for analytical and IBL lighting.
  137380. * It also prefilter the roughness map based on the bump values.
  137381. */
  137382. protected _enableSpecularAntiAliasing: boolean;
  137383. /**
  137384. * Default configuration related to image processing available in the PBR Material.
  137385. */
  137386. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  137387. /**
  137388. * Keep track of the image processing observer to allow dispose and replace.
  137389. */
  137390. private _imageProcessingObserver;
  137391. /**
  137392. * Attaches a new image processing configuration to the PBR Material.
  137393. * @param configuration
  137394. */
  137395. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  137396. /**
  137397. * Stores the available render targets.
  137398. */
  137399. private _renderTargets;
  137400. /**
  137401. * Sets the global ambient color for the material used in lighting calculations.
  137402. */
  137403. private _globalAmbientColor;
  137404. /**
  137405. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  137406. */
  137407. private _useLogarithmicDepth;
  137408. /**
  137409. * If set to true, no lighting calculations will be applied.
  137410. */
  137411. private _unlit;
  137412. private _debugMode;
  137413. /**
  137414. * @hidden
  137415. * This is reserved for the inspector.
  137416. * Defines the material debug mode.
  137417. * It helps seeing only some components of the material while troubleshooting.
  137418. */
  137419. debugMode: number;
  137420. /**
  137421. * @hidden
  137422. * This is reserved for the inspector.
  137423. * Specify from where on screen the debug mode should start.
  137424. * The value goes from -1 (full screen) to 1 (not visible)
  137425. * It helps with side by side comparison against the final render
  137426. * This defaults to -1
  137427. */
  137428. private debugLimit;
  137429. /**
  137430. * @hidden
  137431. * This is reserved for the inspector.
  137432. * As the default viewing range might not be enough (if the ambient is really small for instance)
  137433. * You can use the factor to better multiply the final value.
  137434. */
  137435. private debugFactor;
  137436. /**
  137437. * Defines the clear coat layer parameters for the material.
  137438. */
  137439. readonly clearCoat: PBRClearCoatConfiguration;
  137440. /**
  137441. * Defines the anisotropic parameters for the material.
  137442. */
  137443. readonly anisotropy: PBRAnisotropicConfiguration;
  137444. /**
  137445. * Defines the BRDF parameters for the material.
  137446. */
  137447. readonly brdf: PBRBRDFConfiguration;
  137448. /**
  137449. * Defines the Sheen parameters for the material.
  137450. */
  137451. readonly sheen: PBRSheenConfiguration;
  137452. /**
  137453. * Defines the SubSurface parameters for the material.
  137454. */
  137455. readonly subSurface: PBRSubSurfaceConfiguration;
  137456. /**
  137457. * Defines the detail map parameters for the material.
  137458. */
  137459. readonly detailMap: DetailMapConfiguration;
  137460. protected _rebuildInParallel: boolean;
  137461. /**
  137462. * Instantiates a new PBRMaterial instance.
  137463. *
  137464. * @param name The material name
  137465. * @param scene The scene the material will be use in.
  137466. */
  137467. constructor(name: string, scene: Scene);
  137468. /**
  137469. * Gets a boolean indicating that current material needs to register RTT
  137470. */
  137471. get hasRenderTargetTextures(): boolean;
  137472. /**
  137473. * Gets the name of the material class.
  137474. */
  137475. getClassName(): string;
  137476. /**
  137477. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  137478. */
  137479. get useLogarithmicDepth(): boolean;
  137480. /**
  137481. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  137482. */
  137483. set useLogarithmicDepth(value: boolean);
  137484. /**
  137485. * Returns true if alpha blending should be disabled.
  137486. */
  137487. protected get _disableAlphaBlending(): boolean;
  137488. /**
  137489. * Specifies whether or not this material should be rendered in alpha blend mode.
  137490. */
  137491. needAlphaBlending(): boolean;
  137492. /**
  137493. * Specifies whether or not this material should be rendered in alpha test mode.
  137494. */
  137495. needAlphaTesting(): boolean;
  137496. /**
  137497. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  137498. */
  137499. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  137500. /**
  137501. * Gets the texture used for the alpha test.
  137502. */
  137503. getAlphaTestTexture(): Nullable<BaseTexture>;
  137504. /**
  137505. * Specifies that the submesh is ready to be used.
  137506. * @param mesh - BJS mesh.
  137507. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  137508. * @param useInstances - Specifies that instances should be used.
  137509. * @returns - boolean indicating that the submesh is ready or not.
  137510. */
  137511. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  137512. /**
  137513. * Specifies if the material uses metallic roughness workflow.
  137514. * @returns boolean specifiying if the material uses metallic roughness workflow.
  137515. */
  137516. isMetallicWorkflow(): boolean;
  137517. private _prepareEffect;
  137518. private _prepareDefines;
  137519. /**
  137520. * Force shader compilation
  137521. */
  137522. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  137523. /**
  137524. * Initializes the uniform buffer layout for the shader.
  137525. */
  137526. buildUniformLayout(): void;
  137527. /**
  137528. * Unbinds the material from the mesh
  137529. */
  137530. unbind(): void;
  137531. /**
  137532. * Binds the submesh data.
  137533. * @param world - The world matrix.
  137534. * @param mesh - The BJS mesh.
  137535. * @param subMesh - A submesh of the BJS mesh.
  137536. */
  137537. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  137538. /**
  137539. * Returns the animatable textures.
  137540. * @returns - Array of animatable textures.
  137541. */
  137542. getAnimatables(): IAnimatable[];
  137543. /**
  137544. * Returns the texture used for reflections.
  137545. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  137546. */
  137547. private _getReflectionTexture;
  137548. /**
  137549. * Returns an array of the actively used textures.
  137550. * @returns - Array of BaseTextures
  137551. */
  137552. getActiveTextures(): BaseTexture[];
  137553. /**
  137554. * Checks to see if a texture is used in the material.
  137555. * @param texture - Base texture to use.
  137556. * @returns - Boolean specifying if a texture is used in the material.
  137557. */
  137558. hasTexture(texture: BaseTexture): boolean;
  137559. /**
  137560. * Sets the required values to the prepass renderer.
  137561. * @param prePassRenderer defines the prepass renderer to setup
  137562. */
  137563. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  137564. /**
  137565. * Disposes the resources of the material.
  137566. * @param forceDisposeEffect - Forces the disposal of effects.
  137567. * @param forceDisposeTextures - Forces the disposal of all textures.
  137568. */
  137569. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  137570. }
  137571. }
  137572. declare module BABYLON {
  137573. /**
  137574. * The Physically based material of BJS.
  137575. *
  137576. * This offers the main features of a standard PBR material.
  137577. * For more information, please refer to the documentation :
  137578. * https://doc.babylonjs.com/how_to/physically_based_rendering
  137579. */
  137580. export class PBRMaterial extends PBRBaseMaterial {
  137581. /**
  137582. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  137583. */
  137584. static readonly PBRMATERIAL_OPAQUE: number;
  137585. /**
  137586. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  137587. */
  137588. static readonly PBRMATERIAL_ALPHATEST: number;
  137589. /**
  137590. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137591. */
  137592. static readonly PBRMATERIAL_ALPHABLEND: number;
  137593. /**
  137594. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137595. * They are also discarded below the alpha cutoff threshold to improve performances.
  137596. */
  137597. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  137598. /**
  137599. * Defines the default value of how much AO map is occluding the analytical lights
  137600. * (point spot...).
  137601. */
  137602. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  137603. /**
  137604. * Intensity of the direct lights e.g. the four lights available in your scene.
  137605. * This impacts both the direct diffuse and specular highlights.
  137606. */
  137607. directIntensity: number;
  137608. /**
  137609. * Intensity of the emissive part of the material.
  137610. * This helps controlling the emissive effect without modifying the emissive color.
  137611. */
  137612. emissiveIntensity: number;
  137613. /**
  137614. * Intensity of the environment e.g. how much the environment will light the object
  137615. * either through harmonics for rough material or through the refelction for shiny ones.
  137616. */
  137617. environmentIntensity: number;
  137618. /**
  137619. * This is a special control allowing the reduction of the specular highlights coming from the
  137620. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137621. */
  137622. specularIntensity: number;
  137623. /**
  137624. * Debug Control allowing disabling the bump map on this material.
  137625. */
  137626. disableBumpMap: boolean;
  137627. /**
  137628. * AKA Diffuse Texture in standard nomenclature.
  137629. */
  137630. albedoTexture: BaseTexture;
  137631. /**
  137632. * AKA Occlusion Texture in other nomenclature.
  137633. */
  137634. ambientTexture: BaseTexture;
  137635. /**
  137636. * AKA Occlusion Texture Intensity in other nomenclature.
  137637. */
  137638. ambientTextureStrength: number;
  137639. /**
  137640. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137641. * 1 means it completely occludes it
  137642. * 0 mean it has no impact
  137643. */
  137644. ambientTextureImpactOnAnalyticalLights: number;
  137645. /**
  137646. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  137647. */
  137648. opacityTexture: BaseTexture;
  137649. /**
  137650. * Stores the reflection values in a texture.
  137651. */
  137652. reflectionTexture: Nullable<BaseTexture>;
  137653. /**
  137654. * Stores the emissive values in a texture.
  137655. */
  137656. emissiveTexture: BaseTexture;
  137657. /**
  137658. * AKA Specular texture in other nomenclature.
  137659. */
  137660. reflectivityTexture: BaseTexture;
  137661. /**
  137662. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137663. */
  137664. metallicTexture: BaseTexture;
  137665. /**
  137666. * Specifies the metallic scalar of the metallic/roughness workflow.
  137667. * Can also be used to scale the metalness values of the metallic texture.
  137668. */
  137669. metallic: Nullable<number>;
  137670. /**
  137671. * Specifies the roughness scalar of the metallic/roughness workflow.
  137672. * Can also be used to scale the roughness values of the metallic texture.
  137673. */
  137674. roughness: Nullable<number>;
  137675. /**
  137676. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137677. * By default the indexOfrefraction is used to compute F0;
  137678. *
  137679. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137680. *
  137681. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137682. * F90 = metallicReflectanceColor;
  137683. */
  137684. metallicF0Factor: number;
  137685. /**
  137686. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137687. * By default the F90 is always 1;
  137688. *
  137689. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137690. *
  137691. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137692. * F90 = metallicReflectanceColor;
  137693. */
  137694. metallicReflectanceColor: Color3;
  137695. /**
  137696. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137697. * This is multiply against the scalar values defined in the material.
  137698. */
  137699. metallicReflectanceTexture: Nullable<BaseTexture>;
  137700. /**
  137701. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137702. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137703. */
  137704. microSurfaceTexture: BaseTexture;
  137705. /**
  137706. * Stores surface normal data used to displace a mesh in a texture.
  137707. */
  137708. bumpTexture: BaseTexture;
  137709. /**
  137710. * Stores the pre-calculated light information of a mesh in a texture.
  137711. */
  137712. lightmapTexture: BaseTexture;
  137713. /**
  137714. * Stores the refracted light information in a texture.
  137715. */
  137716. get refractionTexture(): Nullable<BaseTexture>;
  137717. set refractionTexture(value: Nullable<BaseTexture>);
  137718. /**
  137719. * The color of a material in ambient lighting.
  137720. */
  137721. ambientColor: Color3;
  137722. /**
  137723. * AKA Diffuse Color in other nomenclature.
  137724. */
  137725. albedoColor: Color3;
  137726. /**
  137727. * AKA Specular Color in other nomenclature.
  137728. */
  137729. reflectivityColor: Color3;
  137730. /**
  137731. * The color reflected from the material.
  137732. */
  137733. reflectionColor: Color3;
  137734. /**
  137735. * The color emitted from the material.
  137736. */
  137737. emissiveColor: Color3;
  137738. /**
  137739. * AKA Glossiness in other nomenclature.
  137740. */
  137741. microSurface: number;
  137742. /**
  137743. * Index of refraction of the material base layer.
  137744. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  137745. *
  137746. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  137747. *
  137748. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  137749. */
  137750. get indexOfRefraction(): number;
  137751. set indexOfRefraction(value: number);
  137752. /**
  137753. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  137754. */
  137755. get invertRefractionY(): boolean;
  137756. set invertRefractionY(value: boolean);
  137757. /**
  137758. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  137759. * Materials half opaque for instance using refraction could benefit from this control.
  137760. */
  137761. get linkRefractionWithTransparency(): boolean;
  137762. set linkRefractionWithTransparency(value: boolean);
  137763. /**
  137764. * If true, the light map contains occlusion information instead of lighting info.
  137765. */
  137766. useLightmapAsShadowmap: boolean;
  137767. /**
  137768. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137769. */
  137770. useAlphaFromAlbedoTexture: boolean;
  137771. /**
  137772. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137773. */
  137774. forceAlphaTest: boolean;
  137775. /**
  137776. * Defines the alpha limits in alpha test mode.
  137777. */
  137778. alphaCutOff: number;
  137779. /**
  137780. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  137781. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137782. */
  137783. useSpecularOverAlpha: boolean;
  137784. /**
  137785. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137786. */
  137787. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137788. /**
  137789. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137790. */
  137791. useRoughnessFromMetallicTextureAlpha: boolean;
  137792. /**
  137793. * Specifies if the metallic texture contains the roughness information in its green channel.
  137794. */
  137795. useRoughnessFromMetallicTextureGreen: boolean;
  137796. /**
  137797. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137798. */
  137799. useMetallnessFromMetallicTextureBlue: boolean;
  137800. /**
  137801. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137802. */
  137803. useAmbientOcclusionFromMetallicTextureRed: boolean;
  137804. /**
  137805. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137806. */
  137807. useAmbientInGrayScale: boolean;
  137808. /**
  137809. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137810. * The material will try to infer what glossiness each pixel should be.
  137811. */
  137812. useAutoMicroSurfaceFromReflectivityMap: boolean;
  137813. /**
  137814. * BJS is using an harcoded light falloff based on a manually sets up range.
  137815. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137816. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137817. */
  137818. get usePhysicalLightFalloff(): boolean;
  137819. /**
  137820. * BJS is using an harcoded light falloff based on a manually sets up range.
  137821. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137822. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137823. */
  137824. set usePhysicalLightFalloff(value: boolean);
  137825. /**
  137826. * In order to support the falloff compatibility with gltf, a special mode has been added
  137827. * to reproduce the gltf light falloff.
  137828. */
  137829. get useGLTFLightFalloff(): boolean;
  137830. /**
  137831. * In order to support the falloff compatibility with gltf, a special mode has been added
  137832. * to reproduce the gltf light falloff.
  137833. */
  137834. set useGLTFLightFalloff(value: boolean);
  137835. /**
  137836. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137837. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137838. */
  137839. useRadianceOverAlpha: boolean;
  137840. /**
  137841. * Allows using an object space normal map (instead of tangent space).
  137842. */
  137843. useObjectSpaceNormalMap: boolean;
  137844. /**
  137845. * Allows using the bump map in parallax mode.
  137846. */
  137847. useParallax: boolean;
  137848. /**
  137849. * Allows using the bump map in parallax occlusion mode.
  137850. */
  137851. useParallaxOcclusion: boolean;
  137852. /**
  137853. * Controls the scale bias of the parallax mode.
  137854. */
  137855. parallaxScaleBias: number;
  137856. /**
  137857. * If sets to true, disables all the lights affecting the material.
  137858. */
  137859. disableLighting: boolean;
  137860. /**
  137861. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137862. */
  137863. forceIrradianceInFragment: boolean;
  137864. /**
  137865. * Number of Simultaneous lights allowed on the material.
  137866. */
  137867. maxSimultaneousLights: number;
  137868. /**
  137869. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  137870. */
  137871. invertNormalMapX: boolean;
  137872. /**
  137873. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  137874. */
  137875. invertNormalMapY: boolean;
  137876. /**
  137877. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137878. */
  137879. twoSidedLighting: boolean;
  137880. /**
  137881. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137882. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137883. */
  137884. useAlphaFresnel: boolean;
  137885. /**
  137886. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137887. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137888. */
  137889. useLinearAlphaFresnel: boolean;
  137890. /**
  137891. * Let user defines the brdf lookup texture used for IBL.
  137892. * A default 8bit version is embedded but you could point at :
  137893. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  137894. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  137895. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  137896. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  137897. */
  137898. environmentBRDFTexture: Nullable<BaseTexture>;
  137899. /**
  137900. * Force normal to face away from face.
  137901. */
  137902. forceNormalForward: boolean;
  137903. /**
  137904. * Enables specular anti aliasing in the PBR shader.
  137905. * It will both interacts on the Geometry for analytical and IBL lighting.
  137906. * It also prefilter the roughness map based on the bump values.
  137907. */
  137908. enableSpecularAntiAliasing: boolean;
  137909. /**
  137910. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137911. * makes the reflect vector face the model (under horizon).
  137912. */
  137913. useHorizonOcclusion: boolean;
  137914. /**
  137915. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137916. * too much the area relying on ambient texture to define their ambient occlusion.
  137917. */
  137918. useRadianceOcclusion: boolean;
  137919. /**
  137920. * If set to true, no lighting calculations will be applied.
  137921. */
  137922. unlit: boolean;
  137923. /**
  137924. * Gets the image processing configuration used either in this material.
  137925. */
  137926. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  137927. /**
  137928. * Sets the Default image processing configuration used either in the this material.
  137929. *
  137930. * If sets to null, the scene one is in use.
  137931. */
  137932. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  137933. /**
  137934. * Gets wether the color curves effect is enabled.
  137935. */
  137936. get cameraColorCurvesEnabled(): boolean;
  137937. /**
  137938. * Sets wether the color curves effect is enabled.
  137939. */
  137940. set cameraColorCurvesEnabled(value: boolean);
  137941. /**
  137942. * Gets wether the color grading effect is enabled.
  137943. */
  137944. get cameraColorGradingEnabled(): boolean;
  137945. /**
  137946. * Gets wether the color grading effect is enabled.
  137947. */
  137948. set cameraColorGradingEnabled(value: boolean);
  137949. /**
  137950. * Gets wether tonemapping is enabled or not.
  137951. */
  137952. get cameraToneMappingEnabled(): boolean;
  137953. /**
  137954. * Sets wether tonemapping is enabled or not
  137955. */
  137956. set cameraToneMappingEnabled(value: boolean);
  137957. /**
  137958. * The camera exposure used on this material.
  137959. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137960. * This corresponds to a photographic exposure.
  137961. */
  137962. get cameraExposure(): number;
  137963. /**
  137964. * The camera exposure used on this material.
  137965. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137966. * This corresponds to a photographic exposure.
  137967. */
  137968. set cameraExposure(value: number);
  137969. /**
  137970. * Gets The camera contrast used on this material.
  137971. */
  137972. get cameraContrast(): number;
  137973. /**
  137974. * Sets The camera contrast used on this material.
  137975. */
  137976. set cameraContrast(value: number);
  137977. /**
  137978. * Gets the Color Grading 2D Lookup Texture.
  137979. */
  137980. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  137981. /**
  137982. * Sets the Color Grading 2D Lookup Texture.
  137983. */
  137984. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  137985. /**
  137986. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137987. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137988. * 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;
  137989. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137990. */
  137991. get cameraColorCurves(): Nullable<ColorCurves>;
  137992. /**
  137993. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137994. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137995. * 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;
  137996. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137997. */
  137998. set cameraColorCurves(value: Nullable<ColorCurves>);
  137999. /**
  138000. * Instantiates a new PBRMaterial instance.
  138001. *
  138002. * @param name The material name
  138003. * @param scene The scene the material will be use in.
  138004. */
  138005. constructor(name: string, scene: Scene);
  138006. /**
  138007. * Returns the name of this material class.
  138008. */
  138009. getClassName(): string;
  138010. /**
  138011. * Makes a duplicate of the current material.
  138012. * @param name - name to use for the new material.
  138013. */
  138014. clone(name: string): PBRMaterial;
  138015. /**
  138016. * Serializes this PBR Material.
  138017. * @returns - An object with the serialized material.
  138018. */
  138019. serialize(): any;
  138020. /**
  138021. * Parses a PBR Material from a serialized object.
  138022. * @param source - Serialized object.
  138023. * @param scene - BJS scene instance.
  138024. * @param rootUrl - url for the scene object
  138025. * @returns - PBRMaterial
  138026. */
  138027. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  138028. }
  138029. }
  138030. declare module BABYLON {
  138031. /**
  138032. * Direct draw surface info
  138033. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  138034. */
  138035. export interface DDSInfo {
  138036. /**
  138037. * Width of the texture
  138038. */
  138039. width: number;
  138040. /**
  138041. * Width of the texture
  138042. */
  138043. height: number;
  138044. /**
  138045. * Number of Mipmaps for the texture
  138046. * @see https://en.wikipedia.org/wiki/Mipmap
  138047. */
  138048. mipmapCount: number;
  138049. /**
  138050. * If the textures format is a known fourCC format
  138051. * @see https://www.fourcc.org/
  138052. */
  138053. isFourCC: boolean;
  138054. /**
  138055. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  138056. */
  138057. isRGB: boolean;
  138058. /**
  138059. * If the texture is a lumincance format
  138060. */
  138061. isLuminance: boolean;
  138062. /**
  138063. * If this is a cube texture
  138064. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  138065. */
  138066. isCube: boolean;
  138067. /**
  138068. * If the texture is a compressed format eg. FOURCC_DXT1
  138069. */
  138070. isCompressed: boolean;
  138071. /**
  138072. * The dxgiFormat of the texture
  138073. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  138074. */
  138075. dxgiFormat: number;
  138076. /**
  138077. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  138078. */
  138079. textureType: number;
  138080. /**
  138081. * Sphericle polynomial created for the dds texture
  138082. */
  138083. sphericalPolynomial?: SphericalPolynomial;
  138084. }
  138085. /**
  138086. * Class used to provide DDS decompression tools
  138087. */
  138088. export class DDSTools {
  138089. /**
  138090. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  138091. */
  138092. static StoreLODInAlphaChannel: boolean;
  138093. /**
  138094. * Gets DDS information from an array buffer
  138095. * @param data defines the array buffer view to read data from
  138096. * @returns the DDS information
  138097. */
  138098. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  138099. private static _FloatView;
  138100. private static _Int32View;
  138101. private static _ToHalfFloat;
  138102. private static _FromHalfFloat;
  138103. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  138104. private static _GetHalfFloatRGBAArrayBuffer;
  138105. private static _GetFloatRGBAArrayBuffer;
  138106. private static _GetFloatAsUIntRGBAArrayBuffer;
  138107. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  138108. private static _GetRGBAArrayBuffer;
  138109. private static _ExtractLongWordOrder;
  138110. private static _GetRGBArrayBuffer;
  138111. private static _GetLuminanceArrayBuffer;
  138112. /**
  138113. * Uploads DDS Levels to a Babylon Texture
  138114. * @hidden
  138115. */
  138116. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  138117. }
  138118. interface ThinEngine {
  138119. /**
  138120. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  138121. * @param rootUrl defines the url where the file to load is located
  138122. * @param scene defines the current scene
  138123. * @param lodScale defines scale to apply to the mip map selection
  138124. * @param lodOffset defines offset to apply to the mip map selection
  138125. * @param onLoad defines an optional callback raised when the texture is loaded
  138126. * @param onError defines an optional callback raised if there is an issue to load the texture
  138127. * @param format defines the format of the data
  138128. * @param forcedExtension defines the extension to use to pick the right loader
  138129. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  138130. * @returns the cube texture as an InternalTexture
  138131. */
  138132. 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;
  138133. }
  138134. }
  138135. declare module BABYLON {
  138136. /**
  138137. * Implementation of the DDS Texture Loader.
  138138. * @hidden
  138139. */
  138140. export class _DDSTextureLoader implements IInternalTextureLoader {
  138141. /**
  138142. * Defines wether the loader supports cascade loading the different faces.
  138143. */
  138144. readonly supportCascades: boolean;
  138145. /**
  138146. * This returns if the loader support the current file information.
  138147. * @param extension defines the file extension of the file being loaded
  138148. * @returns true if the loader can load the specified file
  138149. */
  138150. canLoad(extension: string): boolean;
  138151. /**
  138152. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138153. * @param data contains the texture data
  138154. * @param texture defines the BabylonJS internal texture
  138155. * @param createPolynomials will be true if polynomials have been requested
  138156. * @param onLoad defines the callback to trigger once the texture is ready
  138157. * @param onError defines the callback to trigger in case of error
  138158. */
  138159. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138160. /**
  138161. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138162. * @param data contains the texture data
  138163. * @param texture defines the BabylonJS internal texture
  138164. * @param callback defines the method to call once ready to upload
  138165. */
  138166. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138167. }
  138168. }
  138169. declare module BABYLON {
  138170. /**
  138171. * Implementation of the ENV Texture Loader.
  138172. * @hidden
  138173. */
  138174. export class _ENVTextureLoader implements IInternalTextureLoader {
  138175. /**
  138176. * Defines wether the loader supports cascade loading the different faces.
  138177. */
  138178. readonly supportCascades: boolean;
  138179. /**
  138180. * This returns if the loader support the current file information.
  138181. * @param extension defines the file extension of the file being loaded
  138182. * @returns true if the loader can load the specified file
  138183. */
  138184. canLoad(extension: string): boolean;
  138185. /**
  138186. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138187. * @param data contains the texture data
  138188. * @param texture defines the BabylonJS internal texture
  138189. * @param createPolynomials will be true if polynomials have been requested
  138190. * @param onLoad defines the callback to trigger once the texture is ready
  138191. * @param onError defines the callback to trigger in case of error
  138192. */
  138193. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138194. /**
  138195. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138196. * @param data contains the texture data
  138197. * @param texture defines the BabylonJS internal texture
  138198. * @param callback defines the method to call once ready to upload
  138199. */
  138200. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138201. }
  138202. }
  138203. declare module BABYLON {
  138204. /**
  138205. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  138206. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  138207. */
  138208. export class KhronosTextureContainer {
  138209. /** contents of the KTX container file */
  138210. data: ArrayBufferView;
  138211. private static HEADER_LEN;
  138212. private static COMPRESSED_2D;
  138213. private static COMPRESSED_3D;
  138214. private static TEX_2D;
  138215. private static TEX_3D;
  138216. /**
  138217. * Gets the openGL type
  138218. */
  138219. glType: number;
  138220. /**
  138221. * Gets the openGL type size
  138222. */
  138223. glTypeSize: number;
  138224. /**
  138225. * Gets the openGL format
  138226. */
  138227. glFormat: number;
  138228. /**
  138229. * Gets the openGL internal format
  138230. */
  138231. glInternalFormat: number;
  138232. /**
  138233. * Gets the base internal format
  138234. */
  138235. glBaseInternalFormat: number;
  138236. /**
  138237. * Gets image width in pixel
  138238. */
  138239. pixelWidth: number;
  138240. /**
  138241. * Gets image height in pixel
  138242. */
  138243. pixelHeight: number;
  138244. /**
  138245. * Gets image depth in pixels
  138246. */
  138247. pixelDepth: number;
  138248. /**
  138249. * Gets the number of array elements
  138250. */
  138251. numberOfArrayElements: number;
  138252. /**
  138253. * Gets the number of faces
  138254. */
  138255. numberOfFaces: number;
  138256. /**
  138257. * Gets the number of mipmap levels
  138258. */
  138259. numberOfMipmapLevels: number;
  138260. /**
  138261. * Gets the bytes of key value data
  138262. */
  138263. bytesOfKeyValueData: number;
  138264. /**
  138265. * Gets the load type
  138266. */
  138267. loadType: number;
  138268. /**
  138269. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  138270. */
  138271. isInvalid: boolean;
  138272. /**
  138273. * Creates a new KhronosTextureContainer
  138274. * @param data contents of the KTX container file
  138275. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  138276. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  138277. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  138278. */
  138279. constructor(
  138280. /** contents of the KTX container file */
  138281. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  138282. /**
  138283. * Uploads KTX content to a Babylon Texture.
  138284. * It is assumed that the texture has already been created & is currently bound
  138285. * @hidden
  138286. */
  138287. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  138288. private _upload2DCompressedLevels;
  138289. /**
  138290. * Checks if the given data starts with a KTX file identifier.
  138291. * @param data the data to check
  138292. * @returns true if the data is a KTX file or false otherwise
  138293. */
  138294. static IsValid(data: ArrayBufferView): boolean;
  138295. }
  138296. }
  138297. declare module BABYLON {
  138298. /**
  138299. * Helper class to push actions to a pool of workers.
  138300. */
  138301. export class WorkerPool implements IDisposable {
  138302. private _workerInfos;
  138303. private _pendingActions;
  138304. /**
  138305. * Constructor
  138306. * @param workers Array of workers to use for actions
  138307. */
  138308. constructor(workers: Array<Worker>);
  138309. /**
  138310. * Terminates all workers and clears any pending actions.
  138311. */
  138312. dispose(): void;
  138313. /**
  138314. * Pushes an action to the worker pool. If all the workers are active, the action will be
  138315. * pended until a worker has completed its action.
  138316. * @param action The action to perform. Call onComplete when the action is complete.
  138317. */
  138318. push(action: (worker: Worker, onComplete: () => void) => void): void;
  138319. private _execute;
  138320. }
  138321. }
  138322. declare module BABYLON {
  138323. /**
  138324. * Class for loading KTX2 files
  138325. */
  138326. export class KhronosTextureContainer2 {
  138327. private static _WorkerPoolPromise?;
  138328. private static _Initialized;
  138329. private static _Ktx2Decoder;
  138330. /**
  138331. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  138332. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  138333. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  138334. * Urls you can change:
  138335. * URLConfig.jsDecoderModule
  138336. * URLConfig.wasmUASTCToASTC
  138337. * URLConfig.wasmUASTCToBC7
  138338. * URLConfig.jsMSCTranscoder
  138339. * URLConfig.wasmMSCTranscoder
  138340. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  138341. */
  138342. static URLConfig: {
  138343. jsDecoderModule: string;
  138344. wasmUASTCToASTC: null;
  138345. wasmUASTCToBC7: null;
  138346. jsMSCTranscoder: null;
  138347. wasmMSCTranscoder: null;
  138348. };
  138349. /**
  138350. * Default number of workers used to handle data decoding
  138351. */
  138352. static DefaultNumWorkers: number;
  138353. private static GetDefaultNumWorkers;
  138354. private _engine;
  138355. private static _CreateWorkerPool;
  138356. /**
  138357. * Constructor
  138358. * @param engine The engine to use
  138359. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  138360. */
  138361. constructor(engine: ThinEngine, numWorkers?: number);
  138362. /** @hidden */
  138363. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  138364. /**
  138365. * Stop all async operations and release resources.
  138366. */
  138367. dispose(): void;
  138368. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  138369. /**
  138370. * Checks if the given data starts with a KTX2 file identifier.
  138371. * @param data the data to check
  138372. * @returns true if the data is a KTX2 file or false otherwise
  138373. */
  138374. static IsValid(data: ArrayBufferView): boolean;
  138375. }
  138376. }
  138377. declare module BABYLON {
  138378. /**
  138379. * Implementation of the KTX Texture Loader.
  138380. * @hidden
  138381. */
  138382. export class _KTXTextureLoader implements IInternalTextureLoader {
  138383. /**
  138384. * Defines wether the loader supports cascade loading the different faces.
  138385. */
  138386. readonly supportCascades: boolean;
  138387. /**
  138388. * This returns if the loader support the current file information.
  138389. * @param extension defines the file extension of the file being loaded
  138390. * @param mimeType defines the optional mime type of the file being loaded
  138391. * @returns true if the loader can load the specified file
  138392. */
  138393. canLoad(extension: string, mimeType?: string): boolean;
  138394. /**
  138395. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138396. * @param data contains the texture data
  138397. * @param texture defines the BabylonJS internal texture
  138398. * @param createPolynomials will be true if polynomials have been requested
  138399. * @param onLoad defines the callback to trigger once the texture is ready
  138400. * @param onError defines the callback to trigger in case of error
  138401. */
  138402. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138403. /**
  138404. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138405. * @param data contains the texture data
  138406. * @param texture defines the BabylonJS internal texture
  138407. * @param callback defines the method to call once ready to upload
  138408. */
  138409. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  138410. }
  138411. }
  138412. declare module BABYLON {
  138413. /** @hidden */
  138414. export var _forceSceneHelpersToBundle: boolean;
  138415. interface Scene {
  138416. /**
  138417. * Creates a default light for the scene.
  138418. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  138419. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  138420. */
  138421. createDefaultLight(replace?: boolean): void;
  138422. /**
  138423. * Creates a default camera for the scene.
  138424. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  138425. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  138426. * @param replace has default false, when true replaces the active camera in the scene
  138427. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  138428. */
  138429. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  138430. /**
  138431. * Creates a default camera and a default light.
  138432. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  138433. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  138434. * @param replace has the default false, when true replaces the active camera/light in the scene
  138435. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  138436. */
  138437. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  138438. /**
  138439. * Creates a new sky box
  138440. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  138441. * @param environmentTexture defines the texture to use as environment texture
  138442. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  138443. * @param scale defines the overall scale of the skybox
  138444. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  138445. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  138446. * @returns a new mesh holding the sky box
  138447. */
  138448. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  138449. /**
  138450. * Creates a new environment
  138451. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  138452. * @param options defines the options you can use to configure the environment
  138453. * @returns the new EnvironmentHelper
  138454. */
  138455. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  138456. /**
  138457. * Creates a new VREXperienceHelper
  138458. * @see https://doc.babylonjs.com/how_to/webvr_helper
  138459. * @param webVROptions defines the options used to create the new VREXperienceHelper
  138460. * @returns a new VREXperienceHelper
  138461. */
  138462. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  138463. /**
  138464. * Creates a new WebXRDefaultExperience
  138465. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  138466. * @param options experience options
  138467. * @returns a promise for a new WebXRDefaultExperience
  138468. */
  138469. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  138470. }
  138471. }
  138472. declare module BABYLON {
  138473. /**
  138474. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  138475. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  138476. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  138477. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138478. */
  138479. export class VideoDome extends TextureDome<VideoTexture> {
  138480. /**
  138481. * Define the video source as a Monoscopic panoramic 360 video.
  138482. */
  138483. static readonly MODE_MONOSCOPIC: number;
  138484. /**
  138485. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  138486. */
  138487. static readonly MODE_TOPBOTTOM: number;
  138488. /**
  138489. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  138490. */
  138491. static readonly MODE_SIDEBYSIDE: number;
  138492. /**
  138493. * Get the video texture associated with this video dome
  138494. */
  138495. get videoTexture(): VideoTexture;
  138496. /**
  138497. * Get the video mode of this dome
  138498. */
  138499. get videoMode(): number;
  138500. /**
  138501. * Set the video mode of this dome.
  138502. * @see textureMode
  138503. */
  138504. set videoMode(value: number);
  138505. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  138506. }
  138507. }
  138508. declare module BABYLON {
  138509. /**
  138510. * This class can be used to get instrumentation data from a Babylon engine
  138511. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138512. */
  138513. export class EngineInstrumentation implements IDisposable {
  138514. /**
  138515. * Define the instrumented engine.
  138516. */
  138517. engine: Engine;
  138518. private _captureGPUFrameTime;
  138519. private _gpuFrameTimeToken;
  138520. private _gpuFrameTime;
  138521. private _captureShaderCompilationTime;
  138522. private _shaderCompilationTime;
  138523. private _onBeginFrameObserver;
  138524. private _onEndFrameObserver;
  138525. private _onBeforeShaderCompilationObserver;
  138526. private _onAfterShaderCompilationObserver;
  138527. /**
  138528. * Gets the perf counter used for GPU frame time
  138529. */
  138530. get gpuFrameTimeCounter(): PerfCounter;
  138531. /**
  138532. * Gets the GPU frame time capture status
  138533. */
  138534. get captureGPUFrameTime(): boolean;
  138535. /**
  138536. * Enable or disable the GPU frame time capture
  138537. */
  138538. set captureGPUFrameTime(value: boolean);
  138539. /**
  138540. * Gets the perf counter used for shader compilation time
  138541. */
  138542. get shaderCompilationTimeCounter(): PerfCounter;
  138543. /**
  138544. * Gets the shader compilation time capture status
  138545. */
  138546. get captureShaderCompilationTime(): boolean;
  138547. /**
  138548. * Enable or disable the shader compilation time capture
  138549. */
  138550. set captureShaderCompilationTime(value: boolean);
  138551. /**
  138552. * Instantiates a new engine instrumentation.
  138553. * This class can be used to get instrumentation data from a Babylon engine
  138554. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138555. * @param engine Defines the engine to instrument
  138556. */
  138557. constructor(
  138558. /**
  138559. * Define the instrumented engine.
  138560. */
  138561. engine: Engine);
  138562. /**
  138563. * Dispose and release associated resources.
  138564. */
  138565. dispose(): void;
  138566. }
  138567. }
  138568. declare module BABYLON {
  138569. /**
  138570. * This class can be used to get instrumentation data from a Babylon engine
  138571. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138572. */
  138573. export class SceneInstrumentation implements IDisposable {
  138574. /**
  138575. * Defines the scene to instrument
  138576. */
  138577. scene: Scene;
  138578. private _captureActiveMeshesEvaluationTime;
  138579. private _activeMeshesEvaluationTime;
  138580. private _captureRenderTargetsRenderTime;
  138581. private _renderTargetsRenderTime;
  138582. private _captureFrameTime;
  138583. private _frameTime;
  138584. private _captureRenderTime;
  138585. private _renderTime;
  138586. private _captureInterFrameTime;
  138587. private _interFrameTime;
  138588. private _captureParticlesRenderTime;
  138589. private _particlesRenderTime;
  138590. private _captureSpritesRenderTime;
  138591. private _spritesRenderTime;
  138592. private _capturePhysicsTime;
  138593. private _physicsTime;
  138594. private _captureAnimationsTime;
  138595. private _animationsTime;
  138596. private _captureCameraRenderTime;
  138597. private _cameraRenderTime;
  138598. private _onBeforeActiveMeshesEvaluationObserver;
  138599. private _onAfterActiveMeshesEvaluationObserver;
  138600. private _onBeforeRenderTargetsRenderObserver;
  138601. private _onAfterRenderTargetsRenderObserver;
  138602. private _onAfterRenderObserver;
  138603. private _onBeforeDrawPhaseObserver;
  138604. private _onAfterDrawPhaseObserver;
  138605. private _onBeforeAnimationsObserver;
  138606. private _onBeforeParticlesRenderingObserver;
  138607. private _onAfterParticlesRenderingObserver;
  138608. private _onBeforeSpritesRenderingObserver;
  138609. private _onAfterSpritesRenderingObserver;
  138610. private _onBeforePhysicsObserver;
  138611. private _onAfterPhysicsObserver;
  138612. private _onAfterAnimationsObserver;
  138613. private _onBeforeCameraRenderObserver;
  138614. private _onAfterCameraRenderObserver;
  138615. /**
  138616. * Gets the perf counter used for active meshes evaluation time
  138617. */
  138618. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  138619. /**
  138620. * Gets the active meshes evaluation time capture status
  138621. */
  138622. get captureActiveMeshesEvaluationTime(): boolean;
  138623. /**
  138624. * Enable or disable the active meshes evaluation time capture
  138625. */
  138626. set captureActiveMeshesEvaluationTime(value: boolean);
  138627. /**
  138628. * Gets the perf counter used for render targets render time
  138629. */
  138630. get renderTargetsRenderTimeCounter(): PerfCounter;
  138631. /**
  138632. * Gets the render targets render time capture status
  138633. */
  138634. get captureRenderTargetsRenderTime(): boolean;
  138635. /**
  138636. * Enable or disable the render targets render time capture
  138637. */
  138638. set captureRenderTargetsRenderTime(value: boolean);
  138639. /**
  138640. * Gets the perf counter used for particles render time
  138641. */
  138642. get particlesRenderTimeCounter(): PerfCounter;
  138643. /**
  138644. * Gets the particles render time capture status
  138645. */
  138646. get captureParticlesRenderTime(): boolean;
  138647. /**
  138648. * Enable or disable the particles render time capture
  138649. */
  138650. set captureParticlesRenderTime(value: boolean);
  138651. /**
  138652. * Gets the perf counter used for sprites render time
  138653. */
  138654. get spritesRenderTimeCounter(): PerfCounter;
  138655. /**
  138656. * Gets the sprites render time capture status
  138657. */
  138658. get captureSpritesRenderTime(): boolean;
  138659. /**
  138660. * Enable or disable the sprites render time capture
  138661. */
  138662. set captureSpritesRenderTime(value: boolean);
  138663. /**
  138664. * Gets the perf counter used for physics time
  138665. */
  138666. get physicsTimeCounter(): PerfCounter;
  138667. /**
  138668. * Gets the physics time capture status
  138669. */
  138670. get capturePhysicsTime(): boolean;
  138671. /**
  138672. * Enable or disable the physics time capture
  138673. */
  138674. set capturePhysicsTime(value: boolean);
  138675. /**
  138676. * Gets the perf counter used for animations time
  138677. */
  138678. get animationsTimeCounter(): PerfCounter;
  138679. /**
  138680. * Gets the animations time capture status
  138681. */
  138682. get captureAnimationsTime(): boolean;
  138683. /**
  138684. * Enable or disable the animations time capture
  138685. */
  138686. set captureAnimationsTime(value: boolean);
  138687. /**
  138688. * Gets the perf counter used for frame time capture
  138689. */
  138690. get frameTimeCounter(): PerfCounter;
  138691. /**
  138692. * Gets the frame time capture status
  138693. */
  138694. get captureFrameTime(): boolean;
  138695. /**
  138696. * Enable or disable the frame time capture
  138697. */
  138698. set captureFrameTime(value: boolean);
  138699. /**
  138700. * Gets the perf counter used for inter-frames time capture
  138701. */
  138702. get interFrameTimeCounter(): PerfCounter;
  138703. /**
  138704. * Gets the inter-frames time capture status
  138705. */
  138706. get captureInterFrameTime(): boolean;
  138707. /**
  138708. * Enable or disable the inter-frames time capture
  138709. */
  138710. set captureInterFrameTime(value: boolean);
  138711. /**
  138712. * Gets the perf counter used for render time capture
  138713. */
  138714. get renderTimeCounter(): PerfCounter;
  138715. /**
  138716. * Gets the render time capture status
  138717. */
  138718. get captureRenderTime(): boolean;
  138719. /**
  138720. * Enable or disable the render time capture
  138721. */
  138722. set captureRenderTime(value: boolean);
  138723. /**
  138724. * Gets the perf counter used for camera render time capture
  138725. */
  138726. get cameraRenderTimeCounter(): PerfCounter;
  138727. /**
  138728. * Gets the camera render time capture status
  138729. */
  138730. get captureCameraRenderTime(): boolean;
  138731. /**
  138732. * Enable or disable the camera render time capture
  138733. */
  138734. set captureCameraRenderTime(value: boolean);
  138735. /**
  138736. * Gets the perf counter used for draw calls
  138737. */
  138738. get drawCallsCounter(): PerfCounter;
  138739. /**
  138740. * Instantiates a new scene instrumentation.
  138741. * This class can be used to get instrumentation data from a Babylon engine
  138742. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138743. * @param scene Defines the scene to instrument
  138744. */
  138745. constructor(
  138746. /**
  138747. * Defines the scene to instrument
  138748. */
  138749. scene: Scene);
  138750. /**
  138751. * Dispose and release associated resources.
  138752. */
  138753. dispose(): void;
  138754. }
  138755. }
  138756. declare module BABYLON {
  138757. /** @hidden */
  138758. export var glowMapGenerationPixelShader: {
  138759. name: string;
  138760. shader: string;
  138761. };
  138762. }
  138763. declare module BABYLON {
  138764. /** @hidden */
  138765. export var glowMapGenerationVertexShader: {
  138766. name: string;
  138767. shader: string;
  138768. };
  138769. }
  138770. declare module BABYLON {
  138771. /**
  138772. * Effect layer options. This helps customizing the behaviour
  138773. * of the effect layer.
  138774. */
  138775. export interface IEffectLayerOptions {
  138776. /**
  138777. * Multiplication factor apply to the canvas size to compute the render target size
  138778. * used to generated the objects (the smaller the faster).
  138779. */
  138780. mainTextureRatio: number;
  138781. /**
  138782. * Enforces a fixed size texture to ensure effect stability across devices.
  138783. */
  138784. mainTextureFixedSize?: number;
  138785. /**
  138786. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  138787. */
  138788. alphaBlendingMode: number;
  138789. /**
  138790. * The camera attached to the layer.
  138791. */
  138792. camera: Nullable<Camera>;
  138793. /**
  138794. * The rendering group to draw the layer in.
  138795. */
  138796. renderingGroupId: number;
  138797. }
  138798. /**
  138799. * The effect layer Helps adding post process effect blended with the main pass.
  138800. *
  138801. * This can be for instance use to generate glow or higlight effects on the scene.
  138802. *
  138803. * The effect layer class can not be used directly and is intented to inherited from to be
  138804. * customized per effects.
  138805. */
  138806. export abstract class EffectLayer {
  138807. private _vertexBuffers;
  138808. private _indexBuffer;
  138809. private _cachedDefines;
  138810. private _effectLayerMapGenerationEffect;
  138811. private _effectLayerOptions;
  138812. private _mergeEffect;
  138813. protected _scene: Scene;
  138814. protected _engine: Engine;
  138815. protected _maxSize: number;
  138816. protected _mainTextureDesiredSize: ISize;
  138817. protected _mainTexture: RenderTargetTexture;
  138818. protected _shouldRender: boolean;
  138819. protected _postProcesses: PostProcess[];
  138820. protected _textures: BaseTexture[];
  138821. protected _emissiveTextureAndColor: {
  138822. texture: Nullable<BaseTexture>;
  138823. color: Color4;
  138824. };
  138825. /**
  138826. * The name of the layer
  138827. */
  138828. name: string;
  138829. /**
  138830. * The clear color of the texture used to generate the glow map.
  138831. */
  138832. neutralColor: Color4;
  138833. /**
  138834. * Specifies whether the highlight layer is enabled or not.
  138835. */
  138836. isEnabled: boolean;
  138837. /**
  138838. * Gets the camera attached to the layer.
  138839. */
  138840. get camera(): Nullable<Camera>;
  138841. /**
  138842. * Gets the rendering group id the layer should render in.
  138843. */
  138844. get renderingGroupId(): number;
  138845. set renderingGroupId(renderingGroupId: number);
  138846. /**
  138847. * An event triggered when the effect layer has been disposed.
  138848. */
  138849. onDisposeObservable: Observable<EffectLayer>;
  138850. /**
  138851. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  138852. */
  138853. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  138854. /**
  138855. * An event triggered when the generated texture is being merged in the scene.
  138856. */
  138857. onBeforeComposeObservable: Observable<EffectLayer>;
  138858. /**
  138859. * An event triggered when the mesh is rendered into the effect render target.
  138860. */
  138861. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  138862. /**
  138863. * An event triggered after the mesh has been rendered into the effect render target.
  138864. */
  138865. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  138866. /**
  138867. * An event triggered when the generated texture has been merged in the scene.
  138868. */
  138869. onAfterComposeObservable: Observable<EffectLayer>;
  138870. /**
  138871. * An event triggered when the efffect layer changes its size.
  138872. */
  138873. onSizeChangedObservable: Observable<EffectLayer>;
  138874. /** @hidden */
  138875. static _SceneComponentInitialization: (scene: Scene) => void;
  138876. /**
  138877. * Instantiates a new effect Layer and references it in the scene.
  138878. * @param name The name of the layer
  138879. * @param scene The scene to use the layer in
  138880. */
  138881. constructor(
  138882. /** The Friendly of the effect in the scene */
  138883. name: string, scene: Scene);
  138884. /**
  138885. * Get the effect name of the layer.
  138886. * @return The effect name
  138887. */
  138888. abstract getEffectName(): string;
  138889. /**
  138890. * Checks for the readiness of the element composing the layer.
  138891. * @param subMesh the mesh to check for
  138892. * @param useInstances specify whether or not to use instances to render the mesh
  138893. * @return true if ready otherwise, false
  138894. */
  138895. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138896. /**
  138897. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  138898. * @returns true if the effect requires stencil during the main canvas render pass.
  138899. */
  138900. abstract needStencil(): boolean;
  138901. /**
  138902. * Create the merge effect. This is the shader use to blit the information back
  138903. * to the main canvas at the end of the scene rendering.
  138904. * @returns The effect containing the shader used to merge the effect on the main canvas
  138905. */
  138906. protected abstract _createMergeEffect(): Effect;
  138907. /**
  138908. * Creates the render target textures and post processes used in the effect layer.
  138909. */
  138910. protected abstract _createTextureAndPostProcesses(): void;
  138911. /**
  138912. * Implementation specific of rendering the generating effect on the main canvas.
  138913. * @param effect The effect used to render through
  138914. */
  138915. protected abstract _internalRender(effect: Effect): void;
  138916. /**
  138917. * Sets the required values for both the emissive texture and and the main color.
  138918. */
  138919. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138920. /**
  138921. * Free any resources and references associated to a mesh.
  138922. * Internal use
  138923. * @param mesh The mesh to free.
  138924. */
  138925. abstract _disposeMesh(mesh: Mesh): void;
  138926. /**
  138927. * Serializes this layer (Glow or Highlight for example)
  138928. * @returns a serialized layer object
  138929. */
  138930. abstract serialize?(): any;
  138931. /**
  138932. * Initializes the effect layer with the required options.
  138933. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  138934. */
  138935. protected _init(options: Partial<IEffectLayerOptions>): void;
  138936. /**
  138937. * Generates the index buffer of the full screen quad blending to the main canvas.
  138938. */
  138939. private _generateIndexBuffer;
  138940. /**
  138941. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  138942. */
  138943. private _generateVertexBuffer;
  138944. /**
  138945. * Sets the main texture desired size which is the closest power of two
  138946. * of the engine canvas size.
  138947. */
  138948. private _setMainTextureSize;
  138949. /**
  138950. * Creates the main texture for the effect layer.
  138951. */
  138952. protected _createMainTexture(): void;
  138953. /**
  138954. * Adds specific effects defines.
  138955. * @param defines The defines to add specifics to.
  138956. */
  138957. protected _addCustomEffectDefines(defines: string[]): void;
  138958. /**
  138959. * Checks for the readiness of the element composing the layer.
  138960. * @param subMesh the mesh to check for
  138961. * @param useInstances specify whether or not to use instances to render the mesh
  138962. * @param emissiveTexture the associated emissive texture used to generate the glow
  138963. * @return true if ready otherwise, false
  138964. */
  138965. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  138966. /**
  138967. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  138968. */
  138969. render(): void;
  138970. /**
  138971. * Determine if a given mesh will be used in the current effect.
  138972. * @param mesh mesh to test
  138973. * @returns true if the mesh will be used
  138974. */
  138975. hasMesh(mesh: AbstractMesh): boolean;
  138976. /**
  138977. * Returns true if the layer contains information to display, otherwise false.
  138978. * @returns true if the glow layer should be rendered
  138979. */
  138980. shouldRender(): boolean;
  138981. /**
  138982. * Returns true if the mesh should render, otherwise false.
  138983. * @param mesh The mesh to render
  138984. * @returns true if it should render otherwise false
  138985. */
  138986. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  138987. /**
  138988. * Returns true if the mesh can be rendered, otherwise false.
  138989. * @param mesh The mesh to render
  138990. * @param material The material used on the mesh
  138991. * @returns true if it can be rendered otherwise false
  138992. */
  138993. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138994. /**
  138995. * Returns true if the mesh should render, otherwise false.
  138996. * @param mesh The mesh to render
  138997. * @returns true if it should render otherwise false
  138998. */
  138999. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  139000. /**
  139001. * Renders the submesh passed in parameter to the generation map.
  139002. */
  139003. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  139004. /**
  139005. * Defines whether the current material of the mesh should be use to render the effect.
  139006. * @param mesh defines the current mesh to render
  139007. */
  139008. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  139009. /**
  139010. * Rebuild the required buffers.
  139011. * @hidden Internal use only.
  139012. */
  139013. _rebuild(): void;
  139014. /**
  139015. * Dispose only the render target textures and post process.
  139016. */
  139017. private _disposeTextureAndPostProcesses;
  139018. /**
  139019. * Dispose the highlight layer and free resources.
  139020. */
  139021. dispose(): void;
  139022. /**
  139023. * Gets the class name of the effect layer
  139024. * @returns the string with the class name of the effect layer
  139025. */
  139026. getClassName(): string;
  139027. /**
  139028. * Creates an effect layer from parsed effect layer data
  139029. * @param parsedEffectLayer defines effect layer data
  139030. * @param scene defines the current scene
  139031. * @param rootUrl defines the root URL containing the effect layer information
  139032. * @returns a parsed effect Layer
  139033. */
  139034. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  139035. }
  139036. }
  139037. declare module BABYLON {
  139038. interface AbstractScene {
  139039. /**
  139040. * The list of effect layers (highlights/glow) added to the scene
  139041. * @see https://doc.babylonjs.com/how_to/highlight_layer
  139042. * @see https://doc.babylonjs.com/how_to/glow_layer
  139043. */
  139044. effectLayers: Array<EffectLayer>;
  139045. /**
  139046. * Removes the given effect layer from this scene.
  139047. * @param toRemove defines the effect layer to remove
  139048. * @returns the index of the removed effect layer
  139049. */
  139050. removeEffectLayer(toRemove: EffectLayer): number;
  139051. /**
  139052. * Adds the given effect layer to this scene
  139053. * @param newEffectLayer defines the effect layer to add
  139054. */
  139055. addEffectLayer(newEffectLayer: EffectLayer): void;
  139056. }
  139057. /**
  139058. * Defines the layer scene component responsible to manage any effect layers
  139059. * in a given scene.
  139060. */
  139061. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  139062. /**
  139063. * The component name helpfull to identify the component in the list of scene components.
  139064. */
  139065. readonly name: string;
  139066. /**
  139067. * The scene the component belongs to.
  139068. */
  139069. scene: Scene;
  139070. private _engine;
  139071. private _renderEffects;
  139072. private _needStencil;
  139073. private _previousStencilState;
  139074. /**
  139075. * Creates a new instance of the component for the given scene
  139076. * @param scene Defines the scene to register the component in
  139077. */
  139078. constructor(scene: Scene);
  139079. /**
  139080. * Registers the component in a given scene
  139081. */
  139082. register(): void;
  139083. /**
  139084. * Rebuilds the elements related to this component in case of
  139085. * context lost for instance.
  139086. */
  139087. rebuild(): void;
  139088. /**
  139089. * Serializes the component data to the specified json object
  139090. * @param serializationObject The object to serialize to
  139091. */
  139092. serialize(serializationObject: any): void;
  139093. /**
  139094. * Adds all the elements from the container to the scene
  139095. * @param container the container holding the elements
  139096. */
  139097. addFromContainer(container: AbstractScene): void;
  139098. /**
  139099. * Removes all the elements in the container from the scene
  139100. * @param container contains the elements to remove
  139101. * @param dispose if the removed element should be disposed (default: false)
  139102. */
  139103. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139104. /**
  139105. * Disposes the component and the associated ressources.
  139106. */
  139107. dispose(): void;
  139108. private _isReadyForMesh;
  139109. private _renderMainTexture;
  139110. private _setStencil;
  139111. private _setStencilBack;
  139112. private _draw;
  139113. private _drawCamera;
  139114. private _drawRenderingGroup;
  139115. }
  139116. }
  139117. declare module BABYLON {
  139118. /** @hidden */
  139119. export var glowMapMergePixelShader: {
  139120. name: string;
  139121. shader: string;
  139122. };
  139123. }
  139124. declare module BABYLON {
  139125. /** @hidden */
  139126. export var glowMapMergeVertexShader: {
  139127. name: string;
  139128. shader: string;
  139129. };
  139130. }
  139131. declare module BABYLON {
  139132. interface AbstractScene {
  139133. /**
  139134. * Return a the first highlight layer of the scene with a given name.
  139135. * @param name The name of the highlight layer to look for.
  139136. * @return The highlight layer if found otherwise null.
  139137. */
  139138. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  139139. }
  139140. /**
  139141. * Glow layer options. This helps customizing the behaviour
  139142. * of the glow layer.
  139143. */
  139144. export interface IGlowLayerOptions {
  139145. /**
  139146. * Multiplication factor apply to the canvas size to compute the render target size
  139147. * used to generated the glowing objects (the smaller the faster).
  139148. */
  139149. mainTextureRatio: number;
  139150. /**
  139151. * Enforces a fixed size texture to ensure resize independant blur.
  139152. */
  139153. mainTextureFixedSize?: number;
  139154. /**
  139155. * How big is the kernel of the blur texture.
  139156. */
  139157. blurKernelSize: number;
  139158. /**
  139159. * The camera attached to the layer.
  139160. */
  139161. camera: Nullable<Camera>;
  139162. /**
  139163. * Enable MSAA by chosing the number of samples.
  139164. */
  139165. mainTextureSamples?: number;
  139166. /**
  139167. * The rendering group to draw the layer in.
  139168. */
  139169. renderingGroupId: number;
  139170. }
  139171. /**
  139172. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  139173. *
  139174. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  139175. *
  139176. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  139177. */
  139178. export class GlowLayer extends EffectLayer {
  139179. /**
  139180. * Effect Name of the layer.
  139181. */
  139182. static readonly EffectName: string;
  139183. /**
  139184. * The default blur kernel size used for the glow.
  139185. */
  139186. static DefaultBlurKernelSize: number;
  139187. /**
  139188. * The default texture size ratio used for the glow.
  139189. */
  139190. static DefaultTextureRatio: number;
  139191. /**
  139192. * Sets the kernel size of the blur.
  139193. */
  139194. set blurKernelSize(value: number);
  139195. /**
  139196. * Gets the kernel size of the blur.
  139197. */
  139198. get blurKernelSize(): number;
  139199. /**
  139200. * Sets the glow intensity.
  139201. */
  139202. set intensity(value: number);
  139203. /**
  139204. * Gets the glow intensity.
  139205. */
  139206. get intensity(): number;
  139207. private _options;
  139208. private _intensity;
  139209. private _horizontalBlurPostprocess1;
  139210. private _verticalBlurPostprocess1;
  139211. private _horizontalBlurPostprocess2;
  139212. private _verticalBlurPostprocess2;
  139213. private _blurTexture1;
  139214. private _blurTexture2;
  139215. private _postProcesses1;
  139216. private _postProcesses2;
  139217. private _includedOnlyMeshes;
  139218. private _excludedMeshes;
  139219. private _meshesUsingTheirOwnMaterials;
  139220. /**
  139221. * Callback used to let the user override the color selection on a per mesh basis
  139222. */
  139223. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  139224. /**
  139225. * Callback used to let the user override the texture selection on a per mesh basis
  139226. */
  139227. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  139228. /**
  139229. * Instantiates a new glow Layer and references it to the scene.
  139230. * @param name The name of the layer
  139231. * @param scene The scene to use the layer in
  139232. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  139233. */
  139234. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  139235. /**
  139236. * Get the effect name of the layer.
  139237. * @return The effect name
  139238. */
  139239. getEffectName(): string;
  139240. /**
  139241. * Create the merge effect. This is the shader use to blit the information back
  139242. * to the main canvas at the end of the scene rendering.
  139243. */
  139244. protected _createMergeEffect(): Effect;
  139245. /**
  139246. * Creates the render target textures and post processes used in the glow layer.
  139247. */
  139248. protected _createTextureAndPostProcesses(): void;
  139249. /**
  139250. * Checks for the readiness of the element composing the layer.
  139251. * @param subMesh the mesh to check for
  139252. * @param useInstances specify wether or not to use instances to render the mesh
  139253. * @param emissiveTexture the associated emissive texture used to generate the glow
  139254. * @return true if ready otherwise, false
  139255. */
  139256. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139257. /**
  139258. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139259. */
  139260. needStencil(): boolean;
  139261. /**
  139262. * Returns true if the mesh can be rendered, otherwise false.
  139263. * @param mesh The mesh to render
  139264. * @param material The material used on the mesh
  139265. * @returns true if it can be rendered otherwise false
  139266. */
  139267. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139268. /**
  139269. * Implementation specific of rendering the generating effect on the main canvas.
  139270. * @param effect The effect used to render through
  139271. */
  139272. protected _internalRender(effect: Effect): void;
  139273. /**
  139274. * Sets the required values for both the emissive texture and and the main color.
  139275. */
  139276. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139277. /**
  139278. * Returns true if the mesh should render, otherwise false.
  139279. * @param mesh The mesh to render
  139280. * @returns true if it should render otherwise false
  139281. */
  139282. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139283. /**
  139284. * Adds specific effects defines.
  139285. * @param defines The defines to add specifics to.
  139286. */
  139287. protected _addCustomEffectDefines(defines: string[]): void;
  139288. /**
  139289. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  139290. * @param mesh The mesh to exclude from the glow layer
  139291. */
  139292. addExcludedMesh(mesh: Mesh): void;
  139293. /**
  139294. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  139295. * @param mesh The mesh to remove
  139296. */
  139297. removeExcludedMesh(mesh: Mesh): void;
  139298. /**
  139299. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  139300. * @param mesh The mesh to include in the glow layer
  139301. */
  139302. addIncludedOnlyMesh(mesh: Mesh): void;
  139303. /**
  139304. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  139305. * @param mesh The mesh to remove
  139306. */
  139307. removeIncludedOnlyMesh(mesh: Mesh): void;
  139308. /**
  139309. * Determine if a given mesh will be used in the glow layer
  139310. * @param mesh The mesh to test
  139311. * @returns true if the mesh will be highlighted by the current glow layer
  139312. */
  139313. hasMesh(mesh: AbstractMesh): boolean;
  139314. /**
  139315. * Defines whether the current material of the mesh should be use to render the effect.
  139316. * @param mesh defines the current mesh to render
  139317. */
  139318. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  139319. /**
  139320. * Add a mesh to be rendered through its own material and not with emissive only.
  139321. * @param mesh The mesh for which we need to use its material
  139322. */
  139323. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  139324. /**
  139325. * Remove a mesh from being rendered through its own material and not with emissive only.
  139326. * @param mesh The mesh for which we need to not use its material
  139327. */
  139328. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  139329. /**
  139330. * Free any resources and references associated to a mesh.
  139331. * Internal use
  139332. * @param mesh The mesh to free.
  139333. * @hidden
  139334. */
  139335. _disposeMesh(mesh: Mesh): void;
  139336. /**
  139337. * Gets the class name of the effect layer
  139338. * @returns the string with the class name of the effect layer
  139339. */
  139340. getClassName(): string;
  139341. /**
  139342. * Serializes this glow layer
  139343. * @returns a serialized glow layer object
  139344. */
  139345. serialize(): any;
  139346. /**
  139347. * Creates a Glow Layer from parsed glow layer data
  139348. * @param parsedGlowLayer defines glow layer data
  139349. * @param scene defines the current scene
  139350. * @param rootUrl defines the root URL containing the glow layer information
  139351. * @returns a parsed Glow Layer
  139352. */
  139353. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  139354. }
  139355. }
  139356. declare module BABYLON {
  139357. /** @hidden */
  139358. export var glowBlurPostProcessPixelShader: {
  139359. name: string;
  139360. shader: string;
  139361. };
  139362. }
  139363. declare module BABYLON {
  139364. interface AbstractScene {
  139365. /**
  139366. * Return a the first highlight layer of the scene with a given name.
  139367. * @param name The name of the highlight layer to look for.
  139368. * @return The highlight layer if found otherwise null.
  139369. */
  139370. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  139371. }
  139372. /**
  139373. * Highlight layer options. This helps customizing the behaviour
  139374. * of the highlight layer.
  139375. */
  139376. export interface IHighlightLayerOptions {
  139377. /**
  139378. * Multiplication factor apply to the canvas size to compute the render target size
  139379. * used to generated the glowing objects (the smaller the faster).
  139380. */
  139381. mainTextureRatio: number;
  139382. /**
  139383. * Enforces a fixed size texture to ensure resize independant blur.
  139384. */
  139385. mainTextureFixedSize?: number;
  139386. /**
  139387. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  139388. * of the picture to blur (the smaller the faster).
  139389. */
  139390. blurTextureSizeRatio: number;
  139391. /**
  139392. * How big in texel of the blur texture is the vertical blur.
  139393. */
  139394. blurVerticalSize: number;
  139395. /**
  139396. * How big in texel of the blur texture is the horizontal blur.
  139397. */
  139398. blurHorizontalSize: number;
  139399. /**
  139400. * Alpha blending mode used to apply the blur. Default is combine.
  139401. */
  139402. alphaBlendingMode: number;
  139403. /**
  139404. * The camera attached to the layer.
  139405. */
  139406. camera: Nullable<Camera>;
  139407. /**
  139408. * Should we display highlight as a solid stroke?
  139409. */
  139410. isStroke?: boolean;
  139411. /**
  139412. * The rendering group to draw the layer in.
  139413. */
  139414. renderingGroupId: number;
  139415. }
  139416. /**
  139417. * The highlight layer Helps adding a glow effect around a mesh.
  139418. *
  139419. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  139420. * glowy meshes to your scene.
  139421. *
  139422. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  139423. */
  139424. export class HighlightLayer extends EffectLayer {
  139425. name: string;
  139426. /**
  139427. * Effect Name of the highlight layer.
  139428. */
  139429. static readonly EffectName: string;
  139430. /**
  139431. * The neutral color used during the preparation of the glow effect.
  139432. * This is black by default as the blend operation is a blend operation.
  139433. */
  139434. static NeutralColor: Color4;
  139435. /**
  139436. * Stencil value used for glowing meshes.
  139437. */
  139438. static GlowingMeshStencilReference: number;
  139439. /**
  139440. * Stencil value used for the other meshes in the scene.
  139441. */
  139442. static NormalMeshStencilReference: number;
  139443. /**
  139444. * Specifies whether or not the inner glow is ACTIVE in the layer.
  139445. */
  139446. innerGlow: boolean;
  139447. /**
  139448. * Specifies whether or not the outer glow is ACTIVE in the layer.
  139449. */
  139450. outerGlow: boolean;
  139451. /**
  139452. * Specifies the horizontal size of the blur.
  139453. */
  139454. set blurHorizontalSize(value: number);
  139455. /**
  139456. * Specifies the vertical size of the blur.
  139457. */
  139458. set blurVerticalSize(value: number);
  139459. /**
  139460. * Gets the horizontal size of the blur.
  139461. */
  139462. get blurHorizontalSize(): number;
  139463. /**
  139464. * Gets the vertical size of the blur.
  139465. */
  139466. get blurVerticalSize(): number;
  139467. /**
  139468. * An event triggered when the highlight layer is being blurred.
  139469. */
  139470. onBeforeBlurObservable: Observable<HighlightLayer>;
  139471. /**
  139472. * An event triggered when the highlight layer has been blurred.
  139473. */
  139474. onAfterBlurObservable: Observable<HighlightLayer>;
  139475. private _instanceGlowingMeshStencilReference;
  139476. private _options;
  139477. private _downSamplePostprocess;
  139478. private _horizontalBlurPostprocess;
  139479. private _verticalBlurPostprocess;
  139480. private _blurTexture;
  139481. private _meshes;
  139482. private _excludedMeshes;
  139483. /**
  139484. * Instantiates a new highlight Layer and references it to the scene..
  139485. * @param name The name of the layer
  139486. * @param scene The scene to use the layer in
  139487. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  139488. */
  139489. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  139490. /**
  139491. * Get the effect name of the layer.
  139492. * @return The effect name
  139493. */
  139494. getEffectName(): string;
  139495. /**
  139496. * Create the merge effect. This is the shader use to blit the information back
  139497. * to the main canvas at the end of the scene rendering.
  139498. */
  139499. protected _createMergeEffect(): Effect;
  139500. /**
  139501. * Creates the render target textures and post processes used in the highlight layer.
  139502. */
  139503. protected _createTextureAndPostProcesses(): void;
  139504. /**
  139505. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  139506. */
  139507. needStencil(): boolean;
  139508. /**
  139509. * Checks for the readiness of the element composing the layer.
  139510. * @param subMesh the mesh to check for
  139511. * @param useInstances specify wether or not to use instances to render the mesh
  139512. * @param emissiveTexture the associated emissive texture used to generate the glow
  139513. * @return true if ready otherwise, false
  139514. */
  139515. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139516. /**
  139517. * Implementation specific of rendering the generating effect on the main canvas.
  139518. * @param effect The effect used to render through
  139519. */
  139520. protected _internalRender(effect: Effect): void;
  139521. /**
  139522. * Returns true if the layer contains information to display, otherwise false.
  139523. */
  139524. shouldRender(): boolean;
  139525. /**
  139526. * Returns true if the mesh should render, otherwise false.
  139527. * @param mesh The mesh to render
  139528. * @returns true if it should render otherwise false
  139529. */
  139530. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139531. /**
  139532. * Returns true if the mesh can be rendered, otherwise false.
  139533. * @param mesh The mesh to render
  139534. * @param material The material used on the mesh
  139535. * @returns true if it can be rendered otherwise false
  139536. */
  139537. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139538. /**
  139539. * Adds specific effects defines.
  139540. * @param defines The defines to add specifics to.
  139541. */
  139542. protected _addCustomEffectDefines(defines: string[]): void;
  139543. /**
  139544. * Sets the required values for both the emissive texture and and the main color.
  139545. */
  139546. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139547. /**
  139548. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  139549. * @param mesh The mesh to exclude from the highlight layer
  139550. */
  139551. addExcludedMesh(mesh: Mesh): void;
  139552. /**
  139553. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  139554. * @param mesh The mesh to highlight
  139555. */
  139556. removeExcludedMesh(mesh: Mesh): void;
  139557. /**
  139558. * Determine if a given mesh will be highlighted by the current HighlightLayer
  139559. * @param mesh mesh to test
  139560. * @returns true if the mesh will be highlighted by the current HighlightLayer
  139561. */
  139562. hasMesh(mesh: AbstractMesh): boolean;
  139563. /**
  139564. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  139565. * @param mesh The mesh to highlight
  139566. * @param color The color of the highlight
  139567. * @param glowEmissiveOnly Extract the glow from the emissive texture
  139568. */
  139569. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  139570. /**
  139571. * Remove a mesh from the highlight layer in order to make it stop glowing.
  139572. * @param mesh The mesh to highlight
  139573. */
  139574. removeMesh(mesh: Mesh): void;
  139575. /**
  139576. * Remove all the meshes currently referenced in the highlight layer
  139577. */
  139578. removeAllMeshes(): void;
  139579. /**
  139580. * Force the stencil to the normal expected value for none glowing parts
  139581. */
  139582. private _defaultStencilReference;
  139583. /**
  139584. * Free any resources and references associated to a mesh.
  139585. * Internal use
  139586. * @param mesh The mesh to free.
  139587. * @hidden
  139588. */
  139589. _disposeMesh(mesh: Mesh): void;
  139590. /**
  139591. * Dispose the highlight layer and free resources.
  139592. */
  139593. dispose(): void;
  139594. /**
  139595. * Gets the class name of the effect layer
  139596. * @returns the string with the class name of the effect layer
  139597. */
  139598. getClassName(): string;
  139599. /**
  139600. * Serializes this Highlight layer
  139601. * @returns a serialized Highlight layer object
  139602. */
  139603. serialize(): any;
  139604. /**
  139605. * Creates a Highlight layer from parsed Highlight layer data
  139606. * @param parsedHightlightLayer defines the Highlight layer data
  139607. * @param scene defines the current scene
  139608. * @param rootUrl defines the root URL containing the Highlight layer information
  139609. * @returns a parsed Highlight layer
  139610. */
  139611. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  139612. }
  139613. }
  139614. declare module BABYLON {
  139615. interface AbstractScene {
  139616. /**
  139617. * The list of layers (background and foreground) of the scene
  139618. */
  139619. layers: Array<Layer>;
  139620. }
  139621. /**
  139622. * Defines the layer scene component responsible to manage any layers
  139623. * in a given scene.
  139624. */
  139625. export class LayerSceneComponent implements ISceneComponent {
  139626. /**
  139627. * The component name helpfull to identify the component in the list of scene components.
  139628. */
  139629. readonly name: string;
  139630. /**
  139631. * The scene the component belongs to.
  139632. */
  139633. scene: Scene;
  139634. private _engine;
  139635. /**
  139636. * Creates a new instance of the component for the given scene
  139637. * @param scene Defines the scene to register the component in
  139638. */
  139639. constructor(scene: Scene);
  139640. /**
  139641. * Registers the component in a given scene
  139642. */
  139643. register(): void;
  139644. /**
  139645. * Rebuilds the elements related to this component in case of
  139646. * context lost for instance.
  139647. */
  139648. rebuild(): void;
  139649. /**
  139650. * Disposes the component and the associated ressources.
  139651. */
  139652. dispose(): void;
  139653. private _draw;
  139654. private _drawCameraPredicate;
  139655. private _drawCameraBackground;
  139656. private _drawCameraForeground;
  139657. private _drawRenderTargetPredicate;
  139658. private _drawRenderTargetBackground;
  139659. private _drawRenderTargetForeground;
  139660. /**
  139661. * Adds all the elements from the container to the scene
  139662. * @param container the container holding the elements
  139663. */
  139664. addFromContainer(container: AbstractScene): void;
  139665. /**
  139666. * Removes all the elements in the container from the scene
  139667. * @param container contains the elements to remove
  139668. * @param dispose if the removed element should be disposed (default: false)
  139669. */
  139670. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139671. }
  139672. }
  139673. declare module BABYLON {
  139674. /** @hidden */
  139675. export var layerPixelShader: {
  139676. name: string;
  139677. shader: string;
  139678. };
  139679. }
  139680. declare module BABYLON {
  139681. /** @hidden */
  139682. export var layerVertexShader: {
  139683. name: string;
  139684. shader: string;
  139685. };
  139686. }
  139687. declare module BABYLON {
  139688. /**
  139689. * This represents a full screen 2d layer.
  139690. * This can be useful to display a picture in the background of your scene for instance.
  139691. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139692. */
  139693. export class Layer {
  139694. /**
  139695. * Define the name of the layer.
  139696. */
  139697. name: string;
  139698. /**
  139699. * Define the texture the layer should display.
  139700. */
  139701. texture: Nullable<Texture>;
  139702. /**
  139703. * Is the layer in background or foreground.
  139704. */
  139705. isBackground: boolean;
  139706. /**
  139707. * Define the color of the layer (instead of texture).
  139708. */
  139709. color: Color4;
  139710. /**
  139711. * Define the scale of the layer in order to zoom in out of the texture.
  139712. */
  139713. scale: Vector2;
  139714. /**
  139715. * Define an offset for the layer in order to shift the texture.
  139716. */
  139717. offset: Vector2;
  139718. /**
  139719. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  139720. */
  139721. alphaBlendingMode: number;
  139722. /**
  139723. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  139724. * Alpha test will not mix with the background color in case of transparency.
  139725. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  139726. */
  139727. alphaTest: boolean;
  139728. /**
  139729. * Define a mask to restrict the layer to only some of the scene cameras.
  139730. */
  139731. layerMask: number;
  139732. /**
  139733. * Define the list of render target the layer is visible into.
  139734. */
  139735. renderTargetTextures: RenderTargetTexture[];
  139736. /**
  139737. * Define if the layer is only used in renderTarget or if it also
  139738. * renders in the main frame buffer of the canvas.
  139739. */
  139740. renderOnlyInRenderTargetTextures: boolean;
  139741. private _scene;
  139742. private _vertexBuffers;
  139743. private _indexBuffer;
  139744. private _effect;
  139745. private _previousDefines;
  139746. /**
  139747. * An event triggered when the layer is disposed.
  139748. */
  139749. onDisposeObservable: Observable<Layer>;
  139750. private _onDisposeObserver;
  139751. /**
  139752. * Back compatibility with callback before the onDisposeObservable existed.
  139753. * The set callback will be triggered when the layer has been disposed.
  139754. */
  139755. set onDispose(callback: () => void);
  139756. /**
  139757. * An event triggered before rendering the scene
  139758. */
  139759. onBeforeRenderObservable: Observable<Layer>;
  139760. private _onBeforeRenderObserver;
  139761. /**
  139762. * Back compatibility with callback before the onBeforeRenderObservable existed.
  139763. * The set callback will be triggered just before rendering the layer.
  139764. */
  139765. set onBeforeRender(callback: () => void);
  139766. /**
  139767. * An event triggered after rendering the scene
  139768. */
  139769. onAfterRenderObservable: Observable<Layer>;
  139770. private _onAfterRenderObserver;
  139771. /**
  139772. * Back compatibility with callback before the onAfterRenderObservable existed.
  139773. * The set callback will be triggered just after rendering the layer.
  139774. */
  139775. set onAfterRender(callback: () => void);
  139776. /**
  139777. * Instantiates a new layer.
  139778. * This represents a full screen 2d layer.
  139779. * This can be useful to display a picture in the background of your scene for instance.
  139780. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139781. * @param name Define the name of the layer in the scene
  139782. * @param imgUrl Define the url of the texture to display in the layer
  139783. * @param scene Define the scene the layer belongs to
  139784. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  139785. * @param color Defines a color for the layer
  139786. */
  139787. constructor(
  139788. /**
  139789. * Define the name of the layer.
  139790. */
  139791. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  139792. private _createIndexBuffer;
  139793. /** @hidden */
  139794. _rebuild(): void;
  139795. /**
  139796. * Renders the layer in the scene.
  139797. */
  139798. render(): void;
  139799. /**
  139800. * Disposes and releases the associated ressources.
  139801. */
  139802. dispose(): void;
  139803. }
  139804. }
  139805. declare module BABYLON {
  139806. /** @hidden */
  139807. export var lensFlarePixelShader: {
  139808. name: string;
  139809. shader: string;
  139810. };
  139811. }
  139812. declare module BABYLON {
  139813. /** @hidden */
  139814. export var lensFlareVertexShader: {
  139815. name: string;
  139816. shader: string;
  139817. };
  139818. }
  139819. declare module BABYLON {
  139820. /**
  139821. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139822. * It is usually composed of several `lensFlare`.
  139823. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139824. */
  139825. export class LensFlareSystem {
  139826. /**
  139827. * Define the name of the lens flare system
  139828. */
  139829. name: string;
  139830. /**
  139831. * List of lens flares used in this system.
  139832. */
  139833. lensFlares: LensFlare[];
  139834. /**
  139835. * Define a limit from the border the lens flare can be visible.
  139836. */
  139837. borderLimit: number;
  139838. /**
  139839. * Define a viewport border we do not want to see the lens flare in.
  139840. */
  139841. viewportBorder: number;
  139842. /**
  139843. * Define a predicate which could limit the list of meshes able to occlude the effect.
  139844. */
  139845. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  139846. /**
  139847. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  139848. */
  139849. layerMask: number;
  139850. /**
  139851. * Define the id of the lens flare system in the scene.
  139852. * (equal to name by default)
  139853. */
  139854. id: string;
  139855. private _scene;
  139856. private _emitter;
  139857. private _vertexBuffers;
  139858. private _indexBuffer;
  139859. private _effect;
  139860. private _positionX;
  139861. private _positionY;
  139862. private _isEnabled;
  139863. /** @hidden */
  139864. static _SceneComponentInitialization: (scene: Scene) => void;
  139865. /**
  139866. * Instantiates a lens flare system.
  139867. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139868. * It is usually composed of several `lensFlare`.
  139869. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139870. * @param name Define the name of the lens flare system in the scene
  139871. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  139872. * @param scene Define the scene the lens flare system belongs to
  139873. */
  139874. constructor(
  139875. /**
  139876. * Define the name of the lens flare system
  139877. */
  139878. name: string, emitter: any, scene: Scene);
  139879. /**
  139880. * Define if the lens flare system is enabled.
  139881. */
  139882. get isEnabled(): boolean;
  139883. set isEnabled(value: boolean);
  139884. /**
  139885. * Get the scene the effects belongs to.
  139886. * @returns the scene holding the lens flare system
  139887. */
  139888. getScene(): Scene;
  139889. /**
  139890. * Get the emitter of the lens flare system.
  139891. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139892. * @returns the emitter of the lens flare system
  139893. */
  139894. getEmitter(): any;
  139895. /**
  139896. * Set the emitter of the lens flare system.
  139897. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139898. * @param newEmitter Define the new emitter of the system
  139899. */
  139900. setEmitter(newEmitter: any): void;
  139901. /**
  139902. * Get the lens flare system emitter position.
  139903. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  139904. * @returns the position
  139905. */
  139906. getEmitterPosition(): Vector3;
  139907. /**
  139908. * @hidden
  139909. */
  139910. computeEffectivePosition(globalViewport: Viewport): boolean;
  139911. /** @hidden */
  139912. _isVisible(): boolean;
  139913. /**
  139914. * @hidden
  139915. */
  139916. render(): boolean;
  139917. /**
  139918. * Dispose and release the lens flare with its associated resources.
  139919. */
  139920. dispose(): void;
  139921. /**
  139922. * Parse a lens flare system from a JSON repressentation
  139923. * @param parsedLensFlareSystem Define the JSON to parse
  139924. * @param scene Define the scene the parsed system should be instantiated in
  139925. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  139926. * @returns the parsed system
  139927. */
  139928. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  139929. /**
  139930. * Serialize the current Lens Flare System into a JSON representation.
  139931. * @returns the serialized JSON
  139932. */
  139933. serialize(): any;
  139934. }
  139935. }
  139936. declare module BABYLON {
  139937. /**
  139938. * This represents one of the lens effect in a `lensFlareSystem`.
  139939. * It controls one of the indiviual texture used in the effect.
  139940. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139941. */
  139942. export class LensFlare {
  139943. /**
  139944. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139945. */
  139946. size: number;
  139947. /**
  139948. * 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.
  139949. */
  139950. position: number;
  139951. /**
  139952. * Define the lens color.
  139953. */
  139954. color: Color3;
  139955. /**
  139956. * Define the lens texture.
  139957. */
  139958. texture: Nullable<Texture>;
  139959. /**
  139960. * Define the alpha mode to render this particular lens.
  139961. */
  139962. alphaMode: number;
  139963. private _system;
  139964. /**
  139965. * Creates a new Lens Flare.
  139966. * This represents one of the lens effect in a `lensFlareSystem`.
  139967. * It controls one of the indiviual texture used in the effect.
  139968. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139969. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  139970. * @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.
  139971. * @param color Define the lens color
  139972. * @param imgUrl Define the lens texture url
  139973. * @param system Define the `lensFlareSystem` this flare is part of
  139974. * @returns The newly created Lens Flare
  139975. */
  139976. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  139977. /**
  139978. * Instantiates a new Lens Flare.
  139979. * This represents one of the lens effect in a `lensFlareSystem`.
  139980. * It controls one of the indiviual texture used in the effect.
  139981. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139982. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  139983. * @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.
  139984. * @param color Define the lens color
  139985. * @param imgUrl Define the lens texture url
  139986. * @param system Define the `lensFlareSystem` this flare is part of
  139987. */
  139988. constructor(
  139989. /**
  139990. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139991. */
  139992. size: number,
  139993. /**
  139994. * 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.
  139995. */
  139996. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  139997. /**
  139998. * Dispose and release the lens flare with its associated resources.
  139999. */
  140000. dispose(): void;
  140001. }
  140002. }
  140003. declare module BABYLON {
  140004. interface AbstractScene {
  140005. /**
  140006. * The list of lens flare system added to the scene
  140007. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140008. */
  140009. lensFlareSystems: Array<LensFlareSystem>;
  140010. /**
  140011. * Removes the given lens flare system from this scene.
  140012. * @param toRemove The lens flare system to remove
  140013. * @returns The index of the removed lens flare system
  140014. */
  140015. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  140016. /**
  140017. * Adds the given lens flare system to this scene
  140018. * @param newLensFlareSystem The lens flare system to add
  140019. */
  140020. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  140021. /**
  140022. * Gets a lens flare system using its name
  140023. * @param name defines the name to look for
  140024. * @returns the lens flare system or null if not found
  140025. */
  140026. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  140027. /**
  140028. * Gets a lens flare system using its id
  140029. * @param id defines the id to look for
  140030. * @returns the lens flare system or null if not found
  140031. */
  140032. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  140033. }
  140034. /**
  140035. * Defines the lens flare scene component responsible to manage any lens flares
  140036. * in a given scene.
  140037. */
  140038. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  140039. /**
  140040. * The component name helpfull to identify the component in the list of scene components.
  140041. */
  140042. readonly name: string;
  140043. /**
  140044. * The scene the component belongs to.
  140045. */
  140046. scene: Scene;
  140047. /**
  140048. * Creates a new instance of the component for the given scene
  140049. * @param scene Defines the scene to register the component in
  140050. */
  140051. constructor(scene: Scene);
  140052. /**
  140053. * Registers the component in a given scene
  140054. */
  140055. register(): void;
  140056. /**
  140057. * Rebuilds the elements related to this component in case of
  140058. * context lost for instance.
  140059. */
  140060. rebuild(): void;
  140061. /**
  140062. * Adds all the elements from the container to the scene
  140063. * @param container the container holding the elements
  140064. */
  140065. addFromContainer(container: AbstractScene): void;
  140066. /**
  140067. * Removes all the elements in the container from the scene
  140068. * @param container contains the elements to remove
  140069. * @param dispose if the removed element should be disposed (default: false)
  140070. */
  140071. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140072. /**
  140073. * Serializes the component data to the specified json object
  140074. * @param serializationObject The object to serialize to
  140075. */
  140076. serialize(serializationObject: any): void;
  140077. /**
  140078. * Disposes the component and the associated ressources.
  140079. */
  140080. dispose(): void;
  140081. private _draw;
  140082. }
  140083. }
  140084. declare module BABYLON {
  140085. /** @hidden */
  140086. export var depthPixelShader: {
  140087. name: string;
  140088. shader: string;
  140089. };
  140090. }
  140091. declare module BABYLON {
  140092. /** @hidden */
  140093. export var depthVertexShader: {
  140094. name: string;
  140095. shader: string;
  140096. };
  140097. }
  140098. declare module BABYLON {
  140099. /**
  140100. * This represents a depth renderer in Babylon.
  140101. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  140102. */
  140103. export class DepthRenderer {
  140104. private _scene;
  140105. private _depthMap;
  140106. private _effect;
  140107. private readonly _storeNonLinearDepth;
  140108. private readonly _clearColor;
  140109. /** Get if the depth renderer is using packed depth or not */
  140110. readonly isPacked: boolean;
  140111. private _cachedDefines;
  140112. private _camera;
  140113. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  140114. enabled: boolean;
  140115. /**
  140116. * Specifiess that the depth renderer will only be used within
  140117. * the camera it is created for.
  140118. * This can help forcing its rendering during the camera processing.
  140119. */
  140120. useOnlyInActiveCamera: boolean;
  140121. /** @hidden */
  140122. static _SceneComponentInitialization: (scene: Scene) => void;
  140123. /**
  140124. * Instantiates a depth renderer
  140125. * @param scene The scene the renderer belongs to
  140126. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  140127. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  140128. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  140129. */
  140130. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  140131. /**
  140132. * Creates the depth rendering effect and checks if the effect is ready.
  140133. * @param subMesh The submesh to be used to render the depth map of
  140134. * @param useInstances If multiple world instances should be used
  140135. * @returns if the depth renderer is ready to render the depth map
  140136. */
  140137. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140138. /**
  140139. * Gets the texture which the depth map will be written to.
  140140. * @returns The depth map texture
  140141. */
  140142. getDepthMap(): RenderTargetTexture;
  140143. /**
  140144. * Disposes of the depth renderer.
  140145. */
  140146. dispose(): void;
  140147. }
  140148. }
  140149. declare module BABYLON {
  140150. /** @hidden */
  140151. export var minmaxReduxPixelShader: {
  140152. name: string;
  140153. shader: string;
  140154. };
  140155. }
  140156. declare module BABYLON {
  140157. /**
  140158. * This class computes a min/max reduction from a texture: it means it computes the minimum
  140159. * and maximum values from all values of the texture.
  140160. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  140161. * The source values are read from the red channel of the texture.
  140162. */
  140163. export class MinMaxReducer {
  140164. /**
  140165. * Observable triggered when the computation has been performed
  140166. */
  140167. onAfterReductionPerformed: Observable<{
  140168. min: number;
  140169. max: number;
  140170. }>;
  140171. protected _camera: Camera;
  140172. protected _sourceTexture: Nullable<RenderTargetTexture>;
  140173. protected _reductionSteps: Nullable<Array<PostProcess>>;
  140174. protected _postProcessManager: PostProcessManager;
  140175. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  140176. protected _forceFullscreenViewport: boolean;
  140177. /**
  140178. * Creates a min/max reducer
  140179. * @param camera The camera to use for the post processes
  140180. */
  140181. constructor(camera: Camera);
  140182. /**
  140183. * Gets the texture used to read the values from.
  140184. */
  140185. get sourceTexture(): Nullable<RenderTargetTexture>;
  140186. /**
  140187. * Sets the source texture to read the values from.
  140188. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  140189. * because in such textures '1' value must not be taken into account to compute the maximum
  140190. * as this value is used to clear the texture.
  140191. * Note that the computation is not activated by calling this function, you must call activate() for that!
  140192. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  140193. * @param depthRedux Indicates if the texture is a depth texture or not
  140194. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  140195. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140196. */
  140197. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140198. /**
  140199. * Defines the refresh rate of the computation.
  140200. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140201. */
  140202. get refreshRate(): number;
  140203. set refreshRate(value: number);
  140204. protected _activated: boolean;
  140205. /**
  140206. * Gets the activation status of the reducer
  140207. */
  140208. get activated(): boolean;
  140209. /**
  140210. * Activates the reduction computation.
  140211. * When activated, the observers registered in onAfterReductionPerformed are
  140212. * called after the compuation is performed
  140213. */
  140214. activate(): void;
  140215. /**
  140216. * Deactivates the reduction computation.
  140217. */
  140218. deactivate(): void;
  140219. /**
  140220. * Disposes the min/max reducer
  140221. * @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.
  140222. */
  140223. dispose(disposeAll?: boolean): void;
  140224. }
  140225. }
  140226. declare module BABYLON {
  140227. /**
  140228. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  140229. */
  140230. export class DepthReducer extends MinMaxReducer {
  140231. private _depthRenderer;
  140232. private _depthRendererId;
  140233. /**
  140234. * Gets the depth renderer used for the computation.
  140235. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  140236. */
  140237. get depthRenderer(): Nullable<DepthRenderer>;
  140238. /**
  140239. * Creates a depth reducer
  140240. * @param camera The camera used to render the depth texture
  140241. */
  140242. constructor(camera: Camera);
  140243. /**
  140244. * Sets the depth renderer to use to generate the depth map
  140245. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  140246. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  140247. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140248. */
  140249. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  140250. /** @hidden */
  140251. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140252. /**
  140253. * Activates the reduction computation.
  140254. * When activated, the observers registered in onAfterReductionPerformed are
  140255. * called after the compuation is performed
  140256. */
  140257. activate(): void;
  140258. /**
  140259. * Deactivates the reduction computation.
  140260. */
  140261. deactivate(): void;
  140262. /**
  140263. * Disposes the depth reducer
  140264. * @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.
  140265. */
  140266. dispose(disposeAll?: boolean): void;
  140267. }
  140268. }
  140269. declare module BABYLON {
  140270. /**
  140271. * A CSM implementation allowing casting shadows on large scenes.
  140272. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140273. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  140274. */
  140275. export class CascadedShadowGenerator extends ShadowGenerator {
  140276. private static readonly frustumCornersNDCSpace;
  140277. /**
  140278. * Name of the CSM class
  140279. */
  140280. static CLASSNAME: string;
  140281. /**
  140282. * Defines the default number of cascades used by the CSM.
  140283. */
  140284. static readonly DEFAULT_CASCADES_COUNT: number;
  140285. /**
  140286. * Defines the minimum number of cascades used by the CSM.
  140287. */
  140288. static readonly MIN_CASCADES_COUNT: number;
  140289. /**
  140290. * Defines the maximum number of cascades used by the CSM.
  140291. */
  140292. static readonly MAX_CASCADES_COUNT: number;
  140293. protected _validateFilter(filter: number): number;
  140294. /**
  140295. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  140296. */
  140297. penumbraDarkness: number;
  140298. private _numCascades;
  140299. /**
  140300. * Gets or set the number of cascades used by the CSM.
  140301. */
  140302. get numCascades(): number;
  140303. set numCascades(value: number);
  140304. /**
  140305. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  140306. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  140307. */
  140308. stabilizeCascades: boolean;
  140309. private _freezeShadowCastersBoundingInfo;
  140310. private _freezeShadowCastersBoundingInfoObservable;
  140311. /**
  140312. * Enables or disables the shadow casters bounding info computation.
  140313. * If your shadow casters don't move, you can disable this feature.
  140314. * If it is enabled, the bounding box computation is done every frame.
  140315. */
  140316. get freezeShadowCastersBoundingInfo(): boolean;
  140317. set freezeShadowCastersBoundingInfo(freeze: boolean);
  140318. private _scbiMin;
  140319. private _scbiMax;
  140320. protected _computeShadowCastersBoundingInfo(): void;
  140321. protected _shadowCastersBoundingInfo: BoundingInfo;
  140322. /**
  140323. * Gets or sets the shadow casters bounding info.
  140324. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  140325. * so that the system won't overwrite the bounds you provide
  140326. */
  140327. get shadowCastersBoundingInfo(): BoundingInfo;
  140328. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  140329. protected _breaksAreDirty: boolean;
  140330. protected _minDistance: number;
  140331. protected _maxDistance: number;
  140332. /**
  140333. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  140334. *
  140335. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  140336. * If you don't know these values, simply leave them to their defaults and don't call this function.
  140337. * @param min minimal distance for the breaks (default to 0.)
  140338. * @param max maximal distance for the breaks (default to 1.)
  140339. */
  140340. setMinMaxDistance(min: number, max: number): void;
  140341. /** Gets the minimal distance used in the cascade break computation */
  140342. get minDistance(): number;
  140343. /** Gets the maximal distance used in the cascade break computation */
  140344. get maxDistance(): number;
  140345. /**
  140346. * Gets the class name of that object
  140347. * @returns "CascadedShadowGenerator"
  140348. */
  140349. getClassName(): string;
  140350. private _cascadeMinExtents;
  140351. private _cascadeMaxExtents;
  140352. /**
  140353. * Gets a cascade minimum extents
  140354. * @param cascadeIndex index of the cascade
  140355. * @returns the minimum cascade extents
  140356. */
  140357. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  140358. /**
  140359. * Gets a cascade maximum extents
  140360. * @param cascadeIndex index of the cascade
  140361. * @returns the maximum cascade extents
  140362. */
  140363. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  140364. private _cascades;
  140365. private _currentLayer;
  140366. private _viewSpaceFrustumsZ;
  140367. private _viewMatrices;
  140368. private _projectionMatrices;
  140369. private _transformMatrices;
  140370. private _transformMatricesAsArray;
  140371. private _frustumLengths;
  140372. private _lightSizeUVCorrection;
  140373. private _depthCorrection;
  140374. private _frustumCornersWorldSpace;
  140375. private _frustumCenter;
  140376. private _shadowCameraPos;
  140377. private _shadowMaxZ;
  140378. /**
  140379. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  140380. * It defaults to camera.maxZ
  140381. */
  140382. get shadowMaxZ(): number;
  140383. /**
  140384. * Sets the shadow max z distance.
  140385. */
  140386. set shadowMaxZ(value: number);
  140387. protected _debug: boolean;
  140388. /**
  140389. * Gets or sets the debug flag.
  140390. * When enabled, the cascades are materialized by different colors on the screen.
  140391. */
  140392. get debug(): boolean;
  140393. set debug(dbg: boolean);
  140394. private _depthClamp;
  140395. /**
  140396. * Gets or sets the depth clamping value.
  140397. *
  140398. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  140399. * to account for the shadow casters far away.
  140400. *
  140401. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  140402. */
  140403. get depthClamp(): boolean;
  140404. set depthClamp(value: boolean);
  140405. private _cascadeBlendPercentage;
  140406. /**
  140407. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  140408. * It defaults to 0.1 (10% blending).
  140409. */
  140410. get cascadeBlendPercentage(): number;
  140411. set cascadeBlendPercentage(value: number);
  140412. private _lambda;
  140413. /**
  140414. * Gets or set the lambda parameter.
  140415. * This parameter is used to split the camera frustum and create the cascades.
  140416. * 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.
  140417. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  140418. */
  140419. get lambda(): number;
  140420. set lambda(value: number);
  140421. /**
  140422. * Gets the view matrix corresponding to a given cascade
  140423. * @param cascadeNum cascade to retrieve the view matrix from
  140424. * @returns the cascade view matrix
  140425. */
  140426. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  140427. /**
  140428. * Gets the projection matrix corresponding to a given cascade
  140429. * @param cascadeNum cascade to retrieve the projection matrix from
  140430. * @returns the cascade projection matrix
  140431. */
  140432. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  140433. /**
  140434. * Gets the transformation matrix corresponding to a given cascade
  140435. * @param cascadeNum cascade to retrieve the transformation matrix from
  140436. * @returns the cascade transformation matrix
  140437. */
  140438. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  140439. private _depthRenderer;
  140440. /**
  140441. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  140442. *
  140443. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  140444. *
  140445. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  140446. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  140447. * @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
  140448. */
  140449. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  140450. private _depthReducer;
  140451. private _autoCalcDepthBounds;
  140452. /**
  140453. * Gets or sets the autoCalcDepthBounds property.
  140454. *
  140455. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  140456. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  140457. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  140458. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  140459. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  140460. */
  140461. get autoCalcDepthBounds(): boolean;
  140462. set autoCalcDepthBounds(value: boolean);
  140463. /**
  140464. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  140465. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140466. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  140467. * for setting the refresh rate on the renderer yourself!
  140468. */
  140469. get autoCalcDepthBoundsRefreshRate(): number;
  140470. set autoCalcDepthBoundsRefreshRate(value: number);
  140471. /**
  140472. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  140473. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  140474. * you change the camera near/far planes!
  140475. */
  140476. splitFrustum(): void;
  140477. private _splitFrustum;
  140478. private _computeMatrices;
  140479. private _computeFrustumInWorldSpace;
  140480. private _computeCascadeFrustum;
  140481. /**
  140482. * Support test.
  140483. */
  140484. static get IsSupported(): boolean;
  140485. /** @hidden */
  140486. static _SceneComponentInitialization: (scene: Scene) => void;
  140487. /**
  140488. * Creates a Cascaded Shadow Generator object.
  140489. * A ShadowGenerator is the required tool to use the shadows.
  140490. * Each directional light casting shadows needs to use its own ShadowGenerator.
  140491. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140492. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  140493. * @param light The directional light object generating the shadows.
  140494. * @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.
  140495. */
  140496. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  140497. protected _initializeGenerator(): void;
  140498. protected _createTargetRenderTexture(): void;
  140499. protected _initializeShadowMap(): void;
  140500. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  140501. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  140502. /**
  140503. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  140504. * @param defines Defines of the material we want to update
  140505. * @param lightIndex Index of the light in the enabled light list of the material
  140506. */
  140507. prepareDefines(defines: any, lightIndex: number): void;
  140508. /**
  140509. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  140510. * defined in the generator but impacting the effect).
  140511. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  140512. * @param effect The effect we are binfing the information for
  140513. */
  140514. bindShadowLight(lightIndex: string, effect: Effect): void;
  140515. /**
  140516. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  140517. * (eq to view projection * shadow projection matrices)
  140518. * @returns The transform matrix used to create the shadow map
  140519. */
  140520. getTransformMatrix(): Matrix;
  140521. /**
  140522. * Disposes the ShadowGenerator.
  140523. * Returns nothing.
  140524. */
  140525. dispose(): void;
  140526. /**
  140527. * Serializes the shadow generator setup to a json object.
  140528. * @returns The serialized JSON object
  140529. */
  140530. serialize(): any;
  140531. /**
  140532. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  140533. * @param parsedShadowGenerator The JSON object to parse
  140534. * @param scene The scene to create the shadow map for
  140535. * @returns The parsed shadow generator
  140536. */
  140537. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  140538. }
  140539. }
  140540. declare module BABYLON {
  140541. /**
  140542. * Defines the shadow generator component responsible to manage any shadow generators
  140543. * in a given scene.
  140544. */
  140545. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  140546. /**
  140547. * The component name helpfull to identify the component in the list of scene components.
  140548. */
  140549. readonly name: string;
  140550. /**
  140551. * The scene the component belongs to.
  140552. */
  140553. scene: Scene;
  140554. /**
  140555. * Creates a new instance of the component for the given scene
  140556. * @param scene Defines the scene to register the component in
  140557. */
  140558. constructor(scene: Scene);
  140559. /**
  140560. * Registers the component in a given scene
  140561. */
  140562. register(): void;
  140563. /**
  140564. * Rebuilds the elements related to this component in case of
  140565. * context lost for instance.
  140566. */
  140567. rebuild(): void;
  140568. /**
  140569. * Serializes the component data to the specified json object
  140570. * @param serializationObject The object to serialize to
  140571. */
  140572. serialize(serializationObject: any): void;
  140573. /**
  140574. * Adds all the elements from the container to the scene
  140575. * @param container the container holding the elements
  140576. */
  140577. addFromContainer(container: AbstractScene): void;
  140578. /**
  140579. * Removes all the elements in the container from the scene
  140580. * @param container contains the elements to remove
  140581. * @param dispose if the removed element should be disposed (default: false)
  140582. */
  140583. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140584. /**
  140585. * Rebuilds the elements related to this component in case of
  140586. * context lost for instance.
  140587. */
  140588. dispose(): void;
  140589. private _gatherRenderTargets;
  140590. }
  140591. }
  140592. declare module BABYLON {
  140593. /**
  140594. * A point light is a light defined by an unique point in world space.
  140595. * The light is emitted in every direction from this point.
  140596. * A good example of a point light is a standard light bulb.
  140597. * Documentation: https://doc.babylonjs.com/babylon101/lights
  140598. */
  140599. export class PointLight extends ShadowLight {
  140600. private _shadowAngle;
  140601. /**
  140602. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140603. * This specifies what angle the shadow will use to be created.
  140604. *
  140605. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140606. */
  140607. get shadowAngle(): number;
  140608. /**
  140609. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140610. * This specifies what angle the shadow will use to be created.
  140611. *
  140612. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140613. */
  140614. set shadowAngle(value: number);
  140615. /**
  140616. * Gets the direction if it has been set.
  140617. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140618. */
  140619. get direction(): Vector3;
  140620. /**
  140621. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140622. */
  140623. set direction(value: Vector3);
  140624. /**
  140625. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  140626. * A PointLight emits the light in every direction.
  140627. * It can cast shadows.
  140628. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  140629. * ```javascript
  140630. * var pointLight = new PointLight("pl", camera.position, scene);
  140631. * ```
  140632. * Documentation : https://doc.babylonjs.com/babylon101/lights
  140633. * @param name The light friendly name
  140634. * @param position The position of the point light in the scene
  140635. * @param scene The scene the lights belongs to
  140636. */
  140637. constructor(name: string, position: Vector3, scene: Scene);
  140638. /**
  140639. * Returns the string "PointLight"
  140640. * @returns the class name
  140641. */
  140642. getClassName(): string;
  140643. /**
  140644. * Returns the integer 0.
  140645. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  140646. */
  140647. getTypeID(): number;
  140648. /**
  140649. * Specifies wether or not the shadowmap should be a cube texture.
  140650. * @returns true if the shadowmap needs to be a cube texture.
  140651. */
  140652. needCube(): boolean;
  140653. /**
  140654. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  140655. * @param faceIndex The index of the face we are computed the direction to generate shadow
  140656. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  140657. */
  140658. getShadowDirection(faceIndex?: number): Vector3;
  140659. /**
  140660. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  140661. * - fov = PI / 2
  140662. * - aspect ratio : 1.0
  140663. * - z-near and far equal to the active camera minZ and maxZ.
  140664. * Returns the PointLight.
  140665. */
  140666. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  140667. protected _buildUniformLayout(): void;
  140668. /**
  140669. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  140670. * @param effect The effect to update
  140671. * @param lightIndex The index of the light in the effect to update
  140672. * @returns The point light
  140673. */
  140674. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  140675. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  140676. /**
  140677. * Prepares the list of defines specific to the light type.
  140678. * @param defines the list of defines
  140679. * @param lightIndex defines the index of the light for the effect
  140680. */
  140681. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  140682. }
  140683. }
  140684. declare module BABYLON {
  140685. /**
  140686. * Header information of HDR texture files.
  140687. */
  140688. export interface HDRInfo {
  140689. /**
  140690. * The height of the texture in pixels.
  140691. */
  140692. height: number;
  140693. /**
  140694. * The width of the texture in pixels.
  140695. */
  140696. width: number;
  140697. /**
  140698. * The index of the beginning of the data in the binary file.
  140699. */
  140700. dataPosition: number;
  140701. }
  140702. /**
  140703. * This groups tools to convert HDR texture to native colors array.
  140704. */
  140705. export class HDRTools {
  140706. private static Ldexp;
  140707. private static Rgbe2float;
  140708. private static readStringLine;
  140709. /**
  140710. * Reads header information from an RGBE texture stored in a native array.
  140711. * More information on this format are available here:
  140712. * https://en.wikipedia.org/wiki/RGBE_image_format
  140713. *
  140714. * @param uint8array The binary file stored in native array.
  140715. * @return The header information.
  140716. */
  140717. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  140718. /**
  140719. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  140720. * This RGBE texture needs to store the information as a panorama.
  140721. *
  140722. * More information on this format are available here:
  140723. * https://en.wikipedia.org/wiki/RGBE_image_format
  140724. *
  140725. * @param buffer The binary file stored in an array buffer.
  140726. * @param size The expected size of the extracted cubemap.
  140727. * @return The Cube Map information.
  140728. */
  140729. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  140730. /**
  140731. * Returns the pixels data extracted from an RGBE texture.
  140732. * This pixels will be stored left to right up to down in the R G B order in one array.
  140733. *
  140734. * More information on this format are available here:
  140735. * https://en.wikipedia.org/wiki/RGBE_image_format
  140736. *
  140737. * @param uint8array The binary file stored in an array buffer.
  140738. * @param hdrInfo The header information of the file.
  140739. * @return The pixels data in RGB right to left up to down order.
  140740. */
  140741. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  140742. private static RGBE_ReadPixels_RLE;
  140743. private static RGBE_ReadPixels_NOT_RLE;
  140744. }
  140745. }
  140746. declare module BABYLON {
  140747. /**
  140748. * Effect Render Options
  140749. */
  140750. export interface IEffectRendererOptions {
  140751. /**
  140752. * Defines the vertices positions.
  140753. */
  140754. positions?: number[];
  140755. /**
  140756. * Defines the indices.
  140757. */
  140758. indices?: number[];
  140759. }
  140760. /**
  140761. * Helper class to render one or more effects.
  140762. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  140763. */
  140764. export class EffectRenderer {
  140765. private engine;
  140766. private static _DefaultOptions;
  140767. private _vertexBuffers;
  140768. private _indexBuffer;
  140769. private _fullscreenViewport;
  140770. /**
  140771. * Creates an effect renderer
  140772. * @param engine the engine to use for rendering
  140773. * @param options defines the options of the effect renderer
  140774. */
  140775. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  140776. /**
  140777. * Sets the current viewport in normalized coordinates 0-1
  140778. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  140779. */
  140780. setViewport(viewport?: Viewport): void;
  140781. /**
  140782. * Binds the embedded attributes buffer to the effect.
  140783. * @param effect Defines the effect to bind the attributes for
  140784. */
  140785. bindBuffers(effect: Effect): void;
  140786. /**
  140787. * Sets the current effect wrapper to use during draw.
  140788. * The effect needs to be ready before calling this api.
  140789. * This also sets the default full screen position attribute.
  140790. * @param effectWrapper Defines the effect to draw with
  140791. */
  140792. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  140793. /**
  140794. * Restores engine states
  140795. */
  140796. restoreStates(): void;
  140797. /**
  140798. * Draws a full screen quad.
  140799. */
  140800. draw(): void;
  140801. private isRenderTargetTexture;
  140802. /**
  140803. * renders one or more effects to a specified texture
  140804. * @param effectWrapper the effect to renderer
  140805. * @param outputTexture texture to draw to, if null it will render to the screen.
  140806. */
  140807. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  140808. /**
  140809. * Disposes of the effect renderer
  140810. */
  140811. dispose(): void;
  140812. }
  140813. /**
  140814. * Options to create an EffectWrapper
  140815. */
  140816. interface EffectWrapperCreationOptions {
  140817. /**
  140818. * Engine to use to create the effect
  140819. */
  140820. engine: ThinEngine;
  140821. /**
  140822. * Fragment shader for the effect
  140823. */
  140824. fragmentShader: string;
  140825. /**
  140826. * Use the shader store instead of direct source code
  140827. */
  140828. useShaderStore?: boolean;
  140829. /**
  140830. * Vertex shader for the effect
  140831. */
  140832. vertexShader?: string;
  140833. /**
  140834. * Attributes to use in the shader
  140835. */
  140836. attributeNames?: Array<string>;
  140837. /**
  140838. * Uniforms to use in the shader
  140839. */
  140840. uniformNames?: Array<string>;
  140841. /**
  140842. * Texture sampler names to use in the shader
  140843. */
  140844. samplerNames?: Array<string>;
  140845. /**
  140846. * Defines to use in the shader
  140847. */
  140848. defines?: Array<string>;
  140849. /**
  140850. * Callback when effect is compiled
  140851. */
  140852. onCompiled?: Nullable<(effect: Effect) => void>;
  140853. /**
  140854. * The friendly name of the effect displayed in Spector.
  140855. */
  140856. name?: string;
  140857. }
  140858. /**
  140859. * Wraps an effect to be used for rendering
  140860. */
  140861. export class EffectWrapper {
  140862. /**
  140863. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  140864. */
  140865. onApplyObservable: Observable<{}>;
  140866. /**
  140867. * The underlying effect
  140868. */
  140869. effect: Effect;
  140870. /**
  140871. * Creates an effect to be renderer
  140872. * @param creationOptions options to create the effect
  140873. */
  140874. constructor(creationOptions: EffectWrapperCreationOptions);
  140875. /**
  140876. * Disposes of the effect wrapper
  140877. */
  140878. dispose(): void;
  140879. }
  140880. }
  140881. declare module BABYLON {
  140882. /** @hidden */
  140883. export var hdrFilteringVertexShader: {
  140884. name: string;
  140885. shader: string;
  140886. };
  140887. }
  140888. declare module BABYLON {
  140889. /** @hidden */
  140890. export var hdrFilteringPixelShader: {
  140891. name: string;
  140892. shader: string;
  140893. };
  140894. }
  140895. declare module BABYLON {
  140896. /**
  140897. * Options for texture filtering
  140898. */
  140899. interface IHDRFilteringOptions {
  140900. /**
  140901. * Scales pixel intensity for the input HDR map.
  140902. */
  140903. hdrScale?: number;
  140904. /**
  140905. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  140906. */
  140907. quality?: number;
  140908. }
  140909. /**
  140910. * Filters HDR maps to get correct renderings of PBR reflections
  140911. */
  140912. export class HDRFiltering {
  140913. private _engine;
  140914. private _effectRenderer;
  140915. private _effectWrapper;
  140916. private _lodGenerationOffset;
  140917. private _lodGenerationScale;
  140918. /**
  140919. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  140920. * you care about baking speed.
  140921. */
  140922. quality: number;
  140923. /**
  140924. * Scales pixel intensity for the input HDR map.
  140925. */
  140926. hdrScale: number;
  140927. /**
  140928. * Instantiates HDR filter for reflection maps
  140929. *
  140930. * @param engine Thin engine
  140931. * @param options Options
  140932. */
  140933. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  140934. private _createRenderTarget;
  140935. private _prefilterInternal;
  140936. private _createEffect;
  140937. /**
  140938. * Get a value indicating if the filter is ready to be used
  140939. * @param texture Texture to filter
  140940. * @returns true if the filter is ready
  140941. */
  140942. isReady(texture: BaseTexture): boolean;
  140943. /**
  140944. * Prefilters a cube texture to have mipmap levels representing roughness values.
  140945. * Prefiltering will be invoked at the end of next rendering pass.
  140946. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  140947. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  140948. * @param texture Texture to filter
  140949. * @param onFinished Callback when filtering is done
  140950. * @return Promise called when prefiltering is done
  140951. */
  140952. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  140953. }
  140954. }
  140955. declare module BABYLON {
  140956. /**
  140957. * This represents a texture coming from an HDR input.
  140958. *
  140959. * The only supported format is currently panorama picture stored in RGBE format.
  140960. * Example of such files can be found on HDRLib: http://hdrlib.com/
  140961. */
  140962. export class HDRCubeTexture extends BaseTexture {
  140963. private static _facesMapping;
  140964. private _generateHarmonics;
  140965. private _noMipmap;
  140966. private _prefilterOnLoad;
  140967. private _textureMatrix;
  140968. private _size;
  140969. private _onLoad;
  140970. private _onError;
  140971. /**
  140972. * The texture URL.
  140973. */
  140974. url: string;
  140975. protected _isBlocking: boolean;
  140976. /**
  140977. * Sets wether or not the texture is blocking during loading.
  140978. */
  140979. set isBlocking(value: boolean);
  140980. /**
  140981. * Gets wether or not the texture is blocking during loading.
  140982. */
  140983. get isBlocking(): boolean;
  140984. protected _rotationY: number;
  140985. /**
  140986. * Sets texture matrix rotation angle around Y axis in radians.
  140987. */
  140988. set rotationY(value: number);
  140989. /**
  140990. * Gets texture matrix rotation angle around Y axis radians.
  140991. */
  140992. get rotationY(): number;
  140993. /**
  140994. * Gets or sets the center of the bounding box associated with the cube texture
  140995. * It must define where the camera used to render the texture was set
  140996. */
  140997. boundingBoxPosition: Vector3;
  140998. private _boundingBoxSize;
  140999. /**
  141000. * Gets or sets the size of the bounding box associated with the cube texture
  141001. * When defined, the cubemap will switch to local mode
  141002. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  141003. * @example https://www.babylonjs-playground.com/#RNASML
  141004. */
  141005. set boundingBoxSize(value: Vector3);
  141006. get boundingBoxSize(): Vector3;
  141007. /**
  141008. * Instantiates an HDRTexture from the following parameters.
  141009. *
  141010. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  141011. * @param sceneOrEngine The scene or engine the texture will be used in
  141012. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  141013. * @param noMipmap Forces to not generate the mipmap if true
  141014. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  141015. * @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)
  141016. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  141017. */
  141018. 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>);
  141019. /**
  141020. * Get the current class name of the texture useful for serialization or dynamic coding.
  141021. * @returns "HDRCubeTexture"
  141022. */
  141023. getClassName(): string;
  141024. /**
  141025. * Occurs when the file is raw .hdr file.
  141026. */
  141027. private loadTexture;
  141028. clone(): HDRCubeTexture;
  141029. delayLoad(): void;
  141030. /**
  141031. * Get the texture reflection matrix used to rotate/transform the reflection.
  141032. * @returns the reflection matrix
  141033. */
  141034. getReflectionTextureMatrix(): Matrix;
  141035. /**
  141036. * Set the texture reflection matrix used to rotate/transform the reflection.
  141037. * @param value Define the reflection matrix to set
  141038. */
  141039. setReflectionTextureMatrix(value: Matrix): void;
  141040. /**
  141041. * Parses a JSON representation of an HDR Texture in order to create the texture
  141042. * @param parsedTexture Define the JSON representation
  141043. * @param scene Define the scene the texture should be created in
  141044. * @param rootUrl Define the root url in case we need to load relative dependencies
  141045. * @returns the newly created texture after parsing
  141046. */
  141047. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  141048. serialize(): any;
  141049. }
  141050. }
  141051. declare module BABYLON {
  141052. /**
  141053. * Class used to control physics engine
  141054. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  141055. */
  141056. export class PhysicsEngine implements IPhysicsEngine {
  141057. private _physicsPlugin;
  141058. /**
  141059. * Global value used to control the smallest number supported by the simulation
  141060. */
  141061. static Epsilon: number;
  141062. private _impostors;
  141063. private _joints;
  141064. private _subTimeStep;
  141065. /**
  141066. * Gets the gravity vector used by the simulation
  141067. */
  141068. gravity: Vector3;
  141069. /**
  141070. * Factory used to create the default physics plugin.
  141071. * @returns The default physics plugin
  141072. */
  141073. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  141074. /**
  141075. * Creates a new Physics Engine
  141076. * @param gravity defines the gravity vector used by the simulation
  141077. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  141078. */
  141079. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  141080. /**
  141081. * Sets the gravity vector used by the simulation
  141082. * @param gravity defines the gravity vector to use
  141083. */
  141084. setGravity(gravity: Vector3): void;
  141085. /**
  141086. * Set the time step of the physics engine.
  141087. * Default is 1/60.
  141088. * To slow it down, enter 1/600 for example.
  141089. * To speed it up, 1/30
  141090. * @param newTimeStep defines the new timestep to apply to this world.
  141091. */
  141092. setTimeStep(newTimeStep?: number): void;
  141093. /**
  141094. * Get the time step of the physics engine.
  141095. * @returns the current time step
  141096. */
  141097. getTimeStep(): number;
  141098. /**
  141099. * Set the sub time step of the physics engine.
  141100. * Default is 0 meaning there is no sub steps
  141101. * To increase physics resolution precision, set a small value (like 1 ms)
  141102. * @param subTimeStep defines the new sub timestep used for physics resolution.
  141103. */
  141104. setSubTimeStep(subTimeStep?: number): void;
  141105. /**
  141106. * Get the sub time step of the physics engine.
  141107. * @returns the current sub time step
  141108. */
  141109. getSubTimeStep(): number;
  141110. /**
  141111. * Release all resources
  141112. */
  141113. dispose(): void;
  141114. /**
  141115. * Gets the name of the current physics plugin
  141116. * @returns the name of the plugin
  141117. */
  141118. getPhysicsPluginName(): string;
  141119. /**
  141120. * Adding a new impostor for the impostor tracking.
  141121. * This will be done by the impostor itself.
  141122. * @param impostor the impostor to add
  141123. */
  141124. addImpostor(impostor: PhysicsImpostor): void;
  141125. /**
  141126. * Remove an impostor from the engine.
  141127. * This impostor and its mesh will not longer be updated by the physics engine.
  141128. * @param impostor the impostor to remove
  141129. */
  141130. removeImpostor(impostor: PhysicsImpostor): void;
  141131. /**
  141132. * Add a joint to the physics engine
  141133. * @param mainImpostor defines the main impostor to which the joint is added.
  141134. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  141135. * @param joint defines the joint that will connect both impostors.
  141136. */
  141137. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141138. /**
  141139. * Removes a joint from the simulation
  141140. * @param mainImpostor defines the impostor used with the joint
  141141. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  141142. * @param joint defines the joint to remove
  141143. */
  141144. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141145. /**
  141146. * Called by the scene. No need to call it.
  141147. * @param delta defines the timespam between frames
  141148. */
  141149. _step(delta: number): void;
  141150. /**
  141151. * Gets the current plugin used to run the simulation
  141152. * @returns current plugin
  141153. */
  141154. getPhysicsPlugin(): IPhysicsEnginePlugin;
  141155. /**
  141156. * Gets the list of physic impostors
  141157. * @returns an array of PhysicsImpostor
  141158. */
  141159. getImpostors(): Array<PhysicsImpostor>;
  141160. /**
  141161. * Gets the impostor for a physics enabled object
  141162. * @param object defines the object impersonated by the impostor
  141163. * @returns the PhysicsImpostor or null if not found
  141164. */
  141165. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  141166. /**
  141167. * Gets the impostor for a physics body object
  141168. * @param body defines physics body used by the impostor
  141169. * @returns the PhysicsImpostor or null if not found
  141170. */
  141171. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  141172. /**
  141173. * Does a raycast in the physics world
  141174. * @param from when should the ray start?
  141175. * @param to when should the ray end?
  141176. * @returns PhysicsRaycastResult
  141177. */
  141178. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141179. }
  141180. }
  141181. declare module BABYLON {
  141182. /** @hidden */
  141183. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  141184. private _useDeltaForWorldStep;
  141185. world: any;
  141186. name: string;
  141187. private _physicsMaterials;
  141188. private _fixedTimeStep;
  141189. private _cannonRaycastResult;
  141190. private _raycastResult;
  141191. private _physicsBodysToRemoveAfterStep;
  141192. private _firstFrame;
  141193. BJSCANNON: any;
  141194. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  141195. setGravity(gravity: Vector3): void;
  141196. setTimeStep(timeStep: number): void;
  141197. getTimeStep(): number;
  141198. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141199. private _removeMarkedPhysicsBodiesFromWorld;
  141200. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141201. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141202. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141203. private _processChildMeshes;
  141204. removePhysicsBody(impostor: PhysicsImpostor): void;
  141205. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141206. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141207. private _addMaterial;
  141208. private _checkWithEpsilon;
  141209. private _createShape;
  141210. private _createHeightmap;
  141211. private _minus90X;
  141212. private _plus90X;
  141213. private _tmpPosition;
  141214. private _tmpDeltaPosition;
  141215. private _tmpUnityRotation;
  141216. private _updatePhysicsBodyTransformation;
  141217. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141218. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141219. isSupported(): boolean;
  141220. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141221. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141222. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141223. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141224. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141225. getBodyMass(impostor: PhysicsImpostor): number;
  141226. getBodyFriction(impostor: PhysicsImpostor): number;
  141227. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141228. getBodyRestitution(impostor: PhysicsImpostor): number;
  141229. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141230. sleepBody(impostor: PhysicsImpostor): void;
  141231. wakeUpBody(impostor: PhysicsImpostor): void;
  141232. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  141233. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141234. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141235. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141236. getRadius(impostor: PhysicsImpostor): number;
  141237. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141238. dispose(): void;
  141239. private _extendNamespace;
  141240. /**
  141241. * Does a raycast in the physics world
  141242. * @param from when should the ray start?
  141243. * @param to when should the ray end?
  141244. * @returns PhysicsRaycastResult
  141245. */
  141246. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141247. }
  141248. }
  141249. declare module BABYLON {
  141250. /** @hidden */
  141251. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  141252. private _useDeltaForWorldStep;
  141253. world: any;
  141254. name: string;
  141255. BJSOIMO: any;
  141256. private _raycastResult;
  141257. private _fixedTimeStep;
  141258. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  141259. setGravity(gravity: Vector3): void;
  141260. setTimeStep(timeStep: number): void;
  141261. getTimeStep(): number;
  141262. private _tmpImpostorsArray;
  141263. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141264. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141265. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141266. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141267. private _tmpPositionVector;
  141268. removePhysicsBody(impostor: PhysicsImpostor): void;
  141269. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141270. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141271. isSupported(): boolean;
  141272. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141273. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141274. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141275. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141276. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141277. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141278. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141279. getBodyMass(impostor: PhysicsImpostor): number;
  141280. getBodyFriction(impostor: PhysicsImpostor): number;
  141281. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141282. getBodyRestitution(impostor: PhysicsImpostor): number;
  141283. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141284. sleepBody(impostor: PhysicsImpostor): void;
  141285. wakeUpBody(impostor: PhysicsImpostor): void;
  141286. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141287. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  141288. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  141289. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141290. getRadius(impostor: PhysicsImpostor): number;
  141291. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141292. dispose(): void;
  141293. /**
  141294. * Does a raycast in the physics world
  141295. * @param from when should the ray start?
  141296. * @param to when should the ray end?
  141297. * @returns PhysicsRaycastResult
  141298. */
  141299. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141300. }
  141301. }
  141302. declare module BABYLON {
  141303. /**
  141304. * AmmoJS Physics plugin
  141305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  141306. * @see https://github.com/kripken/ammo.js/
  141307. */
  141308. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  141309. private _useDeltaForWorldStep;
  141310. /**
  141311. * Reference to the Ammo library
  141312. */
  141313. bjsAMMO: any;
  141314. /**
  141315. * Created ammoJS world which physics bodies are added to
  141316. */
  141317. world: any;
  141318. /**
  141319. * Name of the plugin
  141320. */
  141321. name: string;
  141322. private _timeStep;
  141323. private _fixedTimeStep;
  141324. private _maxSteps;
  141325. private _tmpQuaternion;
  141326. private _tmpAmmoTransform;
  141327. private _tmpAmmoQuaternion;
  141328. private _tmpAmmoConcreteContactResultCallback;
  141329. private _collisionConfiguration;
  141330. private _dispatcher;
  141331. private _overlappingPairCache;
  141332. private _solver;
  141333. private _softBodySolver;
  141334. private _tmpAmmoVectorA;
  141335. private _tmpAmmoVectorB;
  141336. private _tmpAmmoVectorC;
  141337. private _tmpAmmoVectorD;
  141338. private _tmpContactCallbackResult;
  141339. private _tmpAmmoVectorRCA;
  141340. private _tmpAmmoVectorRCB;
  141341. private _raycastResult;
  141342. private static readonly DISABLE_COLLISION_FLAG;
  141343. private static readonly KINEMATIC_FLAG;
  141344. private static readonly DISABLE_DEACTIVATION_FLAG;
  141345. /**
  141346. * Initializes the ammoJS plugin
  141347. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  141348. * @param ammoInjection can be used to inject your own ammo reference
  141349. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  141350. */
  141351. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  141352. /**
  141353. * Sets the gravity of the physics world (m/(s^2))
  141354. * @param gravity Gravity to set
  141355. */
  141356. setGravity(gravity: Vector3): void;
  141357. /**
  141358. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  141359. * @param timeStep timestep to use in seconds
  141360. */
  141361. setTimeStep(timeStep: number): void;
  141362. /**
  141363. * 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)
  141364. * @param fixedTimeStep fixedTimeStep to use in seconds
  141365. */
  141366. setFixedTimeStep(fixedTimeStep: number): void;
  141367. /**
  141368. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  141369. * @param maxSteps the maximum number of steps by the physics engine per frame
  141370. */
  141371. setMaxSteps(maxSteps: number): void;
  141372. /**
  141373. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  141374. * @returns the current timestep in seconds
  141375. */
  141376. getTimeStep(): number;
  141377. /**
  141378. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  141379. */
  141380. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  141381. private _isImpostorInContact;
  141382. private _isImpostorPairInContact;
  141383. private _stepSimulation;
  141384. /**
  141385. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  141386. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  141387. * After the step the babylon meshes are set to the position of the physics imposters
  141388. * @param delta amount of time to step forward
  141389. * @param impostors array of imposters to update before/after the step
  141390. */
  141391. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141392. /**
  141393. * Update babylon mesh to match physics world object
  141394. * @param impostor imposter to match
  141395. */
  141396. private _afterSoftStep;
  141397. /**
  141398. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  141399. * @param impostor imposter to match
  141400. */
  141401. private _ropeStep;
  141402. /**
  141403. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  141404. * @param impostor imposter to match
  141405. */
  141406. private _softbodyOrClothStep;
  141407. private _tmpMatrix;
  141408. /**
  141409. * Applies an impulse on the imposter
  141410. * @param impostor imposter to apply impulse to
  141411. * @param force amount of force to be applied to the imposter
  141412. * @param contactPoint the location to apply the impulse on the imposter
  141413. */
  141414. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141415. /**
  141416. * Applies a force on the imposter
  141417. * @param impostor imposter to apply force
  141418. * @param force amount of force to be applied to the imposter
  141419. * @param contactPoint the location to apply the force on the imposter
  141420. */
  141421. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141422. /**
  141423. * Creates a physics body using the plugin
  141424. * @param impostor the imposter to create the physics body on
  141425. */
  141426. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141427. /**
  141428. * Removes the physics body from the imposter and disposes of the body's memory
  141429. * @param impostor imposter to remove the physics body from
  141430. */
  141431. removePhysicsBody(impostor: PhysicsImpostor): void;
  141432. /**
  141433. * Generates a joint
  141434. * @param impostorJoint the imposter joint to create the joint with
  141435. */
  141436. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141437. /**
  141438. * Removes a joint
  141439. * @param impostorJoint the imposter joint to remove the joint from
  141440. */
  141441. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141442. private _addMeshVerts;
  141443. /**
  141444. * Initialise the soft body vertices to match its object's (mesh) vertices
  141445. * Softbody vertices (nodes) are in world space and to match this
  141446. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  141447. * @param impostor to create the softbody for
  141448. */
  141449. private _softVertexData;
  141450. /**
  141451. * Create an impostor's soft body
  141452. * @param impostor to create the softbody for
  141453. */
  141454. private _createSoftbody;
  141455. /**
  141456. * Create cloth for an impostor
  141457. * @param impostor to create the softbody for
  141458. */
  141459. private _createCloth;
  141460. /**
  141461. * Create rope for an impostor
  141462. * @param impostor to create the softbody for
  141463. */
  141464. private _createRope;
  141465. /**
  141466. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  141467. * @param impostor to create the custom physics shape for
  141468. */
  141469. private _createCustom;
  141470. private _addHullVerts;
  141471. private _createShape;
  141472. /**
  141473. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  141474. * @param impostor imposter containing the physics body and babylon object
  141475. */
  141476. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141477. /**
  141478. * Sets the babylon object's position/rotation from the physics body's position/rotation
  141479. * @param impostor imposter containing the physics body and babylon object
  141480. * @param newPosition new position
  141481. * @param newRotation new rotation
  141482. */
  141483. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141484. /**
  141485. * If this plugin is supported
  141486. * @returns true if its supported
  141487. */
  141488. isSupported(): boolean;
  141489. /**
  141490. * Sets the linear velocity of the physics body
  141491. * @param impostor imposter to set the velocity on
  141492. * @param velocity velocity to set
  141493. */
  141494. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141495. /**
  141496. * Sets the angular velocity of the physics body
  141497. * @param impostor imposter to set the velocity on
  141498. * @param velocity velocity to set
  141499. */
  141500. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141501. /**
  141502. * gets the linear velocity
  141503. * @param impostor imposter to get linear velocity from
  141504. * @returns linear velocity
  141505. */
  141506. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141507. /**
  141508. * gets the angular velocity
  141509. * @param impostor imposter to get angular velocity from
  141510. * @returns angular velocity
  141511. */
  141512. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141513. /**
  141514. * Sets the mass of physics body
  141515. * @param impostor imposter to set the mass on
  141516. * @param mass mass to set
  141517. */
  141518. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141519. /**
  141520. * Gets the mass of the physics body
  141521. * @param impostor imposter to get the mass from
  141522. * @returns mass
  141523. */
  141524. getBodyMass(impostor: PhysicsImpostor): number;
  141525. /**
  141526. * Gets friction of the impostor
  141527. * @param impostor impostor to get friction from
  141528. * @returns friction value
  141529. */
  141530. getBodyFriction(impostor: PhysicsImpostor): number;
  141531. /**
  141532. * Sets friction of the impostor
  141533. * @param impostor impostor to set friction on
  141534. * @param friction friction value
  141535. */
  141536. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141537. /**
  141538. * Gets restitution of the impostor
  141539. * @param impostor impostor to get restitution from
  141540. * @returns restitution value
  141541. */
  141542. getBodyRestitution(impostor: PhysicsImpostor): number;
  141543. /**
  141544. * Sets resitution of the impostor
  141545. * @param impostor impostor to set resitution on
  141546. * @param restitution resitution value
  141547. */
  141548. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141549. /**
  141550. * Gets pressure inside the impostor
  141551. * @param impostor impostor to get pressure from
  141552. * @returns pressure value
  141553. */
  141554. getBodyPressure(impostor: PhysicsImpostor): number;
  141555. /**
  141556. * Sets pressure inside a soft body impostor
  141557. * Cloth and rope must remain 0 pressure
  141558. * @param impostor impostor to set pressure on
  141559. * @param pressure pressure value
  141560. */
  141561. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  141562. /**
  141563. * Gets stiffness of the impostor
  141564. * @param impostor impostor to get stiffness from
  141565. * @returns pressure value
  141566. */
  141567. getBodyStiffness(impostor: PhysicsImpostor): number;
  141568. /**
  141569. * Sets stiffness of the impostor
  141570. * @param impostor impostor to set stiffness on
  141571. * @param stiffness stiffness value from 0 to 1
  141572. */
  141573. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  141574. /**
  141575. * Gets velocityIterations of the impostor
  141576. * @param impostor impostor to get velocity iterations from
  141577. * @returns velocityIterations value
  141578. */
  141579. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  141580. /**
  141581. * Sets velocityIterations of the impostor
  141582. * @param impostor impostor to set velocity iterations on
  141583. * @param velocityIterations velocityIterations value
  141584. */
  141585. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  141586. /**
  141587. * Gets positionIterations of the impostor
  141588. * @param impostor impostor to get position iterations from
  141589. * @returns positionIterations value
  141590. */
  141591. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  141592. /**
  141593. * Sets positionIterations of the impostor
  141594. * @param impostor impostor to set position on
  141595. * @param positionIterations positionIterations value
  141596. */
  141597. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  141598. /**
  141599. * Append an anchor to a cloth object
  141600. * @param impostor is the cloth impostor to add anchor to
  141601. * @param otherImpostor is the rigid impostor to anchor to
  141602. * @param width ratio across width from 0 to 1
  141603. * @param height ratio up height from 0 to 1
  141604. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  141605. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141606. */
  141607. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141608. /**
  141609. * Append an hook to a rope object
  141610. * @param impostor is the rope impostor to add hook to
  141611. * @param otherImpostor is the rigid impostor to hook to
  141612. * @param length ratio along the rope from 0 to 1
  141613. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  141614. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141615. */
  141616. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141617. /**
  141618. * Sleeps the physics body and stops it from being active
  141619. * @param impostor impostor to sleep
  141620. */
  141621. sleepBody(impostor: PhysicsImpostor): void;
  141622. /**
  141623. * Activates the physics body
  141624. * @param impostor impostor to activate
  141625. */
  141626. wakeUpBody(impostor: PhysicsImpostor): void;
  141627. /**
  141628. * Updates the distance parameters of the joint
  141629. * @param joint joint to update
  141630. * @param maxDistance maximum distance of the joint
  141631. * @param minDistance minimum distance of the joint
  141632. */
  141633. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141634. /**
  141635. * Sets a motor on the joint
  141636. * @param joint joint to set motor on
  141637. * @param speed speed of the motor
  141638. * @param maxForce maximum force of the motor
  141639. * @param motorIndex index of the motor
  141640. */
  141641. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141642. /**
  141643. * Sets the motors limit
  141644. * @param joint joint to set limit on
  141645. * @param upperLimit upper limit
  141646. * @param lowerLimit lower limit
  141647. */
  141648. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141649. /**
  141650. * Syncs the position and rotation of a mesh with the impostor
  141651. * @param mesh mesh to sync
  141652. * @param impostor impostor to update the mesh with
  141653. */
  141654. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141655. /**
  141656. * Gets the radius of the impostor
  141657. * @param impostor impostor to get radius from
  141658. * @returns the radius
  141659. */
  141660. getRadius(impostor: PhysicsImpostor): number;
  141661. /**
  141662. * Gets the box size of the impostor
  141663. * @param impostor impostor to get box size from
  141664. * @param result the resulting box size
  141665. */
  141666. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141667. /**
  141668. * Disposes of the impostor
  141669. */
  141670. dispose(): void;
  141671. /**
  141672. * Does a raycast in the physics world
  141673. * @param from when should the ray start?
  141674. * @param to when should the ray end?
  141675. * @returns PhysicsRaycastResult
  141676. */
  141677. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141678. }
  141679. }
  141680. declare module BABYLON {
  141681. interface AbstractScene {
  141682. /**
  141683. * The list of reflection probes added to the scene
  141684. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141685. */
  141686. reflectionProbes: Array<ReflectionProbe>;
  141687. /**
  141688. * Removes the given reflection probe from this scene.
  141689. * @param toRemove The reflection probe to remove
  141690. * @returns The index of the removed reflection probe
  141691. */
  141692. removeReflectionProbe(toRemove: ReflectionProbe): number;
  141693. /**
  141694. * Adds the given reflection probe to this scene.
  141695. * @param newReflectionProbe The reflection probe to add
  141696. */
  141697. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  141698. }
  141699. /**
  141700. * Class used to generate realtime reflection / refraction cube textures
  141701. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141702. */
  141703. export class ReflectionProbe {
  141704. /** defines the name of the probe */
  141705. name: string;
  141706. private _scene;
  141707. private _renderTargetTexture;
  141708. private _projectionMatrix;
  141709. private _viewMatrix;
  141710. private _target;
  141711. private _add;
  141712. private _attachedMesh;
  141713. private _invertYAxis;
  141714. /** Gets or sets probe position (center of the cube map) */
  141715. position: Vector3;
  141716. /**
  141717. * Creates a new reflection probe
  141718. * @param name defines the name of the probe
  141719. * @param size defines the texture resolution (for each face)
  141720. * @param scene defines the hosting scene
  141721. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  141722. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  141723. */
  141724. constructor(
  141725. /** defines the name of the probe */
  141726. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  141727. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  141728. get samples(): number;
  141729. set samples(value: number);
  141730. /** Gets or sets the refresh rate to use (on every frame by default) */
  141731. get refreshRate(): number;
  141732. set refreshRate(value: number);
  141733. /**
  141734. * Gets the hosting scene
  141735. * @returns a Scene
  141736. */
  141737. getScene(): Scene;
  141738. /** Gets the internal CubeTexture used to render to */
  141739. get cubeTexture(): RenderTargetTexture;
  141740. /** Gets the list of meshes to render */
  141741. get renderList(): Nullable<AbstractMesh[]>;
  141742. /**
  141743. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  141744. * @param mesh defines the mesh to attach to
  141745. */
  141746. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  141747. /**
  141748. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  141749. * @param renderingGroupId The rendering group id corresponding to its index
  141750. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  141751. */
  141752. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  141753. /**
  141754. * Clean all associated resources
  141755. */
  141756. dispose(): void;
  141757. /**
  141758. * Converts the reflection probe information to a readable string for debug purpose.
  141759. * @param fullDetails Supports for multiple levels of logging within scene loading
  141760. * @returns the human readable reflection probe info
  141761. */
  141762. toString(fullDetails?: boolean): string;
  141763. /**
  141764. * Get the class name of the relfection probe.
  141765. * @returns "ReflectionProbe"
  141766. */
  141767. getClassName(): string;
  141768. /**
  141769. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  141770. * @returns The JSON representation of the texture
  141771. */
  141772. serialize(): any;
  141773. /**
  141774. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  141775. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  141776. * @param scene Define the scene the parsed reflection probe should be instantiated in
  141777. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  141778. * @returns The parsed reflection probe if successful
  141779. */
  141780. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  141781. }
  141782. }
  141783. declare module BABYLON {
  141784. /** @hidden */
  141785. export var _BabylonLoaderRegistered: boolean;
  141786. /**
  141787. * Helps setting up some configuration for the babylon file loader.
  141788. */
  141789. export class BabylonFileLoaderConfiguration {
  141790. /**
  141791. * The loader does not allow injecting custom physix engine into the plugins.
  141792. * Unfortunately in ES6, we need to manually inject them into the plugin.
  141793. * So you could set this variable to your engine import to make it work.
  141794. */
  141795. static LoaderInjectedPhysicsEngine: any;
  141796. }
  141797. }
  141798. declare module BABYLON {
  141799. /**
  141800. * The Physically based simple base material of BJS.
  141801. *
  141802. * This enables better naming and convention enforcements on top of the pbrMaterial.
  141803. * It is used as the base class for both the specGloss and metalRough conventions.
  141804. */
  141805. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  141806. /**
  141807. * Number of Simultaneous lights allowed on the material.
  141808. */
  141809. maxSimultaneousLights: number;
  141810. /**
  141811. * If sets to true, disables all the lights affecting the material.
  141812. */
  141813. disableLighting: boolean;
  141814. /**
  141815. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  141816. */
  141817. environmentTexture: BaseTexture;
  141818. /**
  141819. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  141820. */
  141821. invertNormalMapX: boolean;
  141822. /**
  141823. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  141824. */
  141825. invertNormalMapY: boolean;
  141826. /**
  141827. * Normal map used in the model.
  141828. */
  141829. normalTexture: BaseTexture;
  141830. /**
  141831. * Emissivie color used to self-illuminate the model.
  141832. */
  141833. emissiveColor: Color3;
  141834. /**
  141835. * Emissivie texture used to self-illuminate the model.
  141836. */
  141837. emissiveTexture: BaseTexture;
  141838. /**
  141839. * Occlusion Channel Strenght.
  141840. */
  141841. occlusionStrength: number;
  141842. /**
  141843. * Occlusion Texture of the material (adding extra occlusion effects).
  141844. */
  141845. occlusionTexture: BaseTexture;
  141846. /**
  141847. * Defines the alpha limits in alpha test mode.
  141848. */
  141849. alphaCutOff: number;
  141850. /**
  141851. * Gets the current double sided mode.
  141852. */
  141853. get doubleSided(): boolean;
  141854. /**
  141855. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  141856. */
  141857. set doubleSided(value: boolean);
  141858. /**
  141859. * Stores the pre-calculated light information of a mesh in a texture.
  141860. */
  141861. lightmapTexture: BaseTexture;
  141862. /**
  141863. * If true, the light map contains occlusion information instead of lighting info.
  141864. */
  141865. useLightmapAsShadowmap: boolean;
  141866. /**
  141867. * Instantiates a new PBRMaterial instance.
  141868. *
  141869. * @param name The material name
  141870. * @param scene The scene the material will be use in.
  141871. */
  141872. constructor(name: string, scene: Scene);
  141873. getClassName(): string;
  141874. }
  141875. }
  141876. declare module BABYLON {
  141877. /**
  141878. * The PBR material of BJS following the metal roughness convention.
  141879. *
  141880. * This fits to the PBR convention in the GLTF definition:
  141881. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  141882. */
  141883. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  141884. /**
  141885. * The base color has two different interpretations depending on the value of metalness.
  141886. * When the material is a metal, the base color is the specific measured reflectance value
  141887. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  141888. * of the material.
  141889. */
  141890. baseColor: Color3;
  141891. /**
  141892. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  141893. * well as opacity information in the alpha channel.
  141894. */
  141895. baseTexture: BaseTexture;
  141896. /**
  141897. * Specifies the metallic scalar value of the material.
  141898. * Can also be used to scale the metalness values of the metallic texture.
  141899. */
  141900. metallic: number;
  141901. /**
  141902. * Specifies the roughness scalar value of the material.
  141903. * Can also be used to scale the roughness values of the metallic texture.
  141904. */
  141905. roughness: number;
  141906. /**
  141907. * Texture containing both the metallic value in the B channel and the
  141908. * roughness value in the G channel to keep better precision.
  141909. */
  141910. metallicRoughnessTexture: BaseTexture;
  141911. /**
  141912. * Instantiates a new PBRMetalRoughnessMaterial instance.
  141913. *
  141914. * @param name The material name
  141915. * @param scene The scene the material will be use in.
  141916. */
  141917. constructor(name: string, scene: Scene);
  141918. /**
  141919. * Return the currrent class name of the material.
  141920. */
  141921. getClassName(): string;
  141922. /**
  141923. * Makes a duplicate of the current material.
  141924. * @param name - name to use for the new material.
  141925. */
  141926. clone(name: string): PBRMetallicRoughnessMaterial;
  141927. /**
  141928. * Serialize the material to a parsable JSON object.
  141929. */
  141930. serialize(): any;
  141931. /**
  141932. * Parses a JSON object correponding to the serialize function.
  141933. */
  141934. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  141935. }
  141936. }
  141937. declare module BABYLON {
  141938. /**
  141939. * The PBR material of BJS following the specular glossiness convention.
  141940. *
  141941. * This fits to the PBR convention in the GLTF definition:
  141942. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  141943. */
  141944. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  141945. /**
  141946. * Specifies the diffuse color of the material.
  141947. */
  141948. diffuseColor: Color3;
  141949. /**
  141950. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  141951. * channel.
  141952. */
  141953. diffuseTexture: BaseTexture;
  141954. /**
  141955. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  141956. */
  141957. specularColor: Color3;
  141958. /**
  141959. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  141960. */
  141961. glossiness: number;
  141962. /**
  141963. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  141964. */
  141965. specularGlossinessTexture: BaseTexture;
  141966. /**
  141967. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  141968. *
  141969. * @param name The material name
  141970. * @param scene The scene the material will be use in.
  141971. */
  141972. constructor(name: string, scene: Scene);
  141973. /**
  141974. * Return the currrent class name of the material.
  141975. */
  141976. getClassName(): string;
  141977. /**
  141978. * Makes a duplicate of the current material.
  141979. * @param name - name to use for the new material.
  141980. */
  141981. clone(name: string): PBRSpecularGlossinessMaterial;
  141982. /**
  141983. * Serialize the material to a parsable JSON object.
  141984. */
  141985. serialize(): any;
  141986. /**
  141987. * Parses a JSON object correponding to the serialize function.
  141988. */
  141989. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  141990. }
  141991. }
  141992. declare module BABYLON {
  141993. /**
  141994. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  141995. * It can help converting any input color in a desired output one. This can then be used to create effects
  141996. * from sepia, black and white to sixties or futuristic rendering...
  141997. *
  141998. * The only supported format is currently 3dl.
  141999. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  142000. */
  142001. export class ColorGradingTexture extends BaseTexture {
  142002. /**
  142003. * The texture URL.
  142004. */
  142005. url: string;
  142006. /**
  142007. * Empty line regex stored for GC.
  142008. */
  142009. private static _noneEmptyLineRegex;
  142010. private _textureMatrix;
  142011. private _onLoad;
  142012. /**
  142013. * Instantiates a ColorGradingTexture from the following parameters.
  142014. *
  142015. * @param url The location of the color gradind data (currently only supporting 3dl)
  142016. * @param sceneOrEngine The scene or engine the texture will be used in
  142017. * @param onLoad defines a callback triggered when the texture has been loaded
  142018. */
  142019. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  142020. /**
  142021. * Fires the onload event from the constructor if requested.
  142022. */
  142023. private _triggerOnLoad;
  142024. /**
  142025. * Returns the texture matrix used in most of the material.
  142026. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  142027. */
  142028. getTextureMatrix(): Matrix;
  142029. /**
  142030. * Occurs when the file being loaded is a .3dl LUT file.
  142031. */
  142032. private load3dlTexture;
  142033. /**
  142034. * Starts the loading process of the texture.
  142035. */
  142036. private loadTexture;
  142037. /**
  142038. * Clones the color gradind texture.
  142039. */
  142040. clone(): ColorGradingTexture;
  142041. /**
  142042. * Called during delayed load for textures.
  142043. */
  142044. delayLoad(): void;
  142045. /**
  142046. * Parses a color grading texture serialized by Babylon.
  142047. * @param parsedTexture The texture information being parsedTexture
  142048. * @param scene The scene to load the texture in
  142049. * @param rootUrl The root url of the data assets to load
  142050. * @return A color gradind texture
  142051. */
  142052. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  142053. /**
  142054. * Serializes the LUT texture to json format.
  142055. */
  142056. serialize(): any;
  142057. }
  142058. }
  142059. declare module BABYLON {
  142060. /**
  142061. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  142062. */
  142063. export class EquiRectangularCubeTexture extends BaseTexture {
  142064. /** The six faces of the cube. */
  142065. private static _FacesMapping;
  142066. private _noMipmap;
  142067. private _onLoad;
  142068. private _onError;
  142069. /** The size of the cubemap. */
  142070. private _size;
  142071. /** The buffer of the image. */
  142072. private _buffer;
  142073. /** The width of the input image. */
  142074. private _width;
  142075. /** The height of the input image. */
  142076. private _height;
  142077. /** The URL to the image. */
  142078. url: string;
  142079. /**
  142080. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  142081. * @param url The location of the image
  142082. * @param scene The scene the texture will be used in
  142083. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  142084. * @param noMipmap Forces to not generate the mipmap if true
  142085. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  142086. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  142087. * @param onLoad — defines a callback called when texture is loaded
  142088. * @param onError — defines a callback called if there is an error
  142089. */
  142090. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  142091. /**
  142092. * Load the image data, by putting the image on a canvas and extracting its buffer.
  142093. */
  142094. private loadImage;
  142095. /**
  142096. * Convert the image buffer into a cubemap and create a CubeTexture.
  142097. */
  142098. private loadTexture;
  142099. /**
  142100. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  142101. * @param buffer The ArrayBuffer that should be converted.
  142102. * @returns The buffer as Float32Array.
  142103. */
  142104. private getFloat32ArrayFromArrayBuffer;
  142105. /**
  142106. * Get the current class name of the texture useful for serialization or dynamic coding.
  142107. * @returns "EquiRectangularCubeTexture"
  142108. */
  142109. getClassName(): string;
  142110. /**
  142111. * Create a clone of the current EquiRectangularCubeTexture and return it.
  142112. * @returns A clone of the current EquiRectangularCubeTexture.
  142113. */
  142114. clone(): EquiRectangularCubeTexture;
  142115. }
  142116. }
  142117. declare module BABYLON {
  142118. /**
  142119. * Defines the options related to the creation of an HtmlElementTexture
  142120. */
  142121. export interface IHtmlElementTextureOptions {
  142122. /**
  142123. * Defines wether mip maps should be created or not.
  142124. */
  142125. generateMipMaps?: boolean;
  142126. /**
  142127. * Defines the sampling mode of the texture.
  142128. */
  142129. samplingMode?: number;
  142130. /**
  142131. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  142132. */
  142133. engine: Nullable<ThinEngine>;
  142134. /**
  142135. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  142136. */
  142137. scene: Nullable<Scene>;
  142138. }
  142139. /**
  142140. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  142141. * To be as efficient as possible depending on your constraints nothing aside the first upload
  142142. * is automatically managed.
  142143. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  142144. * in your application.
  142145. *
  142146. * As the update is not automatic, you need to call them manually.
  142147. */
  142148. export class HtmlElementTexture extends BaseTexture {
  142149. /**
  142150. * The texture URL.
  142151. */
  142152. element: HTMLVideoElement | HTMLCanvasElement;
  142153. private static readonly DefaultOptions;
  142154. private _textureMatrix;
  142155. private _isVideo;
  142156. private _generateMipMaps;
  142157. private _samplingMode;
  142158. /**
  142159. * Instantiates a HtmlElementTexture from the following parameters.
  142160. *
  142161. * @param name Defines the name of the texture
  142162. * @param element Defines the video or canvas the texture is filled with
  142163. * @param options Defines the other none mandatory texture creation options
  142164. */
  142165. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  142166. private _createInternalTexture;
  142167. /**
  142168. * Returns the texture matrix used in most of the material.
  142169. */
  142170. getTextureMatrix(): Matrix;
  142171. /**
  142172. * Updates the content of the texture.
  142173. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  142174. */
  142175. update(invertY?: Nullable<boolean>): void;
  142176. }
  142177. }
  142178. declare module BABYLON {
  142179. /**
  142180. * Based on jsTGALoader - Javascript loader for TGA file
  142181. * By Vincent Thibault
  142182. * @see http://blog.robrowser.com/javascript-tga-loader.html
  142183. */
  142184. export class TGATools {
  142185. private static _TYPE_INDEXED;
  142186. private static _TYPE_RGB;
  142187. private static _TYPE_GREY;
  142188. private static _TYPE_RLE_INDEXED;
  142189. private static _TYPE_RLE_RGB;
  142190. private static _TYPE_RLE_GREY;
  142191. private static _ORIGIN_MASK;
  142192. private static _ORIGIN_SHIFT;
  142193. private static _ORIGIN_BL;
  142194. private static _ORIGIN_BR;
  142195. private static _ORIGIN_UL;
  142196. private static _ORIGIN_UR;
  142197. /**
  142198. * Gets the header of a TGA file
  142199. * @param data defines the TGA data
  142200. * @returns the header
  142201. */
  142202. static GetTGAHeader(data: Uint8Array): any;
  142203. /**
  142204. * Uploads TGA content to a Babylon Texture
  142205. * @hidden
  142206. */
  142207. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  142208. /** @hidden */
  142209. 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;
  142210. /** @hidden */
  142211. 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;
  142212. /** @hidden */
  142213. 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;
  142214. /** @hidden */
  142215. 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;
  142216. /** @hidden */
  142217. 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;
  142218. /** @hidden */
  142219. 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;
  142220. }
  142221. }
  142222. declare module BABYLON {
  142223. /**
  142224. * Implementation of the TGA Texture Loader.
  142225. * @hidden
  142226. */
  142227. export class _TGATextureLoader implements IInternalTextureLoader {
  142228. /**
  142229. * Defines wether the loader supports cascade loading the different faces.
  142230. */
  142231. readonly supportCascades: boolean;
  142232. /**
  142233. * This returns if the loader support the current file information.
  142234. * @param extension defines the file extension of the file being loaded
  142235. * @returns true if the loader can load the specified file
  142236. */
  142237. canLoad(extension: string): boolean;
  142238. /**
  142239. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142240. * @param data contains the texture data
  142241. * @param texture defines the BabylonJS internal texture
  142242. * @param createPolynomials will be true if polynomials have been requested
  142243. * @param onLoad defines the callback to trigger once the texture is ready
  142244. * @param onError defines the callback to trigger in case of error
  142245. */
  142246. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142247. /**
  142248. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142249. * @param data contains the texture data
  142250. * @param texture defines the BabylonJS internal texture
  142251. * @param callback defines the method to call once ready to upload
  142252. */
  142253. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142254. }
  142255. }
  142256. declare module BABYLON {
  142257. /**
  142258. * Info about the .basis files
  142259. */
  142260. class BasisFileInfo {
  142261. /**
  142262. * If the file has alpha
  142263. */
  142264. hasAlpha: boolean;
  142265. /**
  142266. * Info about each image of the basis file
  142267. */
  142268. images: Array<{
  142269. levels: Array<{
  142270. width: number;
  142271. height: number;
  142272. transcodedPixels: ArrayBufferView;
  142273. }>;
  142274. }>;
  142275. }
  142276. /**
  142277. * Result of transcoding a basis file
  142278. */
  142279. class TranscodeResult {
  142280. /**
  142281. * Info about the .basis file
  142282. */
  142283. fileInfo: BasisFileInfo;
  142284. /**
  142285. * Format to use when loading the file
  142286. */
  142287. format: number;
  142288. }
  142289. /**
  142290. * Configuration options for the Basis transcoder
  142291. */
  142292. export class BasisTranscodeConfiguration {
  142293. /**
  142294. * Supported compression formats used to determine the supported output format of the transcoder
  142295. */
  142296. supportedCompressionFormats?: {
  142297. /**
  142298. * etc1 compression format
  142299. */
  142300. etc1?: boolean;
  142301. /**
  142302. * s3tc compression format
  142303. */
  142304. s3tc?: boolean;
  142305. /**
  142306. * pvrtc compression format
  142307. */
  142308. pvrtc?: boolean;
  142309. /**
  142310. * etc2 compression format
  142311. */
  142312. etc2?: boolean;
  142313. };
  142314. /**
  142315. * If mipmap levels should be loaded for transcoded images (Default: true)
  142316. */
  142317. loadMipmapLevels?: boolean;
  142318. /**
  142319. * Index of a single image to load (Default: all images)
  142320. */
  142321. loadSingleImage?: number;
  142322. }
  142323. /**
  142324. * Used to load .Basis files
  142325. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  142326. */
  142327. export class BasisTools {
  142328. private static _IgnoreSupportedFormats;
  142329. /**
  142330. * URL to use when loading the basis transcoder
  142331. */
  142332. static JSModuleURL: string;
  142333. /**
  142334. * URL to use when loading the wasm module for the transcoder
  142335. */
  142336. static WasmModuleURL: string;
  142337. /**
  142338. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  142339. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  142340. * @returns internal format corresponding to the Basis format
  142341. */
  142342. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  142343. private static _WorkerPromise;
  142344. private static _Worker;
  142345. private static _actionId;
  142346. private static _CreateWorkerAsync;
  142347. /**
  142348. * Transcodes a loaded image file to compressed pixel data
  142349. * @param data image data to transcode
  142350. * @param config configuration options for the transcoding
  142351. * @returns a promise resulting in the transcoded image
  142352. */
  142353. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  142354. /**
  142355. * Loads a texture from the transcode result
  142356. * @param texture texture load to
  142357. * @param transcodeResult the result of transcoding the basis file to load from
  142358. */
  142359. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  142360. }
  142361. }
  142362. declare module BABYLON {
  142363. /**
  142364. * Loader for .basis file format
  142365. */
  142366. export class _BasisTextureLoader implements IInternalTextureLoader {
  142367. /**
  142368. * Defines whether the loader supports cascade loading the different faces.
  142369. */
  142370. readonly supportCascades: boolean;
  142371. /**
  142372. * This returns if the loader support the current file information.
  142373. * @param extension defines the file extension of the file being loaded
  142374. * @returns true if the loader can load the specified file
  142375. */
  142376. canLoad(extension: string): boolean;
  142377. /**
  142378. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142379. * @param data contains the texture data
  142380. * @param texture defines the BabylonJS internal texture
  142381. * @param createPolynomials will be true if polynomials have been requested
  142382. * @param onLoad defines the callback to trigger once the texture is ready
  142383. * @param onError defines the callback to trigger in case of error
  142384. */
  142385. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142386. /**
  142387. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142388. * @param data contains the texture data
  142389. * @param texture defines the BabylonJS internal texture
  142390. * @param callback defines the method to call once ready to upload
  142391. */
  142392. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142393. }
  142394. }
  142395. declare module BABYLON {
  142396. /**
  142397. * Defines the basic options interface of a TexturePacker Frame
  142398. */
  142399. export interface ITexturePackerFrame {
  142400. /**
  142401. * The frame ID
  142402. */
  142403. id: number;
  142404. /**
  142405. * The frames Scale
  142406. */
  142407. scale: Vector2;
  142408. /**
  142409. * The Frames offset
  142410. */
  142411. offset: Vector2;
  142412. }
  142413. /**
  142414. * This is a support class for frame Data on texture packer sets.
  142415. */
  142416. export class TexturePackerFrame implements ITexturePackerFrame {
  142417. /**
  142418. * The frame ID
  142419. */
  142420. id: number;
  142421. /**
  142422. * The frames Scale
  142423. */
  142424. scale: Vector2;
  142425. /**
  142426. * The Frames offset
  142427. */
  142428. offset: Vector2;
  142429. /**
  142430. * Initializes a texture package frame.
  142431. * @param id The numerical frame identifier
  142432. * @param scale Scalar Vector2 for UV frame
  142433. * @param offset Vector2 for the frame position in UV units.
  142434. * @returns TexturePackerFrame
  142435. */
  142436. constructor(id: number, scale: Vector2, offset: Vector2);
  142437. }
  142438. }
  142439. declare module BABYLON {
  142440. /**
  142441. * Defines the basic options interface of a TexturePacker
  142442. */
  142443. export interface ITexturePackerOptions {
  142444. /**
  142445. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  142446. */
  142447. map?: string[];
  142448. /**
  142449. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  142450. */
  142451. uvsIn?: string;
  142452. /**
  142453. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  142454. */
  142455. uvsOut?: string;
  142456. /**
  142457. * number representing the layout style. Defaults to LAYOUT_STRIP
  142458. */
  142459. layout?: number;
  142460. /**
  142461. * number of columns if using custom column count layout(2). This defaults to 4.
  142462. */
  142463. colnum?: number;
  142464. /**
  142465. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  142466. */
  142467. updateInputMeshes?: boolean;
  142468. /**
  142469. * boolean flag to dispose all the source textures. Defaults to true.
  142470. */
  142471. disposeSources?: boolean;
  142472. /**
  142473. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  142474. */
  142475. fillBlanks?: boolean;
  142476. /**
  142477. * string value representing the context fill style color. Defaults to 'black'.
  142478. */
  142479. customFillColor?: string;
  142480. /**
  142481. * Width and Height Value of each Frame in the TexturePacker Sets
  142482. */
  142483. frameSize?: number;
  142484. /**
  142485. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  142486. */
  142487. paddingRatio?: number;
  142488. /**
  142489. * Number that declares the fill method for the padding gutter.
  142490. */
  142491. paddingMode?: number;
  142492. /**
  142493. * If in SUBUV_COLOR padding mode what color to use.
  142494. */
  142495. paddingColor?: Color3 | Color4;
  142496. }
  142497. /**
  142498. * Defines the basic interface of a TexturePacker JSON File
  142499. */
  142500. export interface ITexturePackerJSON {
  142501. /**
  142502. * The frame ID
  142503. */
  142504. name: string;
  142505. /**
  142506. * The base64 channel data
  142507. */
  142508. sets: any;
  142509. /**
  142510. * The options of the Packer
  142511. */
  142512. options: ITexturePackerOptions;
  142513. /**
  142514. * The frame data of the Packer
  142515. */
  142516. frames: Array<number>;
  142517. }
  142518. /**
  142519. * This is a support class that generates a series of packed texture sets.
  142520. * @see https://doc.babylonjs.com/babylon101/materials
  142521. */
  142522. export class TexturePacker {
  142523. /** Packer Layout Constant 0 */
  142524. static readonly LAYOUT_STRIP: number;
  142525. /** Packer Layout Constant 1 */
  142526. static readonly LAYOUT_POWER2: number;
  142527. /** Packer Layout Constant 2 */
  142528. static readonly LAYOUT_COLNUM: number;
  142529. /** Packer Layout Constant 0 */
  142530. static readonly SUBUV_WRAP: number;
  142531. /** Packer Layout Constant 1 */
  142532. static readonly SUBUV_EXTEND: number;
  142533. /** Packer Layout Constant 2 */
  142534. static readonly SUBUV_COLOR: number;
  142535. /** The Name of the Texture Package */
  142536. name: string;
  142537. /** The scene scope of the TexturePacker */
  142538. scene: Scene;
  142539. /** The Meshes to target */
  142540. meshes: AbstractMesh[];
  142541. /** Arguments passed with the Constructor */
  142542. options: ITexturePackerOptions;
  142543. /** The promise that is started upon initialization */
  142544. promise: Nullable<Promise<TexturePacker | string>>;
  142545. /** The Container object for the channel sets that are generated */
  142546. sets: object;
  142547. /** The Container array for the frames that are generated */
  142548. frames: TexturePackerFrame[];
  142549. /** The expected number of textures the system is parsing. */
  142550. private _expecting;
  142551. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  142552. private _paddingValue;
  142553. /**
  142554. * Initializes a texture package series from an array of meshes or a single mesh.
  142555. * @param name The name of the package
  142556. * @param meshes The target meshes to compose the package from
  142557. * @param options The arguments that texture packer should follow while building.
  142558. * @param scene The scene which the textures are scoped to.
  142559. * @returns TexturePacker
  142560. */
  142561. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  142562. /**
  142563. * Starts the package process
  142564. * @param resolve The promises resolution function
  142565. * @returns TexturePacker
  142566. */
  142567. private _createFrames;
  142568. /**
  142569. * Calculates the Size of the Channel Sets
  142570. * @returns Vector2
  142571. */
  142572. private _calculateSize;
  142573. /**
  142574. * Calculates the UV data for the frames.
  142575. * @param baseSize the base frameSize
  142576. * @param padding the base frame padding
  142577. * @param dtSize size of the Dynamic Texture for that channel
  142578. * @param dtUnits is 1/dtSize
  142579. * @param update flag to update the input meshes
  142580. */
  142581. private _calculateMeshUVFrames;
  142582. /**
  142583. * Calculates the frames Offset.
  142584. * @param index of the frame
  142585. * @returns Vector2
  142586. */
  142587. private _getFrameOffset;
  142588. /**
  142589. * Updates a Mesh to the frame data
  142590. * @param mesh that is the target
  142591. * @param frameID or the frame index
  142592. */
  142593. private _updateMeshUV;
  142594. /**
  142595. * Updates a Meshes materials to use the texture packer channels
  142596. * @param m is the mesh to target
  142597. * @param force all channels on the packer to be set.
  142598. */
  142599. private _updateTextureReferences;
  142600. /**
  142601. * Public method to set a Mesh to a frame
  142602. * @param m that is the target
  142603. * @param frameID or the frame index
  142604. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  142605. */
  142606. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  142607. /**
  142608. * Starts the async promise to compile the texture packer.
  142609. * @returns Promise<void>
  142610. */
  142611. processAsync(): Promise<void>;
  142612. /**
  142613. * Disposes all textures associated with this packer
  142614. */
  142615. dispose(): void;
  142616. /**
  142617. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  142618. * @param imageType is the image type to use.
  142619. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  142620. */
  142621. download(imageType?: string, quality?: number): void;
  142622. /**
  142623. * Public method to load a texturePacker JSON file.
  142624. * @param data of the JSON file in string format.
  142625. */
  142626. updateFromJSON(data: string): void;
  142627. }
  142628. }
  142629. declare module BABYLON {
  142630. /**
  142631. * 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.
  142632. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142633. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142634. */
  142635. export class CustomProceduralTexture extends ProceduralTexture {
  142636. private _animate;
  142637. private _time;
  142638. private _config;
  142639. private _texturePath;
  142640. /**
  142641. * Instantiates a new Custom Procedural Texture.
  142642. * 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.
  142643. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142644. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142645. * @param name Define the name of the texture
  142646. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  142647. * @param size Define the size of the texture to create
  142648. * @param scene Define the scene the texture belongs to
  142649. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  142650. * @param generateMipMaps Define if the texture should creates mip maps or not
  142651. */
  142652. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142653. private _loadJson;
  142654. /**
  142655. * Is the texture ready to be used ? (rendered at least once)
  142656. * @returns true if ready, otherwise, false.
  142657. */
  142658. isReady(): boolean;
  142659. /**
  142660. * Render the texture to its associated render target.
  142661. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  142662. */
  142663. render(useCameraPostProcess?: boolean): void;
  142664. /**
  142665. * Update the list of dependant textures samplers in the shader.
  142666. */
  142667. updateTextures(): void;
  142668. /**
  142669. * Update the uniform values of the procedural texture in the shader.
  142670. */
  142671. updateShaderUniforms(): void;
  142672. /**
  142673. * Define if the texture animates or not.
  142674. */
  142675. get animate(): boolean;
  142676. set animate(value: boolean);
  142677. }
  142678. }
  142679. declare module BABYLON {
  142680. /** @hidden */
  142681. export var noisePixelShader: {
  142682. name: string;
  142683. shader: string;
  142684. };
  142685. }
  142686. declare module BABYLON {
  142687. /**
  142688. * Class used to generate noise procedural textures
  142689. */
  142690. export class NoiseProceduralTexture extends ProceduralTexture {
  142691. /** Gets or sets the start time (default is 0) */
  142692. time: number;
  142693. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  142694. brightness: number;
  142695. /** Defines the number of octaves to process */
  142696. octaves: number;
  142697. /** Defines the level of persistence (0.8 by default) */
  142698. persistence: number;
  142699. /** Gets or sets animation speed factor (default is 1) */
  142700. animationSpeedFactor: number;
  142701. /**
  142702. * Creates a new NoiseProceduralTexture
  142703. * @param name defines the name fo the texture
  142704. * @param size defines the size of the texture (default is 256)
  142705. * @param scene defines the hosting scene
  142706. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  142707. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  142708. */
  142709. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142710. private _updateShaderUniforms;
  142711. protected _getDefines(): string;
  142712. /** Generate the current state of the procedural texture */
  142713. render(useCameraPostProcess?: boolean): void;
  142714. /**
  142715. * Serializes this noise procedural texture
  142716. * @returns a serialized noise procedural texture object
  142717. */
  142718. serialize(): any;
  142719. /**
  142720. * Clone the texture.
  142721. * @returns the cloned texture
  142722. */
  142723. clone(): NoiseProceduralTexture;
  142724. /**
  142725. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  142726. * @param parsedTexture defines parsed texture data
  142727. * @param scene defines the current scene
  142728. * @param rootUrl defines the root URL containing noise procedural texture information
  142729. * @returns a parsed NoiseProceduralTexture
  142730. */
  142731. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  142732. }
  142733. }
  142734. declare module BABYLON {
  142735. /**
  142736. * Raw cube texture where the raw buffers are passed in
  142737. */
  142738. export class RawCubeTexture extends CubeTexture {
  142739. /**
  142740. * Creates a cube texture where the raw buffers are passed in.
  142741. * @param scene defines the scene the texture is attached to
  142742. * @param data defines the array of data to use to create each face
  142743. * @param size defines the size of the textures
  142744. * @param format defines the format of the data
  142745. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  142746. * @param generateMipMaps defines if the engine should generate the mip levels
  142747. * @param invertY defines if data must be stored with Y axis inverted
  142748. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  142749. * @param compression defines the compression used (null by default)
  142750. */
  142751. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  142752. /**
  142753. * Updates the raw cube texture.
  142754. * @param data defines the data to store
  142755. * @param format defines the data format
  142756. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  142757. * @param invertY defines if data must be stored with Y axis inverted
  142758. * @param compression defines the compression used (null by default)
  142759. * @param level defines which level of the texture to update
  142760. */
  142761. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  142762. /**
  142763. * Updates a raw cube texture with RGBD encoded data.
  142764. * @param data defines the array of data [mipmap][face] to use to create each face
  142765. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  142766. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  142767. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  142768. * @returns a promsie that resolves when the operation is complete
  142769. */
  142770. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  142771. /**
  142772. * Clones the raw cube texture.
  142773. * @return a new cube texture
  142774. */
  142775. clone(): CubeTexture;
  142776. /** @hidden */
  142777. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  142778. }
  142779. }
  142780. declare module BABYLON {
  142781. /**
  142782. * Class used to store 2D array textures containing user data
  142783. */
  142784. export class RawTexture2DArray extends Texture {
  142785. /** Gets or sets the texture format to use */
  142786. format: number;
  142787. /**
  142788. * Create a new RawTexture2DArray
  142789. * @param data defines the data of the texture
  142790. * @param width defines the width of the texture
  142791. * @param height defines the height of the texture
  142792. * @param depth defines the number of layers of the texture
  142793. * @param format defines the texture format to use
  142794. * @param scene defines the hosting scene
  142795. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142796. * @param invertY defines if texture must be stored with Y axis inverted
  142797. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142798. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142799. */
  142800. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142801. /** Gets or sets the texture format to use */
  142802. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142803. /**
  142804. * Update the texture with new data
  142805. * @param data defines the data to store in the texture
  142806. */
  142807. update(data: ArrayBufferView): void;
  142808. }
  142809. }
  142810. declare module BABYLON {
  142811. /**
  142812. * Class used to store 3D textures containing user data
  142813. */
  142814. export class RawTexture3D extends Texture {
  142815. /** Gets or sets the texture format to use */
  142816. format: number;
  142817. /**
  142818. * Create a new RawTexture3D
  142819. * @param data defines the data of the texture
  142820. * @param width defines the width of the texture
  142821. * @param height defines the height of the texture
  142822. * @param depth defines the depth of the texture
  142823. * @param format defines the texture format to use
  142824. * @param scene defines the hosting scene
  142825. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142826. * @param invertY defines if texture must be stored with Y axis inverted
  142827. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142828. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142829. */
  142830. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142831. /** Gets or sets the texture format to use */
  142832. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142833. /**
  142834. * Update the texture with new data
  142835. * @param data defines the data to store in the texture
  142836. */
  142837. update(data: ArrayBufferView): void;
  142838. }
  142839. }
  142840. declare module BABYLON {
  142841. /**
  142842. * Creates a refraction texture used by refraction channel of the standard material.
  142843. * It is like a mirror but to see through a material.
  142844. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142845. */
  142846. export class RefractionTexture extends RenderTargetTexture {
  142847. /**
  142848. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  142849. * 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.
  142850. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142851. */
  142852. refractionPlane: Plane;
  142853. /**
  142854. * Define how deep under the surface we should see.
  142855. */
  142856. depth: number;
  142857. /**
  142858. * Creates a refraction texture used by refraction channel of the standard material.
  142859. * It is like a mirror but to see through a material.
  142860. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142861. * @param name Define the texture name
  142862. * @param size Define the size of the underlying texture
  142863. * @param scene Define the scene the refraction belongs to
  142864. * @param generateMipMaps Define if we need to generate mips level for the refraction
  142865. */
  142866. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  142867. /**
  142868. * Clone the refraction texture.
  142869. * @returns the cloned texture
  142870. */
  142871. clone(): RefractionTexture;
  142872. /**
  142873. * Serialize the texture to a JSON representation you could use in Parse later on
  142874. * @returns the serialized JSON representation
  142875. */
  142876. serialize(): any;
  142877. }
  142878. }
  142879. declare module BABYLON {
  142880. /**
  142881. * Block used to add support for vertex skinning (bones)
  142882. */
  142883. export class BonesBlock extends NodeMaterialBlock {
  142884. /**
  142885. * Creates a new BonesBlock
  142886. * @param name defines the block name
  142887. */
  142888. constructor(name: string);
  142889. /**
  142890. * Initialize the block and prepare the context for build
  142891. * @param state defines the state that will be used for the build
  142892. */
  142893. initialize(state: NodeMaterialBuildState): void;
  142894. /**
  142895. * Gets the current class name
  142896. * @returns the class name
  142897. */
  142898. getClassName(): string;
  142899. /**
  142900. * Gets the matrix indices input component
  142901. */
  142902. get matricesIndices(): NodeMaterialConnectionPoint;
  142903. /**
  142904. * Gets the matrix weights input component
  142905. */
  142906. get matricesWeights(): NodeMaterialConnectionPoint;
  142907. /**
  142908. * Gets the extra matrix indices input component
  142909. */
  142910. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  142911. /**
  142912. * Gets the extra matrix weights input component
  142913. */
  142914. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  142915. /**
  142916. * Gets the world input component
  142917. */
  142918. get world(): NodeMaterialConnectionPoint;
  142919. /**
  142920. * Gets the output component
  142921. */
  142922. get output(): NodeMaterialConnectionPoint;
  142923. autoConfigure(material: NodeMaterial): void;
  142924. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  142925. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142926. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142927. protected _buildBlock(state: NodeMaterialBuildState): this;
  142928. }
  142929. }
  142930. declare module BABYLON {
  142931. /**
  142932. * Block used to add support for instances
  142933. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  142934. */
  142935. export class InstancesBlock extends NodeMaterialBlock {
  142936. /**
  142937. * Creates a new InstancesBlock
  142938. * @param name defines the block name
  142939. */
  142940. constructor(name: string);
  142941. /**
  142942. * Gets the current class name
  142943. * @returns the class name
  142944. */
  142945. getClassName(): string;
  142946. /**
  142947. * Gets the first world row input component
  142948. */
  142949. get world0(): NodeMaterialConnectionPoint;
  142950. /**
  142951. * Gets the second world row input component
  142952. */
  142953. get world1(): NodeMaterialConnectionPoint;
  142954. /**
  142955. * Gets the third world row input component
  142956. */
  142957. get world2(): NodeMaterialConnectionPoint;
  142958. /**
  142959. * Gets the forth world row input component
  142960. */
  142961. get world3(): NodeMaterialConnectionPoint;
  142962. /**
  142963. * Gets the world input component
  142964. */
  142965. get world(): NodeMaterialConnectionPoint;
  142966. /**
  142967. * Gets the output component
  142968. */
  142969. get output(): NodeMaterialConnectionPoint;
  142970. /**
  142971. * Gets the isntanceID component
  142972. */
  142973. get instanceID(): NodeMaterialConnectionPoint;
  142974. autoConfigure(material: NodeMaterial): void;
  142975. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  142976. protected _buildBlock(state: NodeMaterialBuildState): this;
  142977. }
  142978. }
  142979. declare module BABYLON {
  142980. /**
  142981. * Block used to add morph targets support to vertex shader
  142982. */
  142983. export class MorphTargetsBlock extends NodeMaterialBlock {
  142984. private _repeatableContentAnchor;
  142985. /**
  142986. * Create a new MorphTargetsBlock
  142987. * @param name defines the block name
  142988. */
  142989. constructor(name: string);
  142990. /**
  142991. * Gets the current class name
  142992. * @returns the class name
  142993. */
  142994. getClassName(): string;
  142995. /**
  142996. * Gets the position input component
  142997. */
  142998. get position(): NodeMaterialConnectionPoint;
  142999. /**
  143000. * Gets the normal input component
  143001. */
  143002. get normal(): NodeMaterialConnectionPoint;
  143003. /**
  143004. * Gets the tangent input component
  143005. */
  143006. get tangent(): NodeMaterialConnectionPoint;
  143007. /**
  143008. * Gets the tangent input component
  143009. */
  143010. get uv(): NodeMaterialConnectionPoint;
  143011. /**
  143012. * Gets the position output component
  143013. */
  143014. get positionOutput(): NodeMaterialConnectionPoint;
  143015. /**
  143016. * Gets the normal output component
  143017. */
  143018. get normalOutput(): NodeMaterialConnectionPoint;
  143019. /**
  143020. * Gets the tangent output component
  143021. */
  143022. get tangentOutput(): NodeMaterialConnectionPoint;
  143023. /**
  143024. * Gets the tangent output component
  143025. */
  143026. get uvOutput(): NodeMaterialConnectionPoint;
  143027. initialize(state: NodeMaterialBuildState): void;
  143028. autoConfigure(material: NodeMaterial): void;
  143029. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143030. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143031. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  143032. protected _buildBlock(state: NodeMaterialBuildState): this;
  143033. }
  143034. }
  143035. declare module BABYLON {
  143036. /**
  143037. * Block used to get data information from a light
  143038. */
  143039. export class LightInformationBlock extends NodeMaterialBlock {
  143040. private _lightDataUniformName;
  143041. private _lightColorUniformName;
  143042. private _lightTypeDefineName;
  143043. /**
  143044. * Gets or sets the light associated with this block
  143045. */
  143046. light: Nullable<Light>;
  143047. /**
  143048. * Creates a new LightInformationBlock
  143049. * @param name defines the block name
  143050. */
  143051. constructor(name: string);
  143052. /**
  143053. * Gets the current class name
  143054. * @returns the class name
  143055. */
  143056. getClassName(): string;
  143057. /**
  143058. * Gets the world position input component
  143059. */
  143060. get worldPosition(): NodeMaterialConnectionPoint;
  143061. /**
  143062. * Gets the direction output component
  143063. */
  143064. get direction(): NodeMaterialConnectionPoint;
  143065. /**
  143066. * Gets the direction output component
  143067. */
  143068. get color(): NodeMaterialConnectionPoint;
  143069. /**
  143070. * Gets the direction output component
  143071. */
  143072. get intensity(): NodeMaterialConnectionPoint;
  143073. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143074. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143075. protected _buildBlock(state: NodeMaterialBuildState): this;
  143076. serialize(): any;
  143077. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143078. }
  143079. }
  143080. declare module BABYLON {
  143081. /**
  143082. * Block used to add image processing support to fragment shader
  143083. */
  143084. export class ImageProcessingBlock extends NodeMaterialBlock {
  143085. /**
  143086. * Create a new ImageProcessingBlock
  143087. * @param name defines the block name
  143088. */
  143089. constructor(name: string);
  143090. /**
  143091. * Gets the current class name
  143092. * @returns the class name
  143093. */
  143094. getClassName(): string;
  143095. /**
  143096. * Gets the color input component
  143097. */
  143098. get color(): NodeMaterialConnectionPoint;
  143099. /**
  143100. * Gets the output component
  143101. */
  143102. get output(): NodeMaterialConnectionPoint;
  143103. /**
  143104. * Initialize the block and prepare the context for build
  143105. * @param state defines the state that will be used for the build
  143106. */
  143107. initialize(state: NodeMaterialBuildState): void;
  143108. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  143109. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143110. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143111. protected _buildBlock(state: NodeMaterialBuildState): this;
  143112. }
  143113. }
  143114. declare module BABYLON {
  143115. /**
  143116. * Block used to pertub normals based on a normal map
  143117. */
  143118. export class PerturbNormalBlock extends NodeMaterialBlock {
  143119. private _tangentSpaceParameterName;
  143120. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  143121. invertX: boolean;
  143122. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  143123. invertY: boolean;
  143124. /**
  143125. * Create a new PerturbNormalBlock
  143126. * @param name defines the block name
  143127. */
  143128. constructor(name: string);
  143129. /**
  143130. * Gets the current class name
  143131. * @returns the class name
  143132. */
  143133. getClassName(): string;
  143134. /**
  143135. * Gets the world position input component
  143136. */
  143137. get worldPosition(): NodeMaterialConnectionPoint;
  143138. /**
  143139. * Gets the world normal input component
  143140. */
  143141. get worldNormal(): NodeMaterialConnectionPoint;
  143142. /**
  143143. * Gets the world tangent input component
  143144. */
  143145. get worldTangent(): NodeMaterialConnectionPoint;
  143146. /**
  143147. * Gets the uv input component
  143148. */
  143149. get uv(): NodeMaterialConnectionPoint;
  143150. /**
  143151. * Gets the normal map color input component
  143152. */
  143153. get normalMapColor(): NodeMaterialConnectionPoint;
  143154. /**
  143155. * Gets the strength input component
  143156. */
  143157. get strength(): NodeMaterialConnectionPoint;
  143158. /**
  143159. * Gets the output component
  143160. */
  143161. get output(): NodeMaterialConnectionPoint;
  143162. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143163. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143164. autoConfigure(material: NodeMaterial): void;
  143165. protected _buildBlock(state: NodeMaterialBuildState): this;
  143166. protected _dumpPropertiesCode(): string;
  143167. serialize(): any;
  143168. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143169. }
  143170. }
  143171. declare module BABYLON {
  143172. /**
  143173. * Block used to discard a pixel if a value is smaller than a cutoff
  143174. */
  143175. export class DiscardBlock extends NodeMaterialBlock {
  143176. /**
  143177. * Create a new DiscardBlock
  143178. * @param name defines the block name
  143179. */
  143180. constructor(name: string);
  143181. /**
  143182. * Gets the current class name
  143183. * @returns the class name
  143184. */
  143185. getClassName(): string;
  143186. /**
  143187. * Gets the color input component
  143188. */
  143189. get value(): NodeMaterialConnectionPoint;
  143190. /**
  143191. * Gets the cutoff input component
  143192. */
  143193. get cutoff(): NodeMaterialConnectionPoint;
  143194. protected _buildBlock(state: NodeMaterialBuildState): this;
  143195. }
  143196. }
  143197. declare module BABYLON {
  143198. /**
  143199. * Block used to test if the fragment shader is front facing
  143200. */
  143201. export class FrontFacingBlock extends NodeMaterialBlock {
  143202. /**
  143203. * Creates a new FrontFacingBlock
  143204. * @param name defines the block name
  143205. */
  143206. constructor(name: string);
  143207. /**
  143208. * Gets the current class name
  143209. * @returns the class name
  143210. */
  143211. getClassName(): string;
  143212. /**
  143213. * Gets the output component
  143214. */
  143215. get output(): NodeMaterialConnectionPoint;
  143216. protected _buildBlock(state: NodeMaterialBuildState): this;
  143217. }
  143218. }
  143219. declare module BABYLON {
  143220. /**
  143221. * Block used to get the derivative value on x and y of a given input
  143222. */
  143223. export class DerivativeBlock extends NodeMaterialBlock {
  143224. /**
  143225. * Create a new DerivativeBlock
  143226. * @param name defines the block name
  143227. */
  143228. constructor(name: string);
  143229. /**
  143230. * Gets the current class name
  143231. * @returns the class name
  143232. */
  143233. getClassName(): string;
  143234. /**
  143235. * Gets the input component
  143236. */
  143237. get input(): NodeMaterialConnectionPoint;
  143238. /**
  143239. * Gets the derivative output on x
  143240. */
  143241. get dx(): NodeMaterialConnectionPoint;
  143242. /**
  143243. * Gets the derivative output on y
  143244. */
  143245. get dy(): NodeMaterialConnectionPoint;
  143246. protected _buildBlock(state: NodeMaterialBuildState): this;
  143247. }
  143248. }
  143249. declare module BABYLON {
  143250. /**
  143251. * Block used to make gl_FragCoord available
  143252. */
  143253. export class FragCoordBlock extends NodeMaterialBlock {
  143254. /**
  143255. * Creates a new FragCoordBlock
  143256. * @param name defines the block name
  143257. */
  143258. constructor(name: string);
  143259. /**
  143260. * Gets the current class name
  143261. * @returns the class name
  143262. */
  143263. getClassName(): string;
  143264. /**
  143265. * Gets the xy component
  143266. */
  143267. get xy(): NodeMaterialConnectionPoint;
  143268. /**
  143269. * Gets the xyz component
  143270. */
  143271. get xyz(): NodeMaterialConnectionPoint;
  143272. /**
  143273. * Gets the xyzw component
  143274. */
  143275. get xyzw(): NodeMaterialConnectionPoint;
  143276. /**
  143277. * Gets the x component
  143278. */
  143279. get x(): NodeMaterialConnectionPoint;
  143280. /**
  143281. * Gets the y component
  143282. */
  143283. get y(): NodeMaterialConnectionPoint;
  143284. /**
  143285. * Gets the z component
  143286. */
  143287. get z(): NodeMaterialConnectionPoint;
  143288. /**
  143289. * Gets the w component
  143290. */
  143291. get output(): NodeMaterialConnectionPoint;
  143292. protected writeOutputs(state: NodeMaterialBuildState): string;
  143293. protected _buildBlock(state: NodeMaterialBuildState): this;
  143294. }
  143295. }
  143296. declare module BABYLON {
  143297. /**
  143298. * Block used to get the screen sizes
  143299. */
  143300. export class ScreenSizeBlock extends NodeMaterialBlock {
  143301. private _varName;
  143302. private _scene;
  143303. /**
  143304. * Creates a new ScreenSizeBlock
  143305. * @param name defines the block name
  143306. */
  143307. constructor(name: string);
  143308. /**
  143309. * Gets the current class name
  143310. * @returns the class name
  143311. */
  143312. getClassName(): string;
  143313. /**
  143314. * Gets the xy component
  143315. */
  143316. get xy(): NodeMaterialConnectionPoint;
  143317. /**
  143318. * Gets the x component
  143319. */
  143320. get x(): NodeMaterialConnectionPoint;
  143321. /**
  143322. * Gets the y component
  143323. */
  143324. get y(): NodeMaterialConnectionPoint;
  143325. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143326. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  143327. protected _buildBlock(state: NodeMaterialBuildState): this;
  143328. }
  143329. }
  143330. declare module BABYLON {
  143331. /**
  143332. * Block used to add support for scene fog
  143333. */
  143334. export class FogBlock extends NodeMaterialBlock {
  143335. private _fogDistanceName;
  143336. private _fogParameters;
  143337. /**
  143338. * Create a new FogBlock
  143339. * @param name defines the block name
  143340. */
  143341. constructor(name: string);
  143342. /**
  143343. * Gets the current class name
  143344. * @returns the class name
  143345. */
  143346. getClassName(): string;
  143347. /**
  143348. * Gets the world position input component
  143349. */
  143350. get worldPosition(): NodeMaterialConnectionPoint;
  143351. /**
  143352. * Gets the view input component
  143353. */
  143354. get view(): NodeMaterialConnectionPoint;
  143355. /**
  143356. * Gets the color input component
  143357. */
  143358. get input(): NodeMaterialConnectionPoint;
  143359. /**
  143360. * Gets the fog color input component
  143361. */
  143362. get fogColor(): NodeMaterialConnectionPoint;
  143363. /**
  143364. * Gets the output component
  143365. */
  143366. get output(): NodeMaterialConnectionPoint;
  143367. autoConfigure(material: NodeMaterial): void;
  143368. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143369. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143370. protected _buildBlock(state: NodeMaterialBuildState): this;
  143371. }
  143372. }
  143373. declare module BABYLON {
  143374. /**
  143375. * Block used to add light in the fragment shader
  143376. */
  143377. export class LightBlock extends NodeMaterialBlock {
  143378. private _lightId;
  143379. /**
  143380. * Gets or sets the light associated with this block
  143381. */
  143382. light: Nullable<Light>;
  143383. /**
  143384. * Create a new LightBlock
  143385. * @param name defines the block name
  143386. */
  143387. constructor(name: string);
  143388. /**
  143389. * Gets the current class name
  143390. * @returns the class name
  143391. */
  143392. getClassName(): string;
  143393. /**
  143394. * Gets the world position input component
  143395. */
  143396. get worldPosition(): NodeMaterialConnectionPoint;
  143397. /**
  143398. * Gets the world normal input component
  143399. */
  143400. get worldNormal(): NodeMaterialConnectionPoint;
  143401. /**
  143402. * Gets the camera (or eye) position component
  143403. */
  143404. get cameraPosition(): NodeMaterialConnectionPoint;
  143405. /**
  143406. * Gets the glossiness component
  143407. */
  143408. get glossiness(): NodeMaterialConnectionPoint;
  143409. /**
  143410. * Gets the glossinness power component
  143411. */
  143412. get glossPower(): NodeMaterialConnectionPoint;
  143413. /**
  143414. * Gets the diffuse color component
  143415. */
  143416. get diffuseColor(): NodeMaterialConnectionPoint;
  143417. /**
  143418. * Gets the specular color component
  143419. */
  143420. get specularColor(): NodeMaterialConnectionPoint;
  143421. /**
  143422. * Gets the diffuse output component
  143423. */
  143424. get diffuseOutput(): NodeMaterialConnectionPoint;
  143425. /**
  143426. * Gets the specular output component
  143427. */
  143428. get specularOutput(): NodeMaterialConnectionPoint;
  143429. /**
  143430. * Gets the shadow output component
  143431. */
  143432. get shadow(): 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. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143439. serialize(): any;
  143440. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143441. }
  143442. }
  143443. declare module BABYLON {
  143444. /**
  143445. * Block used to read a reflection texture from a sampler
  143446. */
  143447. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  143448. /**
  143449. * Create a new ReflectionTextureBlock
  143450. * @param name defines the block name
  143451. */
  143452. constructor(name: string);
  143453. /**
  143454. * Gets the current class name
  143455. * @returns the class name
  143456. */
  143457. getClassName(): string;
  143458. /**
  143459. * Gets the world position input component
  143460. */
  143461. get position(): NodeMaterialConnectionPoint;
  143462. /**
  143463. * Gets the world position input component
  143464. */
  143465. get worldPosition(): NodeMaterialConnectionPoint;
  143466. /**
  143467. * Gets the world normal input component
  143468. */
  143469. get worldNormal(): NodeMaterialConnectionPoint;
  143470. /**
  143471. * Gets the world input component
  143472. */
  143473. get world(): NodeMaterialConnectionPoint;
  143474. /**
  143475. * Gets the camera (or eye) position component
  143476. */
  143477. get cameraPosition(): NodeMaterialConnectionPoint;
  143478. /**
  143479. * Gets the view input component
  143480. */
  143481. get view(): NodeMaterialConnectionPoint;
  143482. /**
  143483. * Gets the rgb output component
  143484. */
  143485. get rgb(): NodeMaterialConnectionPoint;
  143486. /**
  143487. * Gets the rgba output component
  143488. */
  143489. get rgba(): NodeMaterialConnectionPoint;
  143490. /**
  143491. * Gets the r output component
  143492. */
  143493. get r(): NodeMaterialConnectionPoint;
  143494. /**
  143495. * Gets the g output component
  143496. */
  143497. get g(): NodeMaterialConnectionPoint;
  143498. /**
  143499. * Gets the b output component
  143500. */
  143501. get b(): NodeMaterialConnectionPoint;
  143502. /**
  143503. * Gets the a output component
  143504. */
  143505. get a(): NodeMaterialConnectionPoint;
  143506. autoConfigure(material: NodeMaterial): void;
  143507. protected _buildBlock(state: NodeMaterialBuildState): this;
  143508. }
  143509. }
  143510. declare module BABYLON {
  143511. /**
  143512. * Block used to add 2 vectors
  143513. */
  143514. export class AddBlock extends NodeMaterialBlock {
  143515. /**
  143516. * Creates a new AddBlock
  143517. * @param name defines the block name
  143518. */
  143519. constructor(name: string);
  143520. /**
  143521. * Gets the current class name
  143522. * @returns the class name
  143523. */
  143524. getClassName(): string;
  143525. /**
  143526. * Gets the left operand input component
  143527. */
  143528. get left(): NodeMaterialConnectionPoint;
  143529. /**
  143530. * Gets the right operand input component
  143531. */
  143532. get right(): NodeMaterialConnectionPoint;
  143533. /**
  143534. * Gets the output component
  143535. */
  143536. get output(): NodeMaterialConnectionPoint;
  143537. protected _buildBlock(state: NodeMaterialBuildState): this;
  143538. }
  143539. }
  143540. declare module BABYLON {
  143541. /**
  143542. * Block used to scale a vector by a float
  143543. */
  143544. export class ScaleBlock extends NodeMaterialBlock {
  143545. /**
  143546. * Creates a new ScaleBlock
  143547. * @param name defines the block name
  143548. */
  143549. constructor(name: string);
  143550. /**
  143551. * Gets the current class name
  143552. * @returns the class name
  143553. */
  143554. getClassName(): string;
  143555. /**
  143556. * Gets the input component
  143557. */
  143558. get input(): NodeMaterialConnectionPoint;
  143559. /**
  143560. * Gets the factor input component
  143561. */
  143562. get factor(): NodeMaterialConnectionPoint;
  143563. /**
  143564. * Gets the output component
  143565. */
  143566. get output(): NodeMaterialConnectionPoint;
  143567. protected _buildBlock(state: NodeMaterialBuildState): this;
  143568. }
  143569. }
  143570. declare module BABYLON {
  143571. /**
  143572. * Block used to clamp a float
  143573. */
  143574. export class ClampBlock extends NodeMaterialBlock {
  143575. /** Gets or sets the minimum range */
  143576. minimum: number;
  143577. /** Gets or sets the maximum range */
  143578. maximum: number;
  143579. /**
  143580. * Creates a new ClampBlock
  143581. * @param name defines the block name
  143582. */
  143583. constructor(name: string);
  143584. /**
  143585. * Gets the current class name
  143586. * @returns the class name
  143587. */
  143588. getClassName(): string;
  143589. /**
  143590. * Gets the value input component
  143591. */
  143592. get value(): NodeMaterialConnectionPoint;
  143593. /**
  143594. * Gets the output component
  143595. */
  143596. get output(): NodeMaterialConnectionPoint;
  143597. protected _buildBlock(state: NodeMaterialBuildState): this;
  143598. protected _dumpPropertiesCode(): string;
  143599. serialize(): any;
  143600. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143601. }
  143602. }
  143603. declare module BABYLON {
  143604. /**
  143605. * Block used to apply a cross product between 2 vectors
  143606. */
  143607. export class CrossBlock extends NodeMaterialBlock {
  143608. /**
  143609. * Creates a new CrossBlock
  143610. * @param name defines the block name
  143611. */
  143612. constructor(name: string);
  143613. /**
  143614. * Gets the current class name
  143615. * @returns the class name
  143616. */
  143617. getClassName(): string;
  143618. /**
  143619. * Gets the left operand input component
  143620. */
  143621. get left(): NodeMaterialConnectionPoint;
  143622. /**
  143623. * Gets the right operand input component
  143624. */
  143625. get right(): NodeMaterialConnectionPoint;
  143626. /**
  143627. * Gets the output component
  143628. */
  143629. get output(): NodeMaterialConnectionPoint;
  143630. protected _buildBlock(state: NodeMaterialBuildState): this;
  143631. }
  143632. }
  143633. declare module BABYLON {
  143634. /**
  143635. * Block used to apply a dot product between 2 vectors
  143636. */
  143637. export class DotBlock extends NodeMaterialBlock {
  143638. /**
  143639. * Creates a new DotBlock
  143640. * @param name defines the block name
  143641. */
  143642. constructor(name: string);
  143643. /**
  143644. * Gets the current class name
  143645. * @returns the class name
  143646. */
  143647. getClassName(): string;
  143648. /**
  143649. * Gets the left operand input component
  143650. */
  143651. get left(): NodeMaterialConnectionPoint;
  143652. /**
  143653. * Gets the right operand input component
  143654. */
  143655. get right(): NodeMaterialConnectionPoint;
  143656. /**
  143657. * Gets the output component
  143658. */
  143659. get output(): NodeMaterialConnectionPoint;
  143660. protected _buildBlock(state: NodeMaterialBuildState): this;
  143661. }
  143662. }
  143663. declare module BABYLON {
  143664. /**
  143665. * Block used to normalize a vector
  143666. */
  143667. export class NormalizeBlock extends NodeMaterialBlock {
  143668. /**
  143669. * Creates a new NormalizeBlock
  143670. * @param name defines the block name
  143671. */
  143672. constructor(name: string);
  143673. /**
  143674. * Gets the current class name
  143675. * @returns the class name
  143676. */
  143677. getClassName(): string;
  143678. /**
  143679. * Gets the input component
  143680. */
  143681. get input(): NodeMaterialConnectionPoint;
  143682. /**
  143683. * Gets the output component
  143684. */
  143685. get output(): NodeMaterialConnectionPoint;
  143686. protected _buildBlock(state: NodeMaterialBuildState): this;
  143687. }
  143688. }
  143689. declare module BABYLON {
  143690. /**
  143691. * Block used to create a Color3/4 out of individual inputs (one for each component)
  143692. */
  143693. export class ColorMergerBlock extends NodeMaterialBlock {
  143694. /**
  143695. * Create a new ColorMergerBlock
  143696. * @param name defines the block name
  143697. */
  143698. constructor(name: string);
  143699. /**
  143700. * Gets the current class name
  143701. * @returns the class name
  143702. */
  143703. getClassName(): string;
  143704. /**
  143705. * Gets the rgb component (input)
  143706. */
  143707. get rgbIn(): NodeMaterialConnectionPoint;
  143708. /**
  143709. * Gets the r component (input)
  143710. */
  143711. get r(): NodeMaterialConnectionPoint;
  143712. /**
  143713. * Gets the g component (input)
  143714. */
  143715. get g(): NodeMaterialConnectionPoint;
  143716. /**
  143717. * Gets the b component (input)
  143718. */
  143719. get b(): NodeMaterialConnectionPoint;
  143720. /**
  143721. * Gets the a component (input)
  143722. */
  143723. get a(): NodeMaterialConnectionPoint;
  143724. /**
  143725. * Gets the rgba component (output)
  143726. */
  143727. get rgba(): NodeMaterialConnectionPoint;
  143728. /**
  143729. * Gets the rgb component (output)
  143730. */
  143731. get rgbOut(): NodeMaterialConnectionPoint;
  143732. /**
  143733. * Gets the rgb component (output)
  143734. * @deprecated Please use rgbOut instead.
  143735. */
  143736. get rgb(): NodeMaterialConnectionPoint;
  143737. protected _buildBlock(state: NodeMaterialBuildState): this;
  143738. }
  143739. }
  143740. declare module BABYLON {
  143741. /**
  143742. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  143743. */
  143744. export class VectorSplitterBlock extends NodeMaterialBlock {
  143745. /**
  143746. * Create a new VectorSplitterBlock
  143747. * @param name defines the block name
  143748. */
  143749. constructor(name: string);
  143750. /**
  143751. * Gets the current class name
  143752. * @returns the class name
  143753. */
  143754. getClassName(): string;
  143755. /**
  143756. * Gets the xyzw component (input)
  143757. */
  143758. get xyzw(): NodeMaterialConnectionPoint;
  143759. /**
  143760. * Gets the xyz component (input)
  143761. */
  143762. get xyzIn(): NodeMaterialConnectionPoint;
  143763. /**
  143764. * Gets the xy component (input)
  143765. */
  143766. get xyIn(): NodeMaterialConnectionPoint;
  143767. /**
  143768. * Gets the xyz component (output)
  143769. */
  143770. get xyzOut(): NodeMaterialConnectionPoint;
  143771. /**
  143772. * Gets the xy component (output)
  143773. */
  143774. get xyOut(): NodeMaterialConnectionPoint;
  143775. /**
  143776. * Gets the x component (output)
  143777. */
  143778. get x(): NodeMaterialConnectionPoint;
  143779. /**
  143780. * Gets the y component (output)
  143781. */
  143782. get y(): NodeMaterialConnectionPoint;
  143783. /**
  143784. * Gets the z component (output)
  143785. */
  143786. get z(): NodeMaterialConnectionPoint;
  143787. /**
  143788. * Gets the w component (output)
  143789. */
  143790. get w(): NodeMaterialConnectionPoint;
  143791. protected _inputRename(name: string): string;
  143792. protected _outputRename(name: string): string;
  143793. protected _buildBlock(state: NodeMaterialBuildState): this;
  143794. }
  143795. }
  143796. declare module BABYLON {
  143797. /**
  143798. * Block used to lerp between 2 values
  143799. */
  143800. export class LerpBlock extends NodeMaterialBlock {
  143801. /**
  143802. * Creates a new LerpBlock
  143803. * @param name defines the block name
  143804. */
  143805. constructor(name: string);
  143806. /**
  143807. * Gets the current class name
  143808. * @returns the class name
  143809. */
  143810. getClassName(): string;
  143811. /**
  143812. * Gets the left operand input component
  143813. */
  143814. get left(): NodeMaterialConnectionPoint;
  143815. /**
  143816. * Gets the right operand input component
  143817. */
  143818. get right(): NodeMaterialConnectionPoint;
  143819. /**
  143820. * Gets the gradient operand input component
  143821. */
  143822. get gradient(): NodeMaterialConnectionPoint;
  143823. /**
  143824. * Gets the output component
  143825. */
  143826. get output(): NodeMaterialConnectionPoint;
  143827. protected _buildBlock(state: NodeMaterialBuildState): this;
  143828. }
  143829. }
  143830. declare module BABYLON {
  143831. /**
  143832. * Block used to divide 2 vectors
  143833. */
  143834. export class DivideBlock extends NodeMaterialBlock {
  143835. /**
  143836. * Creates a new DivideBlock
  143837. * @param name defines the block name
  143838. */
  143839. constructor(name: string);
  143840. /**
  143841. * Gets the current class name
  143842. * @returns the class name
  143843. */
  143844. getClassName(): string;
  143845. /**
  143846. * Gets the left operand input component
  143847. */
  143848. get left(): NodeMaterialConnectionPoint;
  143849. /**
  143850. * Gets the right operand input component
  143851. */
  143852. get right(): NodeMaterialConnectionPoint;
  143853. /**
  143854. * Gets the output component
  143855. */
  143856. get output(): NodeMaterialConnectionPoint;
  143857. protected _buildBlock(state: NodeMaterialBuildState): this;
  143858. }
  143859. }
  143860. declare module BABYLON {
  143861. /**
  143862. * Block used to subtract 2 vectors
  143863. */
  143864. export class SubtractBlock extends NodeMaterialBlock {
  143865. /**
  143866. * Creates a new SubtractBlock
  143867. * @param name defines the block name
  143868. */
  143869. constructor(name: string);
  143870. /**
  143871. * Gets the current class name
  143872. * @returns the class name
  143873. */
  143874. getClassName(): string;
  143875. /**
  143876. * Gets the left operand input component
  143877. */
  143878. get left(): NodeMaterialConnectionPoint;
  143879. /**
  143880. * Gets the right operand input component
  143881. */
  143882. get right(): NodeMaterialConnectionPoint;
  143883. /**
  143884. * Gets the output component
  143885. */
  143886. get output(): NodeMaterialConnectionPoint;
  143887. protected _buildBlock(state: NodeMaterialBuildState): this;
  143888. }
  143889. }
  143890. declare module BABYLON {
  143891. /**
  143892. * Block used to step a value
  143893. */
  143894. export class StepBlock extends NodeMaterialBlock {
  143895. /**
  143896. * Creates a new StepBlock
  143897. * @param name defines the block name
  143898. */
  143899. constructor(name: string);
  143900. /**
  143901. * Gets the current class name
  143902. * @returns the class name
  143903. */
  143904. getClassName(): string;
  143905. /**
  143906. * Gets the value operand input component
  143907. */
  143908. get value(): NodeMaterialConnectionPoint;
  143909. /**
  143910. * Gets the edge operand input component
  143911. */
  143912. get edge(): NodeMaterialConnectionPoint;
  143913. /**
  143914. * Gets the output component
  143915. */
  143916. get output(): NodeMaterialConnectionPoint;
  143917. protected _buildBlock(state: NodeMaterialBuildState): this;
  143918. }
  143919. }
  143920. declare module BABYLON {
  143921. /**
  143922. * Block used to get the opposite (1 - x) of a value
  143923. */
  143924. export class OneMinusBlock extends NodeMaterialBlock {
  143925. /**
  143926. * Creates a new OneMinusBlock
  143927. * @param name defines the block name
  143928. */
  143929. constructor(name: string);
  143930. /**
  143931. * Gets the current class name
  143932. * @returns the class name
  143933. */
  143934. getClassName(): string;
  143935. /**
  143936. * Gets the input component
  143937. */
  143938. get input(): NodeMaterialConnectionPoint;
  143939. /**
  143940. * Gets the output component
  143941. */
  143942. get output(): NodeMaterialConnectionPoint;
  143943. protected _buildBlock(state: NodeMaterialBuildState): this;
  143944. }
  143945. }
  143946. declare module BABYLON {
  143947. /**
  143948. * Block used to get the view direction
  143949. */
  143950. export class ViewDirectionBlock extends NodeMaterialBlock {
  143951. /**
  143952. * Creates a new ViewDirectionBlock
  143953. * @param name defines the block name
  143954. */
  143955. constructor(name: string);
  143956. /**
  143957. * Gets the current class name
  143958. * @returns the class name
  143959. */
  143960. getClassName(): string;
  143961. /**
  143962. * Gets the world position component
  143963. */
  143964. get worldPosition(): NodeMaterialConnectionPoint;
  143965. /**
  143966. * Gets the camera position component
  143967. */
  143968. get cameraPosition(): NodeMaterialConnectionPoint;
  143969. /**
  143970. * Gets the output component
  143971. */
  143972. get output(): NodeMaterialConnectionPoint;
  143973. autoConfigure(material: NodeMaterial): void;
  143974. protected _buildBlock(state: NodeMaterialBuildState): this;
  143975. }
  143976. }
  143977. declare module BABYLON {
  143978. /**
  143979. * Block used to compute fresnel value
  143980. */
  143981. export class FresnelBlock extends NodeMaterialBlock {
  143982. /**
  143983. * Create a new FresnelBlock
  143984. * @param name defines the block name
  143985. */
  143986. constructor(name: string);
  143987. /**
  143988. * Gets the current class name
  143989. * @returns the class name
  143990. */
  143991. getClassName(): string;
  143992. /**
  143993. * Gets the world normal input component
  143994. */
  143995. get worldNormal(): NodeMaterialConnectionPoint;
  143996. /**
  143997. * Gets the view direction input component
  143998. */
  143999. get viewDirection(): NodeMaterialConnectionPoint;
  144000. /**
  144001. * Gets the bias input component
  144002. */
  144003. get bias(): NodeMaterialConnectionPoint;
  144004. /**
  144005. * Gets the camera (or eye) position component
  144006. */
  144007. get power(): NodeMaterialConnectionPoint;
  144008. /**
  144009. * Gets the fresnel output component
  144010. */
  144011. get fresnel(): NodeMaterialConnectionPoint;
  144012. autoConfigure(material: NodeMaterial): void;
  144013. protected _buildBlock(state: NodeMaterialBuildState): this;
  144014. }
  144015. }
  144016. declare module BABYLON {
  144017. /**
  144018. * Block used to get the max of 2 values
  144019. */
  144020. export class MaxBlock extends NodeMaterialBlock {
  144021. /**
  144022. * Creates a new MaxBlock
  144023. * @param name defines the block name
  144024. */
  144025. constructor(name: string);
  144026. /**
  144027. * Gets the current class name
  144028. * @returns the class name
  144029. */
  144030. getClassName(): string;
  144031. /**
  144032. * Gets the left operand input component
  144033. */
  144034. get left(): NodeMaterialConnectionPoint;
  144035. /**
  144036. * Gets the right operand input component
  144037. */
  144038. get right(): NodeMaterialConnectionPoint;
  144039. /**
  144040. * Gets the output component
  144041. */
  144042. get output(): NodeMaterialConnectionPoint;
  144043. protected _buildBlock(state: NodeMaterialBuildState): this;
  144044. }
  144045. }
  144046. declare module BABYLON {
  144047. /**
  144048. * Block used to get the min of 2 values
  144049. */
  144050. export class MinBlock extends NodeMaterialBlock {
  144051. /**
  144052. * Creates a new MinBlock
  144053. * @param name defines the block name
  144054. */
  144055. constructor(name: string);
  144056. /**
  144057. * Gets the current class name
  144058. * @returns the class name
  144059. */
  144060. getClassName(): string;
  144061. /**
  144062. * Gets the left operand input component
  144063. */
  144064. get left(): NodeMaterialConnectionPoint;
  144065. /**
  144066. * Gets the right operand input component
  144067. */
  144068. get right(): NodeMaterialConnectionPoint;
  144069. /**
  144070. * Gets the output component
  144071. */
  144072. get output(): NodeMaterialConnectionPoint;
  144073. protected _buildBlock(state: NodeMaterialBuildState): this;
  144074. }
  144075. }
  144076. declare module BABYLON {
  144077. /**
  144078. * Block used to get the distance between 2 values
  144079. */
  144080. export class DistanceBlock extends NodeMaterialBlock {
  144081. /**
  144082. * Creates a new DistanceBlock
  144083. * @param name defines the block name
  144084. */
  144085. constructor(name: string);
  144086. /**
  144087. * Gets the current class name
  144088. * @returns the class name
  144089. */
  144090. getClassName(): string;
  144091. /**
  144092. * Gets the left operand input component
  144093. */
  144094. get left(): NodeMaterialConnectionPoint;
  144095. /**
  144096. * Gets the right operand input component
  144097. */
  144098. get right(): NodeMaterialConnectionPoint;
  144099. /**
  144100. * Gets the output component
  144101. */
  144102. get output(): NodeMaterialConnectionPoint;
  144103. protected _buildBlock(state: NodeMaterialBuildState): this;
  144104. }
  144105. }
  144106. declare module BABYLON {
  144107. /**
  144108. * Block used to get the length of a vector
  144109. */
  144110. export class LengthBlock extends NodeMaterialBlock {
  144111. /**
  144112. * Creates a new LengthBlock
  144113. * @param name defines the block name
  144114. */
  144115. constructor(name: string);
  144116. /**
  144117. * Gets the current class name
  144118. * @returns the class name
  144119. */
  144120. getClassName(): string;
  144121. /**
  144122. * Gets the value input component
  144123. */
  144124. get value(): NodeMaterialConnectionPoint;
  144125. /**
  144126. * Gets the output component
  144127. */
  144128. get output(): NodeMaterialConnectionPoint;
  144129. protected _buildBlock(state: NodeMaterialBuildState): this;
  144130. }
  144131. }
  144132. declare module BABYLON {
  144133. /**
  144134. * Block used to get negative version of a value (i.e. x * -1)
  144135. */
  144136. export class NegateBlock extends NodeMaterialBlock {
  144137. /**
  144138. * Creates a new NegateBlock
  144139. * @param name defines the block name
  144140. */
  144141. constructor(name: string);
  144142. /**
  144143. * Gets the current class name
  144144. * @returns the class name
  144145. */
  144146. getClassName(): string;
  144147. /**
  144148. * Gets the value input component
  144149. */
  144150. get value(): NodeMaterialConnectionPoint;
  144151. /**
  144152. * Gets the output component
  144153. */
  144154. get output(): NodeMaterialConnectionPoint;
  144155. protected _buildBlock(state: NodeMaterialBuildState): this;
  144156. }
  144157. }
  144158. declare module BABYLON {
  144159. /**
  144160. * Block used to get the value of the first parameter raised to the power of the second
  144161. */
  144162. export class PowBlock extends NodeMaterialBlock {
  144163. /**
  144164. * Creates a new PowBlock
  144165. * @param name defines the block name
  144166. */
  144167. constructor(name: string);
  144168. /**
  144169. * Gets the current class name
  144170. * @returns the class name
  144171. */
  144172. getClassName(): string;
  144173. /**
  144174. * Gets the value operand input component
  144175. */
  144176. get value(): NodeMaterialConnectionPoint;
  144177. /**
  144178. * Gets the power operand input component
  144179. */
  144180. get power(): NodeMaterialConnectionPoint;
  144181. /**
  144182. * Gets the output component
  144183. */
  144184. get output(): NodeMaterialConnectionPoint;
  144185. protected _buildBlock(state: NodeMaterialBuildState): this;
  144186. }
  144187. }
  144188. declare module BABYLON {
  144189. /**
  144190. * Block used to get a random number
  144191. */
  144192. export class RandomNumberBlock extends NodeMaterialBlock {
  144193. /**
  144194. * Creates a new RandomNumberBlock
  144195. * @param name defines the block name
  144196. */
  144197. constructor(name: string);
  144198. /**
  144199. * Gets the current class name
  144200. * @returns the class name
  144201. */
  144202. getClassName(): string;
  144203. /**
  144204. * Gets the seed input component
  144205. */
  144206. get seed(): NodeMaterialConnectionPoint;
  144207. /**
  144208. * Gets the output component
  144209. */
  144210. get output(): NodeMaterialConnectionPoint;
  144211. protected _buildBlock(state: NodeMaterialBuildState): this;
  144212. }
  144213. }
  144214. declare module BABYLON {
  144215. /**
  144216. * Block used to compute arc tangent of 2 values
  144217. */
  144218. export class ArcTan2Block extends NodeMaterialBlock {
  144219. /**
  144220. * Creates a new ArcTan2Block
  144221. * @param name defines the block name
  144222. */
  144223. constructor(name: string);
  144224. /**
  144225. * Gets the current class name
  144226. * @returns the class name
  144227. */
  144228. getClassName(): string;
  144229. /**
  144230. * Gets the x operand input component
  144231. */
  144232. get x(): NodeMaterialConnectionPoint;
  144233. /**
  144234. * Gets the y operand input component
  144235. */
  144236. get y(): NodeMaterialConnectionPoint;
  144237. /**
  144238. * Gets the output component
  144239. */
  144240. get output(): NodeMaterialConnectionPoint;
  144241. protected _buildBlock(state: NodeMaterialBuildState): this;
  144242. }
  144243. }
  144244. declare module BABYLON {
  144245. /**
  144246. * Block used to smooth step a value
  144247. */
  144248. export class SmoothStepBlock extends NodeMaterialBlock {
  144249. /**
  144250. * Creates a new SmoothStepBlock
  144251. * @param name defines the block name
  144252. */
  144253. constructor(name: string);
  144254. /**
  144255. * Gets the current class name
  144256. * @returns the class name
  144257. */
  144258. getClassName(): string;
  144259. /**
  144260. * Gets the value operand input component
  144261. */
  144262. get value(): NodeMaterialConnectionPoint;
  144263. /**
  144264. * Gets the first edge operand input component
  144265. */
  144266. get edge0(): NodeMaterialConnectionPoint;
  144267. /**
  144268. * Gets the second edge operand input component
  144269. */
  144270. get edge1(): NodeMaterialConnectionPoint;
  144271. /**
  144272. * Gets the output component
  144273. */
  144274. get output(): NodeMaterialConnectionPoint;
  144275. protected _buildBlock(state: NodeMaterialBuildState): this;
  144276. }
  144277. }
  144278. declare module BABYLON {
  144279. /**
  144280. * Block used to get the reciprocal (1 / x) of a value
  144281. */
  144282. export class ReciprocalBlock extends NodeMaterialBlock {
  144283. /**
  144284. * Creates a new ReciprocalBlock
  144285. * @param name defines the block name
  144286. */
  144287. constructor(name: string);
  144288. /**
  144289. * Gets the current class name
  144290. * @returns the class name
  144291. */
  144292. getClassName(): string;
  144293. /**
  144294. * Gets the input component
  144295. */
  144296. get input(): NodeMaterialConnectionPoint;
  144297. /**
  144298. * Gets the output component
  144299. */
  144300. get output(): NodeMaterialConnectionPoint;
  144301. protected _buildBlock(state: NodeMaterialBuildState): this;
  144302. }
  144303. }
  144304. declare module BABYLON {
  144305. /**
  144306. * Block used to replace a color by another one
  144307. */
  144308. export class ReplaceColorBlock extends NodeMaterialBlock {
  144309. /**
  144310. * Creates a new ReplaceColorBlock
  144311. * @param name defines the block name
  144312. */
  144313. constructor(name: string);
  144314. /**
  144315. * Gets the current class name
  144316. * @returns the class name
  144317. */
  144318. getClassName(): string;
  144319. /**
  144320. * Gets the value input component
  144321. */
  144322. get value(): NodeMaterialConnectionPoint;
  144323. /**
  144324. * Gets the reference input component
  144325. */
  144326. get reference(): NodeMaterialConnectionPoint;
  144327. /**
  144328. * Gets the distance input component
  144329. */
  144330. get distance(): NodeMaterialConnectionPoint;
  144331. /**
  144332. * Gets the replacement input component
  144333. */
  144334. get replacement(): NodeMaterialConnectionPoint;
  144335. /**
  144336. * Gets the output component
  144337. */
  144338. get output(): NodeMaterialConnectionPoint;
  144339. protected _buildBlock(state: NodeMaterialBuildState): this;
  144340. }
  144341. }
  144342. declare module BABYLON {
  144343. /**
  144344. * Block used to posterize a value
  144345. * @see https://en.wikipedia.org/wiki/Posterization
  144346. */
  144347. export class PosterizeBlock extends NodeMaterialBlock {
  144348. /**
  144349. * Creates a new PosterizeBlock
  144350. * @param name defines the block name
  144351. */
  144352. constructor(name: string);
  144353. /**
  144354. * Gets the current class name
  144355. * @returns the class name
  144356. */
  144357. getClassName(): string;
  144358. /**
  144359. * Gets the value input component
  144360. */
  144361. get value(): NodeMaterialConnectionPoint;
  144362. /**
  144363. * Gets the steps input component
  144364. */
  144365. get steps(): NodeMaterialConnectionPoint;
  144366. /**
  144367. * Gets the output component
  144368. */
  144369. get output(): NodeMaterialConnectionPoint;
  144370. protected _buildBlock(state: NodeMaterialBuildState): this;
  144371. }
  144372. }
  144373. declare module BABYLON {
  144374. /**
  144375. * Operations supported by the Wave block
  144376. */
  144377. export enum WaveBlockKind {
  144378. /** SawTooth */
  144379. SawTooth = 0,
  144380. /** Square */
  144381. Square = 1,
  144382. /** Triangle */
  144383. Triangle = 2
  144384. }
  144385. /**
  144386. * Block used to apply wave operation to floats
  144387. */
  144388. export class WaveBlock extends NodeMaterialBlock {
  144389. /**
  144390. * Gets or sets the kibnd of wave to be applied by the block
  144391. */
  144392. kind: WaveBlockKind;
  144393. /**
  144394. * Creates a new WaveBlock
  144395. * @param name defines the block name
  144396. */
  144397. constructor(name: string);
  144398. /**
  144399. * Gets the current class name
  144400. * @returns the class name
  144401. */
  144402. getClassName(): string;
  144403. /**
  144404. * Gets the input component
  144405. */
  144406. get input(): NodeMaterialConnectionPoint;
  144407. /**
  144408. * Gets the output component
  144409. */
  144410. get output(): NodeMaterialConnectionPoint;
  144411. protected _buildBlock(state: NodeMaterialBuildState): this;
  144412. serialize(): any;
  144413. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144414. }
  144415. }
  144416. declare module BABYLON {
  144417. /**
  144418. * Class used to store a color step for the GradientBlock
  144419. */
  144420. export class GradientBlockColorStep {
  144421. private _step;
  144422. /**
  144423. * Gets value indicating which step this color is associated with (between 0 and 1)
  144424. */
  144425. get step(): number;
  144426. /**
  144427. * Sets a value indicating which step this color is associated with (between 0 and 1)
  144428. */
  144429. set step(val: number);
  144430. private _color;
  144431. /**
  144432. * Gets the color associated with this step
  144433. */
  144434. get color(): Color3;
  144435. /**
  144436. * Sets the color associated with this step
  144437. */
  144438. set color(val: Color3);
  144439. /**
  144440. * Creates a new GradientBlockColorStep
  144441. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  144442. * @param color defines the color associated with this step
  144443. */
  144444. constructor(step: number, color: Color3);
  144445. }
  144446. /**
  144447. * Block used to return a color from a gradient based on an input value between 0 and 1
  144448. */
  144449. export class GradientBlock extends NodeMaterialBlock {
  144450. /**
  144451. * Gets or sets the list of color steps
  144452. */
  144453. colorSteps: GradientBlockColorStep[];
  144454. /** Gets an observable raised when the value is changed */
  144455. onValueChangedObservable: Observable<GradientBlock>;
  144456. /** calls observable when the value is changed*/
  144457. colorStepsUpdated(): void;
  144458. /**
  144459. * Creates a new GradientBlock
  144460. * @param name defines the block name
  144461. */
  144462. constructor(name: string);
  144463. /**
  144464. * Gets the current class name
  144465. * @returns the class name
  144466. */
  144467. getClassName(): string;
  144468. /**
  144469. * Gets the gradient input component
  144470. */
  144471. get gradient(): NodeMaterialConnectionPoint;
  144472. /**
  144473. * Gets the output component
  144474. */
  144475. get output(): NodeMaterialConnectionPoint;
  144476. private _writeColorConstant;
  144477. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144478. serialize(): any;
  144479. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144480. protected _dumpPropertiesCode(): string;
  144481. }
  144482. }
  144483. declare module BABYLON {
  144484. /**
  144485. * Block used to normalize lerp between 2 values
  144486. */
  144487. export class NLerpBlock extends NodeMaterialBlock {
  144488. /**
  144489. * Creates a new NLerpBlock
  144490. * @param name defines the block name
  144491. */
  144492. constructor(name: string);
  144493. /**
  144494. * Gets the current class name
  144495. * @returns the class name
  144496. */
  144497. getClassName(): string;
  144498. /**
  144499. * Gets the left operand input component
  144500. */
  144501. get left(): NodeMaterialConnectionPoint;
  144502. /**
  144503. * Gets the right operand input component
  144504. */
  144505. get right(): NodeMaterialConnectionPoint;
  144506. /**
  144507. * Gets the gradient operand input component
  144508. */
  144509. get gradient(): NodeMaterialConnectionPoint;
  144510. /**
  144511. * Gets the output component
  144512. */
  144513. get output(): NodeMaterialConnectionPoint;
  144514. protected _buildBlock(state: NodeMaterialBuildState): this;
  144515. }
  144516. }
  144517. declare module BABYLON {
  144518. /**
  144519. * block used to Generate a Worley Noise 3D Noise Pattern
  144520. */
  144521. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  144522. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  144523. manhattanDistance: boolean;
  144524. /**
  144525. * Creates a new WorleyNoise3DBlock
  144526. * @param name defines the block name
  144527. */
  144528. constructor(name: string);
  144529. /**
  144530. * Gets the current class name
  144531. * @returns the class name
  144532. */
  144533. getClassName(): string;
  144534. /**
  144535. * Gets the seed input component
  144536. */
  144537. get seed(): NodeMaterialConnectionPoint;
  144538. /**
  144539. * Gets the jitter input component
  144540. */
  144541. get jitter(): NodeMaterialConnectionPoint;
  144542. /**
  144543. * Gets the output component
  144544. */
  144545. get output(): NodeMaterialConnectionPoint;
  144546. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144547. /**
  144548. * Exposes the properties to the UI?
  144549. */
  144550. protected _dumpPropertiesCode(): string;
  144551. /**
  144552. * Exposes the properties to the Seralize?
  144553. */
  144554. serialize(): any;
  144555. /**
  144556. * Exposes the properties to the deseralize?
  144557. */
  144558. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144559. }
  144560. }
  144561. declare module BABYLON {
  144562. /**
  144563. * block used to Generate a Simplex Perlin 3d Noise Pattern
  144564. */
  144565. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  144566. /**
  144567. * Creates a new SimplexPerlin3DBlock
  144568. * @param name defines the block name
  144569. */
  144570. constructor(name: string);
  144571. /**
  144572. * Gets the current class name
  144573. * @returns the class name
  144574. */
  144575. getClassName(): string;
  144576. /**
  144577. * Gets the seed operand input component
  144578. */
  144579. get seed(): NodeMaterialConnectionPoint;
  144580. /**
  144581. * Gets the output component
  144582. */
  144583. get output(): NodeMaterialConnectionPoint;
  144584. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144585. }
  144586. }
  144587. declare module BABYLON {
  144588. /**
  144589. * Block used to blend normals
  144590. */
  144591. export class NormalBlendBlock extends NodeMaterialBlock {
  144592. /**
  144593. * Creates a new NormalBlendBlock
  144594. * @param name defines the block name
  144595. */
  144596. constructor(name: string);
  144597. /**
  144598. * Gets the current class name
  144599. * @returns the class name
  144600. */
  144601. getClassName(): string;
  144602. /**
  144603. * Gets the first input component
  144604. */
  144605. get normalMap0(): NodeMaterialConnectionPoint;
  144606. /**
  144607. * Gets the second input component
  144608. */
  144609. get normalMap1(): NodeMaterialConnectionPoint;
  144610. /**
  144611. * Gets the output component
  144612. */
  144613. get output(): NodeMaterialConnectionPoint;
  144614. protected _buildBlock(state: NodeMaterialBuildState): this;
  144615. }
  144616. }
  144617. declare module BABYLON {
  144618. /**
  144619. * Block used to rotate a 2d vector by a given angle
  144620. */
  144621. export class Rotate2dBlock extends NodeMaterialBlock {
  144622. /**
  144623. * Creates a new Rotate2dBlock
  144624. * @param name defines the block name
  144625. */
  144626. constructor(name: string);
  144627. /**
  144628. * Gets the current class name
  144629. * @returns the class name
  144630. */
  144631. getClassName(): string;
  144632. /**
  144633. * Gets the input vector
  144634. */
  144635. get input(): NodeMaterialConnectionPoint;
  144636. /**
  144637. * Gets the input angle
  144638. */
  144639. get angle(): NodeMaterialConnectionPoint;
  144640. /**
  144641. * Gets the output component
  144642. */
  144643. get output(): NodeMaterialConnectionPoint;
  144644. autoConfigure(material: NodeMaterial): void;
  144645. protected _buildBlock(state: NodeMaterialBuildState): this;
  144646. }
  144647. }
  144648. declare module BABYLON {
  144649. /**
  144650. * Block used to get the reflected vector from a direction and a normal
  144651. */
  144652. export class ReflectBlock extends NodeMaterialBlock {
  144653. /**
  144654. * Creates a new ReflectBlock
  144655. * @param name defines the block name
  144656. */
  144657. constructor(name: string);
  144658. /**
  144659. * Gets the current class name
  144660. * @returns the class name
  144661. */
  144662. getClassName(): string;
  144663. /**
  144664. * Gets the incident component
  144665. */
  144666. get incident(): NodeMaterialConnectionPoint;
  144667. /**
  144668. * Gets the normal component
  144669. */
  144670. get normal(): NodeMaterialConnectionPoint;
  144671. /**
  144672. * Gets the output component
  144673. */
  144674. get output(): NodeMaterialConnectionPoint;
  144675. protected _buildBlock(state: NodeMaterialBuildState): this;
  144676. }
  144677. }
  144678. declare module BABYLON {
  144679. /**
  144680. * Block used to get the refracted vector from a direction and a normal
  144681. */
  144682. export class RefractBlock extends NodeMaterialBlock {
  144683. /**
  144684. * Creates a new RefractBlock
  144685. * @param name defines the block name
  144686. */
  144687. constructor(name: string);
  144688. /**
  144689. * Gets the current class name
  144690. * @returns the class name
  144691. */
  144692. getClassName(): string;
  144693. /**
  144694. * Gets the incident component
  144695. */
  144696. get incident(): NodeMaterialConnectionPoint;
  144697. /**
  144698. * Gets the normal component
  144699. */
  144700. get normal(): NodeMaterialConnectionPoint;
  144701. /**
  144702. * Gets the index of refraction component
  144703. */
  144704. get ior(): NodeMaterialConnectionPoint;
  144705. /**
  144706. * Gets the output component
  144707. */
  144708. get output(): NodeMaterialConnectionPoint;
  144709. protected _buildBlock(state: NodeMaterialBuildState): this;
  144710. }
  144711. }
  144712. declare module BABYLON {
  144713. /**
  144714. * Block used to desaturate a color
  144715. */
  144716. export class DesaturateBlock extends NodeMaterialBlock {
  144717. /**
  144718. * Creates a new DesaturateBlock
  144719. * @param name defines the block name
  144720. */
  144721. constructor(name: string);
  144722. /**
  144723. * Gets the current class name
  144724. * @returns the class name
  144725. */
  144726. getClassName(): string;
  144727. /**
  144728. * Gets the color operand input component
  144729. */
  144730. get color(): NodeMaterialConnectionPoint;
  144731. /**
  144732. * Gets the level operand input component
  144733. */
  144734. get level(): NodeMaterialConnectionPoint;
  144735. /**
  144736. * Gets the output component
  144737. */
  144738. get output(): NodeMaterialConnectionPoint;
  144739. protected _buildBlock(state: NodeMaterialBuildState): this;
  144740. }
  144741. }
  144742. declare module BABYLON {
  144743. /**
  144744. * Block used to implement the ambient occlusion module of the PBR material
  144745. */
  144746. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  144747. /**
  144748. * Create a new AmbientOcclusionBlock
  144749. * @param name defines the block name
  144750. */
  144751. constructor(name: string);
  144752. /**
  144753. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  144754. */
  144755. useAmbientInGrayScale: boolean;
  144756. /**
  144757. * Initialize the block and prepare the context for build
  144758. * @param state defines the state that will be used for the build
  144759. */
  144760. initialize(state: NodeMaterialBuildState): void;
  144761. /**
  144762. * Gets the current class name
  144763. * @returns the class name
  144764. */
  144765. getClassName(): string;
  144766. /**
  144767. * Gets the texture input component
  144768. */
  144769. get texture(): NodeMaterialConnectionPoint;
  144770. /**
  144771. * Gets the texture intensity component
  144772. */
  144773. get intensity(): NodeMaterialConnectionPoint;
  144774. /**
  144775. * Gets the direct light intensity input component
  144776. */
  144777. get directLightIntensity(): NodeMaterialConnectionPoint;
  144778. /**
  144779. * Gets the ambient occlusion object output component
  144780. */
  144781. get ambientOcc(): NodeMaterialConnectionPoint;
  144782. /**
  144783. * Gets the main code of the block (fragment side)
  144784. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  144785. * @returns the shader code
  144786. */
  144787. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  144788. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144789. protected _buildBlock(state: NodeMaterialBuildState): this;
  144790. protected _dumpPropertiesCode(): string;
  144791. serialize(): any;
  144792. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144793. }
  144794. }
  144795. declare module BABYLON {
  144796. /**
  144797. * Block used to implement the reflection module of the PBR material
  144798. */
  144799. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  144800. /** @hidden */
  144801. _defineLODReflectionAlpha: string;
  144802. /** @hidden */
  144803. _defineLinearSpecularReflection: string;
  144804. private _vEnvironmentIrradianceName;
  144805. /** @hidden */
  144806. _vReflectionMicrosurfaceInfosName: string;
  144807. /** @hidden */
  144808. _vReflectionInfosName: string;
  144809. /** @hidden */
  144810. _vReflectionFilteringInfoName: string;
  144811. private _scene;
  144812. /**
  144813. * The three properties below are set by the main PBR block prior to calling methods of this class.
  144814. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144815. * It's less burden on the user side in the editor part.
  144816. */
  144817. /** @hidden */
  144818. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144819. /** @hidden */
  144820. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144821. /** @hidden */
  144822. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  144823. /**
  144824. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  144825. * diffuse part of the IBL.
  144826. */
  144827. useSphericalHarmonics: boolean;
  144828. /**
  144829. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  144830. */
  144831. forceIrradianceInFragment: boolean;
  144832. /**
  144833. * Create a new ReflectionBlock
  144834. * @param name defines the block name
  144835. */
  144836. constructor(name: string);
  144837. /**
  144838. * Gets the current class name
  144839. * @returns the class name
  144840. */
  144841. getClassName(): string;
  144842. /**
  144843. * Gets the position input component
  144844. */
  144845. get position(): NodeMaterialConnectionPoint;
  144846. /**
  144847. * Gets the world position input component
  144848. */
  144849. get worldPosition(): NodeMaterialConnectionPoint;
  144850. /**
  144851. * Gets the world normal input component
  144852. */
  144853. get worldNormal(): NodeMaterialConnectionPoint;
  144854. /**
  144855. * Gets the world input component
  144856. */
  144857. get world(): NodeMaterialConnectionPoint;
  144858. /**
  144859. * Gets the camera (or eye) position component
  144860. */
  144861. get cameraPosition(): NodeMaterialConnectionPoint;
  144862. /**
  144863. * Gets the view input component
  144864. */
  144865. get view(): NodeMaterialConnectionPoint;
  144866. /**
  144867. * Gets the color input component
  144868. */
  144869. get color(): NodeMaterialConnectionPoint;
  144870. /**
  144871. * Gets the reflection object output component
  144872. */
  144873. get reflection(): NodeMaterialConnectionPoint;
  144874. /**
  144875. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  144876. */
  144877. get hasTexture(): boolean;
  144878. /**
  144879. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  144880. */
  144881. get reflectionColor(): string;
  144882. protected _getTexture(): Nullable<BaseTexture>;
  144883. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144884. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144885. /**
  144886. * Gets the code to inject in the vertex shader
  144887. * @param state current state of the node material building
  144888. * @returns the shader code
  144889. */
  144890. handleVertexSide(state: NodeMaterialBuildState): string;
  144891. /**
  144892. * Gets the main code of the block (fragment side)
  144893. * @param state current state of the node material building
  144894. * @param normalVarName name of the existing variable corresponding to the normal
  144895. * @returns the shader code
  144896. */
  144897. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  144898. protected _buildBlock(state: NodeMaterialBuildState): this;
  144899. protected _dumpPropertiesCode(): string;
  144900. serialize(): any;
  144901. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144902. }
  144903. }
  144904. declare module BABYLON {
  144905. /**
  144906. * Block used to implement the sheen module of the PBR material
  144907. */
  144908. export class SheenBlock extends NodeMaterialBlock {
  144909. /**
  144910. * Create a new SheenBlock
  144911. * @param name defines the block name
  144912. */
  144913. constructor(name: string);
  144914. /**
  144915. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  144916. * It allows the strength of the sheen effect to not depend on the base color of the material,
  144917. * making it easier to setup and tweak the effect
  144918. */
  144919. albedoScaling: boolean;
  144920. /**
  144921. * Defines if the sheen is linked to the sheen color.
  144922. */
  144923. linkSheenWithAlbedo: boolean;
  144924. /**
  144925. * Initialize the block and prepare the context for build
  144926. * @param state defines the state that will be used for the build
  144927. */
  144928. initialize(state: NodeMaterialBuildState): void;
  144929. /**
  144930. * Gets the current class name
  144931. * @returns the class name
  144932. */
  144933. getClassName(): string;
  144934. /**
  144935. * Gets the intensity input component
  144936. */
  144937. get intensity(): NodeMaterialConnectionPoint;
  144938. /**
  144939. * Gets the color input component
  144940. */
  144941. get color(): NodeMaterialConnectionPoint;
  144942. /**
  144943. * Gets the roughness input component
  144944. */
  144945. get roughness(): NodeMaterialConnectionPoint;
  144946. /**
  144947. * Gets the sheen object output component
  144948. */
  144949. get sheen(): NodeMaterialConnectionPoint;
  144950. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144951. /**
  144952. * Gets the main code of the block (fragment side)
  144953. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144954. * @returns the shader code
  144955. */
  144956. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  144957. protected _buildBlock(state: NodeMaterialBuildState): this;
  144958. protected _dumpPropertiesCode(): string;
  144959. serialize(): any;
  144960. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144961. }
  144962. }
  144963. declare module BABYLON {
  144964. /**
  144965. * Block used to implement the reflectivity module of the PBR material
  144966. */
  144967. export class ReflectivityBlock extends NodeMaterialBlock {
  144968. private _metallicReflectanceColor;
  144969. private _metallicF0Factor;
  144970. /** @hidden */
  144971. _vMetallicReflectanceFactorsName: string;
  144972. /**
  144973. * The property below is set by the main PBR block prior to calling methods of this class.
  144974. */
  144975. /** @hidden */
  144976. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  144977. /**
  144978. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  144979. */
  144980. useAmbientOcclusionFromMetallicTextureRed: boolean;
  144981. /**
  144982. * Specifies if the metallic texture contains the metallness information in its blue channel.
  144983. */
  144984. useMetallnessFromMetallicTextureBlue: boolean;
  144985. /**
  144986. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  144987. */
  144988. useRoughnessFromMetallicTextureAlpha: boolean;
  144989. /**
  144990. * Specifies if the metallic texture contains the roughness information in its green channel.
  144991. */
  144992. useRoughnessFromMetallicTextureGreen: boolean;
  144993. /**
  144994. * Create a new ReflectivityBlock
  144995. * @param name defines the block name
  144996. */
  144997. constructor(name: string);
  144998. /**
  144999. * Initialize the block and prepare the context for build
  145000. * @param state defines the state that will be used for the build
  145001. */
  145002. initialize(state: NodeMaterialBuildState): void;
  145003. /**
  145004. * Gets the current class name
  145005. * @returns the class name
  145006. */
  145007. getClassName(): string;
  145008. /**
  145009. * Gets the metallic input component
  145010. */
  145011. get metallic(): NodeMaterialConnectionPoint;
  145012. /**
  145013. * Gets the roughness input component
  145014. */
  145015. get roughness(): NodeMaterialConnectionPoint;
  145016. /**
  145017. * Gets the texture input component
  145018. */
  145019. get texture(): NodeMaterialConnectionPoint;
  145020. /**
  145021. * Gets the reflectivity object output component
  145022. */
  145023. get reflectivity(): NodeMaterialConnectionPoint;
  145024. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145025. /**
  145026. * Gets the main code of the block (fragment side)
  145027. * @param state current state of the node material building
  145028. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  145029. * @returns the shader code
  145030. */
  145031. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  145032. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145033. protected _buildBlock(state: NodeMaterialBuildState): this;
  145034. protected _dumpPropertiesCode(): string;
  145035. serialize(): any;
  145036. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145037. }
  145038. }
  145039. declare module BABYLON {
  145040. /**
  145041. * Block used to implement the anisotropy module of the PBR material
  145042. */
  145043. export class AnisotropyBlock extends NodeMaterialBlock {
  145044. /**
  145045. * The two properties below are set by the main PBR block prior to calling methods of this class.
  145046. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145047. * It's less burden on the user side in the editor part.
  145048. */
  145049. /** @hidden */
  145050. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145051. /** @hidden */
  145052. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145053. /**
  145054. * Create a new AnisotropyBlock
  145055. * @param name defines the block name
  145056. */
  145057. constructor(name: string);
  145058. /**
  145059. * Initialize the block and prepare the context for build
  145060. * @param state defines the state that will be used for the build
  145061. */
  145062. initialize(state: NodeMaterialBuildState): void;
  145063. /**
  145064. * Gets the current class name
  145065. * @returns the class name
  145066. */
  145067. getClassName(): string;
  145068. /**
  145069. * Gets the intensity input component
  145070. */
  145071. get intensity(): NodeMaterialConnectionPoint;
  145072. /**
  145073. * Gets the direction input component
  145074. */
  145075. get direction(): NodeMaterialConnectionPoint;
  145076. /**
  145077. * Gets the texture input component
  145078. */
  145079. get texture(): NodeMaterialConnectionPoint;
  145080. /**
  145081. * Gets the uv input component
  145082. */
  145083. get uv(): NodeMaterialConnectionPoint;
  145084. /**
  145085. * Gets the worldTangent input component
  145086. */
  145087. get worldTangent(): NodeMaterialConnectionPoint;
  145088. /**
  145089. * Gets the anisotropy object output component
  145090. */
  145091. get anisotropy(): NodeMaterialConnectionPoint;
  145092. private _generateTBNSpace;
  145093. /**
  145094. * Gets the main code of the block (fragment side)
  145095. * @param state current state of the node material building
  145096. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145097. * @returns the shader code
  145098. */
  145099. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  145100. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145101. protected _buildBlock(state: NodeMaterialBuildState): this;
  145102. }
  145103. }
  145104. declare module BABYLON {
  145105. /**
  145106. * Block used to implement the clear coat module of the PBR material
  145107. */
  145108. export class ClearCoatBlock extends NodeMaterialBlock {
  145109. private _scene;
  145110. /**
  145111. * Create a new ClearCoatBlock
  145112. * @param name defines the block name
  145113. */
  145114. constructor(name: string);
  145115. /**
  145116. * Initialize the block and prepare the context for build
  145117. * @param state defines the state that will be used for the build
  145118. */
  145119. initialize(state: NodeMaterialBuildState): void;
  145120. /**
  145121. * Gets the current class name
  145122. * @returns the class name
  145123. */
  145124. getClassName(): string;
  145125. /**
  145126. * Gets the intensity input component
  145127. */
  145128. get intensity(): NodeMaterialConnectionPoint;
  145129. /**
  145130. * Gets the roughness input component
  145131. */
  145132. get roughness(): NodeMaterialConnectionPoint;
  145133. /**
  145134. * Gets the ior input component
  145135. */
  145136. get ior(): NodeMaterialConnectionPoint;
  145137. /**
  145138. * Gets the texture input component
  145139. */
  145140. get texture(): NodeMaterialConnectionPoint;
  145141. /**
  145142. * Gets the bump texture input component
  145143. */
  145144. get bumpTexture(): NodeMaterialConnectionPoint;
  145145. /**
  145146. * Gets the uv input component
  145147. */
  145148. get uv(): NodeMaterialConnectionPoint;
  145149. /**
  145150. * Gets the tint color input component
  145151. */
  145152. get tintColor(): NodeMaterialConnectionPoint;
  145153. /**
  145154. * Gets the tint "at distance" input component
  145155. */
  145156. get tintAtDistance(): NodeMaterialConnectionPoint;
  145157. /**
  145158. * Gets the tint thickness input component
  145159. */
  145160. get tintThickness(): NodeMaterialConnectionPoint;
  145161. /**
  145162. * Gets the world tangent input component
  145163. */
  145164. get worldTangent(): NodeMaterialConnectionPoint;
  145165. /**
  145166. * Gets the clear coat object output component
  145167. */
  145168. get clearcoat(): NodeMaterialConnectionPoint;
  145169. autoConfigure(material: NodeMaterial): void;
  145170. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145171. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145172. private _generateTBNSpace;
  145173. /**
  145174. * Gets the main code of the block (fragment side)
  145175. * @param state current state of the node material building
  145176. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  145177. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145178. * @param worldPosVarName name of the variable holding the world position
  145179. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145180. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  145181. * @param worldNormalVarName name of the variable holding the world normal
  145182. * @returns the shader code
  145183. */
  145184. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  145185. protected _buildBlock(state: NodeMaterialBuildState): this;
  145186. }
  145187. }
  145188. declare module BABYLON {
  145189. /**
  145190. * Block used to implement the sub surface module of the PBR material
  145191. */
  145192. export class SubSurfaceBlock extends NodeMaterialBlock {
  145193. /**
  145194. * Create a new SubSurfaceBlock
  145195. * @param name defines the block name
  145196. */
  145197. constructor(name: string);
  145198. /**
  145199. * Stores the intensity of the different subsurface effects in the thickness texture.
  145200. * * the green channel is the translucency intensity.
  145201. * * the blue channel is the scattering intensity.
  145202. * * the alpha channel is the refraction intensity.
  145203. */
  145204. useMaskFromThicknessTexture: boolean;
  145205. /**
  145206. * Initialize the block and prepare the context for build
  145207. * @param state defines the state that will be used for the build
  145208. */
  145209. initialize(state: NodeMaterialBuildState): void;
  145210. /**
  145211. * Gets the current class name
  145212. * @returns the class name
  145213. */
  145214. getClassName(): string;
  145215. /**
  145216. * Gets the min thickness input component
  145217. */
  145218. get minThickness(): NodeMaterialConnectionPoint;
  145219. /**
  145220. * Gets the max thickness input component
  145221. */
  145222. get maxThickness(): NodeMaterialConnectionPoint;
  145223. /**
  145224. * Gets the thickness texture component
  145225. */
  145226. get thicknessTexture(): NodeMaterialConnectionPoint;
  145227. /**
  145228. * Gets the tint color input component
  145229. */
  145230. get tintColor(): NodeMaterialConnectionPoint;
  145231. /**
  145232. * Gets the translucency intensity input component
  145233. */
  145234. get translucencyIntensity(): NodeMaterialConnectionPoint;
  145235. /**
  145236. * Gets the translucency diffusion distance input component
  145237. */
  145238. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  145239. /**
  145240. * Gets the refraction object parameters
  145241. */
  145242. get refraction(): NodeMaterialConnectionPoint;
  145243. /**
  145244. * Gets the sub surface object output component
  145245. */
  145246. get subsurface(): NodeMaterialConnectionPoint;
  145247. autoConfigure(material: NodeMaterial): void;
  145248. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145249. /**
  145250. * Gets the main code of the block (fragment side)
  145251. * @param state current state of the node material building
  145252. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  145253. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145254. * @param worldPosVarName name of the variable holding the world position
  145255. * @returns the shader code
  145256. */
  145257. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  145258. protected _buildBlock(state: NodeMaterialBuildState): this;
  145259. }
  145260. }
  145261. declare module BABYLON {
  145262. /**
  145263. * Block used to implement the PBR metallic/roughness model
  145264. */
  145265. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  145266. /**
  145267. * Gets or sets the light associated with this block
  145268. */
  145269. light: Nullable<Light>;
  145270. private _lightId;
  145271. private _scene;
  145272. private _environmentBRDFTexture;
  145273. private _environmentBrdfSamplerName;
  145274. private _vNormalWName;
  145275. private _invertNormalName;
  145276. /**
  145277. * Create a new ReflectionBlock
  145278. * @param name defines the block name
  145279. */
  145280. constructor(name: string);
  145281. /**
  145282. * Intensity of the direct lights e.g. the four lights available in your scene.
  145283. * This impacts both the direct diffuse and specular highlights.
  145284. */
  145285. directIntensity: number;
  145286. /**
  145287. * Intensity of the environment e.g. how much the environment will light the object
  145288. * either through harmonics for rough material or through the refelction for shiny ones.
  145289. */
  145290. environmentIntensity: number;
  145291. /**
  145292. * This is a special control allowing the reduction of the specular highlights coming from the
  145293. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  145294. */
  145295. specularIntensity: number;
  145296. /**
  145297. * Defines the falloff type used in this material.
  145298. * It by default is Physical.
  145299. */
  145300. lightFalloff: number;
  145301. /**
  145302. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  145303. */
  145304. useAlphaFromAlbedoTexture: boolean;
  145305. /**
  145306. * Specifies that alpha test should be used
  145307. */
  145308. useAlphaTest: boolean;
  145309. /**
  145310. * Defines the alpha limits in alpha test mode.
  145311. */
  145312. alphaTestCutoff: number;
  145313. /**
  145314. * Specifies that alpha blending should be used
  145315. */
  145316. useAlphaBlending: boolean;
  145317. /**
  145318. * Defines if the alpha value should be determined via the rgb values.
  145319. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  145320. */
  145321. opacityRGB: boolean;
  145322. /**
  145323. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  145324. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  145325. */
  145326. useRadianceOverAlpha: boolean;
  145327. /**
  145328. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  145329. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  145330. */
  145331. useSpecularOverAlpha: boolean;
  145332. /**
  145333. * Enables specular anti aliasing in the PBR shader.
  145334. * It will both interacts on the Geometry for analytical and IBL lighting.
  145335. * It also prefilter the roughness map based on the bump values.
  145336. */
  145337. enableSpecularAntiAliasing: boolean;
  145338. /**
  145339. * Enables realtime filtering on the texture.
  145340. */
  145341. realTimeFiltering: boolean;
  145342. /**
  145343. * Quality switch for realtime filtering
  145344. */
  145345. realTimeFilteringQuality: number;
  145346. /**
  145347. * Defines if the material uses energy conservation.
  145348. */
  145349. useEnergyConservation: boolean;
  145350. /**
  145351. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  145352. * too much the area relying on ambient texture to define their ambient occlusion.
  145353. */
  145354. useRadianceOcclusion: boolean;
  145355. /**
  145356. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  145357. * makes the reflect vector face the model (under horizon).
  145358. */
  145359. useHorizonOcclusion: boolean;
  145360. /**
  145361. * If set to true, no lighting calculations will be applied.
  145362. */
  145363. unlit: boolean;
  145364. /**
  145365. * Force normal to face away from face.
  145366. */
  145367. forceNormalForward: boolean;
  145368. /**
  145369. * Defines the material debug mode.
  145370. * It helps seeing only some components of the material while troubleshooting.
  145371. */
  145372. debugMode: number;
  145373. /**
  145374. * Specify from where on screen the debug mode should start.
  145375. * The value goes from -1 (full screen) to 1 (not visible)
  145376. * It helps with side by side comparison against the final render
  145377. * This defaults to 0
  145378. */
  145379. debugLimit: number;
  145380. /**
  145381. * As the default viewing range might not be enough (if the ambient is really small for instance)
  145382. * You can use the factor to better multiply the final value.
  145383. */
  145384. debugFactor: number;
  145385. /**
  145386. * Initialize the block and prepare the context for build
  145387. * @param state defines the state that will be used for the build
  145388. */
  145389. initialize(state: NodeMaterialBuildState): void;
  145390. /**
  145391. * Gets the current class name
  145392. * @returns the class name
  145393. */
  145394. getClassName(): string;
  145395. /**
  145396. * Gets the world position input component
  145397. */
  145398. get worldPosition(): NodeMaterialConnectionPoint;
  145399. /**
  145400. * Gets the world normal input component
  145401. */
  145402. get worldNormal(): NodeMaterialConnectionPoint;
  145403. /**
  145404. * Gets the perturbed normal input component
  145405. */
  145406. get perturbedNormal(): NodeMaterialConnectionPoint;
  145407. /**
  145408. * Gets the camera position input component
  145409. */
  145410. get cameraPosition(): NodeMaterialConnectionPoint;
  145411. /**
  145412. * Gets the base color input component
  145413. */
  145414. get baseColor(): NodeMaterialConnectionPoint;
  145415. /**
  145416. * Gets the opacity texture input component
  145417. */
  145418. get opacityTexture(): NodeMaterialConnectionPoint;
  145419. /**
  145420. * Gets the ambient color input component
  145421. */
  145422. get ambientColor(): NodeMaterialConnectionPoint;
  145423. /**
  145424. * Gets the reflectivity object parameters
  145425. */
  145426. get reflectivity(): NodeMaterialConnectionPoint;
  145427. /**
  145428. * Gets the ambient occlusion object parameters
  145429. */
  145430. get ambientOcc(): NodeMaterialConnectionPoint;
  145431. /**
  145432. * Gets the reflection object parameters
  145433. */
  145434. get reflection(): NodeMaterialConnectionPoint;
  145435. /**
  145436. * Gets the sheen object parameters
  145437. */
  145438. get sheen(): NodeMaterialConnectionPoint;
  145439. /**
  145440. * Gets the clear coat object parameters
  145441. */
  145442. get clearcoat(): NodeMaterialConnectionPoint;
  145443. /**
  145444. * Gets the sub surface object parameters
  145445. */
  145446. get subsurface(): NodeMaterialConnectionPoint;
  145447. /**
  145448. * Gets the anisotropy object parameters
  145449. */
  145450. get anisotropy(): NodeMaterialConnectionPoint;
  145451. /**
  145452. * Gets the ambient output component
  145453. */
  145454. get ambient(): NodeMaterialConnectionPoint;
  145455. /**
  145456. * Gets the diffuse output component
  145457. */
  145458. get diffuse(): NodeMaterialConnectionPoint;
  145459. /**
  145460. * Gets the specular output component
  145461. */
  145462. get specular(): NodeMaterialConnectionPoint;
  145463. /**
  145464. * Gets the sheen output component
  145465. */
  145466. get sheenDir(): NodeMaterialConnectionPoint;
  145467. /**
  145468. * Gets the clear coat output component
  145469. */
  145470. get clearcoatDir(): NodeMaterialConnectionPoint;
  145471. /**
  145472. * Gets the indirect diffuse output component
  145473. */
  145474. get diffuseIndirect(): NodeMaterialConnectionPoint;
  145475. /**
  145476. * Gets the indirect specular output component
  145477. */
  145478. get specularIndirect(): NodeMaterialConnectionPoint;
  145479. /**
  145480. * Gets the indirect sheen output component
  145481. */
  145482. get sheenIndirect(): NodeMaterialConnectionPoint;
  145483. /**
  145484. * Gets the indirect clear coat output component
  145485. */
  145486. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  145487. /**
  145488. * Gets the refraction output component
  145489. */
  145490. get refraction(): NodeMaterialConnectionPoint;
  145491. /**
  145492. * Gets the global lighting output component
  145493. */
  145494. get lighting(): NodeMaterialConnectionPoint;
  145495. /**
  145496. * Gets the shadow output component
  145497. */
  145498. get shadow(): NodeMaterialConnectionPoint;
  145499. /**
  145500. * Gets the alpha output component
  145501. */
  145502. get alpha(): NodeMaterialConnectionPoint;
  145503. autoConfigure(material: NodeMaterial): void;
  145504. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145505. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  145506. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145507. private _injectVertexCode;
  145508. /**
  145509. * Gets the code corresponding to the albedo/opacity module
  145510. * @returns the shader code
  145511. */
  145512. getAlbedoOpacityCode(): string;
  145513. protected _buildBlock(state: NodeMaterialBuildState): this;
  145514. protected _dumpPropertiesCode(): string;
  145515. serialize(): any;
  145516. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145517. }
  145518. }
  145519. declare module BABYLON {
  145520. /**
  145521. * Block used to compute value of one parameter modulo another
  145522. */
  145523. export class ModBlock extends NodeMaterialBlock {
  145524. /**
  145525. * Creates a new ModBlock
  145526. * @param name defines the block name
  145527. */
  145528. constructor(name: string);
  145529. /**
  145530. * Gets the current class name
  145531. * @returns the class name
  145532. */
  145533. getClassName(): string;
  145534. /**
  145535. * Gets the left operand input component
  145536. */
  145537. get left(): NodeMaterialConnectionPoint;
  145538. /**
  145539. * Gets the right operand input component
  145540. */
  145541. get right(): NodeMaterialConnectionPoint;
  145542. /**
  145543. * Gets the output component
  145544. */
  145545. get output(): NodeMaterialConnectionPoint;
  145546. protected _buildBlock(state: NodeMaterialBuildState): this;
  145547. }
  145548. }
  145549. declare module BABYLON {
  145550. /**
  145551. * Configuration for Draco compression
  145552. */
  145553. export interface IDracoCompressionConfiguration {
  145554. /**
  145555. * Configuration for the decoder.
  145556. */
  145557. decoder: {
  145558. /**
  145559. * The url to the WebAssembly module.
  145560. */
  145561. wasmUrl?: string;
  145562. /**
  145563. * The url to the WebAssembly binary.
  145564. */
  145565. wasmBinaryUrl?: string;
  145566. /**
  145567. * The url to the fallback JavaScript module.
  145568. */
  145569. fallbackUrl?: string;
  145570. };
  145571. }
  145572. /**
  145573. * Draco compression (https://google.github.io/draco/)
  145574. *
  145575. * This class wraps the Draco module.
  145576. *
  145577. * **Encoder**
  145578. *
  145579. * The encoder is not currently implemented.
  145580. *
  145581. * **Decoder**
  145582. *
  145583. * 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.
  145584. *
  145585. * To update the configuration, use the following code:
  145586. * ```javascript
  145587. * DracoCompression.Configuration = {
  145588. * decoder: {
  145589. * wasmUrl: "<url to the WebAssembly library>",
  145590. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  145591. * fallbackUrl: "<url to the fallback JavaScript library>",
  145592. * }
  145593. * };
  145594. * ```
  145595. *
  145596. * 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.
  145597. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  145598. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  145599. *
  145600. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  145601. * ```javascript
  145602. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  145603. * ```
  145604. *
  145605. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  145606. */
  145607. export class DracoCompression implements IDisposable {
  145608. private _workerPoolPromise?;
  145609. private _decoderModulePromise?;
  145610. /**
  145611. * The configuration. Defaults to the following urls:
  145612. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  145613. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  145614. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  145615. */
  145616. static Configuration: IDracoCompressionConfiguration;
  145617. /**
  145618. * Returns true if the decoder configuration is available.
  145619. */
  145620. static get DecoderAvailable(): boolean;
  145621. /**
  145622. * Default number of workers to create when creating the draco compression object.
  145623. */
  145624. static DefaultNumWorkers: number;
  145625. private static GetDefaultNumWorkers;
  145626. private static _Default;
  145627. /**
  145628. * Default instance for the draco compression object.
  145629. */
  145630. static get Default(): DracoCompression;
  145631. /**
  145632. * Constructor
  145633. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  145634. */
  145635. constructor(numWorkers?: number);
  145636. /**
  145637. * Stop all async operations and release resources.
  145638. */
  145639. dispose(): void;
  145640. /**
  145641. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  145642. * @returns a promise that resolves when ready
  145643. */
  145644. whenReadyAsync(): Promise<void>;
  145645. /**
  145646. * Decode Draco compressed mesh data to vertex data.
  145647. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  145648. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  145649. * @returns A promise that resolves with the decoded vertex data
  145650. */
  145651. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  145652. [kind: string]: number;
  145653. }): Promise<VertexData>;
  145654. }
  145655. }
  145656. declare module BABYLON {
  145657. /**
  145658. * Class for building Constructive Solid Geometry
  145659. */
  145660. export class CSG {
  145661. private polygons;
  145662. /**
  145663. * The world matrix
  145664. */
  145665. matrix: Matrix;
  145666. /**
  145667. * Stores the position
  145668. */
  145669. position: Vector3;
  145670. /**
  145671. * Stores the rotation
  145672. */
  145673. rotation: Vector3;
  145674. /**
  145675. * Stores the rotation quaternion
  145676. */
  145677. rotationQuaternion: Nullable<Quaternion>;
  145678. /**
  145679. * Stores the scaling vector
  145680. */
  145681. scaling: Vector3;
  145682. /**
  145683. * Convert the Mesh to CSG
  145684. * @param mesh The Mesh to convert to CSG
  145685. * @returns A new CSG from the Mesh
  145686. */
  145687. static FromMesh(mesh: Mesh): CSG;
  145688. /**
  145689. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  145690. * @param polygons Polygons used to construct a CSG solid
  145691. */
  145692. private static FromPolygons;
  145693. /**
  145694. * Clones, or makes a deep copy, of the CSG
  145695. * @returns A new CSG
  145696. */
  145697. clone(): CSG;
  145698. /**
  145699. * Unions this CSG with another CSG
  145700. * @param csg The CSG to union against this CSG
  145701. * @returns The unioned CSG
  145702. */
  145703. union(csg: CSG): CSG;
  145704. /**
  145705. * Unions this CSG with another CSG in place
  145706. * @param csg The CSG to union against this CSG
  145707. */
  145708. unionInPlace(csg: CSG): void;
  145709. /**
  145710. * Subtracts this CSG with another CSG
  145711. * @param csg The CSG to subtract against this CSG
  145712. * @returns A new CSG
  145713. */
  145714. subtract(csg: CSG): CSG;
  145715. /**
  145716. * Subtracts this CSG with another CSG in place
  145717. * @param csg The CSG to subtact against this CSG
  145718. */
  145719. subtractInPlace(csg: CSG): void;
  145720. /**
  145721. * Intersect this CSG with another CSG
  145722. * @param csg The CSG to intersect against this CSG
  145723. * @returns A new CSG
  145724. */
  145725. intersect(csg: CSG): CSG;
  145726. /**
  145727. * Intersects this CSG with another CSG in place
  145728. * @param csg The CSG to intersect against this CSG
  145729. */
  145730. intersectInPlace(csg: CSG): void;
  145731. /**
  145732. * Return a new CSG solid with solid and empty space switched. This solid is
  145733. * not modified.
  145734. * @returns A new CSG solid with solid and empty space switched
  145735. */
  145736. inverse(): CSG;
  145737. /**
  145738. * Inverses the CSG in place
  145739. */
  145740. inverseInPlace(): void;
  145741. /**
  145742. * This is used to keep meshes transformations so they can be restored
  145743. * when we build back a Babylon Mesh
  145744. * NB : All CSG operations are performed in world coordinates
  145745. * @param csg The CSG to copy the transform attributes from
  145746. * @returns This CSG
  145747. */
  145748. copyTransformAttributes(csg: CSG): CSG;
  145749. /**
  145750. * Build Raw mesh from CSG
  145751. * Coordinates here are in world space
  145752. * @param name The name of the mesh geometry
  145753. * @param scene The Scene
  145754. * @param keepSubMeshes Specifies if the submeshes should be kept
  145755. * @returns A new Mesh
  145756. */
  145757. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145758. /**
  145759. * Build Mesh from CSG taking material and transforms into account
  145760. * @param name The name of the Mesh
  145761. * @param material The material of the Mesh
  145762. * @param scene The Scene
  145763. * @param keepSubMeshes Specifies if submeshes should be kept
  145764. * @returns The new Mesh
  145765. */
  145766. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145767. }
  145768. }
  145769. declare module BABYLON {
  145770. /**
  145771. * Class used to create a trail following a mesh
  145772. */
  145773. export class TrailMesh extends Mesh {
  145774. private _generator;
  145775. private _autoStart;
  145776. private _running;
  145777. private _diameter;
  145778. private _length;
  145779. private _sectionPolygonPointsCount;
  145780. private _sectionVectors;
  145781. private _sectionNormalVectors;
  145782. private _beforeRenderObserver;
  145783. /**
  145784. * @constructor
  145785. * @param name The value used by scene.getMeshByName() to do a lookup.
  145786. * @param generator The mesh or transform node to generate a trail.
  145787. * @param scene The scene to add this mesh to.
  145788. * @param diameter Diameter of trailing mesh. Default is 1.
  145789. * @param length Length of trailing mesh. Default is 60.
  145790. * @param autoStart Automatically start trailing mesh. Default true.
  145791. */
  145792. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  145793. /**
  145794. * "TrailMesh"
  145795. * @returns "TrailMesh"
  145796. */
  145797. getClassName(): string;
  145798. private _createMesh;
  145799. /**
  145800. * Start trailing mesh.
  145801. */
  145802. start(): void;
  145803. /**
  145804. * Stop trailing mesh.
  145805. */
  145806. stop(): void;
  145807. /**
  145808. * Update trailing mesh geometry.
  145809. */
  145810. update(): void;
  145811. /**
  145812. * Returns a new TrailMesh object.
  145813. * @param name is a string, the name given to the new mesh
  145814. * @param newGenerator use new generator object for cloned trail mesh
  145815. * @returns a new mesh
  145816. */
  145817. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  145818. /**
  145819. * Serializes this trail mesh
  145820. * @param serializationObject object to write serialization to
  145821. */
  145822. serialize(serializationObject: any): void;
  145823. /**
  145824. * Parses a serialized trail mesh
  145825. * @param parsedMesh the serialized mesh
  145826. * @param scene the scene to create the trail mesh in
  145827. * @returns the created trail mesh
  145828. */
  145829. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  145830. }
  145831. }
  145832. declare module BABYLON {
  145833. /**
  145834. * Class containing static functions to help procedurally build meshes
  145835. */
  145836. export class TiledBoxBuilder {
  145837. /**
  145838. * Creates a box mesh
  145839. * 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)
  145840. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145844. * @param name defines the name of the mesh
  145845. * @param options defines the options used to create the mesh
  145846. * @param scene defines the hosting scene
  145847. * @returns the box mesh
  145848. */
  145849. static CreateTiledBox(name: string, options: {
  145850. pattern?: number;
  145851. width?: number;
  145852. height?: number;
  145853. depth?: number;
  145854. tileSize?: number;
  145855. tileWidth?: number;
  145856. tileHeight?: number;
  145857. alignHorizontal?: number;
  145858. alignVertical?: number;
  145859. faceUV?: Vector4[];
  145860. faceColors?: Color4[];
  145861. sideOrientation?: number;
  145862. updatable?: boolean;
  145863. }, scene?: Nullable<Scene>): Mesh;
  145864. }
  145865. }
  145866. declare module BABYLON {
  145867. /**
  145868. * Class containing static functions to help procedurally build meshes
  145869. */
  145870. export class TorusKnotBuilder {
  145871. /**
  145872. * Creates a torus knot mesh
  145873. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145874. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145875. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145876. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145878. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145880. * @param name defines the name of the mesh
  145881. * @param options defines the options used to create the mesh
  145882. * @param scene defines the hosting scene
  145883. * @returns the torus knot mesh
  145884. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145885. */
  145886. static CreateTorusKnot(name: string, options: {
  145887. radius?: number;
  145888. tube?: number;
  145889. radialSegments?: number;
  145890. tubularSegments?: number;
  145891. p?: number;
  145892. q?: number;
  145893. updatable?: boolean;
  145894. sideOrientation?: number;
  145895. frontUVs?: Vector4;
  145896. backUVs?: Vector4;
  145897. }, scene: any): Mesh;
  145898. }
  145899. }
  145900. declare module BABYLON {
  145901. /**
  145902. * Polygon
  145903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  145904. */
  145905. export class Polygon {
  145906. /**
  145907. * Creates a rectangle
  145908. * @param xmin bottom X coord
  145909. * @param ymin bottom Y coord
  145910. * @param xmax top X coord
  145911. * @param ymax top Y coord
  145912. * @returns points that make the resulting rectation
  145913. */
  145914. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  145915. /**
  145916. * Creates a circle
  145917. * @param radius radius of circle
  145918. * @param cx scale in x
  145919. * @param cy scale in y
  145920. * @param numberOfSides number of sides that make up the circle
  145921. * @returns points that make the resulting circle
  145922. */
  145923. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  145924. /**
  145925. * Creates a polygon from input string
  145926. * @param input Input polygon data
  145927. * @returns the parsed points
  145928. */
  145929. static Parse(input: string): Vector2[];
  145930. /**
  145931. * Starts building a polygon from x and y coordinates
  145932. * @param x x coordinate
  145933. * @param y y coordinate
  145934. * @returns the started path2
  145935. */
  145936. static StartingAt(x: number, y: number): Path2;
  145937. }
  145938. /**
  145939. * Builds a polygon
  145940. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  145941. */
  145942. export class PolygonMeshBuilder {
  145943. private _points;
  145944. private _outlinepoints;
  145945. private _holes;
  145946. private _name;
  145947. private _scene;
  145948. private _epoints;
  145949. private _eholes;
  145950. private _addToepoint;
  145951. /**
  145952. * Babylon reference to the earcut plugin.
  145953. */
  145954. bjsEarcut: any;
  145955. /**
  145956. * Creates a PolygonMeshBuilder
  145957. * @param name name of the builder
  145958. * @param contours Path of the polygon
  145959. * @param scene scene to add to when creating the mesh
  145960. * @param earcutInjection can be used to inject your own earcut reference
  145961. */
  145962. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  145963. /**
  145964. * Adds a whole within the polygon
  145965. * @param hole Array of points defining the hole
  145966. * @returns this
  145967. */
  145968. addHole(hole: Vector2[]): PolygonMeshBuilder;
  145969. /**
  145970. * Creates the polygon
  145971. * @param updatable If the mesh should be updatable
  145972. * @param depth The depth of the mesh created
  145973. * @returns the created mesh
  145974. */
  145975. build(updatable?: boolean, depth?: number): Mesh;
  145976. /**
  145977. * Creates the polygon
  145978. * @param depth The depth of the mesh created
  145979. * @returns the created VertexData
  145980. */
  145981. buildVertexData(depth?: number): VertexData;
  145982. /**
  145983. * Adds a side to the polygon
  145984. * @param positions points that make the polygon
  145985. * @param normals normals of the polygon
  145986. * @param uvs uvs of the polygon
  145987. * @param indices indices of the polygon
  145988. * @param bounds bounds of the polygon
  145989. * @param points points of the polygon
  145990. * @param depth depth of the polygon
  145991. * @param flip flip of the polygon
  145992. */
  145993. private addSide;
  145994. }
  145995. }
  145996. declare module BABYLON {
  145997. /**
  145998. * Class containing static functions to help procedurally build meshes
  145999. */
  146000. export class PolygonBuilder {
  146001. /**
  146002. * Creates a polygon mesh
  146003. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146004. * * 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
  146005. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146007. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146008. * * Remember you can only change the shape positions, not their number when updating a polygon
  146009. * @param name defines the name of the mesh
  146010. * @param options defines the options used to create the mesh
  146011. * @param scene defines the hosting scene
  146012. * @param earcutInjection can be used to inject your own earcut reference
  146013. * @returns the polygon mesh
  146014. */
  146015. static CreatePolygon(name: string, options: {
  146016. shape: Vector3[];
  146017. holes?: Vector3[][];
  146018. depth?: number;
  146019. faceUV?: Vector4[];
  146020. faceColors?: Color4[];
  146021. updatable?: boolean;
  146022. sideOrientation?: number;
  146023. frontUVs?: Vector4;
  146024. backUVs?: Vector4;
  146025. wrap?: boolean;
  146026. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146027. /**
  146028. * Creates an extruded polygon mesh, with depth in the Y direction.
  146029. * * 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)
  146030. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146031. * @param name defines the name of the mesh
  146032. * @param options defines the options used to create the mesh
  146033. * @param scene defines the hosting scene
  146034. * @param earcutInjection can be used to inject your own earcut reference
  146035. * @returns the polygon mesh
  146036. */
  146037. static ExtrudePolygon(name: string, options: {
  146038. shape: Vector3[];
  146039. holes?: Vector3[][];
  146040. depth?: number;
  146041. faceUV?: Vector4[];
  146042. faceColors?: Color4[];
  146043. updatable?: boolean;
  146044. sideOrientation?: number;
  146045. frontUVs?: Vector4;
  146046. backUVs?: Vector4;
  146047. wrap?: boolean;
  146048. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146049. }
  146050. }
  146051. declare module BABYLON {
  146052. /**
  146053. * Class containing static functions to help procedurally build meshes
  146054. */
  146055. export class LatheBuilder {
  146056. /**
  146057. * Creates lathe mesh.
  146058. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146059. * * 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
  146060. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146061. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146062. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146063. * * 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
  146064. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146065. * * 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
  146066. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146067. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146068. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146070. * @param name defines the name of the mesh
  146071. * @param options defines the options used to create the mesh
  146072. * @param scene defines the hosting scene
  146073. * @returns the lathe mesh
  146074. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146075. */
  146076. static CreateLathe(name: string, options: {
  146077. shape: Vector3[];
  146078. radius?: number;
  146079. tessellation?: number;
  146080. clip?: number;
  146081. arc?: number;
  146082. closed?: boolean;
  146083. updatable?: boolean;
  146084. sideOrientation?: number;
  146085. frontUVs?: Vector4;
  146086. backUVs?: Vector4;
  146087. cap?: number;
  146088. invertUV?: boolean;
  146089. }, scene?: Nullable<Scene>): Mesh;
  146090. }
  146091. }
  146092. declare module BABYLON {
  146093. /**
  146094. * Class containing static functions to help procedurally build meshes
  146095. */
  146096. export class TiledPlaneBuilder {
  146097. /**
  146098. * Creates a tiled plane mesh
  146099. * * The parameter `pattern` will, depending on value, do nothing or
  146100. * * * flip (reflect about central vertical) alternate tiles across and up
  146101. * * * flip every tile on alternate rows
  146102. * * * rotate (180 degs) alternate tiles across and up
  146103. * * * rotate every tile on alternate rows
  146104. * * * flip and rotate alternate tiles across and up
  146105. * * * flip and rotate every tile on alternate rows
  146106. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  146107. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  146108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146109. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146110. * * 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)
  146111. * * 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)
  146112. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146113. * @param name defines the name of the mesh
  146114. * @param options defines the options used to create the mesh
  146115. * @param scene defines the hosting scene
  146116. * @returns the box mesh
  146117. */
  146118. static CreateTiledPlane(name: string, options: {
  146119. pattern?: number;
  146120. tileSize?: number;
  146121. tileWidth?: number;
  146122. tileHeight?: number;
  146123. size?: number;
  146124. width?: number;
  146125. height?: number;
  146126. alignHorizontal?: number;
  146127. alignVertical?: number;
  146128. sideOrientation?: number;
  146129. frontUVs?: Vector4;
  146130. backUVs?: Vector4;
  146131. updatable?: boolean;
  146132. }, scene?: Nullable<Scene>): Mesh;
  146133. }
  146134. }
  146135. declare module BABYLON {
  146136. /**
  146137. * Class containing static functions to help procedurally build meshes
  146138. */
  146139. export class TubeBuilder {
  146140. /**
  146141. * Creates a tube mesh.
  146142. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146143. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146144. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146145. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146146. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146147. * * 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)
  146148. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146149. * * 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
  146150. * * 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
  146151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146152. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146153. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146155. * @param name defines the name of the mesh
  146156. * @param options defines the options used to create the mesh
  146157. * @param scene defines the hosting scene
  146158. * @returns the tube mesh
  146159. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146160. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146161. */
  146162. static CreateTube(name: string, options: {
  146163. path: Vector3[];
  146164. radius?: number;
  146165. tessellation?: number;
  146166. radiusFunction?: {
  146167. (i: number, distance: number): number;
  146168. };
  146169. cap?: number;
  146170. arc?: number;
  146171. updatable?: boolean;
  146172. sideOrientation?: number;
  146173. frontUVs?: Vector4;
  146174. backUVs?: Vector4;
  146175. instance?: Mesh;
  146176. invertUV?: boolean;
  146177. }, scene?: Nullable<Scene>): Mesh;
  146178. }
  146179. }
  146180. declare module BABYLON {
  146181. /**
  146182. * Class containing static functions to help procedurally build meshes
  146183. */
  146184. export class IcoSphereBuilder {
  146185. /**
  146186. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146187. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146188. * * 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`)
  146189. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146190. * * 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
  146191. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146192. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146194. * @param name defines the name of the mesh
  146195. * @param options defines the options used to create the mesh
  146196. * @param scene defines the hosting scene
  146197. * @returns the icosahedron mesh
  146198. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146199. */
  146200. static CreateIcoSphere(name: string, options: {
  146201. radius?: number;
  146202. radiusX?: number;
  146203. radiusY?: number;
  146204. radiusZ?: number;
  146205. flat?: boolean;
  146206. subdivisions?: number;
  146207. sideOrientation?: number;
  146208. frontUVs?: Vector4;
  146209. backUVs?: Vector4;
  146210. updatable?: boolean;
  146211. }, scene?: Nullable<Scene>): Mesh;
  146212. }
  146213. }
  146214. declare module BABYLON {
  146215. /**
  146216. * Class containing static functions to help procedurally build meshes
  146217. */
  146218. export class DecalBuilder {
  146219. /**
  146220. * Creates a decal mesh.
  146221. * 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
  146222. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146223. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146224. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146225. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146226. * @param name defines the name of the mesh
  146227. * @param sourceMesh defines the mesh where the decal must be applied
  146228. * @param options defines the options used to create the mesh
  146229. * @param scene defines the hosting scene
  146230. * @returns the decal mesh
  146231. * @see https://doc.babylonjs.com/how_to/decals
  146232. */
  146233. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146234. position?: Vector3;
  146235. normal?: Vector3;
  146236. size?: Vector3;
  146237. angle?: number;
  146238. }): Mesh;
  146239. }
  146240. }
  146241. declare module BABYLON {
  146242. /**
  146243. * Class containing static functions to help procedurally build meshes
  146244. */
  146245. export class MeshBuilder {
  146246. /**
  146247. * Creates a box mesh
  146248. * * The parameter `size` sets the size (float) of each box side (default 1)
  146249. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  146250. * * 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)
  146251. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146253. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146255. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146256. * @param name defines the name of the mesh
  146257. * @param options defines the options used to create the mesh
  146258. * @param scene defines the hosting scene
  146259. * @returns the box mesh
  146260. */
  146261. static CreateBox(name: string, options: {
  146262. size?: number;
  146263. width?: number;
  146264. height?: number;
  146265. depth?: number;
  146266. faceUV?: Vector4[];
  146267. faceColors?: Color4[];
  146268. sideOrientation?: number;
  146269. frontUVs?: Vector4;
  146270. backUVs?: Vector4;
  146271. wrap?: boolean;
  146272. topBaseAt?: number;
  146273. bottomBaseAt?: number;
  146274. updatable?: boolean;
  146275. }, scene?: Nullable<Scene>): Mesh;
  146276. /**
  146277. * Creates a tiled box mesh
  146278. * * faceTiles sets the pattern, tile size and number of tiles for a face
  146279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146280. * @param name defines the name of the mesh
  146281. * @param options defines the options used to create the mesh
  146282. * @param scene defines the hosting scene
  146283. * @returns the tiled box mesh
  146284. */
  146285. static CreateTiledBox(name: string, options: {
  146286. pattern?: number;
  146287. size?: number;
  146288. width?: number;
  146289. height?: number;
  146290. depth: number;
  146291. tileSize?: number;
  146292. tileWidth?: number;
  146293. tileHeight?: number;
  146294. faceUV?: Vector4[];
  146295. faceColors?: Color4[];
  146296. alignHorizontal?: number;
  146297. alignVertical?: number;
  146298. sideOrientation?: number;
  146299. updatable?: boolean;
  146300. }, scene?: Nullable<Scene>): Mesh;
  146301. /**
  146302. * Creates a sphere mesh
  146303. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  146304. * * 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`)
  146305. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  146306. * * 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
  146307. * * 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)
  146308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146309. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146311. * @param name defines the name of the mesh
  146312. * @param options defines the options used to create the mesh
  146313. * @param scene defines the hosting scene
  146314. * @returns the sphere mesh
  146315. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  146316. */
  146317. static CreateSphere(name: string, options: {
  146318. segments?: number;
  146319. diameter?: number;
  146320. diameterX?: number;
  146321. diameterY?: number;
  146322. diameterZ?: number;
  146323. arc?: number;
  146324. slice?: number;
  146325. sideOrientation?: number;
  146326. frontUVs?: Vector4;
  146327. backUVs?: Vector4;
  146328. updatable?: boolean;
  146329. }, scene?: Nullable<Scene>): Mesh;
  146330. /**
  146331. * Creates a plane polygonal mesh. By default, this is a disc
  146332. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  146333. * * 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
  146334. * * 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
  146335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146336. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146338. * @param name defines the name of the mesh
  146339. * @param options defines the options used to create the mesh
  146340. * @param scene defines the hosting scene
  146341. * @returns the plane polygonal mesh
  146342. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  146343. */
  146344. static CreateDisc(name: string, options: {
  146345. radius?: number;
  146346. tessellation?: number;
  146347. arc?: number;
  146348. updatable?: boolean;
  146349. sideOrientation?: number;
  146350. frontUVs?: Vector4;
  146351. backUVs?: Vector4;
  146352. }, scene?: Nullable<Scene>): Mesh;
  146353. /**
  146354. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146355. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146356. * * 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`)
  146357. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146358. * * 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
  146359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146360. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146362. * @param name defines the name of the mesh
  146363. * @param options defines the options used to create the mesh
  146364. * @param scene defines the hosting scene
  146365. * @returns the icosahedron mesh
  146366. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146367. */
  146368. static CreateIcoSphere(name: string, options: {
  146369. radius?: number;
  146370. radiusX?: number;
  146371. radiusY?: number;
  146372. radiusZ?: number;
  146373. flat?: boolean;
  146374. subdivisions?: number;
  146375. sideOrientation?: number;
  146376. frontUVs?: Vector4;
  146377. backUVs?: Vector4;
  146378. updatable?: boolean;
  146379. }, scene?: Nullable<Scene>): Mesh;
  146380. /**
  146381. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146382. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  146383. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  146384. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  146385. * * 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
  146386. * * 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
  146387. * * 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
  146388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146390. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146391. * * 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
  146392. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  146393. * * 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
  146394. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  146395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146396. * @param name defines the name of the mesh
  146397. * @param options defines the options used to create the mesh
  146398. * @param scene defines the hosting scene
  146399. * @returns the ribbon mesh
  146400. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  146401. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146402. */
  146403. static CreateRibbon(name: string, options: {
  146404. pathArray: Vector3[][];
  146405. closeArray?: boolean;
  146406. closePath?: boolean;
  146407. offset?: number;
  146408. updatable?: boolean;
  146409. sideOrientation?: number;
  146410. frontUVs?: Vector4;
  146411. backUVs?: Vector4;
  146412. instance?: Mesh;
  146413. invertUV?: boolean;
  146414. uvs?: Vector2[];
  146415. colors?: Color4[];
  146416. }, scene?: Nullable<Scene>): Mesh;
  146417. /**
  146418. * Creates a cylinder or a cone mesh
  146419. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  146420. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  146421. * * 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.
  146422. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  146423. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  146424. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  146425. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  146426. * * 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).
  146427. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  146428. * * 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).
  146429. * * 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
  146430. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  146431. * * 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
  146432. * * 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.
  146433. * * If `enclose` is false, a ring surface is one element.
  146434. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  146435. * * 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
  146436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146439. * @param name defines the name of the mesh
  146440. * @param options defines the options used to create the mesh
  146441. * @param scene defines the hosting scene
  146442. * @returns the cylinder mesh
  146443. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  146444. */
  146445. static CreateCylinder(name: string, options: {
  146446. height?: number;
  146447. diameterTop?: number;
  146448. diameterBottom?: number;
  146449. diameter?: number;
  146450. tessellation?: number;
  146451. subdivisions?: number;
  146452. arc?: number;
  146453. faceColors?: Color4[];
  146454. faceUV?: Vector4[];
  146455. updatable?: boolean;
  146456. hasRings?: boolean;
  146457. enclose?: boolean;
  146458. cap?: number;
  146459. sideOrientation?: number;
  146460. frontUVs?: Vector4;
  146461. backUVs?: Vector4;
  146462. }, scene?: Nullable<Scene>): Mesh;
  146463. /**
  146464. * Creates a torus mesh
  146465. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  146466. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  146467. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  146468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146469. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146471. * @param name defines the name of the mesh
  146472. * @param options defines the options used to create the mesh
  146473. * @param scene defines the hosting scene
  146474. * @returns the torus mesh
  146475. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  146476. */
  146477. static CreateTorus(name: string, options: {
  146478. diameter?: number;
  146479. thickness?: number;
  146480. tessellation?: number;
  146481. updatable?: boolean;
  146482. sideOrientation?: number;
  146483. frontUVs?: Vector4;
  146484. backUVs?: Vector4;
  146485. }, scene?: Nullable<Scene>): Mesh;
  146486. /**
  146487. * Creates a torus knot mesh
  146488. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146489. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146490. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146491. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146493. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146495. * @param name defines the name of the mesh
  146496. * @param options defines the options used to create the mesh
  146497. * @param scene defines the hosting scene
  146498. * @returns the torus knot mesh
  146499. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146500. */
  146501. static CreateTorusKnot(name: string, options: {
  146502. radius?: number;
  146503. tube?: number;
  146504. radialSegments?: number;
  146505. tubularSegments?: number;
  146506. p?: number;
  146507. q?: number;
  146508. updatable?: boolean;
  146509. sideOrientation?: number;
  146510. frontUVs?: Vector4;
  146511. backUVs?: Vector4;
  146512. }, scene?: Nullable<Scene>): Mesh;
  146513. /**
  146514. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  146515. * * 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
  146516. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  146517. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  146518. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  146519. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  146520. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  146521. * * 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
  146522. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  146523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146524. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  146525. * @param name defines the name of the new line system
  146526. * @param options defines the options used to create the line system
  146527. * @param scene defines the hosting scene
  146528. * @returns a new line system mesh
  146529. */
  146530. static CreateLineSystem(name: string, options: {
  146531. lines: Vector3[][];
  146532. updatable?: boolean;
  146533. instance?: Nullable<LinesMesh>;
  146534. colors?: Nullable<Color4[][]>;
  146535. useVertexAlpha?: boolean;
  146536. }, scene: Nullable<Scene>): LinesMesh;
  146537. /**
  146538. * Creates a line mesh
  146539. * 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
  146540. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146541. * * The parameter `points` is an array successive Vector3
  146542. * * 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
  146543. * * The optional parameter `colors` is an array of successive Color4, one per line point
  146544. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  146545. * * When updating an instance, remember that only point positions can change, not the number of points
  146546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146547. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  146548. * @param name defines the name of the new line system
  146549. * @param options defines the options used to create the line system
  146550. * @param scene defines the hosting scene
  146551. * @returns a new line mesh
  146552. */
  146553. static CreateLines(name: string, options: {
  146554. points: Vector3[];
  146555. updatable?: boolean;
  146556. instance?: Nullable<LinesMesh>;
  146557. colors?: Color4[];
  146558. useVertexAlpha?: boolean;
  146559. }, scene?: Nullable<Scene>): LinesMesh;
  146560. /**
  146561. * Creates a dashed line mesh
  146562. * * 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
  146563. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146564. * * The parameter `points` is an array successive Vector3
  146565. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  146566. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  146567. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  146568. * * 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
  146569. * * When updating an instance, remember that only point positions can change, not the number of points
  146570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146571. * @param name defines the name of the mesh
  146572. * @param options defines the options used to create the mesh
  146573. * @param scene defines the hosting scene
  146574. * @returns the dashed line mesh
  146575. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  146576. */
  146577. static CreateDashedLines(name: string, options: {
  146578. points: Vector3[];
  146579. dashSize?: number;
  146580. gapSize?: number;
  146581. dashNb?: number;
  146582. updatable?: boolean;
  146583. instance?: LinesMesh;
  146584. }, scene?: Nullable<Scene>): LinesMesh;
  146585. /**
  146586. * 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.
  146587. * * 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.
  146588. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146589. * * 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.
  146590. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  146591. * * 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
  146592. * * 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
  146593. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  146594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146595. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146596. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  146597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146598. * @param name defines the name of the mesh
  146599. * @param options defines the options used to create the mesh
  146600. * @param scene defines the hosting scene
  146601. * @returns the extruded shape mesh
  146602. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146603. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146604. */
  146605. static ExtrudeShape(name: string, options: {
  146606. shape: Vector3[];
  146607. path: Vector3[];
  146608. scale?: number;
  146609. rotation?: number;
  146610. cap?: number;
  146611. updatable?: boolean;
  146612. sideOrientation?: number;
  146613. frontUVs?: Vector4;
  146614. backUVs?: Vector4;
  146615. instance?: Mesh;
  146616. invertUV?: boolean;
  146617. }, scene?: Nullable<Scene>): Mesh;
  146618. /**
  146619. * Creates an custom extruded shape mesh.
  146620. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  146621. * * 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.
  146622. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146623. * * 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
  146624. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  146625. * * 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
  146626. * * It must returns a float value that will be the scale value applied to the shape on each path point
  146627. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  146628. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  146629. * * 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
  146630. * * 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
  146631. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  146632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146633. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146634. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146636. * @param name defines the name of the mesh
  146637. * @param options defines the options used to create the mesh
  146638. * @param scene defines the hosting scene
  146639. * @returns the custom extruded shape mesh
  146640. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  146641. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146642. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146643. */
  146644. static ExtrudeShapeCustom(name: string, options: {
  146645. shape: Vector3[];
  146646. path: Vector3[];
  146647. scaleFunction?: any;
  146648. rotationFunction?: any;
  146649. ribbonCloseArray?: boolean;
  146650. ribbonClosePath?: boolean;
  146651. cap?: number;
  146652. updatable?: boolean;
  146653. sideOrientation?: number;
  146654. frontUVs?: Vector4;
  146655. backUVs?: Vector4;
  146656. instance?: Mesh;
  146657. invertUV?: boolean;
  146658. }, scene?: Nullable<Scene>): Mesh;
  146659. /**
  146660. * Creates lathe mesh.
  146661. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146662. * * 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
  146663. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146664. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146665. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146666. * * 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
  146667. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146668. * * 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
  146669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146670. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146671. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146673. * @param name defines the name of the mesh
  146674. * @param options defines the options used to create the mesh
  146675. * @param scene defines the hosting scene
  146676. * @returns the lathe mesh
  146677. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146678. */
  146679. static CreateLathe(name: string, options: {
  146680. shape: Vector3[];
  146681. radius?: number;
  146682. tessellation?: number;
  146683. clip?: number;
  146684. arc?: number;
  146685. closed?: boolean;
  146686. updatable?: boolean;
  146687. sideOrientation?: number;
  146688. frontUVs?: Vector4;
  146689. backUVs?: Vector4;
  146690. cap?: number;
  146691. invertUV?: boolean;
  146692. }, scene?: Nullable<Scene>): Mesh;
  146693. /**
  146694. * Creates a tiled plane mesh
  146695. * * You can set a limited pattern arrangement with the tiles
  146696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146697. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146699. * @param name defines the name of the mesh
  146700. * @param options defines the options used to create the mesh
  146701. * @param scene defines the hosting scene
  146702. * @returns the plane mesh
  146703. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146704. */
  146705. static CreateTiledPlane(name: string, options: {
  146706. pattern?: number;
  146707. tileSize?: number;
  146708. tileWidth?: number;
  146709. tileHeight?: number;
  146710. size?: number;
  146711. width?: number;
  146712. height?: number;
  146713. alignHorizontal?: number;
  146714. alignVertical?: number;
  146715. sideOrientation?: number;
  146716. frontUVs?: Vector4;
  146717. backUVs?: Vector4;
  146718. updatable?: boolean;
  146719. }, scene?: Nullable<Scene>): Mesh;
  146720. /**
  146721. * Creates a plane mesh
  146722. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  146723. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  146724. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  146725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146726. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146728. * @param name defines the name of the mesh
  146729. * @param options defines the options used to create the mesh
  146730. * @param scene defines the hosting scene
  146731. * @returns the plane mesh
  146732. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146733. */
  146734. static CreatePlane(name: string, options: {
  146735. size?: number;
  146736. width?: number;
  146737. height?: number;
  146738. sideOrientation?: number;
  146739. frontUVs?: Vector4;
  146740. backUVs?: Vector4;
  146741. updatable?: boolean;
  146742. sourcePlane?: Plane;
  146743. }, scene?: Nullable<Scene>): Mesh;
  146744. /**
  146745. * Creates a ground mesh
  146746. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  146747. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  146748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146749. * @param name defines the name of the mesh
  146750. * @param options defines the options used to create the mesh
  146751. * @param scene defines the hosting scene
  146752. * @returns the ground mesh
  146753. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  146754. */
  146755. static CreateGround(name: string, options: {
  146756. width?: number;
  146757. height?: number;
  146758. subdivisions?: number;
  146759. subdivisionsX?: number;
  146760. subdivisionsY?: number;
  146761. updatable?: boolean;
  146762. }, scene?: Nullable<Scene>): Mesh;
  146763. /**
  146764. * Creates a tiled ground mesh
  146765. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  146766. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  146767. * * 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
  146768. * * 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
  146769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146770. * @param name defines the name of the mesh
  146771. * @param options defines the options used to create the mesh
  146772. * @param scene defines the hosting scene
  146773. * @returns the tiled ground mesh
  146774. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  146775. */
  146776. static CreateTiledGround(name: string, options: {
  146777. xmin: number;
  146778. zmin: number;
  146779. xmax: number;
  146780. zmax: number;
  146781. subdivisions?: {
  146782. w: number;
  146783. h: number;
  146784. };
  146785. precision?: {
  146786. w: number;
  146787. h: number;
  146788. };
  146789. updatable?: boolean;
  146790. }, scene?: Nullable<Scene>): Mesh;
  146791. /**
  146792. * Creates a ground mesh from a height map
  146793. * * The parameter `url` sets the URL of the height map image resource.
  146794. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  146795. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  146796. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  146797. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  146798. * * 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.
  146799. * * 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).
  146800. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  146801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146802. * @param name defines the name of the mesh
  146803. * @param url defines the url to the height map
  146804. * @param options defines the options used to create the mesh
  146805. * @param scene defines the hosting scene
  146806. * @returns the ground mesh
  146807. * @see https://doc.babylonjs.com/babylon101/height_map
  146808. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  146809. */
  146810. static CreateGroundFromHeightMap(name: string, url: string, options: {
  146811. width?: number;
  146812. height?: number;
  146813. subdivisions?: number;
  146814. minHeight?: number;
  146815. maxHeight?: number;
  146816. colorFilter?: Color3;
  146817. alphaFilter?: number;
  146818. updatable?: boolean;
  146819. onReady?: (mesh: GroundMesh) => void;
  146820. }, scene?: Nullable<Scene>): GroundMesh;
  146821. /**
  146822. * Creates a polygon mesh
  146823. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146824. * * 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
  146825. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146827. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146828. * * Remember you can only change the shape positions, not their number when updating a polygon
  146829. * @param name defines the name of the mesh
  146830. * @param options defines the options used to create the mesh
  146831. * @param scene defines the hosting scene
  146832. * @param earcutInjection can be used to inject your own earcut reference
  146833. * @returns the polygon mesh
  146834. */
  146835. static CreatePolygon(name: string, options: {
  146836. shape: Vector3[];
  146837. holes?: Vector3[][];
  146838. depth?: number;
  146839. faceUV?: Vector4[];
  146840. faceColors?: Color4[];
  146841. updatable?: boolean;
  146842. sideOrientation?: number;
  146843. frontUVs?: Vector4;
  146844. backUVs?: Vector4;
  146845. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146846. /**
  146847. * Creates an extruded polygon mesh, with depth in the Y direction.
  146848. * * 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)
  146849. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146850. * @param name defines the name of the mesh
  146851. * @param options defines the options used to create the mesh
  146852. * @param scene defines the hosting scene
  146853. * @param earcutInjection can be used to inject your own earcut reference
  146854. * @returns the polygon mesh
  146855. */
  146856. static ExtrudePolygon(name: string, options: {
  146857. shape: Vector3[];
  146858. holes?: Vector3[][];
  146859. depth?: number;
  146860. faceUV?: Vector4[];
  146861. faceColors?: Color4[];
  146862. updatable?: boolean;
  146863. sideOrientation?: number;
  146864. frontUVs?: Vector4;
  146865. backUVs?: Vector4;
  146866. wrap?: boolean;
  146867. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146868. /**
  146869. * Creates a tube mesh.
  146870. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146871. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146872. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146873. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146874. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146875. * * 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)
  146876. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146877. * * 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
  146878. * * 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
  146879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146880. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146881. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146883. * @param name defines the name of the mesh
  146884. * @param options defines the options used to create the mesh
  146885. * @param scene defines the hosting scene
  146886. * @returns the tube mesh
  146887. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146888. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146889. */
  146890. static CreateTube(name: string, options: {
  146891. path: Vector3[];
  146892. radius?: number;
  146893. tessellation?: number;
  146894. radiusFunction?: {
  146895. (i: number, distance: number): number;
  146896. };
  146897. cap?: number;
  146898. arc?: number;
  146899. updatable?: boolean;
  146900. sideOrientation?: number;
  146901. frontUVs?: Vector4;
  146902. backUVs?: Vector4;
  146903. instance?: Mesh;
  146904. invertUV?: boolean;
  146905. }, scene?: Nullable<Scene>): Mesh;
  146906. /**
  146907. * Creates a polyhedron mesh
  146908. * * 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
  146909. * * The parameter `size` (positive float, default 1) sets the polygon size
  146910. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  146911. * * 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`
  146912. * * 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
  146913. * * 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)`)
  146914. * * 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
  146915. * * 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
  146916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146919. * @param name defines the name of the mesh
  146920. * @param options defines the options used to create the mesh
  146921. * @param scene defines the hosting scene
  146922. * @returns the polyhedron mesh
  146923. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  146924. */
  146925. static CreatePolyhedron(name: string, options: {
  146926. type?: number;
  146927. size?: number;
  146928. sizeX?: number;
  146929. sizeY?: number;
  146930. sizeZ?: number;
  146931. custom?: any;
  146932. faceUV?: Vector4[];
  146933. faceColors?: Color4[];
  146934. flat?: boolean;
  146935. updatable?: boolean;
  146936. sideOrientation?: number;
  146937. frontUVs?: Vector4;
  146938. backUVs?: Vector4;
  146939. }, scene?: Nullable<Scene>): Mesh;
  146940. /**
  146941. * Creates a decal mesh.
  146942. * 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
  146943. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146944. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146945. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146946. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146947. * @param name defines the name of the mesh
  146948. * @param sourceMesh defines the mesh where the decal must be applied
  146949. * @param options defines the options used to create the mesh
  146950. * @param scene defines the hosting scene
  146951. * @returns the decal mesh
  146952. * @see https://doc.babylonjs.com/how_to/decals
  146953. */
  146954. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146955. position?: Vector3;
  146956. normal?: Vector3;
  146957. size?: Vector3;
  146958. angle?: number;
  146959. }): Mesh;
  146960. /**
  146961. * Creates a Capsule Mesh
  146962. * @param name defines the name of the mesh.
  146963. * @param options the constructors options used to shape the mesh.
  146964. * @param scene defines the scene the mesh is scoped to.
  146965. * @returns the capsule mesh
  146966. * @see https://doc.babylonjs.com/how_to/capsule_shape
  146967. */
  146968. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  146969. }
  146970. }
  146971. declare module BABYLON {
  146972. /**
  146973. * A simplifier interface for future simplification implementations
  146974. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146975. */
  146976. export interface ISimplifier {
  146977. /**
  146978. * Simplification of a given mesh according to the given settings.
  146979. * Since this requires computation, it is assumed that the function runs async.
  146980. * @param settings The settings of the simplification, including quality and distance
  146981. * @param successCallback A callback that will be called after the mesh was simplified.
  146982. * @param errorCallback in case of an error, this callback will be called. optional.
  146983. */
  146984. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  146985. }
  146986. /**
  146987. * Expected simplification settings.
  146988. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  146989. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146990. */
  146991. export interface ISimplificationSettings {
  146992. /**
  146993. * Gets or sets the expected quality
  146994. */
  146995. quality: number;
  146996. /**
  146997. * Gets or sets the distance when this optimized version should be used
  146998. */
  146999. distance: number;
  147000. /**
  147001. * Gets an already optimized mesh
  147002. */
  147003. optimizeMesh?: boolean;
  147004. }
  147005. /**
  147006. * Class used to specify simplification options
  147007. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147008. */
  147009. export class SimplificationSettings implements ISimplificationSettings {
  147010. /** expected quality */
  147011. quality: number;
  147012. /** distance when this optimized version should be used */
  147013. distance: number;
  147014. /** already optimized mesh */
  147015. optimizeMesh?: boolean | undefined;
  147016. /**
  147017. * Creates a SimplificationSettings
  147018. * @param quality expected quality
  147019. * @param distance distance when this optimized version should be used
  147020. * @param optimizeMesh already optimized mesh
  147021. */
  147022. constructor(
  147023. /** expected quality */
  147024. quality: number,
  147025. /** distance when this optimized version should be used */
  147026. distance: number,
  147027. /** already optimized mesh */
  147028. optimizeMesh?: boolean | undefined);
  147029. }
  147030. /**
  147031. * Interface used to define a simplification task
  147032. */
  147033. export interface ISimplificationTask {
  147034. /**
  147035. * Array of settings
  147036. */
  147037. settings: Array<ISimplificationSettings>;
  147038. /**
  147039. * Simplification type
  147040. */
  147041. simplificationType: SimplificationType;
  147042. /**
  147043. * Mesh to simplify
  147044. */
  147045. mesh: Mesh;
  147046. /**
  147047. * Callback called on success
  147048. */
  147049. successCallback?: () => void;
  147050. /**
  147051. * Defines if parallel processing can be used
  147052. */
  147053. parallelProcessing: boolean;
  147054. }
  147055. /**
  147056. * Queue used to order the simplification tasks
  147057. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147058. */
  147059. export class SimplificationQueue {
  147060. private _simplificationArray;
  147061. /**
  147062. * Gets a boolean indicating that the process is still running
  147063. */
  147064. running: boolean;
  147065. /**
  147066. * Creates a new queue
  147067. */
  147068. constructor();
  147069. /**
  147070. * Adds a new simplification task
  147071. * @param task defines a task to add
  147072. */
  147073. addTask(task: ISimplificationTask): void;
  147074. /**
  147075. * Execute next task
  147076. */
  147077. executeNext(): void;
  147078. /**
  147079. * Execute a simplification task
  147080. * @param task defines the task to run
  147081. */
  147082. runSimplification(task: ISimplificationTask): void;
  147083. private getSimplifier;
  147084. }
  147085. /**
  147086. * The implemented types of simplification
  147087. * At the moment only Quadratic Error Decimation is implemented
  147088. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147089. */
  147090. export enum SimplificationType {
  147091. /** Quadratic error decimation */
  147092. QUADRATIC = 0
  147093. }
  147094. /**
  147095. * An implementation of the Quadratic Error simplification algorithm.
  147096. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  147097. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  147098. * @author RaananW
  147099. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147100. */
  147101. export class QuadraticErrorSimplification implements ISimplifier {
  147102. private _mesh;
  147103. private triangles;
  147104. private vertices;
  147105. private references;
  147106. private _reconstructedMesh;
  147107. /** Gets or sets the number pf sync interations */
  147108. syncIterations: number;
  147109. /** Gets or sets the aggressiveness of the simplifier */
  147110. aggressiveness: number;
  147111. /** Gets or sets the number of allowed iterations for decimation */
  147112. decimationIterations: number;
  147113. /** Gets or sets the espilon to use for bounding box computation */
  147114. boundingBoxEpsilon: number;
  147115. /**
  147116. * Creates a new QuadraticErrorSimplification
  147117. * @param _mesh defines the target mesh
  147118. */
  147119. constructor(_mesh: Mesh);
  147120. /**
  147121. * Simplification of a given mesh according to the given settings.
  147122. * Since this requires computation, it is assumed that the function runs async.
  147123. * @param settings The settings of the simplification, including quality and distance
  147124. * @param successCallback A callback that will be called after the mesh was simplified.
  147125. */
  147126. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  147127. private runDecimation;
  147128. private initWithMesh;
  147129. private init;
  147130. private reconstructMesh;
  147131. private initDecimatedMesh;
  147132. private isFlipped;
  147133. private updateTriangles;
  147134. private identifyBorder;
  147135. private updateMesh;
  147136. private vertexError;
  147137. private calculateError;
  147138. }
  147139. }
  147140. declare module BABYLON {
  147141. interface Scene {
  147142. /** @hidden (Backing field) */
  147143. _simplificationQueue: SimplificationQueue;
  147144. /**
  147145. * Gets or sets the simplification queue attached to the scene
  147146. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147147. */
  147148. simplificationQueue: SimplificationQueue;
  147149. }
  147150. interface Mesh {
  147151. /**
  147152. * Simplify the mesh according to the given array of settings.
  147153. * Function will return immediately and will simplify async
  147154. * @param settings a collection of simplification settings
  147155. * @param parallelProcessing should all levels calculate parallel or one after the other
  147156. * @param simplificationType the type of simplification to run
  147157. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  147158. * @returns the current mesh
  147159. */
  147160. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  147161. }
  147162. /**
  147163. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  147164. * created in a scene
  147165. */
  147166. export class SimplicationQueueSceneComponent implements ISceneComponent {
  147167. /**
  147168. * The component name helpfull to identify the component in the list of scene components.
  147169. */
  147170. readonly name: string;
  147171. /**
  147172. * The scene the component belongs to.
  147173. */
  147174. scene: Scene;
  147175. /**
  147176. * Creates a new instance of the component for the given scene
  147177. * @param scene Defines the scene to register the component in
  147178. */
  147179. constructor(scene: Scene);
  147180. /**
  147181. * Registers the component in a given scene
  147182. */
  147183. register(): void;
  147184. /**
  147185. * Rebuilds the elements related to this component in case of
  147186. * context lost for instance.
  147187. */
  147188. rebuild(): void;
  147189. /**
  147190. * Disposes the component and the associated ressources
  147191. */
  147192. dispose(): void;
  147193. private _beforeCameraUpdate;
  147194. }
  147195. }
  147196. declare module BABYLON {
  147197. interface Mesh {
  147198. /**
  147199. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  147200. */
  147201. thinInstanceEnablePicking: boolean;
  147202. /**
  147203. * Creates a new thin instance
  147204. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  147205. * @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
  147206. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  147207. */
  147208. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  147209. /**
  147210. * Adds the transformation (matrix) of the current mesh as a thin instance
  147211. * @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
  147212. * @returns the thin instance index number
  147213. */
  147214. thinInstanceAddSelf(refresh: boolean): number;
  147215. /**
  147216. * Registers a custom attribute to be used with thin instances
  147217. * @param kind name of the attribute
  147218. * @param stride size in floats of the attribute
  147219. */
  147220. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  147221. /**
  147222. * Sets the matrix of a thin instance
  147223. * @param index index of the thin instance
  147224. * @param matrix matrix to set
  147225. * @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
  147226. */
  147227. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  147228. /**
  147229. * Sets the value of a custom attribute for a thin instance
  147230. * @param kind name of the attribute
  147231. * @param index index of the thin instance
  147232. * @param value value to set
  147233. * @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
  147234. */
  147235. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  147236. /**
  147237. * 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.
  147238. */
  147239. thinInstanceCount: number;
  147240. /**
  147241. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  147242. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  147243. * @param buffer buffer to set
  147244. * @param stride size in floats of each value of the buffer
  147245. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  147246. */
  147247. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  147248. /**
  147249. * Gets the list of world matrices
  147250. * @return an array containing all the world matrices from the thin instances
  147251. */
  147252. thinInstanceGetWorldMatrices(): Matrix[];
  147253. /**
  147254. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  147255. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147256. */
  147257. thinInstanceBufferUpdated(kind: string): void;
  147258. /**
  147259. * Applies a partial update to a buffer directly on the GPU
  147260. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  147261. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147262. * @param data the data to set in the GPU buffer
  147263. * @param offset the offset in the GPU buffer where to update the data
  147264. */
  147265. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  147266. /**
  147267. * Refreshes the bounding info, taking into account all the thin instances defined
  147268. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  147269. */
  147270. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  147271. /** @hidden */
  147272. _thinInstanceInitializeUserStorage(): void;
  147273. /** @hidden */
  147274. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  147275. /** @hidden */
  147276. _userThinInstanceBuffersStorage: {
  147277. data: {
  147278. [key: string]: Float32Array;
  147279. };
  147280. sizes: {
  147281. [key: string]: number;
  147282. };
  147283. vertexBuffers: {
  147284. [key: string]: Nullable<VertexBuffer>;
  147285. };
  147286. strides: {
  147287. [key: string]: number;
  147288. };
  147289. };
  147290. }
  147291. }
  147292. declare module BABYLON {
  147293. /**
  147294. * Navigation plugin interface to add navigation constrained by a navigation mesh
  147295. */
  147296. export interface INavigationEnginePlugin {
  147297. /**
  147298. * plugin name
  147299. */
  147300. name: string;
  147301. /**
  147302. * Creates a navigation mesh
  147303. * @param meshes array of all the geometry used to compute the navigatio mesh
  147304. * @param parameters bunch of parameters used to filter geometry
  147305. */
  147306. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147307. /**
  147308. * Create a navigation mesh debug mesh
  147309. * @param scene is where the mesh will be added
  147310. * @returns debug display mesh
  147311. */
  147312. createDebugNavMesh(scene: Scene): Mesh;
  147313. /**
  147314. * Get a navigation mesh constrained position, closest to the parameter position
  147315. * @param position world position
  147316. * @returns the closest point to position constrained by the navigation mesh
  147317. */
  147318. getClosestPoint(position: Vector3): Vector3;
  147319. /**
  147320. * Get a navigation mesh constrained position, closest to the parameter position
  147321. * @param position world position
  147322. * @param result output the closest point to position constrained by the navigation mesh
  147323. */
  147324. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147325. /**
  147326. * Get a navigation mesh constrained position, within a particular radius
  147327. * @param position world position
  147328. * @param maxRadius the maximum distance to the constrained world position
  147329. * @returns the closest point to position constrained by the navigation mesh
  147330. */
  147331. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147332. /**
  147333. * Get a navigation mesh constrained position, within a particular radius
  147334. * @param position world position
  147335. * @param maxRadius the maximum distance to the constrained world position
  147336. * @param result output the closest point to position constrained by the navigation mesh
  147337. */
  147338. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147339. /**
  147340. * Compute the final position from a segment made of destination-position
  147341. * @param position world position
  147342. * @param destination world position
  147343. * @returns the resulting point along the navmesh
  147344. */
  147345. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147346. /**
  147347. * Compute the final position from a segment made of destination-position
  147348. * @param position world position
  147349. * @param destination world position
  147350. * @param result output the resulting point along the navmesh
  147351. */
  147352. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147353. /**
  147354. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147355. * @param start world position
  147356. * @param end world position
  147357. * @returns array containing world position composing the path
  147358. */
  147359. computePath(start: Vector3, end: Vector3): Vector3[];
  147360. /**
  147361. * If this plugin is supported
  147362. * @returns true if plugin is supported
  147363. */
  147364. isSupported(): boolean;
  147365. /**
  147366. * Create a new Crowd so you can add agents
  147367. * @param maxAgents the maximum agent count in the crowd
  147368. * @param maxAgentRadius the maximum radius an agent can have
  147369. * @param scene to attach the crowd to
  147370. * @returns the crowd you can add agents to
  147371. */
  147372. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147373. /**
  147374. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147375. * The queries will try to find a solution within those bounds
  147376. * default is (1,1,1)
  147377. * @param extent x,y,z value that define the extent around the queries point of reference
  147378. */
  147379. setDefaultQueryExtent(extent: Vector3): void;
  147380. /**
  147381. * Get the Bounding box extent specified by setDefaultQueryExtent
  147382. * @returns the box extent values
  147383. */
  147384. getDefaultQueryExtent(): Vector3;
  147385. /**
  147386. * build the navmesh from a previously saved state using getNavmeshData
  147387. * @param data the Uint8Array returned by getNavmeshData
  147388. */
  147389. buildFromNavmeshData(data: Uint8Array): void;
  147390. /**
  147391. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147392. * @returns data the Uint8Array that can be saved and reused
  147393. */
  147394. getNavmeshData(): Uint8Array;
  147395. /**
  147396. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147397. * @param result output the box extent values
  147398. */
  147399. getDefaultQueryExtentToRef(result: Vector3): void;
  147400. /**
  147401. * Release all resources
  147402. */
  147403. dispose(): void;
  147404. }
  147405. /**
  147406. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  147407. */
  147408. export interface ICrowd {
  147409. /**
  147410. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147411. * You can attach anything to that node. The node position is updated in the scene update tick.
  147412. * @param pos world position that will be constrained by the navigation mesh
  147413. * @param parameters agent parameters
  147414. * @param transform hooked to the agent that will be update by the scene
  147415. * @returns agent index
  147416. */
  147417. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147418. /**
  147419. * Returns the agent position in world space
  147420. * @param index agent index returned by addAgent
  147421. * @returns world space position
  147422. */
  147423. getAgentPosition(index: number): Vector3;
  147424. /**
  147425. * Gets the agent position result in world space
  147426. * @param index agent index returned by addAgent
  147427. * @param result output world space position
  147428. */
  147429. getAgentPositionToRef(index: number, result: Vector3): void;
  147430. /**
  147431. * Gets the agent velocity in world space
  147432. * @param index agent index returned by addAgent
  147433. * @returns world space velocity
  147434. */
  147435. getAgentVelocity(index: number): Vector3;
  147436. /**
  147437. * Gets the agent velocity result in world space
  147438. * @param index agent index returned by addAgent
  147439. * @param result output world space velocity
  147440. */
  147441. getAgentVelocityToRef(index: number, result: Vector3): void;
  147442. /**
  147443. * remove a particular agent previously created
  147444. * @param index agent index returned by addAgent
  147445. */
  147446. removeAgent(index: number): void;
  147447. /**
  147448. * get the list of all agents attached to this crowd
  147449. * @returns list of agent indices
  147450. */
  147451. getAgents(): number[];
  147452. /**
  147453. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147454. * @param deltaTime in seconds
  147455. */
  147456. update(deltaTime: number): void;
  147457. /**
  147458. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147459. * @param index agent index returned by addAgent
  147460. * @param destination targeted world position
  147461. */
  147462. agentGoto(index: number, destination: Vector3): void;
  147463. /**
  147464. * Teleport the agent to a new position
  147465. * @param index agent index returned by addAgent
  147466. * @param destination targeted world position
  147467. */
  147468. agentTeleport(index: number, destination: Vector3): void;
  147469. /**
  147470. * Update agent parameters
  147471. * @param index agent index returned by addAgent
  147472. * @param parameters agent parameters
  147473. */
  147474. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147475. /**
  147476. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147477. * The queries will try to find a solution within those bounds
  147478. * default is (1,1,1)
  147479. * @param extent x,y,z value that define the extent around the queries point of reference
  147480. */
  147481. setDefaultQueryExtent(extent: Vector3): void;
  147482. /**
  147483. * Get the Bounding box extent specified by setDefaultQueryExtent
  147484. * @returns the box extent values
  147485. */
  147486. getDefaultQueryExtent(): Vector3;
  147487. /**
  147488. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147489. * @param result output the box extent values
  147490. */
  147491. getDefaultQueryExtentToRef(result: Vector3): void;
  147492. /**
  147493. * Release all resources
  147494. */
  147495. dispose(): void;
  147496. }
  147497. /**
  147498. * Configures an agent
  147499. */
  147500. export interface IAgentParameters {
  147501. /**
  147502. * Agent radius. [Limit: >= 0]
  147503. */
  147504. radius: number;
  147505. /**
  147506. * Agent height. [Limit: > 0]
  147507. */
  147508. height: number;
  147509. /**
  147510. * Maximum allowed acceleration. [Limit: >= 0]
  147511. */
  147512. maxAcceleration: number;
  147513. /**
  147514. * Maximum allowed speed. [Limit: >= 0]
  147515. */
  147516. maxSpeed: number;
  147517. /**
  147518. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  147519. */
  147520. collisionQueryRange: number;
  147521. /**
  147522. * The path visibility optimization range. [Limit: > 0]
  147523. */
  147524. pathOptimizationRange: number;
  147525. /**
  147526. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  147527. */
  147528. separationWeight: number;
  147529. }
  147530. /**
  147531. * Configures the navigation mesh creation
  147532. */
  147533. export interface INavMeshParameters {
  147534. /**
  147535. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  147536. */
  147537. cs: number;
  147538. /**
  147539. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  147540. */
  147541. ch: number;
  147542. /**
  147543. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  147544. */
  147545. walkableSlopeAngle: number;
  147546. /**
  147547. * Minimum floor to 'ceiling' height that will still allow the floor area to
  147548. * be considered walkable. [Limit: >= 3] [Units: vx]
  147549. */
  147550. walkableHeight: number;
  147551. /**
  147552. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  147553. */
  147554. walkableClimb: number;
  147555. /**
  147556. * The distance to erode/shrink the walkable area of the heightfield away from
  147557. * obstructions. [Limit: >=0] [Units: vx]
  147558. */
  147559. walkableRadius: number;
  147560. /**
  147561. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  147562. */
  147563. maxEdgeLen: number;
  147564. /**
  147565. * The maximum distance a simplfied contour's border edges should deviate
  147566. * the original raw contour. [Limit: >=0] [Units: vx]
  147567. */
  147568. maxSimplificationError: number;
  147569. /**
  147570. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  147571. */
  147572. minRegionArea: number;
  147573. /**
  147574. * Any regions with a span count smaller than this value will, if possible,
  147575. * be merged with larger regions. [Limit: >=0] [Units: vx]
  147576. */
  147577. mergeRegionArea: number;
  147578. /**
  147579. * The maximum number of vertices allowed for polygons generated during the
  147580. * contour to polygon conversion process. [Limit: >= 3]
  147581. */
  147582. maxVertsPerPoly: number;
  147583. /**
  147584. * Sets the sampling distance to use when generating the detail mesh.
  147585. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  147586. */
  147587. detailSampleDist: number;
  147588. /**
  147589. * The maximum distance the detail mesh surface should deviate from heightfield
  147590. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  147591. */
  147592. detailSampleMaxError: number;
  147593. }
  147594. }
  147595. declare module BABYLON {
  147596. /**
  147597. * RecastJS navigation plugin
  147598. */
  147599. export class RecastJSPlugin implements INavigationEnginePlugin {
  147600. /**
  147601. * Reference to the Recast library
  147602. */
  147603. bjsRECAST: any;
  147604. /**
  147605. * plugin name
  147606. */
  147607. name: string;
  147608. /**
  147609. * the first navmesh created. We might extend this to support multiple navmeshes
  147610. */
  147611. navMesh: any;
  147612. /**
  147613. * Initializes the recastJS plugin
  147614. * @param recastInjection can be used to inject your own recast reference
  147615. */
  147616. constructor(recastInjection?: any);
  147617. /**
  147618. * Creates a navigation mesh
  147619. * @param meshes array of all the geometry used to compute the navigatio mesh
  147620. * @param parameters bunch of parameters used to filter geometry
  147621. */
  147622. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147623. /**
  147624. * Create a navigation mesh debug mesh
  147625. * @param scene is where the mesh will be added
  147626. * @returns debug display mesh
  147627. */
  147628. createDebugNavMesh(scene: Scene): Mesh;
  147629. /**
  147630. * Get a navigation mesh constrained position, closest to the parameter position
  147631. * @param position world position
  147632. * @returns the closest point to position constrained by the navigation mesh
  147633. */
  147634. getClosestPoint(position: Vector3): Vector3;
  147635. /**
  147636. * Get a navigation mesh constrained position, closest to the parameter position
  147637. * @param position world position
  147638. * @param result output the closest point to position constrained by the navigation mesh
  147639. */
  147640. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147641. /**
  147642. * Get a navigation mesh constrained position, within a particular radius
  147643. * @param position world position
  147644. * @param maxRadius the maximum distance to the constrained world position
  147645. * @returns the closest point to position constrained by the navigation mesh
  147646. */
  147647. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147648. /**
  147649. * Get a navigation mesh constrained position, within a particular radius
  147650. * @param position world position
  147651. * @param maxRadius the maximum distance to the constrained world position
  147652. * @param result output the closest point to position constrained by the navigation mesh
  147653. */
  147654. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147655. /**
  147656. * Compute the final position from a segment made of destination-position
  147657. * @param position world position
  147658. * @param destination world position
  147659. * @returns the resulting point along the navmesh
  147660. */
  147661. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147662. /**
  147663. * Compute the final position from a segment made of destination-position
  147664. * @param position world position
  147665. * @param destination world position
  147666. * @param result output the resulting point along the navmesh
  147667. */
  147668. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147669. /**
  147670. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147671. * @param start world position
  147672. * @param end world position
  147673. * @returns array containing world position composing the path
  147674. */
  147675. computePath(start: Vector3, end: Vector3): Vector3[];
  147676. /**
  147677. * Create a new Crowd so you can add agents
  147678. * @param maxAgents the maximum agent count in the crowd
  147679. * @param maxAgentRadius the maximum radius an agent can have
  147680. * @param scene to attach the crowd to
  147681. * @returns the crowd you can add agents to
  147682. */
  147683. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147684. /**
  147685. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147686. * The queries will try to find a solution within those bounds
  147687. * default is (1,1,1)
  147688. * @param extent x,y,z value that define the extent around the queries point of reference
  147689. */
  147690. setDefaultQueryExtent(extent: Vector3): void;
  147691. /**
  147692. * Get the Bounding box extent specified by setDefaultQueryExtent
  147693. * @returns the box extent values
  147694. */
  147695. getDefaultQueryExtent(): Vector3;
  147696. /**
  147697. * build the navmesh from a previously saved state using getNavmeshData
  147698. * @param data the Uint8Array returned by getNavmeshData
  147699. */
  147700. buildFromNavmeshData(data: Uint8Array): void;
  147701. /**
  147702. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147703. * @returns data the Uint8Array that can be saved and reused
  147704. */
  147705. getNavmeshData(): Uint8Array;
  147706. /**
  147707. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147708. * @param result output the box extent values
  147709. */
  147710. getDefaultQueryExtentToRef(result: Vector3): void;
  147711. /**
  147712. * Disposes
  147713. */
  147714. dispose(): void;
  147715. /**
  147716. * If this plugin is supported
  147717. * @returns true if plugin is supported
  147718. */
  147719. isSupported(): boolean;
  147720. }
  147721. /**
  147722. * Recast detour crowd implementation
  147723. */
  147724. export class RecastJSCrowd implements ICrowd {
  147725. /**
  147726. * Recast/detour plugin
  147727. */
  147728. bjsRECASTPlugin: RecastJSPlugin;
  147729. /**
  147730. * Link to the detour crowd
  147731. */
  147732. recastCrowd: any;
  147733. /**
  147734. * One transform per agent
  147735. */
  147736. transforms: TransformNode[];
  147737. /**
  147738. * All agents created
  147739. */
  147740. agents: number[];
  147741. /**
  147742. * Link to the scene is kept to unregister the crowd from the scene
  147743. */
  147744. private _scene;
  147745. /**
  147746. * Observer for crowd updates
  147747. */
  147748. private _onBeforeAnimationsObserver;
  147749. /**
  147750. * Constructor
  147751. * @param plugin recastJS plugin
  147752. * @param maxAgents the maximum agent count in the crowd
  147753. * @param maxAgentRadius the maximum radius an agent can have
  147754. * @param scene to attach the crowd to
  147755. * @returns the crowd you can add agents to
  147756. */
  147757. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  147758. /**
  147759. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147760. * You can attach anything to that node. The node position is updated in the scene update tick.
  147761. * @param pos world position that will be constrained by the navigation mesh
  147762. * @param parameters agent parameters
  147763. * @param transform hooked to the agent that will be update by the scene
  147764. * @returns agent index
  147765. */
  147766. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147767. /**
  147768. * Returns the agent position in world space
  147769. * @param index agent index returned by addAgent
  147770. * @returns world space position
  147771. */
  147772. getAgentPosition(index: number): Vector3;
  147773. /**
  147774. * Returns the agent position result in world space
  147775. * @param index agent index returned by addAgent
  147776. * @param result output world space position
  147777. */
  147778. getAgentPositionToRef(index: number, result: Vector3): void;
  147779. /**
  147780. * Returns the agent velocity in world space
  147781. * @param index agent index returned by addAgent
  147782. * @returns world space velocity
  147783. */
  147784. getAgentVelocity(index: number): Vector3;
  147785. /**
  147786. * Returns the agent velocity result in world space
  147787. * @param index agent index returned by addAgent
  147788. * @param result output world space velocity
  147789. */
  147790. getAgentVelocityToRef(index: number, result: Vector3): void;
  147791. /**
  147792. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147793. * @param index agent index returned by addAgent
  147794. * @param destination targeted world position
  147795. */
  147796. agentGoto(index: number, destination: Vector3): void;
  147797. /**
  147798. * Teleport the agent to a new position
  147799. * @param index agent index returned by addAgent
  147800. * @param destination targeted world position
  147801. */
  147802. agentTeleport(index: number, destination: Vector3): void;
  147803. /**
  147804. * Update agent parameters
  147805. * @param index agent index returned by addAgent
  147806. * @param parameters agent parameters
  147807. */
  147808. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147809. /**
  147810. * remove a particular agent previously created
  147811. * @param index agent index returned by addAgent
  147812. */
  147813. removeAgent(index: number): void;
  147814. /**
  147815. * get the list of all agents attached to this crowd
  147816. * @returns list of agent indices
  147817. */
  147818. getAgents(): number[];
  147819. /**
  147820. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147821. * @param deltaTime in seconds
  147822. */
  147823. update(deltaTime: number): void;
  147824. /**
  147825. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147826. * The queries will try to find a solution within those bounds
  147827. * default is (1,1,1)
  147828. * @param extent x,y,z value that define the extent around the queries point of reference
  147829. */
  147830. setDefaultQueryExtent(extent: Vector3): void;
  147831. /**
  147832. * Get the Bounding box extent specified by setDefaultQueryExtent
  147833. * @returns the box extent values
  147834. */
  147835. getDefaultQueryExtent(): Vector3;
  147836. /**
  147837. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147838. * @param result output the box extent values
  147839. */
  147840. getDefaultQueryExtentToRef(result: Vector3): void;
  147841. /**
  147842. * Release all resources
  147843. */
  147844. dispose(): void;
  147845. }
  147846. }
  147847. declare module BABYLON {
  147848. /**
  147849. * Class used to enable access to IndexedDB
  147850. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  147851. */
  147852. export class Database implements IOfflineProvider {
  147853. private _callbackManifestChecked;
  147854. private _currentSceneUrl;
  147855. private _db;
  147856. private _enableSceneOffline;
  147857. private _enableTexturesOffline;
  147858. private _manifestVersionFound;
  147859. private _mustUpdateRessources;
  147860. private _hasReachedQuota;
  147861. private _isSupported;
  147862. private _idbFactory;
  147863. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  147864. private static IsUASupportingBlobStorage;
  147865. /**
  147866. * Gets a boolean indicating if Database storate is enabled (off by default)
  147867. */
  147868. static IDBStorageEnabled: boolean;
  147869. /**
  147870. * Gets a boolean indicating if scene must be saved in the database
  147871. */
  147872. get enableSceneOffline(): boolean;
  147873. /**
  147874. * Gets a boolean indicating if textures must be saved in the database
  147875. */
  147876. get enableTexturesOffline(): boolean;
  147877. /**
  147878. * Creates a new Database
  147879. * @param urlToScene defines the url to load the scene
  147880. * @param callbackManifestChecked defines the callback to use when manifest is checked
  147881. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  147882. */
  147883. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  147884. private static _ParseURL;
  147885. private static _ReturnFullUrlLocation;
  147886. private _checkManifestFile;
  147887. /**
  147888. * Open the database and make it available
  147889. * @param successCallback defines the callback to call on success
  147890. * @param errorCallback defines the callback to call on error
  147891. */
  147892. open(successCallback: () => void, errorCallback: () => void): void;
  147893. /**
  147894. * Loads an image from the database
  147895. * @param url defines the url to load from
  147896. * @param image defines the target DOM image
  147897. */
  147898. loadImage(url: string, image: HTMLImageElement): void;
  147899. private _loadImageFromDBAsync;
  147900. private _saveImageIntoDBAsync;
  147901. private _checkVersionFromDB;
  147902. private _loadVersionFromDBAsync;
  147903. private _saveVersionIntoDBAsync;
  147904. /**
  147905. * Loads a file from database
  147906. * @param url defines the URL to load from
  147907. * @param sceneLoaded defines a callback to call on success
  147908. * @param progressCallBack defines a callback to call when progress changed
  147909. * @param errorCallback defines a callback to call on error
  147910. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  147911. */
  147912. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  147913. private _loadFileAsync;
  147914. private _saveFileAsync;
  147915. /**
  147916. * Validates if xhr data is correct
  147917. * @param xhr defines the request to validate
  147918. * @param dataType defines the expected data type
  147919. * @returns true if data is correct
  147920. */
  147921. private static _ValidateXHRData;
  147922. }
  147923. }
  147924. declare module BABYLON {
  147925. /** @hidden */
  147926. export var gpuUpdateParticlesPixelShader: {
  147927. name: string;
  147928. shader: string;
  147929. };
  147930. }
  147931. declare module BABYLON {
  147932. /** @hidden */
  147933. export var gpuUpdateParticlesVertexShader: {
  147934. name: string;
  147935. shader: string;
  147936. };
  147937. }
  147938. declare module BABYLON {
  147939. /** @hidden */
  147940. export var clipPlaneFragmentDeclaration2: {
  147941. name: string;
  147942. shader: string;
  147943. };
  147944. }
  147945. declare module BABYLON {
  147946. /** @hidden */
  147947. export var gpuRenderParticlesPixelShader: {
  147948. name: string;
  147949. shader: string;
  147950. };
  147951. }
  147952. declare module BABYLON {
  147953. /** @hidden */
  147954. export var clipPlaneVertexDeclaration2: {
  147955. name: string;
  147956. shader: string;
  147957. };
  147958. }
  147959. declare module BABYLON {
  147960. /** @hidden */
  147961. export var gpuRenderParticlesVertexShader: {
  147962. name: string;
  147963. shader: string;
  147964. };
  147965. }
  147966. declare module BABYLON {
  147967. /**
  147968. * This represents a GPU particle system in Babylon
  147969. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  147970. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  147971. */
  147972. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  147973. /**
  147974. * The layer mask we are rendering the particles through.
  147975. */
  147976. layerMask: number;
  147977. private _capacity;
  147978. private _activeCount;
  147979. private _currentActiveCount;
  147980. private _accumulatedCount;
  147981. private _renderEffect;
  147982. private _updateEffect;
  147983. private _buffer0;
  147984. private _buffer1;
  147985. private _spriteBuffer;
  147986. private _updateVAO;
  147987. private _renderVAO;
  147988. private _targetIndex;
  147989. private _sourceBuffer;
  147990. private _targetBuffer;
  147991. private _currentRenderId;
  147992. private _started;
  147993. private _stopped;
  147994. private _timeDelta;
  147995. private _randomTexture;
  147996. private _randomTexture2;
  147997. private _attributesStrideSize;
  147998. private _updateEffectOptions;
  147999. private _randomTextureSize;
  148000. private _actualFrame;
  148001. private _customEffect;
  148002. private readonly _rawTextureWidth;
  148003. /**
  148004. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  148005. */
  148006. static get IsSupported(): boolean;
  148007. /**
  148008. * An event triggered when the system is disposed.
  148009. */
  148010. onDisposeObservable: Observable<IParticleSystem>;
  148011. /**
  148012. * Gets the maximum number of particles active at the same time.
  148013. * @returns The max number of active particles.
  148014. */
  148015. getCapacity(): number;
  148016. /**
  148017. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  148018. * to override the particles.
  148019. */
  148020. forceDepthWrite: boolean;
  148021. /**
  148022. * Gets or set the number of active particles
  148023. */
  148024. get activeParticleCount(): number;
  148025. set activeParticleCount(value: number);
  148026. private _preWarmDone;
  148027. /**
  148028. * Specifies if the particles are updated in emitter local space or world space.
  148029. */
  148030. isLocal: boolean;
  148031. /** Gets or sets a matrix to use to compute projection */
  148032. defaultProjectionMatrix: Matrix;
  148033. /**
  148034. * Is this system ready to be used/rendered
  148035. * @return true if the system is ready
  148036. */
  148037. isReady(): boolean;
  148038. /**
  148039. * Gets if the system has been started. (Note: this will still be true after stop is called)
  148040. * @returns True if it has been started, otherwise false.
  148041. */
  148042. isStarted(): boolean;
  148043. /**
  148044. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  148045. * @returns True if it has been stopped, otherwise false.
  148046. */
  148047. isStopped(): boolean;
  148048. /**
  148049. * Gets a boolean indicating that the system is stopping
  148050. * @returns true if the system is currently stopping
  148051. */
  148052. isStopping(): boolean;
  148053. /**
  148054. * Gets the number of particles active at the same time.
  148055. * @returns The number of active particles.
  148056. */
  148057. getActiveCount(): number;
  148058. /**
  148059. * Starts the particle system and begins to emit
  148060. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  148061. */
  148062. start(delay?: number): void;
  148063. /**
  148064. * Stops the particle system.
  148065. */
  148066. stop(): void;
  148067. /**
  148068. * Remove all active particles
  148069. */
  148070. reset(): void;
  148071. /**
  148072. * Returns the string "GPUParticleSystem"
  148073. * @returns a string containing the class name
  148074. */
  148075. getClassName(): string;
  148076. /**
  148077. * Gets the custom effect used to render the particles
  148078. * @param blendMode Blend mode for which the effect should be retrieved
  148079. * @returns The effect
  148080. */
  148081. getCustomEffect(blendMode?: number): Nullable<Effect>;
  148082. /**
  148083. * Sets the custom effect used to render the particles
  148084. * @param effect The effect to set
  148085. * @param blendMode Blend mode for which the effect should be set
  148086. */
  148087. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  148088. /** @hidden */
  148089. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  148090. /**
  148091. * Observable that will be called just before the particles are drawn
  148092. */
  148093. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  148094. /**
  148095. * Gets the name of the particle vertex shader
  148096. */
  148097. get vertexShaderName(): string;
  148098. private _colorGradientsTexture;
  148099. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  148100. /**
  148101. * Adds a new color gradient
  148102. * @param gradient defines the gradient to use (between 0 and 1)
  148103. * @param color1 defines the color to affect to the specified gradient
  148104. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  148105. * @returns the current particle system
  148106. */
  148107. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  148108. private _refreshColorGradient;
  148109. /** Force the system to rebuild all gradients that need to be resync */
  148110. forceRefreshGradients(): void;
  148111. /**
  148112. * Remove a specific color gradient
  148113. * @param gradient defines the gradient to remove
  148114. * @returns the current particle system
  148115. */
  148116. removeColorGradient(gradient: number): GPUParticleSystem;
  148117. private _angularSpeedGradientsTexture;
  148118. private _sizeGradientsTexture;
  148119. private _velocityGradientsTexture;
  148120. private _limitVelocityGradientsTexture;
  148121. private _dragGradientsTexture;
  148122. private _addFactorGradient;
  148123. /**
  148124. * Adds a new size gradient
  148125. * @param gradient defines the gradient to use (between 0 and 1)
  148126. * @param factor defines the size factor to affect to the specified gradient
  148127. * @returns the current particle system
  148128. */
  148129. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  148130. /**
  148131. * Remove a specific size gradient
  148132. * @param gradient defines the gradient to remove
  148133. * @returns the current particle system
  148134. */
  148135. removeSizeGradient(gradient: number): GPUParticleSystem;
  148136. private _refreshFactorGradient;
  148137. /**
  148138. * Adds a new angular speed gradient
  148139. * @param gradient defines the gradient to use (between 0 and 1)
  148140. * @param factor defines the angular speed to affect to the specified gradient
  148141. * @returns the current particle system
  148142. */
  148143. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  148144. /**
  148145. * Remove a specific angular speed gradient
  148146. * @param gradient defines the gradient to remove
  148147. * @returns the current particle system
  148148. */
  148149. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  148150. /**
  148151. * Adds a new velocity gradient
  148152. * @param gradient defines the gradient to use (between 0 and 1)
  148153. * @param factor defines the velocity to affect to the specified gradient
  148154. * @returns the current particle system
  148155. */
  148156. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148157. /**
  148158. * Remove a specific velocity gradient
  148159. * @param gradient defines the gradient to remove
  148160. * @returns the current particle system
  148161. */
  148162. removeVelocityGradient(gradient: number): GPUParticleSystem;
  148163. /**
  148164. * Adds a new limit velocity gradient
  148165. * @param gradient defines the gradient to use (between 0 and 1)
  148166. * @param factor defines the limit velocity value to affect to the specified gradient
  148167. * @returns the current particle system
  148168. */
  148169. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148170. /**
  148171. * Remove a specific limit velocity gradient
  148172. * @param gradient defines the gradient to remove
  148173. * @returns the current particle system
  148174. */
  148175. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  148176. /**
  148177. * Adds a new drag gradient
  148178. * @param gradient defines the gradient to use (between 0 and 1)
  148179. * @param factor defines the drag value to affect to the specified gradient
  148180. * @returns the current particle system
  148181. */
  148182. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  148183. /**
  148184. * Remove a specific drag gradient
  148185. * @param gradient defines the gradient to remove
  148186. * @returns the current particle system
  148187. */
  148188. removeDragGradient(gradient: number): GPUParticleSystem;
  148189. /**
  148190. * Not supported by GPUParticleSystem
  148191. * @param gradient defines the gradient to use (between 0 and 1)
  148192. * @param factor defines the emit rate value to affect to the specified gradient
  148193. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148194. * @returns the current particle system
  148195. */
  148196. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148197. /**
  148198. * Not supported by GPUParticleSystem
  148199. * @param gradient defines the gradient to remove
  148200. * @returns the current particle system
  148201. */
  148202. removeEmitRateGradient(gradient: number): IParticleSystem;
  148203. /**
  148204. * Not supported by GPUParticleSystem
  148205. * @param gradient defines the gradient to use (between 0 and 1)
  148206. * @param factor defines the start size value to affect to the specified gradient
  148207. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148208. * @returns the current particle system
  148209. */
  148210. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148211. /**
  148212. * Not supported by GPUParticleSystem
  148213. * @param gradient defines the gradient to remove
  148214. * @returns the current particle system
  148215. */
  148216. removeStartSizeGradient(gradient: number): IParticleSystem;
  148217. /**
  148218. * Not supported by GPUParticleSystem
  148219. * @param gradient defines the gradient to use (between 0 and 1)
  148220. * @param min defines the color remap minimal range
  148221. * @param max defines the color remap maximal range
  148222. * @returns the current particle system
  148223. */
  148224. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148225. /**
  148226. * Not supported by GPUParticleSystem
  148227. * @param gradient defines the gradient to remove
  148228. * @returns the current particle system
  148229. */
  148230. removeColorRemapGradient(): IParticleSystem;
  148231. /**
  148232. * Not supported by GPUParticleSystem
  148233. * @param gradient defines the gradient to use (between 0 and 1)
  148234. * @param min defines the alpha remap minimal range
  148235. * @param max defines the alpha remap maximal range
  148236. * @returns the current particle system
  148237. */
  148238. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148239. /**
  148240. * Not supported by GPUParticleSystem
  148241. * @param gradient defines the gradient to remove
  148242. * @returns the current particle system
  148243. */
  148244. removeAlphaRemapGradient(): IParticleSystem;
  148245. /**
  148246. * Not supported by GPUParticleSystem
  148247. * @param gradient defines the gradient to use (between 0 and 1)
  148248. * @param color defines the color to affect to the specified gradient
  148249. * @returns the current particle system
  148250. */
  148251. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  148252. /**
  148253. * Not supported by GPUParticleSystem
  148254. * @param gradient defines the gradient to remove
  148255. * @returns the current particle system
  148256. */
  148257. removeRampGradient(): IParticleSystem;
  148258. /**
  148259. * Not supported by GPUParticleSystem
  148260. * @returns the list of ramp gradients
  148261. */
  148262. getRampGradients(): Nullable<Array<Color3Gradient>>;
  148263. /**
  148264. * Not supported by GPUParticleSystem
  148265. * Gets or sets a boolean indicating that ramp gradients must be used
  148266. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  148267. */
  148268. get useRampGradients(): boolean;
  148269. set useRampGradients(value: boolean);
  148270. /**
  148271. * Not supported by GPUParticleSystem
  148272. * @param gradient defines the gradient to use (between 0 and 1)
  148273. * @param factor defines the life time factor to affect to the specified gradient
  148274. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148275. * @returns the current particle system
  148276. */
  148277. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148278. /**
  148279. * Not supported by GPUParticleSystem
  148280. * @param gradient defines the gradient to remove
  148281. * @returns the current particle system
  148282. */
  148283. removeLifeTimeGradient(gradient: number): IParticleSystem;
  148284. /**
  148285. * Instantiates a GPU particle system.
  148286. * 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.
  148287. * @param name The name of the particle system
  148288. * @param options The options used to create the system
  148289. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  148290. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  148291. * @param customEffect a custom effect used to change the way particles are rendered by default
  148292. */
  148293. constructor(name: string, options: Partial<{
  148294. capacity: number;
  148295. randomTextureSize: number;
  148296. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  148297. protected _reset(): void;
  148298. private _createUpdateVAO;
  148299. private _createRenderVAO;
  148300. private _initialize;
  148301. /** @hidden */
  148302. _recreateUpdateEffect(): void;
  148303. private _getEffect;
  148304. /**
  148305. * Fill the defines array according to the current settings of the particle system
  148306. * @param defines Array to be updated
  148307. * @param blendMode blend mode to take into account when updating the array
  148308. */
  148309. fillDefines(defines: Array<string>, blendMode?: number): void;
  148310. /**
  148311. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  148312. * @param uniforms Uniforms array to fill
  148313. * @param attributes Attributes array to fill
  148314. * @param samplers Samplers array to fill
  148315. */
  148316. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  148317. /** @hidden */
  148318. _recreateRenderEffect(): Effect;
  148319. /**
  148320. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  148321. * @param preWarm defines if we are in the pre-warmimg phase
  148322. */
  148323. animate(preWarm?: boolean): void;
  148324. private _createFactorGradientTexture;
  148325. private _createSizeGradientTexture;
  148326. private _createAngularSpeedGradientTexture;
  148327. private _createVelocityGradientTexture;
  148328. private _createLimitVelocityGradientTexture;
  148329. private _createDragGradientTexture;
  148330. private _createColorGradientTexture;
  148331. /**
  148332. * Renders the particle system in its current state
  148333. * @param preWarm defines if the system should only update the particles but not render them
  148334. * @returns the current number of particles
  148335. */
  148336. render(preWarm?: boolean): number;
  148337. /**
  148338. * Rebuilds the particle system
  148339. */
  148340. rebuild(): void;
  148341. private _releaseBuffers;
  148342. private _releaseVAOs;
  148343. /**
  148344. * Disposes the particle system and free the associated resources
  148345. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  148346. */
  148347. dispose(disposeTexture?: boolean): void;
  148348. /**
  148349. * Clones the particle system.
  148350. * @param name The name of the cloned object
  148351. * @param newEmitter The new emitter to use
  148352. * @returns the cloned particle system
  148353. */
  148354. clone(name: string, newEmitter: any): GPUParticleSystem;
  148355. /**
  148356. * Serializes the particle system to a JSON object
  148357. * @param serializeTexture defines if the texture must be serialized as well
  148358. * @returns the JSON object
  148359. */
  148360. serialize(serializeTexture?: boolean): any;
  148361. /**
  148362. * Parses a JSON object to create a GPU particle system.
  148363. * @param parsedParticleSystem The JSON object to parse
  148364. * @param sceneOrEngine The scene or the engine to create the particle system in
  148365. * @param rootUrl The root url to use to load external dependencies like texture
  148366. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  148367. * @returns the parsed GPU particle system
  148368. */
  148369. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  148370. }
  148371. }
  148372. declare module BABYLON {
  148373. /**
  148374. * Represents a set of particle systems working together to create a specific effect
  148375. */
  148376. export class ParticleSystemSet implements IDisposable {
  148377. /**
  148378. * Gets or sets base Assets URL
  148379. */
  148380. static BaseAssetsUrl: string;
  148381. private _emitterCreationOptions;
  148382. private _emitterNode;
  148383. /**
  148384. * Gets the particle system list
  148385. */
  148386. systems: IParticleSystem[];
  148387. /**
  148388. * Gets the emitter node used with this set
  148389. */
  148390. get emitterNode(): Nullable<TransformNode>;
  148391. /**
  148392. * Creates a new emitter mesh as a sphere
  148393. * @param options defines the options used to create the sphere
  148394. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  148395. * @param scene defines the hosting scene
  148396. */
  148397. setEmitterAsSphere(options: {
  148398. diameter: number;
  148399. segments: number;
  148400. color: Color3;
  148401. }, renderingGroupId: number, scene: Scene): void;
  148402. /**
  148403. * Starts all particle systems of the set
  148404. * @param emitter defines an optional mesh to use as emitter for the particle systems
  148405. */
  148406. start(emitter?: AbstractMesh): void;
  148407. /**
  148408. * Release all associated resources
  148409. */
  148410. dispose(): void;
  148411. /**
  148412. * Serialize the set into a JSON compatible object
  148413. * @param serializeTexture defines if the texture must be serialized as well
  148414. * @returns a JSON compatible representation of the set
  148415. */
  148416. serialize(serializeTexture?: boolean): any;
  148417. /**
  148418. * Parse a new ParticleSystemSet from a serialized source
  148419. * @param data defines a JSON compatible representation of the set
  148420. * @param scene defines the hosting scene
  148421. * @param gpu defines if we want GPU particles or CPU particles
  148422. * @returns a new ParticleSystemSet
  148423. */
  148424. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  148425. }
  148426. }
  148427. declare module BABYLON {
  148428. /**
  148429. * This class is made for on one-liner static method to help creating particle system set.
  148430. */
  148431. export class ParticleHelper {
  148432. /**
  148433. * Gets or sets base Assets URL
  148434. */
  148435. static BaseAssetsUrl: string;
  148436. /** Define the Url to load snippets */
  148437. static SnippetUrl: string;
  148438. /**
  148439. * Create a default particle system that you can tweak
  148440. * @param emitter defines the emitter to use
  148441. * @param capacity defines the system capacity (default is 500 particles)
  148442. * @param scene defines the hosting scene
  148443. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  148444. * @returns the new Particle system
  148445. */
  148446. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  148447. /**
  148448. * This is the main static method (one-liner) of this helper to create different particle systems
  148449. * @param type This string represents the type to the particle system to create
  148450. * @param scene The scene where the particle system should live
  148451. * @param gpu If the system will use gpu
  148452. * @returns the ParticleSystemSet created
  148453. */
  148454. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  148455. /**
  148456. * Static function used to export a particle system to a ParticleSystemSet variable.
  148457. * Please note that the emitter shape is not exported
  148458. * @param systems defines the particle systems to export
  148459. * @returns the created particle system set
  148460. */
  148461. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  148462. /**
  148463. * Creates a particle system from a snippet saved in a remote file
  148464. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  148465. * @param url defines the url to load from
  148466. * @param scene defines the hosting scene
  148467. * @param gpu If the system will use gpu
  148468. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  148469. * @returns a promise that will resolve to the new particle system
  148470. */
  148471. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  148472. /**
  148473. * Creates a particle system from a snippet saved by the particle system editor
  148474. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  148475. * @param scene defines the hosting scene
  148476. * @param gpu If the system will use gpu
  148477. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  148478. * @returns a promise that will resolve to the new particle system
  148479. */
  148480. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  148481. }
  148482. }
  148483. declare module BABYLON {
  148484. interface Engine {
  148485. /**
  148486. * Create an effect to use with particle systems.
  148487. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  148488. * the particle system for which you want to create a custom effect in the last parameter
  148489. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  148490. * @param uniformsNames defines a list of attribute names
  148491. * @param samplers defines an array of string used to represent textures
  148492. * @param defines defines the string containing the defines to use to compile the shaders
  148493. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  148494. * @param onCompiled defines a function to call when the effect creation is successful
  148495. * @param onError defines a function to call when the effect creation has failed
  148496. * @param particleSystem the particle system you want to create the effect for
  148497. * @returns the new Effect
  148498. */
  148499. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  148500. }
  148501. interface Mesh {
  148502. /**
  148503. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  148504. * @returns an array of IParticleSystem
  148505. */
  148506. getEmittedParticleSystems(): IParticleSystem[];
  148507. /**
  148508. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  148509. * @returns an array of IParticleSystem
  148510. */
  148511. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  148512. }
  148513. }
  148514. declare module BABYLON {
  148515. /** Defines the 4 color options */
  148516. export enum PointColor {
  148517. /** color value */
  148518. Color = 2,
  148519. /** uv value */
  148520. UV = 1,
  148521. /** random value */
  148522. Random = 0,
  148523. /** stated value */
  148524. Stated = 3
  148525. }
  148526. /**
  148527. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  148528. * 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.
  148529. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  148530. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  148531. *
  148532. * Full documentation here : TO BE ENTERED
  148533. */
  148534. export class PointsCloudSystem implements IDisposable {
  148535. /**
  148536. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  148537. * Example : var p = SPS.particles[i];
  148538. */
  148539. particles: CloudPoint[];
  148540. /**
  148541. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  148542. */
  148543. nbParticles: number;
  148544. /**
  148545. * This a counter for your own usage. It's not set by any SPS functions.
  148546. */
  148547. counter: number;
  148548. /**
  148549. * The PCS name. This name is also given to the underlying mesh.
  148550. */
  148551. name: string;
  148552. /**
  148553. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  148554. */
  148555. mesh: Mesh;
  148556. /**
  148557. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  148558. * Please read :
  148559. */
  148560. vars: any;
  148561. /**
  148562. * @hidden
  148563. */
  148564. _size: number;
  148565. private _scene;
  148566. private _promises;
  148567. private _positions;
  148568. private _indices;
  148569. private _normals;
  148570. private _colors;
  148571. private _uvs;
  148572. private _indices32;
  148573. private _positions32;
  148574. private _colors32;
  148575. private _uvs32;
  148576. private _updatable;
  148577. private _isVisibilityBoxLocked;
  148578. private _alwaysVisible;
  148579. private _groups;
  148580. private _groupCounter;
  148581. private _computeParticleColor;
  148582. private _computeParticleTexture;
  148583. private _computeParticleRotation;
  148584. private _computeBoundingBox;
  148585. private _isReady;
  148586. /**
  148587. * Creates a PCS (Points Cloud System) object
  148588. * @param name (String) is the PCS name, this will be the underlying mesh name
  148589. * @param pointSize (number) is the size for each point
  148590. * @param scene (Scene) is the scene in which the PCS is added
  148591. * @param options defines the options of the PCS e.g.
  148592. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  148593. */
  148594. constructor(name: string, pointSize: number, scene: Scene, options?: {
  148595. updatable?: boolean;
  148596. });
  148597. /**
  148598. * Builds the PCS underlying mesh. Returns a standard Mesh.
  148599. * If no points were added to the PCS, the returned mesh is just a single point.
  148600. * @returns a promise for the created mesh
  148601. */
  148602. buildMeshAsync(): Promise<Mesh>;
  148603. /**
  148604. * @hidden
  148605. */
  148606. private _buildMesh;
  148607. private _addParticle;
  148608. private _randomUnitVector;
  148609. private _getColorIndicesForCoord;
  148610. private _setPointsColorOrUV;
  148611. private _colorFromTexture;
  148612. private _calculateDensity;
  148613. /**
  148614. * Adds points to the PCS in random positions within a unit sphere
  148615. * @param nb (positive integer) the number of particles to be created from this model
  148616. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  148617. * @returns the number of groups in the system
  148618. */
  148619. addPoints(nb: number, pointFunction?: any): number;
  148620. /**
  148621. * Adds points to the PCS from the surface of the model shape
  148622. * @param mesh is any Mesh object that will be used as a surface model for the points
  148623. * @param nb (positive integer) the number of particles to be created from this model
  148624. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148625. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148626. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148627. * @returns the number of groups in the system
  148628. */
  148629. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148630. /**
  148631. * Adds points to the PCS inside the model shape
  148632. * @param mesh is any Mesh object that will be used as a surface model for the points
  148633. * @param nb (positive integer) the number of particles to be created from this model
  148634. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148635. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148636. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148637. * @returns the number of groups in the system
  148638. */
  148639. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148640. /**
  148641. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  148642. * This method calls `updateParticle()` for each particle of the SPS.
  148643. * For an animated SPS, it is usually called within the render loop.
  148644. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  148645. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  148646. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  148647. * @returns the PCS.
  148648. */
  148649. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  148650. /**
  148651. * Disposes the PCS.
  148652. */
  148653. dispose(): void;
  148654. /**
  148655. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  148656. * doc :
  148657. * @returns the PCS.
  148658. */
  148659. refreshVisibleSize(): PointsCloudSystem;
  148660. /**
  148661. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  148662. * @param size the size (float) of the visibility box
  148663. * note : this doesn't lock the PCS mesh bounding box.
  148664. * doc :
  148665. */
  148666. setVisibilityBox(size: number): void;
  148667. /**
  148668. * Gets whether the PCS is always visible or not
  148669. * doc :
  148670. */
  148671. get isAlwaysVisible(): boolean;
  148672. /**
  148673. * Sets the PCS as always visible or not
  148674. * doc :
  148675. */
  148676. set isAlwaysVisible(val: boolean);
  148677. /**
  148678. * Tells to `setParticles()` to compute the particle rotations or not
  148679. * Default value : false. The PCS is faster when it's set to false
  148680. * Note : particle rotations are only applied to parent particles
  148681. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  148682. */
  148683. set computeParticleRotation(val: boolean);
  148684. /**
  148685. * Tells to `setParticles()` to compute the particle colors or not.
  148686. * Default value : true. The PCS is faster when it's set to false.
  148687. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148688. */
  148689. set computeParticleColor(val: boolean);
  148690. set computeParticleTexture(val: boolean);
  148691. /**
  148692. * Gets if `setParticles()` computes the particle colors or not.
  148693. * Default value : false. The PCS is faster when it's set to false.
  148694. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148695. */
  148696. get computeParticleColor(): boolean;
  148697. /**
  148698. * Gets if `setParticles()` computes the particle textures or not.
  148699. * Default value : false. The PCS is faster when it's set to false.
  148700. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  148701. */
  148702. get computeParticleTexture(): boolean;
  148703. /**
  148704. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  148705. */
  148706. set computeBoundingBox(val: boolean);
  148707. /**
  148708. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  148709. */
  148710. get computeBoundingBox(): boolean;
  148711. /**
  148712. * This function does nothing. It may be overwritten to set all the particle first values.
  148713. * The PCS doesn't call this function, you may have to call it by your own.
  148714. * doc :
  148715. */
  148716. initParticles(): void;
  148717. /**
  148718. * This function does nothing. It may be overwritten to recycle a particle
  148719. * The PCS doesn't call this function, you can to call it
  148720. * doc :
  148721. * @param particle The particle to recycle
  148722. * @returns the recycled particle
  148723. */
  148724. recycleParticle(particle: CloudPoint): CloudPoint;
  148725. /**
  148726. * Updates a particle : this function should be overwritten by the user.
  148727. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  148728. * doc :
  148729. * @example : just set a particle position or velocity and recycle conditions
  148730. * @param particle The particle to update
  148731. * @returns the updated particle
  148732. */
  148733. updateParticle(particle: CloudPoint): CloudPoint;
  148734. /**
  148735. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  148736. * This does nothing and may be overwritten by the user.
  148737. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148738. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148739. * @param update the boolean update value actually passed to setParticles()
  148740. */
  148741. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148742. /**
  148743. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  148744. * This will be passed three parameters.
  148745. * This does nothing and may be overwritten by the user.
  148746. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148747. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148748. * @param update the boolean update value actually passed to setParticles()
  148749. */
  148750. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148751. }
  148752. }
  148753. declare module BABYLON {
  148754. /**
  148755. * Represents one particle of a points cloud system.
  148756. */
  148757. export class CloudPoint {
  148758. /**
  148759. * particle global index
  148760. */
  148761. idx: number;
  148762. /**
  148763. * The color of the particle
  148764. */
  148765. color: Nullable<Color4>;
  148766. /**
  148767. * The world space position of the particle.
  148768. */
  148769. position: Vector3;
  148770. /**
  148771. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  148772. */
  148773. rotation: Vector3;
  148774. /**
  148775. * The world space rotation quaternion of the particle.
  148776. */
  148777. rotationQuaternion: Nullable<Quaternion>;
  148778. /**
  148779. * The uv of the particle.
  148780. */
  148781. uv: Nullable<Vector2>;
  148782. /**
  148783. * The current speed of the particle.
  148784. */
  148785. velocity: Vector3;
  148786. /**
  148787. * The pivot point in the particle local space.
  148788. */
  148789. pivot: Vector3;
  148790. /**
  148791. * Must the particle be translated from its pivot point in its local space ?
  148792. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  148793. * Default : false
  148794. */
  148795. translateFromPivot: boolean;
  148796. /**
  148797. * Index of this particle in the global "positions" array (Internal use)
  148798. * @hidden
  148799. */
  148800. _pos: number;
  148801. /**
  148802. * @hidden Index of this particle in the global "indices" array (Internal use)
  148803. */
  148804. _ind: number;
  148805. /**
  148806. * Group this particle belongs to
  148807. */
  148808. _group: PointsGroup;
  148809. /**
  148810. * Group id of this particle
  148811. */
  148812. groupId: number;
  148813. /**
  148814. * Index of the particle in its group id (Internal use)
  148815. */
  148816. idxInGroup: number;
  148817. /**
  148818. * @hidden Particle BoundingInfo object (Internal use)
  148819. */
  148820. _boundingInfo: BoundingInfo;
  148821. /**
  148822. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  148823. */
  148824. _pcs: PointsCloudSystem;
  148825. /**
  148826. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  148827. */
  148828. _stillInvisible: boolean;
  148829. /**
  148830. * @hidden Last computed particle rotation matrix
  148831. */
  148832. _rotationMatrix: number[];
  148833. /**
  148834. * Parent particle Id, if any.
  148835. * Default null.
  148836. */
  148837. parentId: Nullable<number>;
  148838. /**
  148839. * @hidden Internal global position in the PCS.
  148840. */
  148841. _globalPosition: Vector3;
  148842. /**
  148843. * Creates a Point Cloud object.
  148844. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  148845. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  148846. * @param group (PointsGroup) is the group the particle belongs to
  148847. * @param groupId (integer) is the group identifier in the PCS.
  148848. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  148849. * @param pcs defines the PCS it is associated to
  148850. */
  148851. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  148852. /**
  148853. * get point size
  148854. */
  148855. get size(): Vector3;
  148856. /**
  148857. * Set point size
  148858. */
  148859. set size(scale: Vector3);
  148860. /**
  148861. * Legacy support, changed quaternion to rotationQuaternion
  148862. */
  148863. get quaternion(): Nullable<Quaternion>;
  148864. /**
  148865. * Legacy support, changed quaternion to rotationQuaternion
  148866. */
  148867. set quaternion(q: Nullable<Quaternion>);
  148868. /**
  148869. * Returns a boolean. True if the particle intersects a mesh, else false
  148870. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  148871. * @param target is the object (point or mesh) what the intersection is computed against
  148872. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  148873. * @returns true if it intersects
  148874. */
  148875. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  148876. /**
  148877. * get the rotation matrix of the particle
  148878. * @hidden
  148879. */
  148880. getRotationMatrix(m: Matrix): void;
  148881. }
  148882. /**
  148883. * Represents a group of points in a points cloud system
  148884. * * PCS internal tool, don't use it manually.
  148885. */
  148886. export class PointsGroup {
  148887. /**
  148888. * The group id
  148889. * @hidden
  148890. */
  148891. groupID: number;
  148892. /**
  148893. * image data for group (internal use)
  148894. * @hidden
  148895. */
  148896. _groupImageData: Nullable<ArrayBufferView>;
  148897. /**
  148898. * Image Width (internal use)
  148899. * @hidden
  148900. */
  148901. _groupImgWidth: number;
  148902. /**
  148903. * Image Height (internal use)
  148904. * @hidden
  148905. */
  148906. _groupImgHeight: number;
  148907. /**
  148908. * Custom position function (internal use)
  148909. * @hidden
  148910. */
  148911. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  148912. /**
  148913. * density per facet for surface points
  148914. * @hidden
  148915. */
  148916. _groupDensity: number[];
  148917. /**
  148918. * Only when points are colored by texture carries pointer to texture list array
  148919. * @hidden
  148920. */
  148921. _textureNb: number;
  148922. /**
  148923. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  148924. * PCS internal tool, don't use it manually.
  148925. * @hidden
  148926. */
  148927. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  148928. }
  148929. }
  148930. declare module BABYLON {
  148931. interface Scene {
  148932. /** @hidden (Backing field) */
  148933. _physicsEngine: Nullable<IPhysicsEngine>;
  148934. /** @hidden */
  148935. _physicsTimeAccumulator: number;
  148936. /**
  148937. * Gets the current physics engine
  148938. * @returns a IPhysicsEngine or null if none attached
  148939. */
  148940. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  148941. /**
  148942. * Enables physics to the current scene
  148943. * @param gravity defines the scene's gravity for the physics engine
  148944. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  148945. * @return a boolean indicating if the physics engine was initialized
  148946. */
  148947. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  148948. /**
  148949. * Disables and disposes the physics engine associated with the scene
  148950. */
  148951. disablePhysicsEngine(): void;
  148952. /**
  148953. * Gets a boolean indicating if there is an active physics engine
  148954. * @returns a boolean indicating if there is an active physics engine
  148955. */
  148956. isPhysicsEnabled(): boolean;
  148957. /**
  148958. * Deletes a physics compound impostor
  148959. * @param compound defines the compound to delete
  148960. */
  148961. deleteCompoundImpostor(compound: any): void;
  148962. /**
  148963. * An event triggered when physic simulation is about to be run
  148964. */
  148965. onBeforePhysicsObservable: Observable<Scene>;
  148966. /**
  148967. * An event triggered when physic simulation has been done
  148968. */
  148969. onAfterPhysicsObservable: Observable<Scene>;
  148970. }
  148971. interface AbstractMesh {
  148972. /** @hidden */
  148973. _physicsImpostor: Nullable<PhysicsImpostor>;
  148974. /**
  148975. * Gets or sets impostor used for physic simulation
  148976. * @see https://doc.babylonjs.com/features/physics_engine
  148977. */
  148978. physicsImpostor: Nullable<PhysicsImpostor>;
  148979. /**
  148980. * Gets the current physics impostor
  148981. * @see https://doc.babylonjs.com/features/physics_engine
  148982. * @returns a physics impostor or null
  148983. */
  148984. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  148985. /** Apply a physic impulse to the mesh
  148986. * @param force defines the force to apply
  148987. * @param contactPoint defines where to apply the force
  148988. * @returns the current mesh
  148989. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  148990. */
  148991. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  148992. /**
  148993. * Creates a physic joint between two meshes
  148994. * @param otherMesh defines the other mesh to use
  148995. * @param pivot1 defines the pivot to use on this mesh
  148996. * @param pivot2 defines the pivot to use on the other mesh
  148997. * @param options defines additional options (can be plugin dependent)
  148998. * @returns the current mesh
  148999. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  149000. */
  149001. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  149002. /** @hidden */
  149003. _disposePhysicsObserver: Nullable<Observer<Node>>;
  149004. }
  149005. /**
  149006. * Defines the physics engine scene component responsible to manage a physics engine
  149007. */
  149008. export class PhysicsEngineSceneComponent implements ISceneComponent {
  149009. /**
  149010. * The component name helpful to identify the component in the list of scene components.
  149011. */
  149012. readonly name: string;
  149013. /**
  149014. * The scene the component belongs to.
  149015. */
  149016. scene: Scene;
  149017. /**
  149018. * Creates a new instance of the component for the given scene
  149019. * @param scene Defines the scene to register the component in
  149020. */
  149021. constructor(scene: Scene);
  149022. /**
  149023. * Registers the component in a given scene
  149024. */
  149025. register(): void;
  149026. /**
  149027. * Rebuilds the elements related to this component in case of
  149028. * context lost for instance.
  149029. */
  149030. rebuild(): void;
  149031. /**
  149032. * Disposes the component and the associated ressources
  149033. */
  149034. dispose(): void;
  149035. }
  149036. }
  149037. declare module BABYLON {
  149038. /**
  149039. * A helper for physics simulations
  149040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149041. */
  149042. export class PhysicsHelper {
  149043. private _scene;
  149044. private _physicsEngine;
  149045. /**
  149046. * Initializes the Physics helper
  149047. * @param scene Babylon.js scene
  149048. */
  149049. constructor(scene: Scene);
  149050. /**
  149051. * Applies a radial explosion impulse
  149052. * @param origin the origin of the explosion
  149053. * @param radiusOrEventOptions the radius or the options of radial explosion
  149054. * @param strength the explosion strength
  149055. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149056. * @returns A physics radial explosion event, or null
  149057. */
  149058. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  149059. /**
  149060. * Applies a radial explosion force
  149061. * @param origin the origin of the explosion
  149062. * @param radiusOrEventOptions the radius or the options of radial explosion
  149063. * @param strength the explosion strength
  149064. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149065. * @returns A physics radial explosion event, or null
  149066. */
  149067. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  149068. /**
  149069. * Creates a gravitational field
  149070. * @param origin the origin of the explosion
  149071. * @param radiusOrEventOptions the radius or the options of radial explosion
  149072. * @param strength the explosion strength
  149073. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149074. * @returns A physics gravitational field event, or null
  149075. */
  149076. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  149077. /**
  149078. * Creates a physics updraft event
  149079. * @param origin the origin of the updraft
  149080. * @param radiusOrEventOptions the radius or the options of the updraft
  149081. * @param strength the strength of the updraft
  149082. * @param height the height of the updraft
  149083. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  149084. * @returns A physics updraft event, or null
  149085. */
  149086. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  149087. /**
  149088. * Creates a physics vortex event
  149089. * @param origin the of the vortex
  149090. * @param radiusOrEventOptions the radius or the options of the vortex
  149091. * @param strength the strength of the vortex
  149092. * @param height the height of the vortex
  149093. * @returns a Physics vortex event, or null
  149094. * A physics vortex event or null
  149095. */
  149096. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  149097. }
  149098. /**
  149099. * Represents a physics radial explosion event
  149100. */
  149101. class PhysicsRadialExplosionEvent {
  149102. private _scene;
  149103. private _options;
  149104. private _sphere;
  149105. private _dataFetched;
  149106. /**
  149107. * Initializes a radial explosioin event
  149108. * @param _scene BabylonJS scene
  149109. * @param _options The options for the vortex event
  149110. */
  149111. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  149112. /**
  149113. * Returns the data related to the radial explosion event (sphere).
  149114. * @returns The radial explosion event data
  149115. */
  149116. getData(): PhysicsRadialExplosionEventData;
  149117. /**
  149118. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  149119. * @param impostor A physics imposter
  149120. * @param origin the origin of the explosion
  149121. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  149122. */
  149123. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  149124. /**
  149125. * Triggers affecterd impostors callbacks
  149126. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  149127. */
  149128. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  149129. /**
  149130. * Disposes the sphere.
  149131. * @param force Specifies if the sphere should be disposed by force
  149132. */
  149133. dispose(force?: boolean): void;
  149134. /*** Helpers ***/
  149135. private _prepareSphere;
  149136. private _intersectsWithSphere;
  149137. }
  149138. /**
  149139. * Represents a gravitational field event
  149140. */
  149141. class PhysicsGravitationalFieldEvent {
  149142. private _physicsHelper;
  149143. private _scene;
  149144. private _origin;
  149145. private _options;
  149146. private _tickCallback;
  149147. private _sphere;
  149148. private _dataFetched;
  149149. /**
  149150. * Initializes the physics gravitational field event
  149151. * @param _physicsHelper A physics helper
  149152. * @param _scene BabylonJS scene
  149153. * @param _origin The origin position of the gravitational field event
  149154. * @param _options The options for the vortex event
  149155. */
  149156. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  149157. /**
  149158. * Returns the data related to the gravitational field event (sphere).
  149159. * @returns A gravitational field event
  149160. */
  149161. getData(): PhysicsGravitationalFieldEventData;
  149162. /**
  149163. * Enables the gravitational field.
  149164. */
  149165. enable(): void;
  149166. /**
  149167. * Disables the gravitational field.
  149168. */
  149169. disable(): void;
  149170. /**
  149171. * Disposes the sphere.
  149172. * @param force The force to dispose from the gravitational field event
  149173. */
  149174. dispose(force?: boolean): void;
  149175. private _tick;
  149176. }
  149177. /**
  149178. * Represents a physics updraft event
  149179. */
  149180. class PhysicsUpdraftEvent {
  149181. private _scene;
  149182. private _origin;
  149183. private _options;
  149184. private _physicsEngine;
  149185. private _originTop;
  149186. private _originDirection;
  149187. private _tickCallback;
  149188. private _cylinder;
  149189. private _cylinderPosition;
  149190. private _dataFetched;
  149191. /**
  149192. * Initializes the physics updraft event
  149193. * @param _scene BabylonJS scene
  149194. * @param _origin The origin position of the updraft
  149195. * @param _options The options for the updraft event
  149196. */
  149197. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  149198. /**
  149199. * Returns the data related to the updraft event (cylinder).
  149200. * @returns A physics updraft event
  149201. */
  149202. getData(): PhysicsUpdraftEventData;
  149203. /**
  149204. * Enables the updraft.
  149205. */
  149206. enable(): void;
  149207. /**
  149208. * Disables the updraft.
  149209. */
  149210. disable(): void;
  149211. /**
  149212. * Disposes the cylinder.
  149213. * @param force Specifies if the updraft should be disposed by force
  149214. */
  149215. dispose(force?: boolean): void;
  149216. private getImpostorHitData;
  149217. private _tick;
  149218. /*** Helpers ***/
  149219. private _prepareCylinder;
  149220. private _intersectsWithCylinder;
  149221. }
  149222. /**
  149223. * Represents a physics vortex event
  149224. */
  149225. class PhysicsVortexEvent {
  149226. private _scene;
  149227. private _origin;
  149228. private _options;
  149229. private _physicsEngine;
  149230. private _originTop;
  149231. private _tickCallback;
  149232. private _cylinder;
  149233. private _cylinderPosition;
  149234. private _dataFetched;
  149235. /**
  149236. * Initializes the physics vortex event
  149237. * @param _scene The BabylonJS scene
  149238. * @param _origin The origin position of the vortex
  149239. * @param _options The options for the vortex event
  149240. */
  149241. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  149242. /**
  149243. * Returns the data related to the vortex event (cylinder).
  149244. * @returns The physics vortex event data
  149245. */
  149246. getData(): PhysicsVortexEventData;
  149247. /**
  149248. * Enables the vortex.
  149249. */
  149250. enable(): void;
  149251. /**
  149252. * Disables the cortex.
  149253. */
  149254. disable(): void;
  149255. /**
  149256. * Disposes the sphere.
  149257. * @param force
  149258. */
  149259. dispose(force?: boolean): void;
  149260. private getImpostorHitData;
  149261. private _tick;
  149262. /*** Helpers ***/
  149263. private _prepareCylinder;
  149264. private _intersectsWithCylinder;
  149265. }
  149266. /**
  149267. * Options fot the radial explosion event
  149268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149269. */
  149270. export class PhysicsRadialExplosionEventOptions {
  149271. /**
  149272. * The radius of the sphere for the radial explosion.
  149273. */
  149274. radius: number;
  149275. /**
  149276. * The strenth of the explosion.
  149277. */
  149278. strength: number;
  149279. /**
  149280. * The strenght of the force in correspondence to the distance of the affected object
  149281. */
  149282. falloff: PhysicsRadialImpulseFalloff;
  149283. /**
  149284. * Sphere options for the radial explosion.
  149285. */
  149286. sphere: {
  149287. segments: number;
  149288. diameter: number;
  149289. };
  149290. /**
  149291. * Sphere options for the radial explosion.
  149292. */
  149293. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  149294. }
  149295. /**
  149296. * Options fot the updraft event
  149297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149298. */
  149299. export class PhysicsUpdraftEventOptions {
  149300. /**
  149301. * The radius of the cylinder for the vortex
  149302. */
  149303. radius: number;
  149304. /**
  149305. * The strenth of the updraft.
  149306. */
  149307. strength: number;
  149308. /**
  149309. * The height of the cylinder for the updraft.
  149310. */
  149311. height: number;
  149312. /**
  149313. * The mode for the the updraft.
  149314. */
  149315. updraftMode: PhysicsUpdraftMode;
  149316. }
  149317. /**
  149318. * Options fot the vortex event
  149319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149320. */
  149321. export class PhysicsVortexEventOptions {
  149322. /**
  149323. * The radius of the cylinder for the vortex
  149324. */
  149325. radius: number;
  149326. /**
  149327. * The strenth of the vortex.
  149328. */
  149329. strength: number;
  149330. /**
  149331. * The height of the cylinder for the vortex.
  149332. */
  149333. height: number;
  149334. /**
  149335. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  149336. */
  149337. centripetalForceThreshold: number;
  149338. /**
  149339. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  149340. */
  149341. centripetalForceMultiplier: number;
  149342. /**
  149343. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  149344. */
  149345. centrifugalForceMultiplier: number;
  149346. /**
  149347. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  149348. */
  149349. updraftForceMultiplier: number;
  149350. }
  149351. /**
  149352. * The strenght of the force in correspondence to the distance of the affected object
  149353. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149354. */
  149355. export enum PhysicsRadialImpulseFalloff {
  149356. /** Defines that impulse is constant in strength across it's whole radius */
  149357. Constant = 0,
  149358. /** Defines that impulse gets weaker if it's further from the origin */
  149359. Linear = 1
  149360. }
  149361. /**
  149362. * The strength of the force in correspondence to the distance of the affected object
  149363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149364. */
  149365. export enum PhysicsUpdraftMode {
  149366. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  149367. Center = 0,
  149368. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  149369. Perpendicular = 1
  149370. }
  149371. /**
  149372. * Interface for a physics hit data
  149373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149374. */
  149375. export interface PhysicsHitData {
  149376. /**
  149377. * The force applied at the contact point
  149378. */
  149379. force: Vector3;
  149380. /**
  149381. * The contact point
  149382. */
  149383. contactPoint: Vector3;
  149384. /**
  149385. * The distance from the origin to the contact point
  149386. */
  149387. distanceFromOrigin: number;
  149388. }
  149389. /**
  149390. * Interface for radial explosion event data
  149391. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149392. */
  149393. export interface PhysicsRadialExplosionEventData {
  149394. /**
  149395. * A sphere used for the radial explosion event
  149396. */
  149397. sphere: Mesh;
  149398. }
  149399. /**
  149400. * Interface for gravitational field event data
  149401. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149402. */
  149403. export interface PhysicsGravitationalFieldEventData {
  149404. /**
  149405. * A sphere mesh used for the gravitational field event
  149406. */
  149407. sphere: Mesh;
  149408. }
  149409. /**
  149410. * Interface for updraft event data
  149411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149412. */
  149413. export interface PhysicsUpdraftEventData {
  149414. /**
  149415. * A cylinder used for the updraft event
  149416. */
  149417. cylinder: Mesh;
  149418. }
  149419. /**
  149420. * Interface for vortex event data
  149421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149422. */
  149423. export interface PhysicsVortexEventData {
  149424. /**
  149425. * A cylinder used for the vortex event
  149426. */
  149427. cylinder: Mesh;
  149428. }
  149429. /**
  149430. * Interface for an affected physics impostor
  149431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149432. */
  149433. export interface PhysicsAffectedImpostorWithData {
  149434. /**
  149435. * The impostor affected by the effect
  149436. */
  149437. impostor: PhysicsImpostor;
  149438. /**
  149439. * The data about the hit/horce from the explosion
  149440. */
  149441. hitData: PhysicsHitData;
  149442. }
  149443. }
  149444. declare module BABYLON {
  149445. /** @hidden */
  149446. export var blackAndWhitePixelShader: {
  149447. name: string;
  149448. shader: string;
  149449. };
  149450. }
  149451. declare module BABYLON {
  149452. /**
  149453. * Post process used to render in black and white
  149454. */
  149455. export class BlackAndWhitePostProcess extends PostProcess {
  149456. /**
  149457. * Linear about to convert he result to black and white (default: 1)
  149458. */
  149459. degree: number;
  149460. /**
  149461. * Gets a string identifying the name of the class
  149462. * @returns "BlackAndWhitePostProcess" string
  149463. */
  149464. getClassName(): string;
  149465. /**
  149466. * Creates a black and white post process
  149467. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  149468. * @param name The name of the effect.
  149469. * @param options The required width/height ratio to downsize to before computing the render pass.
  149470. * @param camera The camera to apply the render pass to.
  149471. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149472. * @param engine The engine which the post process will be applied. (default: current engine)
  149473. * @param reusable If the post process can be reused on the same frame. (default: false)
  149474. */
  149475. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149476. /** @hidden */
  149477. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  149478. }
  149479. }
  149480. declare module BABYLON {
  149481. /**
  149482. * This represents a set of one or more post processes in Babylon.
  149483. * A post process can be used to apply a shader to a texture after it is rendered.
  149484. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149485. */
  149486. export class PostProcessRenderEffect {
  149487. private _postProcesses;
  149488. private _getPostProcesses;
  149489. private _singleInstance;
  149490. private _cameras;
  149491. private _indicesForCamera;
  149492. /**
  149493. * Name of the effect
  149494. * @hidden
  149495. */
  149496. _name: string;
  149497. /**
  149498. * Instantiates a post process render effect.
  149499. * A post process can be used to apply a shader to a texture after it is rendered.
  149500. * @param engine The engine the effect is tied to
  149501. * @param name The name of the effect
  149502. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  149503. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  149504. */
  149505. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  149506. /**
  149507. * Checks if all the post processes in the effect are supported.
  149508. */
  149509. get isSupported(): boolean;
  149510. /**
  149511. * Updates the current state of the effect
  149512. * @hidden
  149513. */
  149514. _update(): void;
  149515. /**
  149516. * Attaches the effect on cameras
  149517. * @param cameras The camera to attach to.
  149518. * @hidden
  149519. */
  149520. _attachCameras(cameras: Camera): void;
  149521. /**
  149522. * Attaches the effect on cameras
  149523. * @param cameras The camera to attach to.
  149524. * @hidden
  149525. */
  149526. _attachCameras(cameras: Camera[]): void;
  149527. /**
  149528. * Detaches the effect on cameras
  149529. * @param cameras The camera to detatch from.
  149530. * @hidden
  149531. */
  149532. _detachCameras(cameras: Camera): void;
  149533. /**
  149534. * Detatches the effect on cameras
  149535. * @param cameras The camera to detatch from.
  149536. * @hidden
  149537. */
  149538. _detachCameras(cameras: Camera[]): void;
  149539. /**
  149540. * Enables the effect on given cameras
  149541. * @param cameras The camera to enable.
  149542. * @hidden
  149543. */
  149544. _enable(cameras: Camera): void;
  149545. /**
  149546. * Enables the effect on given cameras
  149547. * @param cameras The camera to enable.
  149548. * @hidden
  149549. */
  149550. _enable(cameras: Nullable<Camera[]>): void;
  149551. /**
  149552. * Disables the effect on the given cameras
  149553. * @param cameras The camera to disable.
  149554. * @hidden
  149555. */
  149556. _disable(cameras: Camera): void;
  149557. /**
  149558. * Disables the effect on the given cameras
  149559. * @param cameras The camera to disable.
  149560. * @hidden
  149561. */
  149562. _disable(cameras: Nullable<Camera[]>): void;
  149563. /**
  149564. * Gets a list of the post processes contained in the effect.
  149565. * @param camera The camera to get the post processes on.
  149566. * @returns The list of the post processes in the effect.
  149567. */
  149568. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  149569. }
  149570. }
  149571. declare module BABYLON {
  149572. /** @hidden */
  149573. export var extractHighlightsPixelShader: {
  149574. name: string;
  149575. shader: string;
  149576. };
  149577. }
  149578. declare module BABYLON {
  149579. /**
  149580. * 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.
  149581. */
  149582. export class ExtractHighlightsPostProcess extends PostProcess {
  149583. /**
  149584. * The luminance threshold, pixels below this value will be set to black.
  149585. */
  149586. threshold: number;
  149587. /** @hidden */
  149588. _exposure: number;
  149589. /**
  149590. * Post process which has the input texture to be used when performing highlight extraction
  149591. * @hidden
  149592. */
  149593. _inputPostProcess: Nullable<PostProcess>;
  149594. /**
  149595. * Gets a string identifying the name of the class
  149596. * @returns "ExtractHighlightsPostProcess" string
  149597. */
  149598. getClassName(): string;
  149599. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149600. }
  149601. }
  149602. declare module BABYLON {
  149603. /** @hidden */
  149604. export var bloomMergePixelShader: {
  149605. name: string;
  149606. shader: string;
  149607. };
  149608. }
  149609. declare module BABYLON {
  149610. /**
  149611. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149612. */
  149613. export class BloomMergePostProcess extends PostProcess {
  149614. /** Weight of the bloom to be added to the original input. */
  149615. weight: number;
  149616. /**
  149617. * Gets a string identifying the name of the class
  149618. * @returns "BloomMergePostProcess" string
  149619. */
  149620. getClassName(): string;
  149621. /**
  149622. * Creates a new instance of @see BloomMergePostProcess
  149623. * @param name The name of the effect.
  149624. * @param originalFromInput Post process which's input will be used for the merge.
  149625. * @param blurred Blurred highlights post process which's output will be used.
  149626. * @param weight Weight of the bloom to be added to the original input.
  149627. * @param options The required width/height ratio to downsize to before computing the render pass.
  149628. * @param camera The camera to apply the render pass to.
  149629. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149630. * @param engine The engine which the post process will be applied. (default: current engine)
  149631. * @param reusable If the post process can be reused on the same frame. (default: false)
  149632. * @param textureType Type of textures used when performing the post process. (default: 0)
  149633. * @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)
  149634. */
  149635. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  149636. /** Weight of the bloom to be added to the original input. */
  149637. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149638. }
  149639. }
  149640. declare module BABYLON {
  149641. /**
  149642. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  149643. */
  149644. export class BloomEffect extends PostProcessRenderEffect {
  149645. private bloomScale;
  149646. /**
  149647. * @hidden Internal
  149648. */
  149649. _effects: Array<PostProcess>;
  149650. /**
  149651. * @hidden Internal
  149652. */
  149653. _downscale: ExtractHighlightsPostProcess;
  149654. private _blurX;
  149655. private _blurY;
  149656. private _merge;
  149657. /**
  149658. * The luminance threshold to find bright areas of the image to bloom.
  149659. */
  149660. get threshold(): number;
  149661. set threshold(value: number);
  149662. /**
  149663. * The strength of the bloom.
  149664. */
  149665. get weight(): number;
  149666. set weight(value: number);
  149667. /**
  149668. * Specifies the size of the bloom blur kernel, relative to the final output size
  149669. */
  149670. get kernel(): number;
  149671. set kernel(value: number);
  149672. /**
  149673. * Creates a new instance of @see BloomEffect
  149674. * @param scene The scene the effect belongs to.
  149675. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  149676. * @param bloomKernel The size of the kernel to be used when applying the blur.
  149677. * @param bloomWeight The the strength of bloom.
  149678. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149679. * @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)
  149680. */
  149681. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  149682. /**
  149683. * Disposes each of the internal effects for a given camera.
  149684. * @param camera The camera to dispose the effect on.
  149685. */
  149686. disposeEffects(camera: Camera): void;
  149687. /**
  149688. * @hidden Internal
  149689. */
  149690. _updateEffects(): void;
  149691. /**
  149692. * Internal
  149693. * @returns if all the contained post processes are ready.
  149694. * @hidden
  149695. */
  149696. _isReady(): boolean;
  149697. }
  149698. }
  149699. declare module BABYLON {
  149700. /** @hidden */
  149701. export var chromaticAberrationPixelShader: {
  149702. name: string;
  149703. shader: string;
  149704. };
  149705. }
  149706. declare module BABYLON {
  149707. /**
  149708. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  149709. */
  149710. export class ChromaticAberrationPostProcess extends PostProcess {
  149711. /**
  149712. * The amount of seperation of rgb channels (default: 30)
  149713. */
  149714. aberrationAmount: number;
  149715. /**
  149716. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  149717. */
  149718. radialIntensity: number;
  149719. /**
  149720. * 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))
  149721. */
  149722. direction: Vector2;
  149723. /**
  149724. * 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))
  149725. */
  149726. centerPosition: Vector2;
  149727. /** The width of the screen to apply the effect on */
  149728. screenWidth: number;
  149729. /** The height of the screen to apply the effect on */
  149730. screenHeight: number;
  149731. /**
  149732. * Gets a string identifying the name of the class
  149733. * @returns "ChromaticAberrationPostProcess" string
  149734. */
  149735. getClassName(): string;
  149736. /**
  149737. * Creates a new instance ChromaticAberrationPostProcess
  149738. * @param name The name of the effect.
  149739. * @param screenWidth The width of the screen to apply the effect on.
  149740. * @param screenHeight The height of the screen to apply the effect on.
  149741. * @param options The required width/height ratio to downsize to before computing the render pass.
  149742. * @param camera The camera to apply the render pass to.
  149743. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149744. * @param engine The engine which the post process will be applied. (default: current engine)
  149745. * @param reusable If the post process can be reused on the same frame. (default: false)
  149746. * @param textureType Type of textures used when performing the post process. (default: 0)
  149747. * @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)
  149748. */
  149749. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149750. /** @hidden */
  149751. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  149752. }
  149753. }
  149754. declare module BABYLON {
  149755. /** @hidden */
  149756. export var circleOfConfusionPixelShader: {
  149757. name: string;
  149758. shader: string;
  149759. };
  149760. }
  149761. declare module BABYLON {
  149762. /**
  149763. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  149764. */
  149765. export class CircleOfConfusionPostProcess extends PostProcess {
  149766. /**
  149767. * 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.
  149768. */
  149769. lensSize: number;
  149770. /**
  149771. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149772. */
  149773. fStop: number;
  149774. /**
  149775. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149776. */
  149777. focusDistance: number;
  149778. /**
  149779. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  149780. */
  149781. focalLength: number;
  149782. /**
  149783. * Gets a string identifying the name of the class
  149784. * @returns "CircleOfConfusionPostProcess" string
  149785. */
  149786. getClassName(): string;
  149787. private _depthTexture;
  149788. /**
  149789. * Creates a new instance CircleOfConfusionPostProcess
  149790. * @param name The name of the effect.
  149791. * @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.
  149792. * @param options The required width/height ratio to downsize to before computing the render pass.
  149793. * @param camera The camera to apply the render pass to.
  149794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149795. * @param engine The engine which the post process will be applied. (default: current engine)
  149796. * @param reusable If the post process can be reused on the same frame. (default: false)
  149797. * @param textureType Type of textures used when performing the post process. (default: 0)
  149798. * @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)
  149799. */
  149800. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149801. /**
  149802. * 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.
  149803. */
  149804. set depthTexture(value: RenderTargetTexture);
  149805. }
  149806. }
  149807. declare module BABYLON {
  149808. /** @hidden */
  149809. export var colorCorrectionPixelShader: {
  149810. name: string;
  149811. shader: string;
  149812. };
  149813. }
  149814. declare module BABYLON {
  149815. /**
  149816. *
  149817. * This post-process allows the modification of rendered colors by using
  149818. * a 'look-up table' (LUT). This effect is also called Color Grading.
  149819. *
  149820. * The object needs to be provided an url to a texture containing the color
  149821. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  149822. * Use an image editing software to tweak the LUT to match your needs.
  149823. *
  149824. * For an example of a color LUT, see here:
  149825. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  149826. * For explanations on color grading, see here:
  149827. * @see http://udn.epicgames.com/Three/ColorGrading.html
  149828. *
  149829. */
  149830. export class ColorCorrectionPostProcess extends PostProcess {
  149831. private _colorTableTexture;
  149832. /**
  149833. * Gets the color table url used to create the LUT texture
  149834. */
  149835. colorTableUrl: string;
  149836. /**
  149837. * Gets a string identifying the name of the class
  149838. * @returns "ColorCorrectionPostProcess" string
  149839. */
  149840. getClassName(): string;
  149841. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149842. /** @hidden */
  149843. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  149844. }
  149845. }
  149846. declare module BABYLON {
  149847. /** @hidden */
  149848. export var convolutionPixelShader: {
  149849. name: string;
  149850. shader: string;
  149851. };
  149852. }
  149853. declare module BABYLON {
  149854. /**
  149855. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  149856. * input texture to perform effects such as edge detection or sharpening
  149857. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  149858. */
  149859. export class ConvolutionPostProcess extends PostProcess {
  149860. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  149861. kernel: number[];
  149862. /**
  149863. * Gets a string identifying the name of the class
  149864. * @returns "ConvolutionPostProcess" string
  149865. */
  149866. getClassName(): string;
  149867. /**
  149868. * Creates a new instance ConvolutionPostProcess
  149869. * @param name The name of the effect.
  149870. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  149871. * @param options The required width/height ratio to downsize to before computing the render pass.
  149872. * @param camera The camera to apply the render pass to.
  149873. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149874. * @param engine The engine which the post process will be applied. (default: current engine)
  149875. * @param reusable If the post process can be reused on the same frame. (default: false)
  149876. * @param textureType Type of textures used when performing the post process. (default: 0)
  149877. */
  149878. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149879. /** @hidden */
  149880. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  149881. /**
  149882. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149883. */
  149884. static EdgeDetect0Kernel: number[];
  149885. /**
  149886. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149887. */
  149888. static EdgeDetect1Kernel: number[];
  149889. /**
  149890. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149891. */
  149892. static EdgeDetect2Kernel: number[];
  149893. /**
  149894. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149895. */
  149896. static SharpenKernel: number[];
  149897. /**
  149898. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149899. */
  149900. static EmbossKernel: number[];
  149901. /**
  149902. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149903. */
  149904. static GaussianKernel: number[];
  149905. }
  149906. }
  149907. declare module BABYLON {
  149908. /**
  149909. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  149910. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  149911. * based on samples that have a large difference in distance than the center pixel.
  149912. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  149913. */
  149914. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  149915. /**
  149916. * The direction the blur should be applied
  149917. */
  149918. direction: Vector2;
  149919. /**
  149920. * Gets a string identifying the name of the class
  149921. * @returns "DepthOfFieldBlurPostProcess" string
  149922. */
  149923. getClassName(): string;
  149924. /**
  149925. * Creates a new instance CircleOfConfusionPostProcess
  149926. * @param name The name of the effect.
  149927. * @param scene The scene the effect belongs to.
  149928. * @param direction The direction the blur should be applied.
  149929. * @param kernel The size of the kernel used to blur.
  149930. * @param options The required width/height ratio to downsize to before computing the render pass.
  149931. * @param camera The camera to apply the render pass to.
  149932. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  149933. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  149934. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149935. * @param engine The engine which the post process will be applied. (default: current engine)
  149936. * @param reusable If the post process can be reused on the same frame. (default: false)
  149937. * @param textureType Type of textures used when performing the post process. (default: 0)
  149938. * @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)
  149939. */
  149940. 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);
  149941. }
  149942. }
  149943. declare module BABYLON {
  149944. /** @hidden */
  149945. export var depthOfFieldMergePixelShader: {
  149946. name: string;
  149947. shader: string;
  149948. };
  149949. }
  149950. declare module BABYLON {
  149951. /**
  149952. * Options to be set when merging outputs from the default pipeline.
  149953. */
  149954. export class DepthOfFieldMergePostProcessOptions {
  149955. /**
  149956. * The original image to merge on top of
  149957. */
  149958. originalFromInput: PostProcess;
  149959. /**
  149960. * Parameters to perform the merge of the depth of field effect
  149961. */
  149962. depthOfField?: {
  149963. circleOfConfusion: PostProcess;
  149964. blurSteps: Array<PostProcess>;
  149965. };
  149966. /**
  149967. * Parameters to perform the merge of bloom effect
  149968. */
  149969. bloom?: {
  149970. blurred: PostProcess;
  149971. weight: number;
  149972. };
  149973. }
  149974. /**
  149975. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149976. */
  149977. export class DepthOfFieldMergePostProcess extends PostProcess {
  149978. private blurSteps;
  149979. /**
  149980. * Gets a string identifying the name of the class
  149981. * @returns "DepthOfFieldMergePostProcess" string
  149982. */
  149983. getClassName(): string;
  149984. /**
  149985. * Creates a new instance of DepthOfFieldMergePostProcess
  149986. * @param name The name of the effect.
  149987. * @param originalFromInput Post process which's input will be used for the merge.
  149988. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  149989. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  149990. * @param options The required width/height ratio to downsize to before computing the render pass.
  149991. * @param camera The camera to apply the render pass to.
  149992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149993. * @param engine The engine which the post process will be applied. (default: current engine)
  149994. * @param reusable If the post process can be reused on the same frame. (default: false)
  149995. * @param textureType Type of textures used when performing the post process. (default: 0)
  149996. * @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)
  149997. */
  149998. 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);
  149999. /**
  150000. * Updates the effect with the current post process compile time values and recompiles the shader.
  150001. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  150002. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  150003. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  150004. * @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
  150005. * @param onCompiled Called when the shader has been compiled.
  150006. * @param onError Called if there is an error when compiling a shader.
  150007. */
  150008. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  150009. }
  150010. }
  150011. declare module BABYLON {
  150012. /**
  150013. * Specifies the level of max blur that should be applied when using the depth of field effect
  150014. */
  150015. export enum DepthOfFieldEffectBlurLevel {
  150016. /**
  150017. * Subtle blur
  150018. */
  150019. Low = 0,
  150020. /**
  150021. * Medium blur
  150022. */
  150023. Medium = 1,
  150024. /**
  150025. * Large blur
  150026. */
  150027. High = 2
  150028. }
  150029. /**
  150030. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  150031. */
  150032. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  150033. private _circleOfConfusion;
  150034. /**
  150035. * @hidden Internal, blurs from high to low
  150036. */
  150037. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  150038. private _depthOfFieldBlurY;
  150039. private _dofMerge;
  150040. /**
  150041. * @hidden Internal post processes in depth of field effect
  150042. */
  150043. _effects: Array<PostProcess>;
  150044. /**
  150045. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  150046. */
  150047. set focalLength(value: number);
  150048. get focalLength(): number;
  150049. /**
  150050. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150051. */
  150052. set fStop(value: number);
  150053. get fStop(): number;
  150054. /**
  150055. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150056. */
  150057. set focusDistance(value: number);
  150058. get focusDistance(): number;
  150059. /**
  150060. * 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.
  150061. */
  150062. set lensSize(value: number);
  150063. get lensSize(): number;
  150064. /**
  150065. * Creates a new instance DepthOfFieldEffect
  150066. * @param scene The scene the effect belongs to.
  150067. * @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.
  150068. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  150069. * @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)
  150070. */
  150071. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  150072. /**
  150073. * Get the current class name of the current effet
  150074. * @returns "DepthOfFieldEffect"
  150075. */
  150076. getClassName(): string;
  150077. /**
  150078. * 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.
  150079. */
  150080. set depthTexture(value: RenderTargetTexture);
  150081. /**
  150082. * Disposes each of the internal effects for a given camera.
  150083. * @param camera The camera to dispose the effect on.
  150084. */
  150085. disposeEffects(camera: Camera): void;
  150086. /**
  150087. * @hidden Internal
  150088. */
  150089. _updateEffects(): void;
  150090. /**
  150091. * Internal
  150092. * @returns if all the contained post processes are ready.
  150093. * @hidden
  150094. */
  150095. _isReady(): boolean;
  150096. }
  150097. }
  150098. declare module BABYLON {
  150099. /** @hidden */
  150100. export var displayPassPixelShader: {
  150101. name: string;
  150102. shader: string;
  150103. };
  150104. }
  150105. declare module BABYLON {
  150106. /**
  150107. * DisplayPassPostProcess which produces an output the same as it's input
  150108. */
  150109. export class DisplayPassPostProcess extends PostProcess {
  150110. /**
  150111. * Gets a string identifying the name of the class
  150112. * @returns "DisplayPassPostProcess" string
  150113. */
  150114. getClassName(): string;
  150115. /**
  150116. * Creates the DisplayPassPostProcess
  150117. * @param name The name of the effect.
  150118. * @param options The required width/height ratio to downsize to before computing the render pass.
  150119. * @param camera The camera to apply the render pass to.
  150120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150121. * @param engine The engine which the post process will be applied. (default: current engine)
  150122. * @param reusable If the post process can be reused on the same frame. (default: false)
  150123. */
  150124. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150125. /** @hidden */
  150126. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  150127. }
  150128. }
  150129. declare module BABYLON {
  150130. /** @hidden */
  150131. export var filterPixelShader: {
  150132. name: string;
  150133. shader: string;
  150134. };
  150135. }
  150136. declare module BABYLON {
  150137. /**
  150138. * Applies a kernel filter to the image
  150139. */
  150140. export class FilterPostProcess extends PostProcess {
  150141. /** The matrix to be applied to the image */
  150142. kernelMatrix: Matrix;
  150143. /**
  150144. * Gets a string identifying the name of the class
  150145. * @returns "FilterPostProcess" string
  150146. */
  150147. getClassName(): string;
  150148. /**
  150149. *
  150150. * @param name The name of the effect.
  150151. * @param kernelMatrix The matrix to be applied to the image
  150152. * @param options The required width/height ratio to downsize to before computing the render pass.
  150153. * @param camera The camera to apply the render pass to.
  150154. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150155. * @param engine The engine which the post process will be applied. (default: current engine)
  150156. * @param reusable If the post process can be reused on the same frame. (default: false)
  150157. */
  150158. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150159. /** @hidden */
  150160. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  150161. }
  150162. }
  150163. declare module BABYLON {
  150164. /** @hidden */
  150165. export var fxaaPixelShader: {
  150166. name: string;
  150167. shader: string;
  150168. };
  150169. }
  150170. declare module BABYLON {
  150171. /** @hidden */
  150172. export var fxaaVertexShader: {
  150173. name: string;
  150174. shader: string;
  150175. };
  150176. }
  150177. declare module BABYLON {
  150178. /**
  150179. * Fxaa post process
  150180. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  150181. */
  150182. export class FxaaPostProcess extends PostProcess {
  150183. /**
  150184. * Gets a string identifying the name of the class
  150185. * @returns "FxaaPostProcess" string
  150186. */
  150187. getClassName(): string;
  150188. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150189. private _getDefines;
  150190. /** @hidden */
  150191. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  150192. }
  150193. }
  150194. declare module BABYLON {
  150195. /** @hidden */
  150196. export var grainPixelShader: {
  150197. name: string;
  150198. shader: string;
  150199. };
  150200. }
  150201. declare module BABYLON {
  150202. /**
  150203. * The GrainPostProcess adds noise to the image at mid luminance levels
  150204. */
  150205. export class GrainPostProcess extends PostProcess {
  150206. /**
  150207. * The intensity of the grain added (default: 30)
  150208. */
  150209. intensity: number;
  150210. /**
  150211. * If the grain should be randomized on every frame
  150212. */
  150213. animated: boolean;
  150214. /**
  150215. * Gets a string identifying the name of the class
  150216. * @returns "GrainPostProcess" string
  150217. */
  150218. getClassName(): string;
  150219. /**
  150220. * Creates a new instance of @see GrainPostProcess
  150221. * @param name The name of the effect.
  150222. * @param options The required width/height ratio to downsize to before computing the render pass.
  150223. * @param camera The camera to apply the render pass to.
  150224. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150225. * @param engine The engine which the post process will be applied. (default: current engine)
  150226. * @param reusable If the post process can be reused on the same frame. (default: false)
  150227. * @param textureType Type of textures used when performing the post process. (default: 0)
  150228. * @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)
  150229. */
  150230. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150231. /** @hidden */
  150232. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  150233. }
  150234. }
  150235. declare module BABYLON {
  150236. /** @hidden */
  150237. export var highlightsPixelShader: {
  150238. name: string;
  150239. shader: string;
  150240. };
  150241. }
  150242. declare module BABYLON {
  150243. /**
  150244. * Extracts highlights from the image
  150245. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150246. */
  150247. export class HighlightsPostProcess extends PostProcess {
  150248. /**
  150249. * Gets a string identifying the name of the class
  150250. * @returns "HighlightsPostProcess" string
  150251. */
  150252. getClassName(): string;
  150253. /**
  150254. * Extracts highlights from the image
  150255. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150256. * @param name The name of the effect.
  150257. * @param options The required width/height ratio to downsize to before computing the render pass.
  150258. * @param camera The camera to apply the render pass to.
  150259. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150260. * @param engine The engine which the post process will be applied. (default: current engine)
  150261. * @param reusable If the post process can be reused on the same frame. (default: false)
  150262. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  150263. */
  150264. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150265. }
  150266. }
  150267. declare module BABYLON {
  150268. /** @hidden */
  150269. export var mrtFragmentDeclaration: {
  150270. name: string;
  150271. shader: string;
  150272. };
  150273. }
  150274. declare module BABYLON {
  150275. /** @hidden */
  150276. export var geometryPixelShader: {
  150277. name: string;
  150278. shader: string;
  150279. };
  150280. }
  150281. declare module BABYLON {
  150282. /** @hidden */
  150283. export var geometryVertexShader: {
  150284. name: string;
  150285. shader: string;
  150286. };
  150287. }
  150288. declare module BABYLON {
  150289. /** @hidden */
  150290. interface ISavedTransformationMatrix {
  150291. world: Matrix;
  150292. viewProjection: Matrix;
  150293. }
  150294. /**
  150295. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  150296. */
  150297. export class GeometryBufferRenderer {
  150298. /**
  150299. * Constant used to retrieve the position texture index in the G-Buffer textures array
  150300. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  150301. */
  150302. static readonly POSITION_TEXTURE_TYPE: number;
  150303. /**
  150304. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  150305. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  150306. */
  150307. static readonly VELOCITY_TEXTURE_TYPE: number;
  150308. /**
  150309. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  150310. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  150311. */
  150312. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  150313. /**
  150314. * Dictionary used to store the previous transformation matrices of each rendered mesh
  150315. * in order to compute objects velocities when enableVelocity is set to "true"
  150316. * @hidden
  150317. */
  150318. _previousTransformationMatrices: {
  150319. [index: number]: ISavedTransformationMatrix;
  150320. };
  150321. /**
  150322. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  150323. * in order to compute objects velocities when enableVelocity is set to "true"
  150324. * @hidden
  150325. */
  150326. _previousBonesTransformationMatrices: {
  150327. [index: number]: Float32Array;
  150328. };
  150329. /**
  150330. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  150331. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  150332. */
  150333. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  150334. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  150335. renderTransparentMeshes: boolean;
  150336. private _scene;
  150337. private _resizeObserver;
  150338. private _multiRenderTarget;
  150339. private _ratio;
  150340. private _enablePosition;
  150341. private _enableVelocity;
  150342. private _enableReflectivity;
  150343. private _positionIndex;
  150344. private _velocityIndex;
  150345. private _reflectivityIndex;
  150346. protected _effect: Effect;
  150347. protected _cachedDefines: string;
  150348. /**
  150349. * Set the render list (meshes to be rendered) used in the G buffer.
  150350. */
  150351. set renderList(meshes: Mesh[]);
  150352. /**
  150353. * Gets wether or not G buffer are supported by the running hardware.
  150354. * This requires draw buffer supports
  150355. */
  150356. get isSupported(): boolean;
  150357. /**
  150358. * Returns the index of the given texture type in the G-Buffer textures array
  150359. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  150360. * @returns the index of the given texture type in the G-Buffer textures array
  150361. */
  150362. getTextureIndex(textureType: number): number;
  150363. /**
  150364. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  150365. */
  150366. get enablePosition(): boolean;
  150367. /**
  150368. * Sets whether or not objects positions are enabled for the G buffer.
  150369. */
  150370. set enablePosition(enable: boolean);
  150371. /**
  150372. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  150373. */
  150374. get enableVelocity(): boolean;
  150375. /**
  150376. * Sets wether or not objects velocities are enabled for the G buffer.
  150377. */
  150378. set enableVelocity(enable: boolean);
  150379. /**
  150380. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  150381. */
  150382. get enableReflectivity(): boolean;
  150383. /**
  150384. * Sets wether or not objects roughness are enabled for the G buffer.
  150385. */
  150386. set enableReflectivity(enable: boolean);
  150387. /**
  150388. * Gets the scene associated with the buffer.
  150389. */
  150390. get scene(): Scene;
  150391. /**
  150392. * Gets the ratio used by the buffer during its creation.
  150393. * How big is the buffer related to the main canvas.
  150394. */
  150395. get ratio(): number;
  150396. /** @hidden */
  150397. static _SceneComponentInitialization: (scene: Scene) => void;
  150398. /**
  150399. * Creates a new G Buffer for the scene
  150400. * @param scene The scene the buffer belongs to
  150401. * @param ratio How big is the buffer related to the main canvas.
  150402. */
  150403. constructor(scene: Scene, ratio?: number);
  150404. /**
  150405. * Checks wether everything is ready to render a submesh to the G buffer.
  150406. * @param subMesh the submesh to check readiness for
  150407. * @param useInstances is the mesh drawn using instance or not
  150408. * @returns true if ready otherwise false
  150409. */
  150410. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  150411. /**
  150412. * Gets the current underlying G Buffer.
  150413. * @returns the buffer
  150414. */
  150415. getGBuffer(): MultiRenderTarget;
  150416. /**
  150417. * Gets the number of samples used to render the buffer (anti aliasing).
  150418. */
  150419. get samples(): number;
  150420. /**
  150421. * Sets the number of samples used to render the buffer (anti aliasing).
  150422. */
  150423. set samples(value: number);
  150424. /**
  150425. * Disposes the renderer and frees up associated resources.
  150426. */
  150427. dispose(): void;
  150428. protected _createRenderTargets(): void;
  150429. private _copyBonesTransformationMatrices;
  150430. }
  150431. }
  150432. declare module BABYLON {
  150433. interface Scene {
  150434. /** @hidden (Backing field) */
  150435. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150436. /**
  150437. * Gets or Sets the current geometry buffer associated to the scene.
  150438. */
  150439. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150440. /**
  150441. * Enables a GeometryBufferRender and associates it with the scene
  150442. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  150443. * @returns the GeometryBufferRenderer
  150444. */
  150445. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  150446. /**
  150447. * Disables the GeometryBufferRender associated with the scene
  150448. */
  150449. disableGeometryBufferRenderer(): void;
  150450. }
  150451. /**
  150452. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  150453. * in several rendering techniques.
  150454. */
  150455. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  150456. /**
  150457. * The component name helpful to identify the component in the list of scene components.
  150458. */
  150459. readonly name: string;
  150460. /**
  150461. * The scene the component belongs to.
  150462. */
  150463. scene: Scene;
  150464. /**
  150465. * Creates a new instance of the component for the given scene
  150466. * @param scene Defines the scene to register the component in
  150467. */
  150468. constructor(scene: Scene);
  150469. /**
  150470. * Registers the component in a given scene
  150471. */
  150472. register(): void;
  150473. /**
  150474. * Rebuilds the elements related to this component in case of
  150475. * context lost for instance.
  150476. */
  150477. rebuild(): void;
  150478. /**
  150479. * Disposes the component and the associated ressources
  150480. */
  150481. dispose(): void;
  150482. private _gatherRenderTargets;
  150483. }
  150484. }
  150485. declare module BABYLON {
  150486. /** @hidden */
  150487. export var motionBlurPixelShader: {
  150488. name: string;
  150489. shader: string;
  150490. };
  150491. }
  150492. declare module BABYLON {
  150493. /**
  150494. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  150495. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  150496. * As an example, all you have to do is to create the post-process:
  150497. * var mb = new BABYLON.MotionBlurPostProcess(
  150498. * 'mb', // The name of the effect.
  150499. * scene, // The scene containing the objects to blur according to their velocity.
  150500. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  150501. * camera // The camera to apply the render pass to.
  150502. * );
  150503. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  150504. */
  150505. export class MotionBlurPostProcess extends PostProcess {
  150506. /**
  150507. * Defines how much the image is blurred by the movement. Default value is equal to 1
  150508. */
  150509. motionStrength: number;
  150510. /**
  150511. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  150512. */
  150513. get motionBlurSamples(): number;
  150514. /**
  150515. * Sets the number of iterations to be used for motion blur quality
  150516. */
  150517. set motionBlurSamples(samples: number);
  150518. private _motionBlurSamples;
  150519. private _geometryBufferRenderer;
  150520. /**
  150521. * Gets a string identifying the name of the class
  150522. * @returns "MotionBlurPostProcess" string
  150523. */
  150524. getClassName(): string;
  150525. /**
  150526. * Creates a new instance MotionBlurPostProcess
  150527. * @param name The name of the effect.
  150528. * @param scene The scene containing the objects to blur according to their velocity.
  150529. * @param options The required width/height ratio to downsize to before computing the render pass.
  150530. * @param camera The camera to apply the render pass to.
  150531. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150532. * @param engine The engine which the post process will be applied. (default: current engine)
  150533. * @param reusable If the post process can be reused on the same frame. (default: false)
  150534. * @param textureType Type of textures used when performing the post process. (default: 0)
  150535. * @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)
  150536. */
  150537. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150538. /**
  150539. * Excludes the given skinned mesh from computing bones velocities.
  150540. * 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.
  150541. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  150542. */
  150543. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150544. /**
  150545. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  150546. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  150547. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  150548. */
  150549. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150550. /**
  150551. * Disposes the post process.
  150552. * @param camera The camera to dispose the post process on.
  150553. */
  150554. dispose(camera?: Camera): void;
  150555. /** @hidden */
  150556. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  150557. }
  150558. }
  150559. declare module BABYLON {
  150560. /** @hidden */
  150561. export var refractionPixelShader: {
  150562. name: string;
  150563. shader: string;
  150564. };
  150565. }
  150566. declare module BABYLON {
  150567. /**
  150568. * Post process which applies a refractin texture
  150569. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150570. */
  150571. export class RefractionPostProcess extends PostProcess {
  150572. private _refTexture;
  150573. private _ownRefractionTexture;
  150574. /** the base color of the refraction (used to taint the rendering) */
  150575. color: Color3;
  150576. /** simulated refraction depth */
  150577. depth: number;
  150578. /** the coefficient of the base color (0 to remove base color tainting) */
  150579. colorLevel: number;
  150580. /** Gets the url used to load the refraction texture */
  150581. refractionTextureUrl: string;
  150582. /**
  150583. * Gets or sets the refraction texture
  150584. * Please note that you are responsible for disposing the texture if you set it manually
  150585. */
  150586. get refractionTexture(): Texture;
  150587. set refractionTexture(value: Texture);
  150588. /**
  150589. * Gets a string identifying the name of the class
  150590. * @returns "RefractionPostProcess" string
  150591. */
  150592. getClassName(): string;
  150593. /**
  150594. * Initializes the RefractionPostProcess
  150595. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150596. * @param name The name of the effect.
  150597. * @param refractionTextureUrl Url of the refraction texture to use
  150598. * @param color the base color of the refraction (used to taint the rendering)
  150599. * @param depth simulated refraction depth
  150600. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  150601. * @param camera The camera to apply the render pass to.
  150602. * @param options The required width/height ratio to downsize to before computing the render pass.
  150603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150604. * @param engine The engine which the post process will be applied. (default: current engine)
  150605. * @param reusable If the post process can be reused on the same frame. (default: false)
  150606. */
  150607. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150608. /**
  150609. * Disposes of the post process
  150610. * @param camera Camera to dispose post process on
  150611. */
  150612. dispose(camera: Camera): void;
  150613. /** @hidden */
  150614. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  150615. }
  150616. }
  150617. declare module BABYLON {
  150618. /** @hidden */
  150619. export var sharpenPixelShader: {
  150620. name: string;
  150621. shader: string;
  150622. };
  150623. }
  150624. declare module BABYLON {
  150625. /**
  150626. * The SharpenPostProcess applies a sharpen kernel to every pixel
  150627. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150628. */
  150629. export class SharpenPostProcess extends PostProcess {
  150630. /**
  150631. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  150632. */
  150633. colorAmount: number;
  150634. /**
  150635. * How much sharpness should be applied (default: 0.3)
  150636. */
  150637. edgeAmount: number;
  150638. /**
  150639. * Gets a string identifying the name of the class
  150640. * @returns "SharpenPostProcess" string
  150641. */
  150642. getClassName(): string;
  150643. /**
  150644. * Creates a new instance ConvolutionPostProcess
  150645. * @param name The name of the effect.
  150646. * @param options The required width/height ratio to downsize to before computing the render pass.
  150647. * @param camera The camera to apply the render pass to.
  150648. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150649. * @param engine The engine which the post process will be applied. (default: current engine)
  150650. * @param reusable If the post process can be reused on the same frame. (default: false)
  150651. * @param textureType Type of textures used when performing the post process. (default: 0)
  150652. * @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)
  150653. */
  150654. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150655. /** @hidden */
  150656. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  150657. }
  150658. }
  150659. declare module BABYLON {
  150660. /**
  150661. * PostProcessRenderPipeline
  150662. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150663. */
  150664. export class PostProcessRenderPipeline {
  150665. private engine;
  150666. private _renderEffects;
  150667. private _renderEffectsForIsolatedPass;
  150668. /**
  150669. * List of inspectable custom properties (used by the Inspector)
  150670. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  150671. */
  150672. inspectableCustomProperties: IInspectable[];
  150673. /**
  150674. * @hidden
  150675. */
  150676. protected _cameras: Camera[];
  150677. /** @hidden */
  150678. _name: string;
  150679. /**
  150680. * Gets pipeline name
  150681. */
  150682. get name(): string;
  150683. /** Gets the list of attached cameras */
  150684. get cameras(): Camera[];
  150685. /**
  150686. * Initializes a PostProcessRenderPipeline
  150687. * @param engine engine to add the pipeline to
  150688. * @param name name of the pipeline
  150689. */
  150690. constructor(engine: Engine, name: string);
  150691. /**
  150692. * Gets the class name
  150693. * @returns "PostProcessRenderPipeline"
  150694. */
  150695. getClassName(): string;
  150696. /**
  150697. * If all the render effects in the pipeline are supported
  150698. */
  150699. get isSupported(): boolean;
  150700. /**
  150701. * Adds an effect to the pipeline
  150702. * @param renderEffect the effect to add
  150703. */
  150704. addEffect(renderEffect: PostProcessRenderEffect): void;
  150705. /** @hidden */
  150706. _rebuild(): void;
  150707. /** @hidden */
  150708. _enableEffect(renderEffectName: string, cameras: Camera): void;
  150709. /** @hidden */
  150710. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  150711. /** @hidden */
  150712. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150713. /** @hidden */
  150714. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150715. /** @hidden */
  150716. _attachCameras(cameras: Camera, unique: boolean): void;
  150717. /** @hidden */
  150718. _attachCameras(cameras: Camera[], unique: boolean): void;
  150719. /** @hidden */
  150720. _detachCameras(cameras: Camera): void;
  150721. /** @hidden */
  150722. _detachCameras(cameras: Nullable<Camera[]>): void;
  150723. /** @hidden */
  150724. _update(): void;
  150725. /** @hidden */
  150726. _reset(): void;
  150727. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  150728. /**
  150729. * Sets the required values to the prepass renderer.
  150730. * @param prePassRenderer defines the prepass renderer to setup.
  150731. * @returns true if the pre pass is needed.
  150732. */
  150733. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150734. /**
  150735. * Disposes of the pipeline
  150736. */
  150737. dispose(): void;
  150738. }
  150739. }
  150740. declare module BABYLON {
  150741. /**
  150742. * PostProcessRenderPipelineManager class
  150743. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150744. */
  150745. export class PostProcessRenderPipelineManager {
  150746. private _renderPipelines;
  150747. /**
  150748. * Initializes a PostProcessRenderPipelineManager
  150749. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150750. */
  150751. constructor();
  150752. /**
  150753. * Gets the list of supported render pipelines
  150754. */
  150755. get supportedPipelines(): PostProcessRenderPipeline[];
  150756. /**
  150757. * Adds a pipeline to the manager
  150758. * @param renderPipeline The pipeline to add
  150759. */
  150760. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  150761. /**
  150762. * Attaches a camera to the pipeline
  150763. * @param renderPipelineName The name of the pipeline to attach to
  150764. * @param cameras the camera to attach
  150765. * @param unique if the camera can be attached multiple times to the pipeline
  150766. */
  150767. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  150768. /**
  150769. * Detaches a camera from the pipeline
  150770. * @param renderPipelineName The name of the pipeline to detach from
  150771. * @param cameras the camera to detach
  150772. */
  150773. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  150774. /**
  150775. * Enables an effect by name on a pipeline
  150776. * @param renderPipelineName the name of the pipeline to enable the effect in
  150777. * @param renderEffectName the name of the effect to enable
  150778. * @param cameras the cameras that the effect should be enabled on
  150779. */
  150780. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150781. /**
  150782. * Disables an effect by name on a pipeline
  150783. * @param renderPipelineName the name of the pipeline to disable the effect in
  150784. * @param renderEffectName the name of the effect to disable
  150785. * @param cameras the cameras that the effect should be disabled on
  150786. */
  150787. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150788. /**
  150789. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  150790. */
  150791. update(): void;
  150792. /** @hidden */
  150793. _rebuild(): void;
  150794. /**
  150795. * Disposes of the manager and pipelines
  150796. */
  150797. dispose(): void;
  150798. }
  150799. }
  150800. declare module BABYLON {
  150801. interface Scene {
  150802. /** @hidden (Backing field) */
  150803. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150804. /**
  150805. * Gets the postprocess render pipeline manager
  150806. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150807. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150808. */
  150809. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150810. }
  150811. /**
  150812. * Defines the Render Pipeline scene component responsible to rendering pipelines
  150813. */
  150814. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  150815. /**
  150816. * The component name helpfull to identify the component in the list of scene components.
  150817. */
  150818. readonly name: string;
  150819. /**
  150820. * The scene the component belongs to.
  150821. */
  150822. scene: Scene;
  150823. /**
  150824. * Creates a new instance of the component for the given scene
  150825. * @param scene Defines the scene to register the component in
  150826. */
  150827. constructor(scene: Scene);
  150828. /**
  150829. * Registers the component in a given scene
  150830. */
  150831. register(): void;
  150832. /**
  150833. * Rebuilds the elements related to this component in case of
  150834. * context lost for instance.
  150835. */
  150836. rebuild(): void;
  150837. /**
  150838. * Disposes the component and the associated ressources
  150839. */
  150840. dispose(): void;
  150841. private _gatherRenderTargets;
  150842. }
  150843. }
  150844. declare module BABYLON {
  150845. /**
  150846. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  150847. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150848. */
  150849. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  150850. private _scene;
  150851. private _camerasToBeAttached;
  150852. /**
  150853. * ID of the sharpen post process,
  150854. */
  150855. private readonly SharpenPostProcessId;
  150856. /**
  150857. * @ignore
  150858. * ID of the image processing post process;
  150859. */
  150860. readonly ImageProcessingPostProcessId: string;
  150861. /**
  150862. * @ignore
  150863. * ID of the Fast Approximate Anti-Aliasing post process;
  150864. */
  150865. readonly FxaaPostProcessId: string;
  150866. /**
  150867. * ID of the chromatic aberration post process,
  150868. */
  150869. private readonly ChromaticAberrationPostProcessId;
  150870. /**
  150871. * ID of the grain post process
  150872. */
  150873. private readonly GrainPostProcessId;
  150874. /**
  150875. * Sharpen post process which will apply a sharpen convolution to enhance edges
  150876. */
  150877. sharpen: SharpenPostProcess;
  150878. private _sharpenEffect;
  150879. private bloom;
  150880. /**
  150881. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  150882. */
  150883. depthOfField: DepthOfFieldEffect;
  150884. /**
  150885. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  150886. */
  150887. fxaa: FxaaPostProcess;
  150888. /**
  150889. * Image post processing pass used to perform operations such as tone mapping or color grading.
  150890. */
  150891. imageProcessing: ImageProcessingPostProcess;
  150892. /**
  150893. * Chromatic aberration post process which will shift rgb colors in the image
  150894. */
  150895. chromaticAberration: ChromaticAberrationPostProcess;
  150896. private _chromaticAberrationEffect;
  150897. /**
  150898. * Grain post process which add noise to the image
  150899. */
  150900. grain: GrainPostProcess;
  150901. private _grainEffect;
  150902. /**
  150903. * Glow post process which adds a glow to emissive areas of the image
  150904. */
  150905. private _glowLayer;
  150906. /**
  150907. * Animations which can be used to tweak settings over a period of time
  150908. */
  150909. animations: Animation[];
  150910. private _imageProcessingConfigurationObserver;
  150911. private _sharpenEnabled;
  150912. private _bloomEnabled;
  150913. private _depthOfFieldEnabled;
  150914. private _depthOfFieldBlurLevel;
  150915. private _fxaaEnabled;
  150916. private _imageProcessingEnabled;
  150917. private _defaultPipelineTextureType;
  150918. private _bloomScale;
  150919. private _chromaticAberrationEnabled;
  150920. private _grainEnabled;
  150921. private _buildAllowed;
  150922. /**
  150923. * Gets active scene
  150924. */
  150925. get scene(): Scene;
  150926. /**
  150927. * Enable or disable the sharpen process from the pipeline
  150928. */
  150929. set sharpenEnabled(enabled: boolean);
  150930. get sharpenEnabled(): boolean;
  150931. private _resizeObserver;
  150932. private _hardwareScaleLevel;
  150933. private _bloomKernel;
  150934. /**
  150935. * Specifies the size of the bloom blur kernel, relative to the final output size
  150936. */
  150937. get bloomKernel(): number;
  150938. set bloomKernel(value: number);
  150939. /**
  150940. * Specifies the weight of the bloom in the final rendering
  150941. */
  150942. private _bloomWeight;
  150943. /**
  150944. * Specifies the luma threshold for the area that will be blurred by the bloom
  150945. */
  150946. private _bloomThreshold;
  150947. private _hdr;
  150948. /**
  150949. * The strength of the bloom.
  150950. */
  150951. set bloomWeight(value: number);
  150952. get bloomWeight(): number;
  150953. /**
  150954. * The strength of the bloom.
  150955. */
  150956. set bloomThreshold(value: number);
  150957. get bloomThreshold(): number;
  150958. /**
  150959. * The scale of the bloom, lower value will provide better performance.
  150960. */
  150961. set bloomScale(value: number);
  150962. get bloomScale(): number;
  150963. /**
  150964. * Enable or disable the bloom from the pipeline
  150965. */
  150966. set bloomEnabled(enabled: boolean);
  150967. get bloomEnabled(): boolean;
  150968. private _rebuildBloom;
  150969. /**
  150970. * If the depth of field is enabled.
  150971. */
  150972. get depthOfFieldEnabled(): boolean;
  150973. set depthOfFieldEnabled(enabled: boolean);
  150974. /**
  150975. * Blur level of the depth of field effect. (Higher blur will effect performance)
  150976. */
  150977. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  150978. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  150979. /**
  150980. * If the anti aliasing is enabled.
  150981. */
  150982. set fxaaEnabled(enabled: boolean);
  150983. get fxaaEnabled(): boolean;
  150984. private _samples;
  150985. /**
  150986. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  150987. */
  150988. set samples(sampleCount: number);
  150989. get samples(): number;
  150990. /**
  150991. * If image processing is enabled.
  150992. */
  150993. set imageProcessingEnabled(enabled: boolean);
  150994. get imageProcessingEnabled(): boolean;
  150995. /**
  150996. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  150997. */
  150998. set glowLayerEnabled(enabled: boolean);
  150999. get glowLayerEnabled(): boolean;
  151000. /**
  151001. * Gets the glow layer (or null if not defined)
  151002. */
  151003. get glowLayer(): Nullable<GlowLayer>;
  151004. /**
  151005. * Enable or disable the chromaticAberration process from the pipeline
  151006. */
  151007. set chromaticAberrationEnabled(enabled: boolean);
  151008. get chromaticAberrationEnabled(): boolean;
  151009. /**
  151010. * Enable or disable the grain process from the pipeline
  151011. */
  151012. set grainEnabled(enabled: boolean);
  151013. get grainEnabled(): boolean;
  151014. /**
  151015. * @constructor
  151016. * @param name - The rendering pipeline name (default: "")
  151017. * @param hdr - If high dynamic range textures should be used (default: true)
  151018. * @param scene - The scene linked to this pipeline (default: the last created scene)
  151019. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  151020. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  151021. */
  151022. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  151023. /**
  151024. * Get the class name
  151025. * @returns "DefaultRenderingPipeline"
  151026. */
  151027. getClassName(): string;
  151028. /**
  151029. * Force the compilation of the entire pipeline.
  151030. */
  151031. prepare(): void;
  151032. private _hasCleared;
  151033. private _prevPostProcess;
  151034. private _prevPrevPostProcess;
  151035. private _setAutoClearAndTextureSharing;
  151036. private _depthOfFieldSceneObserver;
  151037. private _buildPipeline;
  151038. private _disposePostProcesses;
  151039. /**
  151040. * Adds a camera to the pipeline
  151041. * @param camera the camera to be added
  151042. */
  151043. addCamera(camera: Camera): void;
  151044. /**
  151045. * Removes a camera from the pipeline
  151046. * @param camera the camera to remove
  151047. */
  151048. removeCamera(camera: Camera): void;
  151049. /**
  151050. * Dispose of the pipeline and stop all post processes
  151051. */
  151052. dispose(): void;
  151053. /**
  151054. * Serialize the rendering pipeline (Used when exporting)
  151055. * @returns the serialized object
  151056. */
  151057. serialize(): any;
  151058. /**
  151059. * Parse the serialized pipeline
  151060. * @param source Source pipeline.
  151061. * @param scene The scene to load the pipeline to.
  151062. * @param rootUrl The URL of the serialized pipeline.
  151063. * @returns An instantiated pipeline from the serialized object.
  151064. */
  151065. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  151066. }
  151067. }
  151068. declare module BABYLON {
  151069. /** @hidden */
  151070. export var lensHighlightsPixelShader: {
  151071. name: string;
  151072. shader: string;
  151073. };
  151074. }
  151075. declare module BABYLON {
  151076. /** @hidden */
  151077. export var depthOfFieldPixelShader: {
  151078. name: string;
  151079. shader: string;
  151080. };
  151081. }
  151082. declare module BABYLON {
  151083. /**
  151084. * BABYLON.JS Chromatic Aberration GLSL Shader
  151085. * Author: Olivier Guyot
  151086. * Separates very slightly R, G and B colors on the edges of the screen
  151087. * Inspired by Francois Tarlier & Martins Upitis
  151088. */
  151089. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  151090. /**
  151091. * @ignore
  151092. * The chromatic aberration PostProcess id in the pipeline
  151093. */
  151094. LensChromaticAberrationEffect: string;
  151095. /**
  151096. * @ignore
  151097. * The highlights enhancing PostProcess id in the pipeline
  151098. */
  151099. HighlightsEnhancingEffect: string;
  151100. /**
  151101. * @ignore
  151102. * The depth-of-field PostProcess id in the pipeline
  151103. */
  151104. LensDepthOfFieldEffect: string;
  151105. private _scene;
  151106. private _depthTexture;
  151107. private _grainTexture;
  151108. private _chromaticAberrationPostProcess;
  151109. private _highlightsPostProcess;
  151110. private _depthOfFieldPostProcess;
  151111. private _edgeBlur;
  151112. private _grainAmount;
  151113. private _chromaticAberration;
  151114. private _distortion;
  151115. private _highlightsGain;
  151116. private _highlightsThreshold;
  151117. private _dofDistance;
  151118. private _dofAperture;
  151119. private _dofDarken;
  151120. private _dofPentagon;
  151121. private _blurNoise;
  151122. /**
  151123. * @constructor
  151124. *
  151125. * Effect parameters are as follow:
  151126. * {
  151127. * chromatic_aberration: number; // from 0 to x (1 for realism)
  151128. * edge_blur: number; // from 0 to x (1 for realism)
  151129. * distortion: number; // from 0 to x (1 for realism)
  151130. * grain_amount: number; // from 0 to 1
  151131. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  151132. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  151133. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  151134. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  151135. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  151136. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  151137. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  151138. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  151139. * }
  151140. * Note: if an effect parameter is unset, effect is disabled
  151141. *
  151142. * @param name The rendering pipeline name
  151143. * @param parameters - An object containing all parameters (see above)
  151144. * @param scene The scene linked to this pipeline
  151145. * @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)
  151146. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151147. */
  151148. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  151149. /**
  151150. * Get the class name
  151151. * @returns "LensRenderingPipeline"
  151152. */
  151153. getClassName(): string;
  151154. /**
  151155. * Gets associated scene
  151156. */
  151157. get scene(): Scene;
  151158. /**
  151159. * Gets or sets the edge blur
  151160. */
  151161. get edgeBlur(): number;
  151162. set edgeBlur(value: number);
  151163. /**
  151164. * Gets or sets the grain amount
  151165. */
  151166. get grainAmount(): number;
  151167. set grainAmount(value: number);
  151168. /**
  151169. * Gets or sets the chromatic aberration amount
  151170. */
  151171. get chromaticAberration(): number;
  151172. set chromaticAberration(value: number);
  151173. /**
  151174. * Gets or sets the depth of field aperture
  151175. */
  151176. get dofAperture(): number;
  151177. set dofAperture(value: number);
  151178. /**
  151179. * Gets or sets the edge distortion
  151180. */
  151181. get edgeDistortion(): number;
  151182. set edgeDistortion(value: number);
  151183. /**
  151184. * Gets or sets the depth of field distortion
  151185. */
  151186. get dofDistortion(): number;
  151187. set dofDistortion(value: number);
  151188. /**
  151189. * Gets or sets the darken out of focus amount
  151190. */
  151191. get darkenOutOfFocus(): number;
  151192. set darkenOutOfFocus(value: number);
  151193. /**
  151194. * Gets or sets a boolean indicating if blur noise is enabled
  151195. */
  151196. get blurNoise(): boolean;
  151197. set blurNoise(value: boolean);
  151198. /**
  151199. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  151200. */
  151201. get pentagonBokeh(): boolean;
  151202. set pentagonBokeh(value: boolean);
  151203. /**
  151204. * Gets or sets the highlight grain amount
  151205. */
  151206. get highlightsGain(): number;
  151207. set highlightsGain(value: number);
  151208. /**
  151209. * Gets or sets the highlight threshold
  151210. */
  151211. get highlightsThreshold(): number;
  151212. set highlightsThreshold(value: number);
  151213. /**
  151214. * Sets the amount of blur at the edges
  151215. * @param amount blur amount
  151216. */
  151217. setEdgeBlur(amount: number): void;
  151218. /**
  151219. * Sets edge blur to 0
  151220. */
  151221. disableEdgeBlur(): void;
  151222. /**
  151223. * Sets the amout of grain
  151224. * @param amount Amount of grain
  151225. */
  151226. setGrainAmount(amount: number): void;
  151227. /**
  151228. * Set grain amount to 0
  151229. */
  151230. disableGrain(): void;
  151231. /**
  151232. * Sets the chromatic aberration amount
  151233. * @param amount amount of chromatic aberration
  151234. */
  151235. setChromaticAberration(amount: number): void;
  151236. /**
  151237. * Sets chromatic aberration amount to 0
  151238. */
  151239. disableChromaticAberration(): void;
  151240. /**
  151241. * Sets the EdgeDistortion amount
  151242. * @param amount amount of EdgeDistortion
  151243. */
  151244. setEdgeDistortion(amount: number): void;
  151245. /**
  151246. * Sets edge distortion to 0
  151247. */
  151248. disableEdgeDistortion(): void;
  151249. /**
  151250. * Sets the FocusDistance amount
  151251. * @param amount amount of FocusDistance
  151252. */
  151253. setFocusDistance(amount: number): void;
  151254. /**
  151255. * Disables depth of field
  151256. */
  151257. disableDepthOfField(): void;
  151258. /**
  151259. * Sets the Aperture amount
  151260. * @param amount amount of Aperture
  151261. */
  151262. setAperture(amount: number): void;
  151263. /**
  151264. * Sets the DarkenOutOfFocus amount
  151265. * @param amount amount of DarkenOutOfFocus
  151266. */
  151267. setDarkenOutOfFocus(amount: number): void;
  151268. private _pentagonBokehIsEnabled;
  151269. /**
  151270. * Creates a pentagon bokeh effect
  151271. */
  151272. enablePentagonBokeh(): void;
  151273. /**
  151274. * Disables the pentagon bokeh effect
  151275. */
  151276. disablePentagonBokeh(): void;
  151277. /**
  151278. * Enables noise blur
  151279. */
  151280. enableNoiseBlur(): void;
  151281. /**
  151282. * Disables noise blur
  151283. */
  151284. disableNoiseBlur(): void;
  151285. /**
  151286. * Sets the HighlightsGain amount
  151287. * @param amount amount of HighlightsGain
  151288. */
  151289. setHighlightsGain(amount: number): void;
  151290. /**
  151291. * Sets the HighlightsThreshold amount
  151292. * @param amount amount of HighlightsThreshold
  151293. */
  151294. setHighlightsThreshold(amount: number): void;
  151295. /**
  151296. * Disables highlights
  151297. */
  151298. disableHighlights(): void;
  151299. /**
  151300. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  151301. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  151302. */
  151303. dispose(disableDepthRender?: boolean): void;
  151304. private _createChromaticAberrationPostProcess;
  151305. private _createHighlightsPostProcess;
  151306. private _createDepthOfFieldPostProcess;
  151307. private _createGrainTexture;
  151308. }
  151309. }
  151310. declare module BABYLON {
  151311. /**
  151312. * Contains all parameters needed for the prepass to perform
  151313. * screen space subsurface scattering
  151314. */
  151315. export class SSAO2Configuration implements PrePassEffectConfiguration {
  151316. /**
  151317. * Is subsurface enabled
  151318. */
  151319. enabled: boolean;
  151320. /**
  151321. * Name of the configuration
  151322. */
  151323. name: string;
  151324. /**
  151325. * Textures that should be present in the MRT for this effect to work
  151326. */
  151327. readonly texturesRequired: number[];
  151328. /**
  151329. * Builds a ssao2 configuration object
  151330. * @param scene The scene
  151331. */
  151332. constructor();
  151333. /**
  151334. * Disposes the configuration
  151335. */
  151336. dispose(): void;
  151337. }
  151338. }
  151339. declare module BABYLON {
  151340. /** @hidden */
  151341. export var ssao2PixelShader: {
  151342. name: string;
  151343. shader: string;
  151344. };
  151345. }
  151346. declare module BABYLON {
  151347. /** @hidden */
  151348. export var ssaoCombinePixelShader: {
  151349. name: string;
  151350. shader: string;
  151351. };
  151352. }
  151353. declare module BABYLON {
  151354. /**
  151355. * Render pipeline to produce ssao effect
  151356. */
  151357. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  151358. /**
  151359. * @ignore
  151360. * The PassPostProcess id in the pipeline that contains the original scene color
  151361. */
  151362. SSAOOriginalSceneColorEffect: string;
  151363. /**
  151364. * @ignore
  151365. * The SSAO PostProcess id in the pipeline
  151366. */
  151367. SSAORenderEffect: string;
  151368. /**
  151369. * @ignore
  151370. * The horizontal blur PostProcess id in the pipeline
  151371. */
  151372. SSAOBlurHRenderEffect: string;
  151373. /**
  151374. * @ignore
  151375. * The vertical blur PostProcess id in the pipeline
  151376. */
  151377. SSAOBlurVRenderEffect: string;
  151378. /**
  151379. * @ignore
  151380. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151381. */
  151382. SSAOCombineRenderEffect: string;
  151383. /**
  151384. * The output strength of the SSAO post-process. Default value is 1.0.
  151385. */
  151386. totalStrength: number;
  151387. /**
  151388. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  151389. */
  151390. maxZ: number;
  151391. /**
  151392. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  151393. */
  151394. minZAspect: number;
  151395. private _samples;
  151396. /**
  151397. * Number of samples used for the SSAO calculations. Default value is 8
  151398. */
  151399. set samples(n: number);
  151400. get samples(): number;
  151401. private _textureSamples;
  151402. /**
  151403. * Number of samples to use for antialiasing
  151404. */
  151405. set textureSamples(n: number);
  151406. get textureSamples(): number;
  151407. /**
  151408. * Force rendering the geometry through geometry buffer
  151409. */
  151410. private _forceGeometryBuffer;
  151411. /**
  151412. * Ratio object used for SSAO ratio and blur ratio
  151413. */
  151414. private _ratio;
  151415. /**
  151416. * Dynamically generated sphere sampler.
  151417. */
  151418. private _sampleSphere;
  151419. private _ssao2PrePassConfiguration;
  151420. /**
  151421. * Blur filter offsets
  151422. */
  151423. private _samplerOffsets;
  151424. private _expensiveBlur;
  151425. /**
  151426. * If bilateral blur should be used
  151427. */
  151428. set expensiveBlur(b: boolean);
  151429. get expensiveBlur(): boolean;
  151430. /**
  151431. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  151432. */
  151433. radius: number;
  151434. /**
  151435. * The base color of the SSAO post-process
  151436. * The final result is "base + ssao" between [0, 1]
  151437. */
  151438. base: number;
  151439. /**
  151440. * Support test.
  151441. */
  151442. static get IsSupported(): boolean;
  151443. private _scene;
  151444. private _randomTexture;
  151445. private _originalColorPostProcess;
  151446. private _ssaoPostProcess;
  151447. private _blurHPostProcess;
  151448. private _blurVPostProcess;
  151449. private _ssaoCombinePostProcess;
  151450. private _prePassRenderer;
  151451. /**
  151452. * Gets active scene
  151453. */
  151454. get scene(): Scene;
  151455. /**
  151456. * @constructor
  151457. * @param name The rendering pipeline name
  151458. * @param scene The scene linked to this pipeline
  151459. * @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 }
  151460. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151461. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  151462. */
  151463. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  151464. /**
  151465. * Get the class name
  151466. * @returns "SSAO2RenderingPipeline"
  151467. */
  151468. getClassName(): string;
  151469. /**
  151470. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151471. */
  151472. dispose(disableGeometryBufferRenderer?: boolean): void;
  151473. private _createBlurPostProcess;
  151474. /** @hidden */
  151475. _rebuild(): void;
  151476. private _bits;
  151477. private _radicalInverse_VdC;
  151478. private _hammersley;
  151479. private _hemisphereSample_uniform;
  151480. private _generateHemisphere;
  151481. private _getDefinesForSSAO;
  151482. private _createSSAOPostProcess;
  151483. private _createSSAOCombinePostProcess;
  151484. private _createRandomTexture;
  151485. /**
  151486. * Serialize the rendering pipeline (Used when exporting)
  151487. * @returns the serialized object
  151488. */
  151489. serialize(): any;
  151490. /**
  151491. * Parse the serialized pipeline
  151492. * @param source Source pipeline.
  151493. * @param scene The scene to load the pipeline to.
  151494. * @param rootUrl The URL of the serialized pipeline.
  151495. * @returns An instantiated pipeline from the serialized object.
  151496. */
  151497. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  151498. /**
  151499. * Sets the required values to the prepass renderer.
  151500. * @param prePassRenderer defines the prepass renderer to setup
  151501. * @returns true if the pre pass is needed.
  151502. */
  151503. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  151504. }
  151505. }
  151506. declare module BABYLON {
  151507. /** @hidden */
  151508. export var ssaoPixelShader: {
  151509. name: string;
  151510. shader: string;
  151511. };
  151512. }
  151513. declare module BABYLON {
  151514. /**
  151515. * Render pipeline to produce ssao effect
  151516. */
  151517. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  151518. /**
  151519. * @ignore
  151520. * The PassPostProcess id in the pipeline that contains the original scene color
  151521. */
  151522. SSAOOriginalSceneColorEffect: string;
  151523. /**
  151524. * @ignore
  151525. * The SSAO PostProcess id in the pipeline
  151526. */
  151527. SSAORenderEffect: string;
  151528. /**
  151529. * @ignore
  151530. * The horizontal blur PostProcess id in the pipeline
  151531. */
  151532. SSAOBlurHRenderEffect: string;
  151533. /**
  151534. * @ignore
  151535. * The vertical blur PostProcess id in the pipeline
  151536. */
  151537. SSAOBlurVRenderEffect: string;
  151538. /**
  151539. * @ignore
  151540. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151541. */
  151542. SSAOCombineRenderEffect: string;
  151543. /**
  151544. * The output strength of the SSAO post-process. Default value is 1.0.
  151545. */
  151546. totalStrength: number;
  151547. /**
  151548. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  151549. */
  151550. radius: number;
  151551. /**
  151552. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  151553. * Must not be equal to fallOff and superior to fallOff.
  151554. * Default value is 0.0075
  151555. */
  151556. area: number;
  151557. /**
  151558. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  151559. * Must not be equal to area and inferior to area.
  151560. * Default value is 0.000001
  151561. */
  151562. fallOff: number;
  151563. /**
  151564. * The base color of the SSAO post-process
  151565. * The final result is "base + ssao" between [0, 1]
  151566. */
  151567. base: number;
  151568. private _scene;
  151569. private _depthTexture;
  151570. private _randomTexture;
  151571. private _originalColorPostProcess;
  151572. private _ssaoPostProcess;
  151573. private _blurHPostProcess;
  151574. private _blurVPostProcess;
  151575. private _ssaoCombinePostProcess;
  151576. private _firstUpdate;
  151577. /**
  151578. * Gets active scene
  151579. */
  151580. get scene(): Scene;
  151581. /**
  151582. * @constructor
  151583. * @param name - The rendering pipeline name
  151584. * @param scene - The scene linked to this pipeline
  151585. * @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 }
  151586. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  151587. */
  151588. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  151589. /**
  151590. * Get the class name
  151591. * @returns "SSAORenderingPipeline"
  151592. */
  151593. getClassName(): string;
  151594. /**
  151595. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151596. */
  151597. dispose(disableDepthRender?: boolean): void;
  151598. private _createBlurPostProcess;
  151599. /** @hidden */
  151600. _rebuild(): void;
  151601. private _createSSAOPostProcess;
  151602. private _createSSAOCombinePostProcess;
  151603. private _createRandomTexture;
  151604. }
  151605. }
  151606. declare module BABYLON {
  151607. /** @hidden */
  151608. export var screenSpaceReflectionPixelShader: {
  151609. name: string;
  151610. shader: string;
  151611. };
  151612. }
  151613. declare module BABYLON {
  151614. /**
  151615. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  151616. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  151617. */
  151618. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  151619. /**
  151620. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  151621. */
  151622. threshold: number;
  151623. /**
  151624. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  151625. */
  151626. strength: number;
  151627. /**
  151628. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  151629. */
  151630. reflectionSpecularFalloffExponent: number;
  151631. /**
  151632. * 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]
  151633. */
  151634. step: number;
  151635. /**
  151636. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  151637. */
  151638. roughnessFactor: number;
  151639. private _geometryBufferRenderer;
  151640. private _enableSmoothReflections;
  151641. private _reflectionSamples;
  151642. private _smoothSteps;
  151643. /**
  151644. * Gets a string identifying the name of the class
  151645. * @returns "ScreenSpaceReflectionPostProcess" string
  151646. */
  151647. getClassName(): string;
  151648. /**
  151649. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  151650. * @param name The name of the effect.
  151651. * @param scene The scene containing the objects to calculate reflections.
  151652. * @param options The required width/height ratio to downsize to before computing the render pass.
  151653. * @param camera The camera to apply the render pass to.
  151654. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151655. * @param engine The engine which the post process will be applied. (default: current engine)
  151656. * @param reusable If the post process can be reused on the same frame. (default: false)
  151657. * @param textureType Type of textures used when performing the post process. (default: 0)
  151658. * @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)
  151659. */
  151660. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151661. /**
  151662. * Gets wether or not smoothing reflections is enabled.
  151663. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151664. */
  151665. get enableSmoothReflections(): boolean;
  151666. /**
  151667. * Sets wether or not smoothing reflections is enabled.
  151668. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151669. */
  151670. set enableSmoothReflections(enabled: boolean);
  151671. /**
  151672. * Gets the number of samples taken while computing reflections. More samples count is high,
  151673. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151674. */
  151675. get reflectionSamples(): number;
  151676. /**
  151677. * Sets the number of samples taken while computing reflections. More samples count is high,
  151678. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151679. */
  151680. set reflectionSamples(samples: number);
  151681. /**
  151682. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  151683. * more the post-process will require GPU power and can generate a drop in FPS.
  151684. * Default value (5.0) work pretty well in all cases but can be adjusted.
  151685. */
  151686. get smoothSteps(): number;
  151687. set smoothSteps(steps: number);
  151688. private _updateEffectDefines;
  151689. /** @hidden */
  151690. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  151691. }
  151692. }
  151693. declare module BABYLON {
  151694. /** @hidden */
  151695. export var standardPixelShader: {
  151696. name: string;
  151697. shader: string;
  151698. };
  151699. }
  151700. declare module BABYLON {
  151701. /**
  151702. * Standard rendering pipeline
  151703. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151704. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  151705. */
  151706. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151707. /**
  151708. * Public members
  151709. */
  151710. /**
  151711. * Post-process which contains the original scene color before the pipeline applies all the effects
  151712. */
  151713. originalPostProcess: Nullable<PostProcess>;
  151714. /**
  151715. * Post-process used to down scale an image x4
  151716. */
  151717. downSampleX4PostProcess: Nullable<PostProcess>;
  151718. /**
  151719. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  151720. */
  151721. brightPassPostProcess: Nullable<PostProcess>;
  151722. /**
  151723. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  151724. */
  151725. blurHPostProcesses: PostProcess[];
  151726. /**
  151727. * Post-process array storing all the vertical blur post-processes used by the pipeline
  151728. */
  151729. blurVPostProcesses: PostProcess[];
  151730. /**
  151731. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  151732. */
  151733. textureAdderPostProcess: Nullable<PostProcess>;
  151734. /**
  151735. * Post-process used to create volumetric lighting effect
  151736. */
  151737. volumetricLightPostProcess: Nullable<PostProcess>;
  151738. /**
  151739. * Post-process used to smooth the previous volumetric light post-process on the X axis
  151740. */
  151741. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  151742. /**
  151743. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  151744. */
  151745. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  151746. /**
  151747. * Post-process used to merge the volumetric light effect and the real scene color
  151748. */
  151749. volumetricLightMergePostProces: Nullable<PostProcess>;
  151750. /**
  151751. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  151752. */
  151753. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  151754. /**
  151755. * Base post-process used to calculate the average luminance of the final image for HDR
  151756. */
  151757. luminancePostProcess: Nullable<PostProcess>;
  151758. /**
  151759. * Post-processes used to create down sample post-processes in order to get
  151760. * the average luminance of the final image for HDR
  151761. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  151762. */
  151763. luminanceDownSamplePostProcesses: PostProcess[];
  151764. /**
  151765. * Post-process used to create a HDR effect (light adaptation)
  151766. */
  151767. hdrPostProcess: Nullable<PostProcess>;
  151768. /**
  151769. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  151770. */
  151771. textureAdderFinalPostProcess: Nullable<PostProcess>;
  151772. /**
  151773. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  151774. */
  151775. lensFlareFinalPostProcess: Nullable<PostProcess>;
  151776. /**
  151777. * Post-process used to merge the final HDR post-process and the real scene color
  151778. */
  151779. hdrFinalPostProcess: Nullable<PostProcess>;
  151780. /**
  151781. * Post-process used to create a lens flare effect
  151782. */
  151783. lensFlarePostProcess: Nullable<PostProcess>;
  151784. /**
  151785. * Post-process that merges the result of the lens flare post-process and the real scene color
  151786. */
  151787. lensFlareComposePostProcess: Nullable<PostProcess>;
  151788. /**
  151789. * Post-process used to create a motion blur effect
  151790. */
  151791. motionBlurPostProcess: Nullable<PostProcess>;
  151792. /**
  151793. * Post-process used to create a depth of field effect
  151794. */
  151795. depthOfFieldPostProcess: Nullable<PostProcess>;
  151796. /**
  151797. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151798. */
  151799. fxaaPostProcess: Nullable<FxaaPostProcess>;
  151800. /**
  151801. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  151802. */
  151803. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  151804. /**
  151805. * Represents the brightness threshold in order to configure the illuminated surfaces
  151806. */
  151807. brightThreshold: number;
  151808. /**
  151809. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  151810. */
  151811. blurWidth: number;
  151812. /**
  151813. * Sets if the blur for highlighted surfaces must be only horizontal
  151814. */
  151815. horizontalBlur: boolean;
  151816. /**
  151817. * Gets the overall exposure used by the pipeline
  151818. */
  151819. get exposure(): number;
  151820. /**
  151821. * Sets the overall exposure used by the pipeline
  151822. */
  151823. set exposure(value: number);
  151824. /**
  151825. * Texture used typically to simulate "dirty" on camera lens
  151826. */
  151827. lensTexture: Nullable<Texture>;
  151828. /**
  151829. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  151830. */
  151831. volumetricLightCoefficient: number;
  151832. /**
  151833. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  151834. */
  151835. volumetricLightPower: number;
  151836. /**
  151837. * Used the set the blur intensity to smooth the volumetric lights
  151838. */
  151839. volumetricLightBlurScale: number;
  151840. /**
  151841. * Light (spot or directional) used to generate the volumetric lights rays
  151842. * The source light must have a shadow generate so the pipeline can get its
  151843. * depth map
  151844. */
  151845. sourceLight: Nullable<SpotLight | DirectionalLight>;
  151846. /**
  151847. * For eye adaptation, represents the minimum luminance the eye can see
  151848. */
  151849. hdrMinimumLuminance: number;
  151850. /**
  151851. * For eye adaptation, represents the decrease luminance speed
  151852. */
  151853. hdrDecreaseRate: number;
  151854. /**
  151855. * For eye adaptation, represents the increase luminance speed
  151856. */
  151857. hdrIncreaseRate: number;
  151858. /**
  151859. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151860. */
  151861. get hdrAutoExposure(): boolean;
  151862. /**
  151863. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151864. */
  151865. set hdrAutoExposure(value: boolean);
  151866. /**
  151867. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  151868. */
  151869. lensColorTexture: Nullable<Texture>;
  151870. /**
  151871. * The overall strengh for the lens flare effect
  151872. */
  151873. lensFlareStrength: number;
  151874. /**
  151875. * Dispersion coefficient for lens flare ghosts
  151876. */
  151877. lensFlareGhostDispersal: number;
  151878. /**
  151879. * Main lens flare halo width
  151880. */
  151881. lensFlareHaloWidth: number;
  151882. /**
  151883. * Based on the lens distortion effect, defines how much the lens flare result
  151884. * is distorted
  151885. */
  151886. lensFlareDistortionStrength: number;
  151887. /**
  151888. * Configures the blur intensity used for for lens flare (halo)
  151889. */
  151890. lensFlareBlurWidth: number;
  151891. /**
  151892. * Lens star texture must be used to simulate rays on the flares and is available
  151893. * in the documentation
  151894. */
  151895. lensStarTexture: Nullable<Texture>;
  151896. /**
  151897. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  151898. * flare effect by taking account of the dirt texture
  151899. */
  151900. lensFlareDirtTexture: Nullable<Texture>;
  151901. /**
  151902. * Represents the focal length for the depth of field effect
  151903. */
  151904. depthOfFieldDistance: number;
  151905. /**
  151906. * Represents the blur intensity for the blurred part of the depth of field effect
  151907. */
  151908. depthOfFieldBlurWidth: number;
  151909. /**
  151910. * Gets how much the image is blurred by the movement while using the motion blur post-process
  151911. */
  151912. get motionStrength(): number;
  151913. /**
  151914. * Sets how much the image is blurred by the movement while using the motion blur post-process
  151915. */
  151916. set motionStrength(strength: number);
  151917. /**
  151918. * Gets wether or not the motion blur post-process is object based or screen based.
  151919. */
  151920. get objectBasedMotionBlur(): boolean;
  151921. /**
  151922. * Sets wether or not the motion blur post-process should be object based or screen based
  151923. */
  151924. set objectBasedMotionBlur(value: boolean);
  151925. /**
  151926. * List of animations for the pipeline (IAnimatable implementation)
  151927. */
  151928. animations: Animation[];
  151929. /**
  151930. * Private members
  151931. */
  151932. private _scene;
  151933. private _currentDepthOfFieldSource;
  151934. private _basePostProcess;
  151935. private _fixedExposure;
  151936. private _currentExposure;
  151937. private _hdrAutoExposure;
  151938. private _hdrCurrentLuminance;
  151939. private _motionStrength;
  151940. private _isObjectBasedMotionBlur;
  151941. private _floatTextureType;
  151942. private _camerasToBeAttached;
  151943. private _ratio;
  151944. private _bloomEnabled;
  151945. private _depthOfFieldEnabled;
  151946. private _vlsEnabled;
  151947. private _lensFlareEnabled;
  151948. private _hdrEnabled;
  151949. private _motionBlurEnabled;
  151950. private _fxaaEnabled;
  151951. private _screenSpaceReflectionsEnabled;
  151952. private _motionBlurSamples;
  151953. private _volumetricLightStepsCount;
  151954. private _samples;
  151955. /**
  151956. * @ignore
  151957. * Specifies if the bloom pipeline is enabled
  151958. */
  151959. get BloomEnabled(): boolean;
  151960. set BloomEnabled(enabled: boolean);
  151961. /**
  151962. * @ignore
  151963. * Specifies if the depth of field pipeline is enabed
  151964. */
  151965. get DepthOfFieldEnabled(): boolean;
  151966. set DepthOfFieldEnabled(enabled: boolean);
  151967. /**
  151968. * @ignore
  151969. * Specifies if the lens flare pipeline is enabed
  151970. */
  151971. get LensFlareEnabled(): boolean;
  151972. set LensFlareEnabled(enabled: boolean);
  151973. /**
  151974. * @ignore
  151975. * Specifies if the HDR pipeline is enabled
  151976. */
  151977. get HDREnabled(): boolean;
  151978. set HDREnabled(enabled: boolean);
  151979. /**
  151980. * @ignore
  151981. * Specifies if the volumetric lights scattering effect is enabled
  151982. */
  151983. get VLSEnabled(): boolean;
  151984. set VLSEnabled(enabled: boolean);
  151985. /**
  151986. * @ignore
  151987. * Specifies if the motion blur effect is enabled
  151988. */
  151989. get MotionBlurEnabled(): boolean;
  151990. set MotionBlurEnabled(enabled: boolean);
  151991. /**
  151992. * Specifies if anti-aliasing is enabled
  151993. */
  151994. get fxaaEnabled(): boolean;
  151995. set fxaaEnabled(enabled: boolean);
  151996. /**
  151997. * Specifies if screen space reflections are enabled.
  151998. */
  151999. get screenSpaceReflectionsEnabled(): boolean;
  152000. set screenSpaceReflectionsEnabled(enabled: boolean);
  152001. /**
  152002. * Specifies the number of steps used to calculate the volumetric lights
  152003. * Typically in interval [50, 200]
  152004. */
  152005. get volumetricLightStepsCount(): number;
  152006. set volumetricLightStepsCount(count: number);
  152007. /**
  152008. * Specifies the number of samples used for the motion blur effect
  152009. * Typically in interval [16, 64]
  152010. */
  152011. get motionBlurSamples(): number;
  152012. set motionBlurSamples(samples: number);
  152013. /**
  152014. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  152015. */
  152016. get samples(): number;
  152017. set samples(sampleCount: number);
  152018. /**
  152019. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152020. * @constructor
  152021. * @param name The rendering pipeline name
  152022. * @param scene The scene linked to this pipeline
  152023. * @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)
  152024. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  152025. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152026. */
  152027. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  152028. private _buildPipeline;
  152029. private _createDownSampleX4PostProcess;
  152030. private _createBrightPassPostProcess;
  152031. private _createBlurPostProcesses;
  152032. private _createTextureAdderPostProcess;
  152033. private _createVolumetricLightPostProcess;
  152034. private _createLuminancePostProcesses;
  152035. private _createHdrPostProcess;
  152036. private _createLensFlarePostProcess;
  152037. private _createDepthOfFieldPostProcess;
  152038. private _createMotionBlurPostProcess;
  152039. private _getDepthTexture;
  152040. private _disposePostProcesses;
  152041. /**
  152042. * Dispose of the pipeline and stop all post processes
  152043. */
  152044. dispose(): void;
  152045. /**
  152046. * Serialize the rendering pipeline (Used when exporting)
  152047. * @returns the serialized object
  152048. */
  152049. serialize(): any;
  152050. /**
  152051. * Parse the serialized pipeline
  152052. * @param source Source pipeline.
  152053. * @param scene The scene to load the pipeline to.
  152054. * @param rootUrl The URL of the serialized pipeline.
  152055. * @returns An instantiated pipeline from the serialized object.
  152056. */
  152057. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  152058. /**
  152059. * Luminance steps
  152060. */
  152061. static LuminanceSteps: number;
  152062. }
  152063. }
  152064. declare module BABYLON {
  152065. /** @hidden */
  152066. export var stereoscopicInterlacePixelShader: {
  152067. name: string;
  152068. shader: string;
  152069. };
  152070. }
  152071. declare module BABYLON {
  152072. /**
  152073. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  152074. */
  152075. export class StereoscopicInterlacePostProcessI extends PostProcess {
  152076. private _stepSize;
  152077. private _passedProcess;
  152078. /**
  152079. * Gets a string identifying the name of the class
  152080. * @returns "StereoscopicInterlacePostProcessI" string
  152081. */
  152082. getClassName(): string;
  152083. /**
  152084. * Initializes a StereoscopicInterlacePostProcessI
  152085. * @param name The name of the effect.
  152086. * @param rigCameras The rig cameras to be appled to the post process
  152087. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  152088. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  152089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152090. * @param engine The engine which the post process will be applied. (default: current engine)
  152091. * @param reusable If the post process can be reused on the same frame. (default: false)
  152092. */
  152093. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152094. }
  152095. /**
  152096. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  152097. */
  152098. export class StereoscopicInterlacePostProcess extends PostProcess {
  152099. private _stepSize;
  152100. private _passedProcess;
  152101. /**
  152102. * Gets a string identifying the name of the class
  152103. * @returns "StereoscopicInterlacePostProcess" string
  152104. */
  152105. getClassName(): string;
  152106. /**
  152107. * Initializes a StereoscopicInterlacePostProcess
  152108. * @param name The name of the effect.
  152109. * @param rigCameras The rig cameras to be appled to the post process
  152110. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  152111. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152112. * @param engine The engine which the post process will be applied. (default: current engine)
  152113. * @param reusable If the post process can be reused on the same frame. (default: false)
  152114. */
  152115. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152116. }
  152117. }
  152118. declare module BABYLON {
  152119. /** @hidden */
  152120. export var tonemapPixelShader: {
  152121. name: string;
  152122. shader: string;
  152123. };
  152124. }
  152125. declare module BABYLON {
  152126. /** Defines operator used for tonemapping */
  152127. export enum TonemappingOperator {
  152128. /** Hable */
  152129. Hable = 0,
  152130. /** Reinhard */
  152131. Reinhard = 1,
  152132. /** HejiDawson */
  152133. HejiDawson = 2,
  152134. /** Photographic */
  152135. Photographic = 3
  152136. }
  152137. /**
  152138. * Defines a post process to apply tone mapping
  152139. */
  152140. export class TonemapPostProcess extends PostProcess {
  152141. private _operator;
  152142. /** Defines the required exposure adjustement */
  152143. exposureAdjustment: number;
  152144. /**
  152145. * Gets a string identifying the name of the class
  152146. * @returns "TonemapPostProcess" string
  152147. */
  152148. getClassName(): string;
  152149. /**
  152150. * Creates a new TonemapPostProcess
  152151. * @param name defines the name of the postprocess
  152152. * @param _operator defines the operator to use
  152153. * @param exposureAdjustment defines the required exposure adjustement
  152154. * @param camera defines the camera to use (can be null)
  152155. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  152156. * @param engine defines the hosting engine (can be ignore if camera is set)
  152157. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  152158. */
  152159. constructor(name: string, _operator: TonemappingOperator,
  152160. /** Defines the required exposure adjustement */
  152161. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  152162. }
  152163. }
  152164. declare module BABYLON {
  152165. /** @hidden */
  152166. export var volumetricLightScatteringPixelShader: {
  152167. name: string;
  152168. shader: string;
  152169. };
  152170. }
  152171. declare module BABYLON {
  152172. /** @hidden */
  152173. export var volumetricLightScatteringPassVertexShader: {
  152174. name: string;
  152175. shader: string;
  152176. };
  152177. }
  152178. declare module BABYLON {
  152179. /** @hidden */
  152180. export var volumetricLightScatteringPassPixelShader: {
  152181. name: string;
  152182. shader: string;
  152183. };
  152184. }
  152185. declare module BABYLON {
  152186. /**
  152187. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  152188. */
  152189. export class VolumetricLightScatteringPostProcess extends PostProcess {
  152190. private _volumetricLightScatteringPass;
  152191. private _volumetricLightScatteringRTT;
  152192. private _viewPort;
  152193. private _screenCoordinates;
  152194. private _cachedDefines;
  152195. /**
  152196. * If not undefined, the mesh position is computed from the attached node position
  152197. */
  152198. attachedNode: {
  152199. position: Vector3;
  152200. };
  152201. /**
  152202. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  152203. */
  152204. customMeshPosition: Vector3;
  152205. /**
  152206. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  152207. */
  152208. useCustomMeshPosition: boolean;
  152209. /**
  152210. * If the post-process should inverse the light scattering direction
  152211. */
  152212. invert: boolean;
  152213. /**
  152214. * The internal mesh used by the post-process
  152215. */
  152216. mesh: Mesh;
  152217. /**
  152218. * @hidden
  152219. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  152220. */
  152221. get useDiffuseColor(): boolean;
  152222. set useDiffuseColor(useDiffuseColor: boolean);
  152223. /**
  152224. * Array containing the excluded meshes not rendered in the internal pass
  152225. */
  152226. excludedMeshes: AbstractMesh[];
  152227. /**
  152228. * Controls the overall intensity of the post-process
  152229. */
  152230. exposure: number;
  152231. /**
  152232. * Dissipates each sample's contribution in range [0, 1]
  152233. */
  152234. decay: number;
  152235. /**
  152236. * Controls the overall intensity of each sample
  152237. */
  152238. weight: number;
  152239. /**
  152240. * Controls the density of each sample
  152241. */
  152242. density: number;
  152243. /**
  152244. * @constructor
  152245. * @param name The post-process name
  152246. * @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)
  152247. * @param camera The camera that the post-process will be attached to
  152248. * @param mesh The mesh used to create the light scattering
  152249. * @param samples The post-process quality, default 100
  152250. * @param samplingModeThe post-process filtering mode
  152251. * @param engine The babylon engine
  152252. * @param reusable If the post-process is reusable
  152253. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  152254. */
  152255. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  152256. /**
  152257. * Returns the string "VolumetricLightScatteringPostProcess"
  152258. * @returns "VolumetricLightScatteringPostProcess"
  152259. */
  152260. getClassName(): string;
  152261. private _isReady;
  152262. /**
  152263. * Sets the new light position for light scattering effect
  152264. * @param position The new custom light position
  152265. */
  152266. setCustomMeshPosition(position: Vector3): void;
  152267. /**
  152268. * Returns the light position for light scattering effect
  152269. * @return Vector3 The custom light position
  152270. */
  152271. getCustomMeshPosition(): Vector3;
  152272. /**
  152273. * Disposes the internal assets and detaches the post-process from the camera
  152274. */
  152275. dispose(camera: Camera): void;
  152276. /**
  152277. * Returns the render target texture used by the post-process
  152278. * @return the render target texture used by the post-process
  152279. */
  152280. getPass(): RenderTargetTexture;
  152281. private _meshExcluded;
  152282. private _createPass;
  152283. private _updateMeshScreenCoordinates;
  152284. /**
  152285. * Creates a default mesh for the Volumeric Light Scattering post-process
  152286. * @param name The mesh name
  152287. * @param scene The scene where to create the mesh
  152288. * @return the default mesh
  152289. */
  152290. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  152291. }
  152292. }
  152293. declare module BABYLON {
  152294. /** @hidden */
  152295. export var screenSpaceCurvaturePixelShader: {
  152296. name: string;
  152297. shader: string;
  152298. };
  152299. }
  152300. declare module BABYLON {
  152301. /**
  152302. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  152303. */
  152304. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  152305. /**
  152306. * Defines how much ridge the curvature effect displays.
  152307. */
  152308. ridge: number;
  152309. /**
  152310. * Defines how much valley the curvature effect displays.
  152311. */
  152312. valley: number;
  152313. private _geometryBufferRenderer;
  152314. /**
  152315. * Gets a string identifying the name of the class
  152316. * @returns "ScreenSpaceCurvaturePostProcess" string
  152317. */
  152318. getClassName(): string;
  152319. /**
  152320. * Creates a new instance ScreenSpaceCurvaturePostProcess
  152321. * @param name The name of the effect.
  152322. * @param scene The scene containing the objects to blur according to their velocity.
  152323. * @param options The required width/height ratio to downsize to before computing the render pass.
  152324. * @param camera The camera to apply the render pass to.
  152325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152326. * @param engine The engine which the post process will be applied. (default: current engine)
  152327. * @param reusable If the post process can be reused on the same frame. (default: false)
  152328. * @param textureType Type of textures used when performing the post process. (default: 0)
  152329. * @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)
  152330. */
  152331. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152332. /**
  152333. * Support test.
  152334. */
  152335. static get IsSupported(): boolean;
  152336. /** @hidden */
  152337. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  152338. }
  152339. }
  152340. declare module BABYLON {
  152341. interface Scene {
  152342. /** @hidden (Backing field) */
  152343. _boundingBoxRenderer: BoundingBoxRenderer;
  152344. /** @hidden (Backing field) */
  152345. _forceShowBoundingBoxes: boolean;
  152346. /**
  152347. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  152348. */
  152349. forceShowBoundingBoxes: boolean;
  152350. /**
  152351. * Gets the bounding box renderer associated with the scene
  152352. * @returns a BoundingBoxRenderer
  152353. */
  152354. getBoundingBoxRenderer(): BoundingBoxRenderer;
  152355. }
  152356. interface AbstractMesh {
  152357. /** @hidden (Backing field) */
  152358. _showBoundingBox: boolean;
  152359. /**
  152360. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  152361. */
  152362. showBoundingBox: boolean;
  152363. }
  152364. /**
  152365. * Component responsible of rendering the bounding box of the meshes in a scene.
  152366. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  152367. */
  152368. export class BoundingBoxRenderer implements ISceneComponent {
  152369. /**
  152370. * The component name helpfull to identify the component in the list of scene components.
  152371. */
  152372. readonly name: string;
  152373. /**
  152374. * The scene the component belongs to.
  152375. */
  152376. scene: Scene;
  152377. /**
  152378. * Color of the bounding box lines placed in front of an object
  152379. */
  152380. frontColor: Color3;
  152381. /**
  152382. * Color of the bounding box lines placed behind an object
  152383. */
  152384. backColor: Color3;
  152385. /**
  152386. * Defines if the renderer should show the back lines or not
  152387. */
  152388. showBackLines: boolean;
  152389. /**
  152390. * Observable raised before rendering a bounding box
  152391. */
  152392. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  152393. /**
  152394. * Observable raised after rendering a bounding box
  152395. */
  152396. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  152397. /**
  152398. * @hidden
  152399. */
  152400. renderList: SmartArray<BoundingBox>;
  152401. private _colorShader;
  152402. private _vertexBuffers;
  152403. private _indexBuffer;
  152404. private _fillIndexBuffer;
  152405. private _fillIndexData;
  152406. /**
  152407. * Instantiates a new bounding box renderer in a scene.
  152408. * @param scene the scene the renderer renders in
  152409. */
  152410. constructor(scene: Scene);
  152411. /**
  152412. * Registers the component in a given scene
  152413. */
  152414. register(): void;
  152415. private _evaluateSubMesh;
  152416. private _activeMesh;
  152417. private _prepareRessources;
  152418. private _createIndexBuffer;
  152419. /**
  152420. * Rebuilds the elements related to this component in case of
  152421. * context lost for instance.
  152422. */
  152423. rebuild(): void;
  152424. /**
  152425. * @hidden
  152426. */
  152427. reset(): void;
  152428. /**
  152429. * Render the bounding boxes of a specific rendering group
  152430. * @param renderingGroupId defines the rendering group to render
  152431. */
  152432. render(renderingGroupId: number): void;
  152433. /**
  152434. * In case of occlusion queries, we can render the occlusion bounding box through this method
  152435. * @param mesh Define the mesh to render the occlusion bounding box for
  152436. */
  152437. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  152438. /**
  152439. * Dispose and release the resources attached to this renderer.
  152440. */
  152441. dispose(): void;
  152442. }
  152443. }
  152444. declare module BABYLON {
  152445. interface Scene {
  152446. /** @hidden (Backing field) */
  152447. _depthRenderer: {
  152448. [id: string]: DepthRenderer;
  152449. };
  152450. /**
  152451. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  152452. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  152453. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  152454. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  152455. * @returns the created depth renderer
  152456. */
  152457. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  152458. /**
  152459. * Disables a depth renderer for a given camera
  152460. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  152461. */
  152462. disableDepthRenderer(camera?: Nullable<Camera>): void;
  152463. }
  152464. /**
  152465. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  152466. * in several rendering techniques.
  152467. */
  152468. export class DepthRendererSceneComponent implements ISceneComponent {
  152469. /**
  152470. * The component name helpfull to identify the component in the list of scene components.
  152471. */
  152472. readonly name: string;
  152473. /**
  152474. * The scene the component belongs to.
  152475. */
  152476. scene: Scene;
  152477. /**
  152478. * Creates a new instance of the component for the given scene
  152479. * @param scene Defines the scene to register the component in
  152480. */
  152481. constructor(scene: Scene);
  152482. /**
  152483. * Registers the component in a given scene
  152484. */
  152485. register(): void;
  152486. /**
  152487. * Rebuilds the elements related to this component in case of
  152488. * context lost for instance.
  152489. */
  152490. rebuild(): void;
  152491. /**
  152492. * Disposes the component and the associated ressources
  152493. */
  152494. dispose(): void;
  152495. private _gatherRenderTargets;
  152496. private _gatherActiveCameraRenderTargets;
  152497. }
  152498. }
  152499. declare module BABYLON {
  152500. interface AbstractScene {
  152501. /** @hidden (Backing field) */
  152502. _prePassRenderer: Nullable<PrePassRenderer>;
  152503. /**
  152504. * Gets or Sets the current prepass renderer associated to the scene.
  152505. */
  152506. prePassRenderer: Nullable<PrePassRenderer>;
  152507. /**
  152508. * Enables the prepass and associates it with the scene
  152509. * @returns the PrePassRenderer
  152510. */
  152511. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  152512. /**
  152513. * Disables the prepass associated with the scene
  152514. */
  152515. disablePrePassRenderer(): void;
  152516. }
  152517. /**
  152518. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152519. * in several rendering techniques.
  152520. */
  152521. export class PrePassRendererSceneComponent implements ISceneComponent {
  152522. /**
  152523. * The component name helpful to identify the component in the list of scene components.
  152524. */
  152525. readonly name: string;
  152526. /**
  152527. * The scene the component belongs to.
  152528. */
  152529. scene: Scene;
  152530. /**
  152531. * Creates a new instance of the component for the given scene
  152532. * @param scene Defines the scene to register the component in
  152533. */
  152534. constructor(scene: Scene);
  152535. /**
  152536. * Registers the component in a given scene
  152537. */
  152538. register(): void;
  152539. private _beforeCameraDraw;
  152540. private _afterCameraDraw;
  152541. private _beforeClearStage;
  152542. /**
  152543. * Rebuilds the elements related to this component in case of
  152544. * context lost for instance.
  152545. */
  152546. rebuild(): void;
  152547. /**
  152548. * Disposes the component and the associated ressources
  152549. */
  152550. dispose(): void;
  152551. }
  152552. }
  152553. declare module BABYLON {
  152554. /** @hidden */
  152555. export var fibonacci: {
  152556. name: string;
  152557. shader: string;
  152558. };
  152559. }
  152560. declare module BABYLON {
  152561. /** @hidden */
  152562. export var diffusionProfile: {
  152563. name: string;
  152564. shader: string;
  152565. };
  152566. }
  152567. declare module BABYLON {
  152568. /** @hidden */
  152569. export var subSurfaceScatteringPixelShader: {
  152570. name: string;
  152571. shader: string;
  152572. };
  152573. }
  152574. declare module BABYLON {
  152575. /**
  152576. * Sub surface scattering post process
  152577. */
  152578. export class SubSurfaceScatteringPostProcess extends PostProcess {
  152579. /**
  152580. * Gets a string identifying the name of the class
  152581. * @returns "SubSurfaceScatteringPostProcess" string
  152582. */
  152583. getClassName(): string;
  152584. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152585. }
  152586. }
  152587. declare module BABYLON {
  152588. /**
  152589. * Contains all parameters needed for the prepass to perform
  152590. * screen space subsurface scattering
  152591. */
  152592. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  152593. /** @hidden */
  152594. static _SceneComponentInitialization: (scene: Scene) => void;
  152595. private _ssDiffusionS;
  152596. private _ssFilterRadii;
  152597. private _ssDiffusionD;
  152598. /**
  152599. * Post process to attach for screen space subsurface scattering
  152600. */
  152601. postProcess: SubSurfaceScatteringPostProcess;
  152602. /**
  152603. * Diffusion profile color for subsurface scattering
  152604. */
  152605. get ssDiffusionS(): number[];
  152606. /**
  152607. * Diffusion profile max color channel value for subsurface scattering
  152608. */
  152609. get ssDiffusionD(): number[];
  152610. /**
  152611. * Diffusion profile filter radius for subsurface scattering
  152612. */
  152613. get ssFilterRadii(): number[];
  152614. /**
  152615. * Is subsurface enabled
  152616. */
  152617. enabled: boolean;
  152618. /**
  152619. * Name of the configuration
  152620. */
  152621. name: string;
  152622. /**
  152623. * Diffusion profile colors for subsurface scattering
  152624. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  152625. * See ...
  152626. * Note that you can only store up to 5 of them
  152627. */
  152628. ssDiffusionProfileColors: Color3[];
  152629. /**
  152630. * Defines the ratio real world => scene units.
  152631. * Used for subsurface scattering
  152632. */
  152633. metersPerUnit: number;
  152634. /**
  152635. * Textures that should be present in the MRT for this effect to work
  152636. */
  152637. readonly texturesRequired: number[];
  152638. private _scene;
  152639. /**
  152640. * Builds a subsurface configuration object
  152641. * @param scene The scene
  152642. */
  152643. constructor(scene: Scene);
  152644. /**
  152645. * Adds a new diffusion profile.
  152646. * Useful for more realistic subsurface scattering on diverse materials.
  152647. * @param color The color of the diffusion profile. Should be the average color of the material.
  152648. * @return The index of the diffusion profile for the material subsurface configuration
  152649. */
  152650. addDiffusionProfile(color: Color3): number;
  152651. /**
  152652. * Creates the sss post process
  152653. * @return The created post process
  152654. */
  152655. createPostProcess(): SubSurfaceScatteringPostProcess;
  152656. /**
  152657. * Deletes all diffusion profiles.
  152658. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  152659. */
  152660. clearAllDiffusionProfiles(): void;
  152661. /**
  152662. * Disposes this object
  152663. */
  152664. dispose(): void;
  152665. /**
  152666. * @hidden
  152667. * https://zero-radiance.github.io/post/sampling-diffusion/
  152668. *
  152669. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  152670. * ------------------------------------------------------------------------------------
  152671. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  152672. * PDF[r, phi, s] = r * R[r, phi, s]
  152673. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  152674. * ------------------------------------------------------------------------------------
  152675. * We importance sample the color channel with the widest scattering distance.
  152676. */
  152677. getDiffusionProfileParameters(color: Color3): number;
  152678. /**
  152679. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  152680. * 'u' is the random number (the value of the CDF): [0, 1).
  152681. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  152682. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  152683. */
  152684. private _sampleBurleyDiffusionProfile;
  152685. }
  152686. }
  152687. declare module BABYLON {
  152688. interface AbstractScene {
  152689. /** @hidden (Backing field) */
  152690. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  152691. /**
  152692. * Gets or Sets the current prepass renderer associated to the scene.
  152693. */
  152694. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  152695. /**
  152696. * Enables the subsurface effect for prepass
  152697. * @returns the SubSurfaceConfiguration
  152698. */
  152699. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  152700. /**
  152701. * Disables the subsurface effect for prepass
  152702. */
  152703. disableSubSurfaceForPrePass(): void;
  152704. }
  152705. /**
  152706. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152707. * in several rendering techniques.
  152708. */
  152709. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  152710. /**
  152711. * The component name helpful to identify the component in the list of scene components.
  152712. */
  152713. readonly name: string;
  152714. /**
  152715. * The scene the component belongs to.
  152716. */
  152717. scene: Scene;
  152718. /**
  152719. * Creates a new instance of the component for the given scene
  152720. * @param scene Defines the scene to register the component in
  152721. */
  152722. constructor(scene: Scene);
  152723. /**
  152724. * Registers the component in a given scene
  152725. */
  152726. register(): void;
  152727. /**
  152728. * Serializes the component data to the specified json object
  152729. * @param serializationObject The object to serialize to
  152730. */
  152731. serialize(serializationObject: any): void;
  152732. /**
  152733. * Adds all the elements from the container to the scene
  152734. * @param container the container holding the elements
  152735. */
  152736. addFromContainer(container: AbstractScene): void;
  152737. /**
  152738. * Removes all the elements in the container from the scene
  152739. * @param container contains the elements to remove
  152740. * @param dispose if the removed element should be disposed (default: false)
  152741. */
  152742. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  152743. /**
  152744. * Rebuilds the elements related to this component in case of
  152745. * context lost for instance.
  152746. */
  152747. rebuild(): void;
  152748. /**
  152749. * Disposes the component and the associated ressources
  152750. */
  152751. dispose(): void;
  152752. }
  152753. }
  152754. declare module BABYLON {
  152755. /** @hidden */
  152756. export var outlinePixelShader: {
  152757. name: string;
  152758. shader: string;
  152759. };
  152760. }
  152761. declare module BABYLON {
  152762. /** @hidden */
  152763. export var outlineVertexShader: {
  152764. name: string;
  152765. shader: string;
  152766. };
  152767. }
  152768. declare module BABYLON {
  152769. interface Scene {
  152770. /** @hidden */
  152771. _outlineRenderer: OutlineRenderer;
  152772. /**
  152773. * Gets the outline renderer associated with the scene
  152774. * @returns a OutlineRenderer
  152775. */
  152776. getOutlineRenderer(): OutlineRenderer;
  152777. }
  152778. interface AbstractMesh {
  152779. /** @hidden (Backing field) */
  152780. _renderOutline: boolean;
  152781. /**
  152782. * Gets or sets a boolean indicating if the outline must be rendered as well
  152783. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  152784. */
  152785. renderOutline: boolean;
  152786. /** @hidden (Backing field) */
  152787. _renderOverlay: boolean;
  152788. /**
  152789. * Gets or sets a boolean indicating if the overlay must be rendered as well
  152790. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  152791. */
  152792. renderOverlay: boolean;
  152793. }
  152794. /**
  152795. * This class is responsible to draw bothe outline/overlay of meshes.
  152796. * It should not be used directly but through the available method on mesh.
  152797. */
  152798. export class OutlineRenderer implements ISceneComponent {
  152799. /**
  152800. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  152801. */
  152802. private static _StencilReference;
  152803. /**
  152804. * The name of the component. Each component must have a unique name.
  152805. */
  152806. name: string;
  152807. /**
  152808. * The scene the component belongs to.
  152809. */
  152810. scene: Scene;
  152811. /**
  152812. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  152813. */
  152814. zOffset: number;
  152815. private _engine;
  152816. private _effect;
  152817. private _cachedDefines;
  152818. private _savedDepthWrite;
  152819. /**
  152820. * Instantiates a new outline renderer. (There could be only one per scene).
  152821. * @param scene Defines the scene it belongs to
  152822. */
  152823. constructor(scene: Scene);
  152824. /**
  152825. * Register the component to one instance of a scene.
  152826. */
  152827. register(): void;
  152828. /**
  152829. * Rebuilds the elements related to this component in case of
  152830. * context lost for instance.
  152831. */
  152832. rebuild(): void;
  152833. /**
  152834. * Disposes the component and the associated ressources.
  152835. */
  152836. dispose(): void;
  152837. /**
  152838. * Renders the outline in the canvas.
  152839. * @param subMesh Defines the sumesh to render
  152840. * @param batch Defines the batch of meshes in case of instances
  152841. * @param useOverlay Defines if the rendering is for the overlay or the outline
  152842. */
  152843. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  152844. /**
  152845. * Returns whether or not the outline renderer is ready for a given submesh.
  152846. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  152847. * @param subMesh Defines the submesh to check readyness for
  152848. * @param useInstances Defines wheter wee are trying to render instances or not
  152849. * @returns true if ready otherwise false
  152850. */
  152851. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  152852. private _beforeRenderingMesh;
  152853. private _afterRenderingMesh;
  152854. }
  152855. }
  152856. declare module BABYLON {
  152857. /**
  152858. * Defines the basic options interface of a Sprite Frame Source Size.
  152859. */
  152860. export interface ISpriteJSONSpriteSourceSize {
  152861. /**
  152862. * number of the original width of the Frame
  152863. */
  152864. w: number;
  152865. /**
  152866. * number of the original height of the Frame
  152867. */
  152868. h: number;
  152869. }
  152870. /**
  152871. * Defines the basic options interface of a Sprite Frame Data.
  152872. */
  152873. export interface ISpriteJSONSpriteFrameData {
  152874. /**
  152875. * number of the x offset of the Frame
  152876. */
  152877. x: number;
  152878. /**
  152879. * number of the y offset of the Frame
  152880. */
  152881. y: number;
  152882. /**
  152883. * number of the width of the Frame
  152884. */
  152885. w: number;
  152886. /**
  152887. * number of the height of the Frame
  152888. */
  152889. h: number;
  152890. }
  152891. /**
  152892. * Defines the basic options interface of a JSON Sprite.
  152893. */
  152894. export interface ISpriteJSONSprite {
  152895. /**
  152896. * string name of the Frame
  152897. */
  152898. filename: string;
  152899. /**
  152900. * ISpriteJSONSpriteFrame basic object of the frame data
  152901. */
  152902. frame: ISpriteJSONSpriteFrameData;
  152903. /**
  152904. * boolean to flag is the frame was rotated.
  152905. */
  152906. rotated: boolean;
  152907. /**
  152908. * boolean to flag is the frame was trimmed.
  152909. */
  152910. trimmed: boolean;
  152911. /**
  152912. * ISpriteJSONSpriteFrame basic object of the source data
  152913. */
  152914. spriteSourceSize: ISpriteJSONSpriteFrameData;
  152915. /**
  152916. * ISpriteJSONSpriteFrame basic object of the source data
  152917. */
  152918. sourceSize: ISpriteJSONSpriteSourceSize;
  152919. }
  152920. /**
  152921. * Defines the basic options interface of a JSON atlas.
  152922. */
  152923. export interface ISpriteJSONAtlas {
  152924. /**
  152925. * Array of objects that contain the frame data.
  152926. */
  152927. frames: Array<ISpriteJSONSprite>;
  152928. /**
  152929. * object basic object containing the sprite meta data.
  152930. */
  152931. meta?: object;
  152932. }
  152933. }
  152934. declare module BABYLON {
  152935. /** @hidden */
  152936. export var spriteMapPixelShader: {
  152937. name: string;
  152938. shader: string;
  152939. };
  152940. }
  152941. declare module BABYLON {
  152942. /** @hidden */
  152943. export var spriteMapVertexShader: {
  152944. name: string;
  152945. shader: string;
  152946. };
  152947. }
  152948. declare module BABYLON {
  152949. /**
  152950. * Defines the basic options interface of a SpriteMap
  152951. */
  152952. export interface ISpriteMapOptions {
  152953. /**
  152954. * Vector2 of the number of cells in the grid.
  152955. */
  152956. stageSize?: Vector2;
  152957. /**
  152958. * Vector2 of the size of the output plane in World Units.
  152959. */
  152960. outputSize?: Vector2;
  152961. /**
  152962. * Vector3 of the position of the output plane in World Units.
  152963. */
  152964. outputPosition?: Vector3;
  152965. /**
  152966. * Vector3 of the rotation of the output plane.
  152967. */
  152968. outputRotation?: Vector3;
  152969. /**
  152970. * number of layers that the system will reserve in resources.
  152971. */
  152972. layerCount?: number;
  152973. /**
  152974. * number of max animation frames a single cell will reserve in resources.
  152975. */
  152976. maxAnimationFrames?: number;
  152977. /**
  152978. * number cell index of the base tile when the system compiles.
  152979. */
  152980. baseTile?: number;
  152981. /**
  152982. * boolean flip the sprite after its been repositioned by the framing data.
  152983. */
  152984. flipU?: boolean;
  152985. /**
  152986. * Vector3 scalar of the global RGB values of the SpriteMap.
  152987. */
  152988. colorMultiply?: Vector3;
  152989. }
  152990. /**
  152991. * Defines the IDisposable interface in order to be cleanable from resources.
  152992. */
  152993. export interface ISpriteMap extends IDisposable {
  152994. /**
  152995. * String name of the SpriteMap.
  152996. */
  152997. name: string;
  152998. /**
  152999. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  153000. */
  153001. atlasJSON: ISpriteJSONAtlas;
  153002. /**
  153003. * Texture of the SpriteMap.
  153004. */
  153005. spriteSheet: Texture;
  153006. /**
  153007. * The parameters to initialize the SpriteMap with.
  153008. */
  153009. options: ISpriteMapOptions;
  153010. }
  153011. /**
  153012. * Class used to manage a grid restricted sprite deployment on an Output plane.
  153013. */
  153014. export class SpriteMap implements ISpriteMap {
  153015. /** The Name of the spriteMap */
  153016. name: string;
  153017. /** The JSON file with the frame and meta data */
  153018. atlasJSON: ISpriteJSONAtlas;
  153019. /** The systems Sprite Sheet Texture */
  153020. spriteSheet: Texture;
  153021. /** Arguments passed with the Constructor */
  153022. options: ISpriteMapOptions;
  153023. /** Public Sprite Storage array, parsed from atlasJSON */
  153024. sprites: Array<ISpriteJSONSprite>;
  153025. /** Returns the Number of Sprites in the System */
  153026. get spriteCount(): number;
  153027. /** Returns the Position of Output Plane*/
  153028. get position(): Vector3;
  153029. /** Returns the Position of Output Plane*/
  153030. set position(v: Vector3);
  153031. /** Returns the Rotation of Output Plane*/
  153032. get rotation(): Vector3;
  153033. /** Returns the Rotation of Output Plane*/
  153034. set rotation(v: Vector3);
  153035. /** Sets the AnimationMap*/
  153036. get animationMap(): RawTexture;
  153037. /** Sets the AnimationMap*/
  153038. set animationMap(v: RawTexture);
  153039. /** Scene that the SpriteMap was created in */
  153040. private _scene;
  153041. /** Texture Buffer of Float32 that holds tile frame data*/
  153042. private _frameMap;
  153043. /** Texture Buffers of Float32 that holds tileMap data*/
  153044. private _tileMaps;
  153045. /** Texture Buffer of Float32 that holds Animation Data*/
  153046. private _animationMap;
  153047. /** Custom ShaderMaterial Central to the System*/
  153048. private _material;
  153049. /** Custom ShaderMaterial Central to the System*/
  153050. private _output;
  153051. /** Systems Time Ticker*/
  153052. private _time;
  153053. /**
  153054. * Creates a new SpriteMap
  153055. * @param name defines the SpriteMaps Name
  153056. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  153057. * @param spriteSheet is the Texture that the Sprites are on.
  153058. * @param options a basic deployment configuration
  153059. * @param scene The Scene that the map is deployed on
  153060. */
  153061. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  153062. /**
  153063. * Returns tileID location
  153064. * @returns Vector2 the cell position ID
  153065. */
  153066. getTileID(): Vector2;
  153067. /**
  153068. * Gets the UV location of the mouse over the SpriteMap.
  153069. * @returns Vector2 the UV position of the mouse interaction
  153070. */
  153071. getMousePosition(): Vector2;
  153072. /**
  153073. * Creates the "frame" texture Buffer
  153074. * -------------------------------------
  153075. * Structure of frames
  153076. * "filename": "Falling-Water-2.png",
  153077. * "frame": {"x":69,"y":103,"w":24,"h":32},
  153078. * "rotated": true,
  153079. * "trimmed": true,
  153080. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  153081. * "sourceSize": {"w":32,"h":32}
  153082. * @returns RawTexture of the frameMap
  153083. */
  153084. private _createFrameBuffer;
  153085. /**
  153086. * Creates the tileMap texture Buffer
  153087. * @param buffer normally and array of numbers, or a false to generate from scratch
  153088. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  153089. * @returns RawTexture of the tileMap
  153090. */
  153091. private _createTileBuffer;
  153092. /**
  153093. * Modifies the data of the tileMaps
  153094. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  153095. * @param pos is the iVector2 Coordinates of the Tile
  153096. * @param tile The SpriteIndex of the new Tile
  153097. */
  153098. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  153099. /**
  153100. * Creates the animationMap texture Buffer
  153101. * @param buffer normally and array of numbers, or a false to generate from scratch
  153102. * @returns RawTexture of the animationMap
  153103. */
  153104. private _createTileAnimationBuffer;
  153105. /**
  153106. * Modifies the data of the animationMap
  153107. * @param cellID is the Index of the Sprite
  153108. * @param _frame is the target Animation frame
  153109. * @param toCell is the Target Index of the next frame of the animation
  153110. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  153111. * @param speed is a global scalar of the time variable on the map.
  153112. */
  153113. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  153114. /**
  153115. * Exports the .tilemaps file
  153116. */
  153117. saveTileMaps(): void;
  153118. /**
  153119. * Imports the .tilemaps file
  153120. * @param url of the .tilemaps file
  153121. */
  153122. loadTileMaps(url: string): void;
  153123. /**
  153124. * Release associated resources
  153125. */
  153126. dispose(): void;
  153127. }
  153128. }
  153129. declare module BABYLON {
  153130. /**
  153131. * Class used to manage multiple sprites of different sizes on the same spritesheet
  153132. * @see https://doc.babylonjs.com/babylon101/sprites
  153133. */
  153134. export class SpritePackedManager extends SpriteManager {
  153135. /** defines the packed manager's name */
  153136. name: string;
  153137. /**
  153138. * Creates a new sprite manager from a packed sprite sheet
  153139. * @param name defines the manager's name
  153140. * @param imgUrl defines the sprite sheet url
  153141. * @param capacity defines the maximum allowed number of sprites
  153142. * @param scene defines the hosting scene
  153143. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  153144. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  153145. * @param samplingMode defines the smapling mode to use with spritesheet
  153146. * @param fromPacked set to true; do not alter
  153147. */
  153148. constructor(
  153149. /** defines the packed manager's name */
  153150. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  153151. }
  153152. }
  153153. declare module BABYLON {
  153154. /**
  153155. * Defines the list of states available for a task inside a AssetsManager
  153156. */
  153157. export enum AssetTaskState {
  153158. /**
  153159. * Initialization
  153160. */
  153161. INIT = 0,
  153162. /**
  153163. * Running
  153164. */
  153165. RUNNING = 1,
  153166. /**
  153167. * Done
  153168. */
  153169. DONE = 2,
  153170. /**
  153171. * Error
  153172. */
  153173. ERROR = 3
  153174. }
  153175. /**
  153176. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  153177. */
  153178. export abstract class AbstractAssetTask {
  153179. /**
  153180. * Task name
  153181. */ name: string;
  153182. /**
  153183. * Callback called when the task is successful
  153184. */
  153185. onSuccess: (task: any) => void;
  153186. /**
  153187. * Callback called when the task is not successful
  153188. */
  153189. onError: (task: any, message?: string, exception?: any) => void;
  153190. /**
  153191. * Creates a new AssetsManager
  153192. * @param name defines the name of the task
  153193. */
  153194. constructor(
  153195. /**
  153196. * Task name
  153197. */ name: string);
  153198. private _isCompleted;
  153199. private _taskState;
  153200. private _errorObject;
  153201. /**
  153202. * Get if the task is completed
  153203. */
  153204. get isCompleted(): boolean;
  153205. /**
  153206. * Gets the current state of the task
  153207. */
  153208. get taskState(): AssetTaskState;
  153209. /**
  153210. * Gets the current error object (if task is in error)
  153211. */
  153212. get errorObject(): {
  153213. message?: string;
  153214. exception?: any;
  153215. };
  153216. /**
  153217. * Internal only
  153218. * @hidden
  153219. */
  153220. _setErrorObject(message?: string, exception?: any): void;
  153221. /**
  153222. * Execute the current task
  153223. * @param scene defines the scene where you want your assets to be loaded
  153224. * @param onSuccess is a callback called when the task is successfully executed
  153225. * @param onError is a callback called if an error occurs
  153226. */
  153227. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153228. /**
  153229. * Execute the current task
  153230. * @param scene defines the scene where you want your assets to be loaded
  153231. * @param onSuccess is a callback called when the task is successfully executed
  153232. * @param onError is a callback called if an error occurs
  153233. */
  153234. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153235. /**
  153236. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  153237. * This can be used with failed tasks that have the reason for failure fixed.
  153238. */
  153239. reset(): void;
  153240. private onErrorCallback;
  153241. private onDoneCallback;
  153242. }
  153243. /**
  153244. * Define the interface used by progress events raised during assets loading
  153245. */
  153246. export interface IAssetsProgressEvent {
  153247. /**
  153248. * Defines the number of remaining tasks to process
  153249. */
  153250. remainingCount: number;
  153251. /**
  153252. * Defines the total number of tasks
  153253. */
  153254. totalCount: number;
  153255. /**
  153256. * Defines the task that was just processed
  153257. */
  153258. task: AbstractAssetTask;
  153259. }
  153260. /**
  153261. * Class used to share progress information about assets loading
  153262. */
  153263. export class AssetsProgressEvent implements IAssetsProgressEvent {
  153264. /**
  153265. * Defines the number of remaining tasks to process
  153266. */
  153267. remainingCount: number;
  153268. /**
  153269. * Defines the total number of tasks
  153270. */
  153271. totalCount: number;
  153272. /**
  153273. * Defines the task that was just processed
  153274. */
  153275. task: AbstractAssetTask;
  153276. /**
  153277. * Creates a AssetsProgressEvent
  153278. * @param remainingCount defines the number of remaining tasks to process
  153279. * @param totalCount defines the total number of tasks
  153280. * @param task defines the task that was just processed
  153281. */
  153282. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  153283. }
  153284. /**
  153285. * Define a task used by AssetsManager to load assets into a container
  153286. */
  153287. export class ContainerAssetTask extends AbstractAssetTask {
  153288. /**
  153289. * Defines the name of the task
  153290. */
  153291. name: string;
  153292. /**
  153293. * Defines the list of mesh's names you want to load
  153294. */
  153295. meshesNames: any;
  153296. /**
  153297. * Defines the root url to use as a base to load your meshes and associated resources
  153298. */
  153299. rootUrl: string;
  153300. /**
  153301. * Defines the filename or File of the scene to load from
  153302. */
  153303. sceneFilename: string | File;
  153304. /**
  153305. * Get the loaded asset container
  153306. */
  153307. loadedContainer: AssetContainer;
  153308. /**
  153309. * Gets the list of loaded meshes
  153310. */
  153311. loadedMeshes: Array<AbstractMesh>;
  153312. /**
  153313. * Gets the list of loaded particle systems
  153314. */
  153315. loadedParticleSystems: Array<IParticleSystem>;
  153316. /**
  153317. * Gets the list of loaded skeletons
  153318. */
  153319. loadedSkeletons: Array<Skeleton>;
  153320. /**
  153321. * Gets the list of loaded animation groups
  153322. */
  153323. loadedAnimationGroups: Array<AnimationGroup>;
  153324. /**
  153325. * Callback called when the task is successful
  153326. */
  153327. onSuccess: (task: ContainerAssetTask) => void;
  153328. /**
  153329. * Callback called when the task is successful
  153330. */
  153331. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  153332. /**
  153333. * Creates a new ContainerAssetTask
  153334. * @param name defines the name of the task
  153335. * @param meshesNames defines the list of mesh's names you want to load
  153336. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153337. * @param sceneFilename defines the filename or File of the scene to load from
  153338. */
  153339. constructor(
  153340. /**
  153341. * Defines the name of the task
  153342. */
  153343. name: string,
  153344. /**
  153345. * Defines the list of mesh's names you want to load
  153346. */
  153347. meshesNames: any,
  153348. /**
  153349. * Defines the root url to use as a base to load your meshes and associated resources
  153350. */
  153351. rootUrl: string,
  153352. /**
  153353. * Defines the filename or File of the scene to load from
  153354. */
  153355. sceneFilename: string | File);
  153356. /**
  153357. * Execute the current task
  153358. * @param scene defines the scene where you want your assets to be loaded
  153359. * @param onSuccess is a callback called when the task is successfully executed
  153360. * @param onError is a callback called if an error occurs
  153361. */
  153362. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153363. }
  153364. /**
  153365. * Define a task used by AssetsManager to load meshes
  153366. */
  153367. export class MeshAssetTask extends AbstractAssetTask {
  153368. /**
  153369. * Defines the name of the task
  153370. */
  153371. name: string;
  153372. /**
  153373. * Defines the list of mesh's names you want to load
  153374. */
  153375. meshesNames: any;
  153376. /**
  153377. * Defines the root url to use as a base to load your meshes and associated resources
  153378. */
  153379. rootUrl: string;
  153380. /**
  153381. * Defines the filename or File of the scene to load from
  153382. */
  153383. sceneFilename: string | File;
  153384. /**
  153385. * Gets the list of loaded meshes
  153386. */
  153387. loadedMeshes: Array<AbstractMesh>;
  153388. /**
  153389. * Gets the list of loaded particle systems
  153390. */
  153391. loadedParticleSystems: Array<IParticleSystem>;
  153392. /**
  153393. * Gets the list of loaded skeletons
  153394. */
  153395. loadedSkeletons: Array<Skeleton>;
  153396. /**
  153397. * Gets the list of loaded animation groups
  153398. */
  153399. loadedAnimationGroups: Array<AnimationGroup>;
  153400. /**
  153401. * Callback called when the task is successful
  153402. */
  153403. onSuccess: (task: MeshAssetTask) => void;
  153404. /**
  153405. * Callback called when the task is successful
  153406. */
  153407. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  153408. /**
  153409. * Creates a new MeshAssetTask
  153410. * @param name defines the name of the task
  153411. * @param meshesNames defines the list of mesh's names you want to load
  153412. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153413. * @param sceneFilename defines the filename or File of the scene to load from
  153414. */
  153415. constructor(
  153416. /**
  153417. * Defines the name of the task
  153418. */
  153419. name: string,
  153420. /**
  153421. * Defines the list of mesh's names you want to load
  153422. */
  153423. meshesNames: any,
  153424. /**
  153425. * Defines the root url to use as a base to load your meshes and associated resources
  153426. */
  153427. rootUrl: string,
  153428. /**
  153429. * Defines the filename or File of the scene to load from
  153430. */
  153431. sceneFilename: string | File);
  153432. /**
  153433. * Execute the current task
  153434. * @param scene defines the scene where you want your assets to be loaded
  153435. * @param onSuccess is a callback called when the task is successfully executed
  153436. * @param onError is a callback called if an error occurs
  153437. */
  153438. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153439. }
  153440. /**
  153441. * Define a task used by AssetsManager to load text content
  153442. */
  153443. export class TextFileAssetTask extends AbstractAssetTask {
  153444. /**
  153445. * Defines the name of the task
  153446. */
  153447. name: string;
  153448. /**
  153449. * Defines the location of the file to load
  153450. */
  153451. url: string;
  153452. /**
  153453. * Gets the loaded text string
  153454. */
  153455. text: string;
  153456. /**
  153457. * Callback called when the task is successful
  153458. */
  153459. onSuccess: (task: TextFileAssetTask) => void;
  153460. /**
  153461. * Callback called when the task is successful
  153462. */
  153463. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  153464. /**
  153465. * Creates a new TextFileAssetTask object
  153466. * @param name defines the name of the task
  153467. * @param url defines the location of the file to load
  153468. */
  153469. constructor(
  153470. /**
  153471. * Defines the name of the task
  153472. */
  153473. name: string,
  153474. /**
  153475. * Defines the location of the file to load
  153476. */
  153477. url: string);
  153478. /**
  153479. * Execute the current task
  153480. * @param scene defines the scene where you want your assets to be loaded
  153481. * @param onSuccess is a callback called when the task is successfully executed
  153482. * @param onError is a callback called if an error occurs
  153483. */
  153484. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153485. }
  153486. /**
  153487. * Define a task used by AssetsManager to load binary data
  153488. */
  153489. export class BinaryFileAssetTask extends AbstractAssetTask {
  153490. /**
  153491. * Defines the name of the task
  153492. */
  153493. name: string;
  153494. /**
  153495. * Defines the location of the file to load
  153496. */
  153497. url: string;
  153498. /**
  153499. * Gets the lodaded data (as an array buffer)
  153500. */
  153501. data: ArrayBuffer;
  153502. /**
  153503. * Callback called when the task is successful
  153504. */
  153505. onSuccess: (task: BinaryFileAssetTask) => void;
  153506. /**
  153507. * Callback called when the task is successful
  153508. */
  153509. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  153510. /**
  153511. * Creates a new BinaryFileAssetTask object
  153512. * @param name defines the name of the new task
  153513. * @param url defines the location of the file to load
  153514. */
  153515. constructor(
  153516. /**
  153517. * Defines the name of the task
  153518. */
  153519. name: string,
  153520. /**
  153521. * Defines the location of the file to load
  153522. */
  153523. url: string);
  153524. /**
  153525. * Execute the current task
  153526. * @param scene defines the scene where you want your assets to be loaded
  153527. * @param onSuccess is a callback called when the task is successfully executed
  153528. * @param onError is a callback called if an error occurs
  153529. */
  153530. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153531. }
  153532. /**
  153533. * Define a task used by AssetsManager to load images
  153534. */
  153535. export class ImageAssetTask extends AbstractAssetTask {
  153536. /**
  153537. * Defines the name of the task
  153538. */
  153539. name: string;
  153540. /**
  153541. * Defines the location of the image to load
  153542. */
  153543. url: string;
  153544. /**
  153545. * Gets the loaded images
  153546. */
  153547. image: HTMLImageElement;
  153548. /**
  153549. * Callback called when the task is successful
  153550. */
  153551. onSuccess: (task: ImageAssetTask) => void;
  153552. /**
  153553. * Callback called when the task is successful
  153554. */
  153555. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  153556. /**
  153557. * Creates a new ImageAssetTask
  153558. * @param name defines the name of the task
  153559. * @param url defines the location of the image to load
  153560. */
  153561. constructor(
  153562. /**
  153563. * Defines the name of the task
  153564. */
  153565. name: string,
  153566. /**
  153567. * Defines the location of the image to load
  153568. */
  153569. url: string);
  153570. /**
  153571. * Execute the current task
  153572. * @param scene defines the scene where you want your assets to be loaded
  153573. * @param onSuccess is a callback called when the task is successfully executed
  153574. * @param onError is a callback called if an error occurs
  153575. */
  153576. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153577. }
  153578. /**
  153579. * Defines the interface used by texture loading tasks
  153580. */
  153581. export interface ITextureAssetTask<TEX extends BaseTexture> {
  153582. /**
  153583. * Gets the loaded texture
  153584. */
  153585. texture: TEX;
  153586. }
  153587. /**
  153588. * Define a task used by AssetsManager to load 2D textures
  153589. */
  153590. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  153591. /**
  153592. * Defines the name of the task
  153593. */
  153594. name: string;
  153595. /**
  153596. * Defines the location of the file to load
  153597. */
  153598. url: string;
  153599. /**
  153600. * Defines if mipmap should not be generated (default is false)
  153601. */
  153602. noMipmap?: boolean | undefined;
  153603. /**
  153604. * Defines if texture must be inverted on Y axis (default is true)
  153605. */
  153606. invertY: boolean;
  153607. /**
  153608. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153609. */
  153610. samplingMode: number;
  153611. /**
  153612. * Gets the loaded texture
  153613. */
  153614. texture: Texture;
  153615. /**
  153616. * Callback called when the task is successful
  153617. */
  153618. onSuccess: (task: TextureAssetTask) => void;
  153619. /**
  153620. * Callback called when the task is successful
  153621. */
  153622. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  153623. /**
  153624. * Creates a new TextureAssetTask object
  153625. * @param name defines the name of the task
  153626. * @param url defines the location of the file to load
  153627. * @param noMipmap defines if mipmap should not be generated (default is false)
  153628. * @param invertY defines if texture must be inverted on Y axis (default is true)
  153629. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153630. */
  153631. constructor(
  153632. /**
  153633. * Defines the name of the task
  153634. */
  153635. name: string,
  153636. /**
  153637. * Defines the location of the file to load
  153638. */
  153639. url: string,
  153640. /**
  153641. * Defines if mipmap should not be generated (default is false)
  153642. */
  153643. noMipmap?: boolean | undefined,
  153644. /**
  153645. * Defines if texture must be inverted on Y axis (default is true)
  153646. */
  153647. invertY?: boolean,
  153648. /**
  153649. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153650. */
  153651. samplingMode?: number);
  153652. /**
  153653. * Execute the current task
  153654. * @param scene defines the scene where you want your assets to be loaded
  153655. * @param onSuccess is a callback called when the task is successfully executed
  153656. * @param onError is a callback called if an error occurs
  153657. */
  153658. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153659. }
  153660. /**
  153661. * Define a task used by AssetsManager to load cube textures
  153662. */
  153663. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  153664. /**
  153665. * Defines the name of the task
  153666. */
  153667. name: string;
  153668. /**
  153669. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153670. */
  153671. url: string;
  153672. /**
  153673. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153674. */
  153675. extensions?: string[] | undefined;
  153676. /**
  153677. * Defines if mipmaps should not be generated (default is false)
  153678. */
  153679. noMipmap?: boolean | undefined;
  153680. /**
  153681. * Defines the explicit list of files (undefined by default)
  153682. */
  153683. files?: string[] | undefined;
  153684. /**
  153685. * Gets the loaded texture
  153686. */
  153687. texture: CubeTexture;
  153688. /**
  153689. * Callback called when the task is successful
  153690. */
  153691. onSuccess: (task: CubeTextureAssetTask) => void;
  153692. /**
  153693. * Callback called when the task is successful
  153694. */
  153695. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  153696. /**
  153697. * Creates a new CubeTextureAssetTask
  153698. * @param name defines the name of the task
  153699. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153700. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153701. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153702. * @param files defines the explicit list of files (undefined by default)
  153703. */
  153704. constructor(
  153705. /**
  153706. * Defines the name of the task
  153707. */
  153708. name: string,
  153709. /**
  153710. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153711. */
  153712. url: string,
  153713. /**
  153714. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153715. */
  153716. extensions?: string[] | undefined,
  153717. /**
  153718. * Defines if mipmaps should not be generated (default is false)
  153719. */
  153720. noMipmap?: boolean | undefined,
  153721. /**
  153722. * Defines the explicit list of files (undefined by default)
  153723. */
  153724. files?: string[] | undefined);
  153725. /**
  153726. * Execute the current task
  153727. * @param scene defines the scene where you want your assets to be loaded
  153728. * @param onSuccess is a callback called when the task is successfully executed
  153729. * @param onError is a callback called if an error occurs
  153730. */
  153731. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153732. }
  153733. /**
  153734. * Define a task used by AssetsManager to load HDR cube textures
  153735. */
  153736. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  153737. /**
  153738. * Defines the name of the task
  153739. */
  153740. name: string;
  153741. /**
  153742. * Defines the location of the file to load
  153743. */
  153744. url: string;
  153745. /**
  153746. * Defines the desired size (the more it increases the longer the generation will be)
  153747. */
  153748. size: number;
  153749. /**
  153750. * Defines if mipmaps should not be generated (default is false)
  153751. */
  153752. noMipmap: boolean;
  153753. /**
  153754. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153755. */
  153756. generateHarmonics: boolean;
  153757. /**
  153758. * 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)
  153759. */
  153760. gammaSpace: boolean;
  153761. /**
  153762. * Internal Use Only
  153763. */
  153764. reserved: boolean;
  153765. /**
  153766. * Gets the loaded texture
  153767. */
  153768. texture: HDRCubeTexture;
  153769. /**
  153770. * Callback called when the task is successful
  153771. */
  153772. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  153773. /**
  153774. * Callback called when the task is successful
  153775. */
  153776. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  153777. /**
  153778. * Creates a new HDRCubeTextureAssetTask object
  153779. * @param name defines the name of the task
  153780. * @param url defines the location of the file to load
  153781. * @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.
  153782. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153783. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153784. * @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)
  153785. * @param reserved Internal use only
  153786. */
  153787. constructor(
  153788. /**
  153789. * Defines the name of the task
  153790. */
  153791. name: string,
  153792. /**
  153793. * Defines the location of the file to load
  153794. */
  153795. url: string,
  153796. /**
  153797. * Defines the desired size (the more it increases the longer the generation will be)
  153798. */
  153799. size: number,
  153800. /**
  153801. * Defines if mipmaps should not be generated (default is false)
  153802. */
  153803. noMipmap?: boolean,
  153804. /**
  153805. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153806. */
  153807. generateHarmonics?: boolean,
  153808. /**
  153809. * 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)
  153810. */
  153811. gammaSpace?: boolean,
  153812. /**
  153813. * Internal Use Only
  153814. */
  153815. reserved?: boolean);
  153816. /**
  153817. * Execute the current task
  153818. * @param scene defines the scene where you want your assets to be loaded
  153819. * @param onSuccess is a callback called when the task is successfully executed
  153820. * @param onError is a callback called if an error occurs
  153821. */
  153822. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153823. }
  153824. /**
  153825. * Define a task used by AssetsManager to load Equirectangular cube textures
  153826. */
  153827. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  153828. /**
  153829. * Defines the name of the task
  153830. */
  153831. name: string;
  153832. /**
  153833. * Defines the location of the file to load
  153834. */
  153835. url: string;
  153836. /**
  153837. * Defines the desired size (the more it increases the longer the generation will be)
  153838. */
  153839. size: number;
  153840. /**
  153841. * Defines if mipmaps should not be generated (default is false)
  153842. */
  153843. noMipmap: boolean;
  153844. /**
  153845. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  153846. * but the standard material would require them in Gamma space) (default is true)
  153847. */
  153848. gammaSpace: boolean;
  153849. /**
  153850. * Gets the loaded texture
  153851. */
  153852. texture: EquiRectangularCubeTexture;
  153853. /**
  153854. * Callback called when the task is successful
  153855. */
  153856. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  153857. /**
  153858. * Callback called when the task is successful
  153859. */
  153860. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  153861. /**
  153862. * Creates a new EquiRectangularCubeTextureAssetTask object
  153863. * @param name defines the name of the task
  153864. * @param url defines the location of the file to load
  153865. * @param size defines the desired size (the more it increases the longer the generation will be)
  153866. * If the size is omitted this implies you are using a preprocessed cubemap.
  153867. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153868. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  153869. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  153870. * (default is true)
  153871. */
  153872. constructor(
  153873. /**
  153874. * Defines the name of the task
  153875. */
  153876. name: string,
  153877. /**
  153878. * Defines the location of the file to load
  153879. */
  153880. url: string,
  153881. /**
  153882. * Defines the desired size (the more it increases the longer the generation will be)
  153883. */
  153884. size: number,
  153885. /**
  153886. * Defines if mipmaps should not be generated (default is false)
  153887. */
  153888. noMipmap?: boolean,
  153889. /**
  153890. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  153891. * but the standard material would require them in Gamma space) (default is true)
  153892. */
  153893. gammaSpace?: boolean);
  153894. /**
  153895. * Execute the current task
  153896. * @param scene defines the scene where you want your assets to be loaded
  153897. * @param onSuccess is a callback called when the task is successfully executed
  153898. * @param onError is a callback called if an error occurs
  153899. */
  153900. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153901. }
  153902. /**
  153903. * This class can be used to easily import assets into a scene
  153904. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  153905. */
  153906. export class AssetsManager {
  153907. private _scene;
  153908. private _isLoading;
  153909. protected _tasks: AbstractAssetTask[];
  153910. protected _waitingTasksCount: number;
  153911. protected _totalTasksCount: number;
  153912. /**
  153913. * Callback called when all tasks are processed
  153914. */
  153915. onFinish: (tasks: AbstractAssetTask[]) => void;
  153916. /**
  153917. * Callback called when a task is successful
  153918. */
  153919. onTaskSuccess: (task: AbstractAssetTask) => void;
  153920. /**
  153921. * Callback called when a task had an error
  153922. */
  153923. onTaskError: (task: AbstractAssetTask) => void;
  153924. /**
  153925. * Callback called when a task is done (whatever the result is)
  153926. */
  153927. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  153928. /**
  153929. * Observable called when all tasks are processed
  153930. */
  153931. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  153932. /**
  153933. * Observable called when a task had an error
  153934. */
  153935. onTaskErrorObservable: Observable<AbstractAssetTask>;
  153936. /**
  153937. * Observable called when all tasks were executed
  153938. */
  153939. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  153940. /**
  153941. * Observable called when a task is done (whatever the result is)
  153942. */
  153943. onProgressObservable: Observable<IAssetsProgressEvent>;
  153944. /**
  153945. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  153946. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  153947. */
  153948. useDefaultLoadingScreen: boolean;
  153949. /**
  153950. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  153951. * when all assets have been downloaded.
  153952. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  153953. */
  153954. autoHideLoadingUI: boolean;
  153955. /**
  153956. * Creates a new AssetsManager
  153957. * @param scene defines the scene to work on
  153958. */
  153959. constructor(scene: Scene);
  153960. /**
  153961. * Add a ContainerAssetTask to the list of active tasks
  153962. * @param taskName defines the name of the new task
  153963. * @param meshesNames defines the name of meshes to load
  153964. * @param rootUrl defines the root url to use to locate files
  153965. * @param sceneFilename defines the filename of the scene file
  153966. * @returns a new ContainerAssetTask object
  153967. */
  153968. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  153969. /**
  153970. * Add a MeshAssetTask to the list of active tasks
  153971. * @param taskName defines the name of the new task
  153972. * @param meshesNames defines the name of meshes to load
  153973. * @param rootUrl defines the root url to use to locate files
  153974. * @param sceneFilename defines the filename of the scene file
  153975. * @returns a new MeshAssetTask object
  153976. */
  153977. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  153978. /**
  153979. * Add a TextFileAssetTask to the list of active tasks
  153980. * @param taskName defines the name of the new task
  153981. * @param url defines the url of the file to load
  153982. * @returns a new TextFileAssetTask object
  153983. */
  153984. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  153985. /**
  153986. * Add a BinaryFileAssetTask to the list of active tasks
  153987. * @param taskName defines the name of the new task
  153988. * @param url defines the url of the file to load
  153989. * @returns a new BinaryFileAssetTask object
  153990. */
  153991. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  153992. /**
  153993. * Add a ImageAssetTask to the list of active tasks
  153994. * @param taskName defines the name of the new task
  153995. * @param url defines the url of the file to load
  153996. * @returns a new ImageAssetTask object
  153997. */
  153998. addImageTask(taskName: string, url: string): ImageAssetTask;
  153999. /**
  154000. * Add a TextureAssetTask to the list of active tasks
  154001. * @param taskName defines the name of the new task
  154002. * @param url defines the url of the file to load
  154003. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154004. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  154005. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  154006. * @returns a new TextureAssetTask object
  154007. */
  154008. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  154009. /**
  154010. * Add a CubeTextureAssetTask to the list of active tasks
  154011. * @param taskName defines the name of the new task
  154012. * @param url defines the url of the file to load
  154013. * @param extensions defines the extension to use to load the cube map (can be null)
  154014. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154015. * @param files defines the list of files to load (can be null)
  154016. * @returns a new CubeTextureAssetTask object
  154017. */
  154018. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  154019. /**
  154020. *
  154021. * Add a HDRCubeTextureAssetTask to the list of active tasks
  154022. * @param taskName defines the name of the new task
  154023. * @param url defines the url of the file to load
  154024. * @param size defines the size you want for the cubemap (can be null)
  154025. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154026. * @param generateHarmonics defines if you want to automatically generate (true by default)
  154027. * @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)
  154028. * @param reserved Internal use only
  154029. * @returns a new HDRCubeTextureAssetTask object
  154030. */
  154031. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  154032. /**
  154033. *
  154034. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  154035. * @param taskName defines the name of the new task
  154036. * @param url defines the url of the file to load
  154037. * @param size defines the size you want for the cubemap (can be null)
  154038. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154039. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  154040. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  154041. * @returns a new EquiRectangularCubeTextureAssetTask object
  154042. */
  154043. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  154044. /**
  154045. * Remove a task from the assets manager.
  154046. * @param task the task to remove
  154047. */
  154048. removeTask(task: AbstractAssetTask): void;
  154049. private _decreaseWaitingTasksCount;
  154050. private _runTask;
  154051. /**
  154052. * Reset the AssetsManager and remove all tasks
  154053. * @return the current instance of the AssetsManager
  154054. */
  154055. reset(): AssetsManager;
  154056. /**
  154057. * Start the loading process
  154058. * @return the current instance of the AssetsManager
  154059. */
  154060. load(): AssetsManager;
  154061. /**
  154062. * Start the loading process as an async operation
  154063. * @return a promise returning the list of failed tasks
  154064. */
  154065. loadAsync(): Promise<void>;
  154066. }
  154067. }
  154068. declare module BABYLON {
  154069. /**
  154070. * Wrapper class for promise with external resolve and reject.
  154071. */
  154072. export class Deferred<T> {
  154073. /**
  154074. * The promise associated with this deferred object.
  154075. */
  154076. readonly promise: Promise<T>;
  154077. private _resolve;
  154078. private _reject;
  154079. /**
  154080. * The resolve method of the promise associated with this deferred object.
  154081. */
  154082. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  154083. /**
  154084. * The reject method of the promise associated with this deferred object.
  154085. */
  154086. get reject(): (reason?: any) => void;
  154087. /**
  154088. * Constructor for this deferred object.
  154089. */
  154090. constructor();
  154091. }
  154092. }
  154093. declare module BABYLON {
  154094. /**
  154095. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  154096. */
  154097. export class MeshExploder {
  154098. private _centerMesh;
  154099. private _meshes;
  154100. private _meshesOrigins;
  154101. private _toCenterVectors;
  154102. private _scaledDirection;
  154103. private _newPosition;
  154104. private _centerPosition;
  154105. /**
  154106. * Explodes meshes from a center mesh.
  154107. * @param meshes The meshes to explode.
  154108. * @param centerMesh The mesh to be center of explosion.
  154109. */
  154110. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  154111. private _setCenterMesh;
  154112. /**
  154113. * Get class name
  154114. * @returns "MeshExploder"
  154115. */
  154116. getClassName(): string;
  154117. /**
  154118. * "Exploded meshes"
  154119. * @returns Array of meshes with the centerMesh at index 0.
  154120. */
  154121. getMeshes(): Array<Mesh>;
  154122. /**
  154123. * Explodes meshes giving a specific direction
  154124. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  154125. */
  154126. explode(direction?: number): void;
  154127. }
  154128. }
  154129. declare module BABYLON {
  154130. /**
  154131. * Class used to help managing file picking and drag'n'drop
  154132. */
  154133. export class FilesInput {
  154134. /**
  154135. * List of files ready to be loaded
  154136. */
  154137. static get FilesToLoad(): {
  154138. [key: string]: File;
  154139. };
  154140. /**
  154141. * Callback called when a file is processed
  154142. */
  154143. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  154144. private _engine;
  154145. private _currentScene;
  154146. private _sceneLoadedCallback;
  154147. private _progressCallback;
  154148. private _additionalRenderLoopLogicCallback;
  154149. private _textureLoadingCallback;
  154150. private _startingProcessingFilesCallback;
  154151. private _onReloadCallback;
  154152. private _errorCallback;
  154153. private _elementToMonitor;
  154154. private _sceneFileToLoad;
  154155. private _filesToLoad;
  154156. /**
  154157. * Creates a new FilesInput
  154158. * @param engine defines the rendering engine
  154159. * @param scene defines the hosting scene
  154160. * @param sceneLoadedCallback callback called when scene is loaded
  154161. * @param progressCallback callback called to track progress
  154162. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  154163. * @param textureLoadingCallback callback called when a texture is loading
  154164. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  154165. * @param onReloadCallback callback called when a reload is requested
  154166. * @param errorCallback callback call if an error occurs
  154167. */
  154168. 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>);
  154169. private _dragEnterHandler;
  154170. private _dragOverHandler;
  154171. private _dropHandler;
  154172. /**
  154173. * Calls this function to listen to drag'n'drop events on a specific DOM element
  154174. * @param elementToMonitor defines the DOM element to track
  154175. */
  154176. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  154177. /** Gets the current list of files to load */
  154178. get filesToLoad(): File[];
  154179. /**
  154180. * Release all associated resources
  154181. */
  154182. dispose(): void;
  154183. private renderFunction;
  154184. private drag;
  154185. private drop;
  154186. private _traverseFolder;
  154187. private _processFiles;
  154188. /**
  154189. * Load files from a drop event
  154190. * @param event defines the drop event to use as source
  154191. */
  154192. loadFiles(event: any): void;
  154193. private _processReload;
  154194. /**
  154195. * Reload the current scene from the loaded files
  154196. */
  154197. reload(): void;
  154198. }
  154199. }
  154200. declare module BABYLON {
  154201. /**
  154202. * Defines the root class used to create scene optimization to use with SceneOptimizer
  154203. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154204. */
  154205. export class SceneOptimization {
  154206. /**
  154207. * Defines the priority of this optimization (0 by default which means first in the list)
  154208. */
  154209. priority: number;
  154210. /**
  154211. * Gets a string describing the action executed by the current optimization
  154212. * @returns description string
  154213. */
  154214. getDescription(): string;
  154215. /**
  154216. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154217. * @param scene defines the current scene where to apply this optimization
  154218. * @param optimizer defines the current optimizer
  154219. * @returns true if everything that can be done was applied
  154220. */
  154221. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154222. /**
  154223. * Creates the SceneOptimization object
  154224. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154225. * @param desc defines the description associated with the optimization
  154226. */
  154227. constructor(
  154228. /**
  154229. * Defines the priority of this optimization (0 by default which means first in the list)
  154230. */
  154231. priority?: number);
  154232. }
  154233. /**
  154234. * Defines an optimization used to reduce the size of render target textures
  154235. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154236. */
  154237. export class TextureOptimization extends SceneOptimization {
  154238. /**
  154239. * Defines the priority of this optimization (0 by default which means first in the list)
  154240. */
  154241. priority: number;
  154242. /**
  154243. * 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
  154244. */
  154245. maximumSize: number;
  154246. /**
  154247. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154248. */
  154249. step: number;
  154250. /**
  154251. * Gets a string describing the action executed by the current optimization
  154252. * @returns description string
  154253. */
  154254. getDescription(): string;
  154255. /**
  154256. * Creates the TextureOptimization object
  154257. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154258. * @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
  154259. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154260. */
  154261. constructor(
  154262. /**
  154263. * Defines the priority of this optimization (0 by default which means first in the list)
  154264. */
  154265. priority?: number,
  154266. /**
  154267. * 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
  154268. */
  154269. maximumSize?: number,
  154270. /**
  154271. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154272. */
  154273. step?: number);
  154274. /**
  154275. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154276. * @param scene defines the current scene where to apply this optimization
  154277. * @param optimizer defines the current optimizer
  154278. * @returns true if everything that can be done was applied
  154279. */
  154280. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154281. }
  154282. /**
  154283. * Defines an optimization used to increase or decrease the rendering resolution
  154284. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154285. */
  154286. export class HardwareScalingOptimization extends SceneOptimization {
  154287. /**
  154288. * Defines the priority of this optimization (0 by default which means first in the list)
  154289. */
  154290. priority: number;
  154291. /**
  154292. * Defines the maximum scale to use (2 by default)
  154293. */
  154294. maximumScale: number;
  154295. /**
  154296. * Defines the step to use between two passes (0.5 by default)
  154297. */
  154298. step: number;
  154299. private _currentScale;
  154300. private _directionOffset;
  154301. /**
  154302. * Gets a string describing the action executed by the current optimization
  154303. * @return description string
  154304. */
  154305. getDescription(): string;
  154306. /**
  154307. * Creates the HardwareScalingOptimization object
  154308. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154309. * @param maximumScale defines the maximum scale to use (2 by default)
  154310. * @param step defines the step to use between two passes (0.5 by default)
  154311. */
  154312. constructor(
  154313. /**
  154314. * Defines the priority of this optimization (0 by default which means first in the list)
  154315. */
  154316. priority?: number,
  154317. /**
  154318. * Defines the maximum scale to use (2 by default)
  154319. */
  154320. maximumScale?: number,
  154321. /**
  154322. * Defines the step to use between two passes (0.5 by default)
  154323. */
  154324. step?: number);
  154325. /**
  154326. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154327. * @param scene defines the current scene where to apply this optimization
  154328. * @param optimizer defines the current optimizer
  154329. * @returns true if everything that can be done was applied
  154330. */
  154331. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154332. }
  154333. /**
  154334. * Defines an optimization used to remove shadows
  154335. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154336. */
  154337. export class ShadowsOptimization extends SceneOptimization {
  154338. /**
  154339. * Gets a string describing the action executed by the current optimization
  154340. * @return description string
  154341. */
  154342. getDescription(): string;
  154343. /**
  154344. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154345. * @param scene defines the current scene where to apply this optimization
  154346. * @param optimizer defines the current optimizer
  154347. * @returns true if everything that can be done was applied
  154348. */
  154349. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154350. }
  154351. /**
  154352. * Defines an optimization used to turn post-processes off
  154353. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154354. */
  154355. export class PostProcessesOptimization extends SceneOptimization {
  154356. /**
  154357. * Gets a string describing the action executed by the current optimization
  154358. * @return description string
  154359. */
  154360. getDescription(): string;
  154361. /**
  154362. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154363. * @param scene defines the current scene where to apply this optimization
  154364. * @param optimizer defines the current optimizer
  154365. * @returns true if everything that can be done was applied
  154366. */
  154367. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154368. }
  154369. /**
  154370. * Defines an optimization used to turn lens flares off
  154371. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154372. */
  154373. export class LensFlaresOptimization extends SceneOptimization {
  154374. /**
  154375. * Gets a string describing the action executed by the current optimization
  154376. * @return description string
  154377. */
  154378. getDescription(): string;
  154379. /**
  154380. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154381. * @param scene defines the current scene where to apply this optimization
  154382. * @param optimizer defines the current optimizer
  154383. * @returns true if everything that can be done was applied
  154384. */
  154385. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154386. }
  154387. /**
  154388. * Defines an optimization based on user defined callback.
  154389. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154390. */
  154391. export class CustomOptimization extends SceneOptimization {
  154392. /**
  154393. * Callback called to apply the custom optimization.
  154394. */
  154395. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  154396. /**
  154397. * Callback called to get custom description
  154398. */
  154399. onGetDescription: () => string;
  154400. /**
  154401. * Gets a string describing the action executed by the current optimization
  154402. * @returns description string
  154403. */
  154404. getDescription(): string;
  154405. /**
  154406. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154407. * @param scene defines the current scene where to apply this optimization
  154408. * @param optimizer defines the current optimizer
  154409. * @returns true if everything that can be done was applied
  154410. */
  154411. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154412. }
  154413. /**
  154414. * Defines an optimization used to turn particles off
  154415. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154416. */
  154417. export class ParticlesOptimization extends SceneOptimization {
  154418. /**
  154419. * Gets a string describing the action executed by the current optimization
  154420. * @return description string
  154421. */
  154422. getDescription(): string;
  154423. /**
  154424. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154425. * @param scene defines the current scene where to apply this optimization
  154426. * @param optimizer defines the current optimizer
  154427. * @returns true if everything that can be done was applied
  154428. */
  154429. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154430. }
  154431. /**
  154432. * Defines an optimization used to turn render targets off
  154433. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154434. */
  154435. export class RenderTargetsOptimization extends SceneOptimization {
  154436. /**
  154437. * Gets a string describing the action executed by the current optimization
  154438. * @return description string
  154439. */
  154440. getDescription(): string;
  154441. /**
  154442. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154443. * @param scene defines the current scene where to apply this optimization
  154444. * @param optimizer defines the current optimizer
  154445. * @returns true if everything that can be done was applied
  154446. */
  154447. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154448. }
  154449. /**
  154450. * Defines an optimization used to merge meshes with compatible materials
  154451. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154452. */
  154453. export class MergeMeshesOptimization extends SceneOptimization {
  154454. private static _UpdateSelectionTree;
  154455. /**
  154456. * Gets or sets a boolean which defines if optimization octree has to be updated
  154457. */
  154458. static get UpdateSelectionTree(): boolean;
  154459. /**
  154460. * Gets or sets a boolean which defines if optimization octree has to be updated
  154461. */
  154462. static set UpdateSelectionTree(value: boolean);
  154463. /**
  154464. * Gets a string describing the action executed by the current optimization
  154465. * @return description string
  154466. */
  154467. getDescription(): string;
  154468. private _canBeMerged;
  154469. /**
  154470. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154471. * @param scene defines the current scene where to apply this optimization
  154472. * @param optimizer defines the current optimizer
  154473. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  154474. * @returns true if everything that can be done was applied
  154475. */
  154476. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  154477. }
  154478. /**
  154479. * Defines a list of options used by SceneOptimizer
  154480. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154481. */
  154482. export class SceneOptimizerOptions {
  154483. /**
  154484. * Defines the target frame rate to reach (60 by default)
  154485. */
  154486. targetFrameRate: number;
  154487. /**
  154488. * Defines the interval between two checkes (2000ms by default)
  154489. */
  154490. trackerDuration: number;
  154491. /**
  154492. * Gets the list of optimizations to apply
  154493. */
  154494. optimizations: SceneOptimization[];
  154495. /**
  154496. * Creates a new list of options used by SceneOptimizer
  154497. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  154498. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  154499. */
  154500. constructor(
  154501. /**
  154502. * Defines the target frame rate to reach (60 by default)
  154503. */
  154504. targetFrameRate?: number,
  154505. /**
  154506. * Defines the interval between two checkes (2000ms by default)
  154507. */
  154508. trackerDuration?: number);
  154509. /**
  154510. * Add a new optimization
  154511. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  154512. * @returns the current SceneOptimizerOptions
  154513. */
  154514. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  154515. /**
  154516. * Add a new custom optimization
  154517. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  154518. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  154519. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154520. * @returns the current SceneOptimizerOptions
  154521. */
  154522. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  154523. /**
  154524. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  154525. * @param targetFrameRate defines the target frame rate (60 by default)
  154526. * @returns a SceneOptimizerOptions object
  154527. */
  154528. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154529. /**
  154530. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  154531. * @param targetFrameRate defines the target frame rate (60 by default)
  154532. * @returns a SceneOptimizerOptions object
  154533. */
  154534. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154535. /**
  154536. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  154537. * @param targetFrameRate defines the target frame rate (60 by default)
  154538. * @returns a SceneOptimizerOptions object
  154539. */
  154540. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154541. }
  154542. /**
  154543. * Class used to run optimizations in order to reach a target frame rate
  154544. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154545. */
  154546. export class SceneOptimizer implements IDisposable {
  154547. private _isRunning;
  154548. private _options;
  154549. private _scene;
  154550. private _currentPriorityLevel;
  154551. private _targetFrameRate;
  154552. private _trackerDuration;
  154553. private _currentFrameRate;
  154554. private _sceneDisposeObserver;
  154555. private _improvementMode;
  154556. /**
  154557. * Defines an observable called when the optimizer reaches the target frame rate
  154558. */
  154559. onSuccessObservable: Observable<SceneOptimizer>;
  154560. /**
  154561. * Defines an observable called when the optimizer enables an optimization
  154562. */
  154563. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  154564. /**
  154565. * Defines an observable called when the optimizer is not able to reach the target frame rate
  154566. */
  154567. onFailureObservable: Observable<SceneOptimizer>;
  154568. /**
  154569. * Gets a boolean indicating if the optimizer is in improvement mode
  154570. */
  154571. get isInImprovementMode(): boolean;
  154572. /**
  154573. * Gets the current priority level (0 at start)
  154574. */
  154575. get currentPriorityLevel(): number;
  154576. /**
  154577. * Gets the current frame rate checked by the SceneOptimizer
  154578. */
  154579. get currentFrameRate(): number;
  154580. /**
  154581. * Gets or sets the current target frame rate (60 by default)
  154582. */
  154583. get targetFrameRate(): number;
  154584. /**
  154585. * Gets or sets the current target frame rate (60 by default)
  154586. */
  154587. set targetFrameRate(value: number);
  154588. /**
  154589. * Gets or sets the current interval between two checks (every 2000ms by default)
  154590. */
  154591. get trackerDuration(): number;
  154592. /**
  154593. * Gets or sets the current interval between two checks (every 2000ms by default)
  154594. */
  154595. set trackerDuration(value: number);
  154596. /**
  154597. * Gets the list of active optimizations
  154598. */
  154599. get optimizations(): SceneOptimization[];
  154600. /**
  154601. * Creates a new SceneOptimizer
  154602. * @param scene defines the scene to work on
  154603. * @param options defines the options to use with the SceneOptimizer
  154604. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  154605. * @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)
  154606. */
  154607. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  154608. /**
  154609. * Stops the current optimizer
  154610. */
  154611. stop(): void;
  154612. /**
  154613. * Reset the optimizer to initial step (current priority level = 0)
  154614. */
  154615. reset(): void;
  154616. /**
  154617. * Start the optimizer. By default it will try to reach a specific framerate
  154618. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  154619. */
  154620. start(): void;
  154621. private _checkCurrentState;
  154622. /**
  154623. * Release all resources
  154624. */
  154625. dispose(): void;
  154626. /**
  154627. * Helper function to create a SceneOptimizer with one single line of code
  154628. * @param scene defines the scene to work on
  154629. * @param options defines the options to use with the SceneOptimizer
  154630. * @param onSuccess defines a callback to call on success
  154631. * @param onFailure defines a callback to call on failure
  154632. * @returns the new SceneOptimizer object
  154633. */
  154634. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  154635. }
  154636. }
  154637. declare module BABYLON {
  154638. /**
  154639. * Class used to serialize a scene into a string
  154640. */
  154641. export class SceneSerializer {
  154642. /**
  154643. * Clear cache used by a previous serialization
  154644. */
  154645. static ClearCache(): void;
  154646. /**
  154647. * Serialize a scene into a JSON compatible object
  154648. * @param scene defines the scene to serialize
  154649. * @returns a JSON compatible object
  154650. */
  154651. static Serialize(scene: Scene): any;
  154652. /**
  154653. * Serialize a mesh into a JSON compatible object
  154654. * @param toSerialize defines the mesh to serialize
  154655. * @param withParents defines if parents must be serialized as well
  154656. * @param withChildren defines if children must be serialized as well
  154657. * @returns a JSON compatible object
  154658. */
  154659. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  154660. }
  154661. }
  154662. declare module BABYLON {
  154663. /**
  154664. * Class used to host texture specific utilities
  154665. */
  154666. export class TextureTools {
  154667. /**
  154668. * Uses the GPU to create a copy texture rescaled at a given size
  154669. * @param texture Texture to copy from
  154670. * @param width defines the desired width
  154671. * @param height defines the desired height
  154672. * @param useBilinearMode defines if bilinear mode has to be used
  154673. * @return the generated texture
  154674. */
  154675. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  154676. }
  154677. }
  154678. declare module BABYLON {
  154679. /**
  154680. * This represents the different options available for the video capture.
  154681. */
  154682. export interface VideoRecorderOptions {
  154683. /** Defines the mime type of the video. */
  154684. mimeType: string;
  154685. /** Defines the FPS the video should be recorded at. */
  154686. fps: number;
  154687. /** Defines the chunk size for the recording data. */
  154688. recordChunckSize: number;
  154689. /** The audio tracks to attach to the recording. */
  154690. audioTracks?: MediaStreamTrack[];
  154691. }
  154692. /**
  154693. * This can help with recording videos from BabylonJS.
  154694. * This is based on the available WebRTC functionalities of the browser.
  154695. *
  154696. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  154697. */
  154698. export class VideoRecorder {
  154699. private static readonly _defaultOptions;
  154700. /**
  154701. * Returns whether or not the VideoRecorder is available in your browser.
  154702. * @param engine Defines the Babylon Engine.
  154703. * @returns true if supported otherwise false.
  154704. */
  154705. static IsSupported(engine: Engine): boolean;
  154706. private readonly _options;
  154707. private _canvas;
  154708. private _mediaRecorder;
  154709. private _recordedChunks;
  154710. private _fileName;
  154711. private _resolve;
  154712. private _reject;
  154713. /**
  154714. * True when a recording is already in progress.
  154715. */
  154716. get isRecording(): boolean;
  154717. /**
  154718. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  154719. * @param engine Defines the BabylonJS Engine you wish to record.
  154720. * @param options Defines options that can be used to customize the capture.
  154721. */
  154722. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  154723. /**
  154724. * Stops the current recording before the default capture timeout passed in the startRecording function.
  154725. */
  154726. stopRecording(): void;
  154727. /**
  154728. * Starts recording the canvas for a max duration specified in parameters.
  154729. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  154730. * If null no automatic download will start and you can rely on the promise to get the data back.
  154731. * @param maxDuration Defines the maximum recording time in seconds.
  154732. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  154733. * @return A promise callback at the end of the recording with the video data in Blob.
  154734. */
  154735. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  154736. /**
  154737. * Releases internal resources used during the recording.
  154738. */
  154739. dispose(): void;
  154740. private _handleDataAvailable;
  154741. private _handleError;
  154742. private _handleStop;
  154743. }
  154744. }
  154745. declare module BABYLON {
  154746. /**
  154747. * Class containing a set of static utilities functions for screenshots
  154748. */
  154749. export class ScreenshotTools {
  154750. /**
  154751. * Captures a screenshot of the current rendering
  154752. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154753. * @param engine defines the rendering engine
  154754. * @param camera defines the source camera
  154755. * @param size This parameter can be set to a single number or to an object with the
  154756. * following (optional) properties: precision, width, height. If a single number is passed,
  154757. * it will be used for both width and height. If an object is passed, the screenshot size
  154758. * will be derived from the parameters. The precision property is a multiplier allowing
  154759. * rendering at a higher or lower resolution
  154760. * @param successCallback defines the callback receives a single parameter which contains the
  154761. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  154762. * src parameter of an <img> to display it
  154763. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  154764. * Check your browser for supported MIME types
  154765. */
  154766. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  154767. /**
  154768. * Captures a screenshot of the current rendering
  154769. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154770. * @param engine defines the rendering engine
  154771. * @param camera defines the source camera
  154772. * @param size This parameter can be set to a single number or to an object with the
  154773. * following (optional) properties: precision, width, height. If a single number is passed,
  154774. * it will be used for both width and height. If an object is passed, the screenshot size
  154775. * will be derived from the parameters. The precision property is a multiplier allowing
  154776. * rendering at a higher or lower resolution
  154777. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  154778. * Check your browser for supported MIME types
  154779. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  154780. * to the src parameter of an <img> to display it
  154781. */
  154782. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  154783. /**
  154784. * Generates an image screenshot from the specified camera.
  154785. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154786. * @param engine The engine to use for rendering
  154787. * @param camera The camera to use for rendering
  154788. * @param size This parameter can be set to a single number or to an object with the
  154789. * following (optional) properties: precision, width, height. If a single number is passed,
  154790. * it will be used for both width and height. If an object is passed, the screenshot size
  154791. * will be derived from the parameters. The precision property is a multiplier allowing
  154792. * rendering at a higher or lower resolution
  154793. * @param successCallback The callback receives a single parameter which contains the
  154794. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  154795. * src parameter of an <img> to display it
  154796. * @param mimeType The MIME type of the screenshot image (default: image/png).
  154797. * Check your browser for supported MIME types
  154798. * @param samples Texture samples (default: 1)
  154799. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  154800. * @param fileName A name for for the downloaded file.
  154801. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  154802. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  154803. */
  154804. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  154805. /**
  154806. * Generates an image screenshot from the specified camera.
  154807. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154808. * @param engine The engine to use for rendering
  154809. * @param camera The camera to use for rendering
  154810. * @param size This parameter can be set to a single number or to an object with the
  154811. * following (optional) properties: precision, width, height. If a single number is passed,
  154812. * it will be used for both width and height. If an object is passed, the screenshot size
  154813. * will be derived from the parameters. The precision property is a multiplier allowing
  154814. * rendering at a higher or lower resolution
  154815. * @param mimeType The MIME type of the screenshot image (default: image/png).
  154816. * Check your browser for supported MIME types
  154817. * @param samples Texture samples (default: 1)
  154818. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  154819. * @param fileName A name for for the downloaded file.
  154820. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  154821. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  154822. * to the src parameter of an <img> to display it
  154823. */
  154824. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  154825. /**
  154826. * Gets height and width for screenshot size
  154827. * @private
  154828. */
  154829. private static _getScreenshotSize;
  154830. }
  154831. }
  154832. declare module BABYLON {
  154833. /**
  154834. * Interface for a data buffer
  154835. */
  154836. export interface IDataBuffer {
  154837. /**
  154838. * Reads bytes from the data buffer.
  154839. * @param byteOffset The byte offset to read
  154840. * @param byteLength The byte length to read
  154841. * @returns A promise that resolves when the bytes are read
  154842. */
  154843. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  154844. /**
  154845. * The byte length of the buffer.
  154846. */
  154847. readonly byteLength: number;
  154848. }
  154849. /**
  154850. * Utility class for reading from a data buffer
  154851. */
  154852. export class DataReader {
  154853. /**
  154854. * The data buffer associated with this data reader.
  154855. */
  154856. readonly buffer: IDataBuffer;
  154857. /**
  154858. * The current byte offset from the beginning of the data buffer.
  154859. */
  154860. byteOffset: number;
  154861. private _dataView;
  154862. private _dataByteOffset;
  154863. /**
  154864. * Constructor
  154865. * @param buffer The buffer to read
  154866. */
  154867. constructor(buffer: IDataBuffer);
  154868. /**
  154869. * Loads the given byte length.
  154870. * @param byteLength The byte length to load
  154871. * @returns A promise that resolves when the load is complete
  154872. */
  154873. loadAsync(byteLength: number): Promise<void>;
  154874. /**
  154875. * Read a unsigned 32-bit integer from the currently loaded data range.
  154876. * @returns The 32-bit integer read
  154877. */
  154878. readUint32(): number;
  154879. /**
  154880. * Read a byte array from the currently loaded data range.
  154881. * @param byteLength The byte length to read
  154882. * @returns The byte array read
  154883. */
  154884. readUint8Array(byteLength: number): Uint8Array;
  154885. /**
  154886. * Read a string from the currently loaded data range.
  154887. * @param byteLength The byte length to read
  154888. * @returns The string read
  154889. */
  154890. readString(byteLength: number): string;
  154891. /**
  154892. * Skips the given byte length the currently loaded data range.
  154893. * @param byteLength The byte length to skip
  154894. */
  154895. skipBytes(byteLength: number): void;
  154896. }
  154897. }
  154898. declare module BABYLON {
  154899. /**
  154900. * Class for storing data to local storage if available or in-memory storage otherwise
  154901. */
  154902. export class DataStorage {
  154903. private static _Storage;
  154904. private static _GetStorage;
  154905. /**
  154906. * Reads a string from the data storage
  154907. * @param key The key to read
  154908. * @param defaultValue The value if the key doesn't exist
  154909. * @returns The string value
  154910. */
  154911. static ReadString(key: string, defaultValue: string): string;
  154912. /**
  154913. * Writes a string to the data storage
  154914. * @param key The key to write
  154915. * @param value The value to write
  154916. */
  154917. static WriteString(key: string, value: string): void;
  154918. /**
  154919. * Reads a boolean from the data storage
  154920. * @param key The key to read
  154921. * @param defaultValue The value if the key doesn't exist
  154922. * @returns The boolean value
  154923. */
  154924. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  154925. /**
  154926. * Writes a boolean to the data storage
  154927. * @param key The key to write
  154928. * @param value The value to write
  154929. */
  154930. static WriteBoolean(key: string, value: boolean): void;
  154931. /**
  154932. * Reads a number from the data storage
  154933. * @param key The key to read
  154934. * @param defaultValue The value if the key doesn't exist
  154935. * @returns The number value
  154936. */
  154937. static ReadNumber(key: string, defaultValue: number): number;
  154938. /**
  154939. * Writes a number to the data storage
  154940. * @param key The key to write
  154941. * @param value The value to write
  154942. */
  154943. static WriteNumber(key: string, value: number): void;
  154944. }
  154945. }
  154946. declare module BABYLON {
  154947. /**
  154948. * Class used to record delta files between 2 scene states
  154949. */
  154950. export class SceneRecorder {
  154951. private _trackedScene;
  154952. private _savedJSON;
  154953. /**
  154954. * Track a given scene. This means the current scene state will be considered the original state
  154955. * @param scene defines the scene to track
  154956. */
  154957. track(scene: Scene): void;
  154958. /**
  154959. * Get the delta between current state and original state
  154960. * @returns a string containing the delta
  154961. */
  154962. getDelta(): any;
  154963. private _compareArray;
  154964. private _compareObjects;
  154965. private _compareCollections;
  154966. private static GetShadowGeneratorById;
  154967. /**
  154968. * Apply a given delta to a given scene
  154969. * @param deltaJSON defines the JSON containing the delta
  154970. * @param scene defines the scene to apply the delta to
  154971. */
  154972. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  154973. private static _ApplyPropertiesToEntity;
  154974. private static _ApplyDeltaForEntity;
  154975. }
  154976. }
  154977. declare module BABYLON {
  154978. /**
  154979. * A 3D trajectory consisting of an order list of vectors describing a
  154980. * path of motion through 3D space.
  154981. */
  154982. export class Trajectory {
  154983. private _points;
  154984. private readonly _segmentLength;
  154985. /**
  154986. * Serialize to JSON.
  154987. * @returns serialized JSON string
  154988. */
  154989. serialize(): string;
  154990. /**
  154991. * Deserialize from JSON.
  154992. * @param json serialized JSON string
  154993. * @returns deserialized Trajectory
  154994. */
  154995. static Deserialize(json: string): Trajectory;
  154996. /**
  154997. * Create a new empty Trajectory.
  154998. * @param segmentLength radius of discretization for Trajectory points
  154999. */
  155000. constructor(segmentLength?: number);
  155001. /**
  155002. * Get the length of the Trajectory.
  155003. * @returns length of the Trajectory
  155004. */
  155005. getLength(): number;
  155006. /**
  155007. * Append a new point to the Trajectory.
  155008. * NOTE: This implementation has many allocations.
  155009. * @param point point to append to the Trajectory
  155010. */
  155011. add(point: DeepImmutable<Vector3>): void;
  155012. /**
  155013. * Create a new Trajectory with a segment length chosen to make it
  155014. * probable that the new Trajectory will have a specified number of
  155015. * segments. This operation is imprecise.
  155016. * @param targetResolution number of segments desired
  155017. * @returns new Trajectory with approximately the requested number of segments
  155018. */
  155019. resampleAtTargetResolution(targetResolution: number): Trajectory;
  155020. /**
  155021. * Convert Trajectory segments into tokenized representation. This
  155022. * representation is an array of numbers where each nth number is the
  155023. * index of the token which is most similar to the nth segment of the
  155024. * Trajectory.
  155025. * @param tokens list of vectors which serve as discrete tokens
  155026. * @returns list of indices of most similar token per segment
  155027. */
  155028. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  155029. private static _forwardDir;
  155030. private static _inverseFromVec;
  155031. private static _upDir;
  155032. private static _fromToVec;
  155033. private static _lookMatrix;
  155034. /**
  155035. * Transform the rotation (i.e., direction) of a segment to isolate
  155036. * the relative transformation represented by the segment. This operation
  155037. * may or may not succeed due to singularities in the equations that define
  155038. * motion relativity in this context.
  155039. * @param priorVec the origin of the prior segment
  155040. * @param fromVec the origin of the current segment
  155041. * @param toVec the destination of the current segment
  155042. * @param result reference to output variable
  155043. * @returns whether or not transformation was successful
  155044. */
  155045. private static _transformSegmentDirToRef;
  155046. private static _bestMatch;
  155047. private static _score;
  155048. private static _bestScore;
  155049. /**
  155050. * Determine which token vector is most similar to the
  155051. * segment vector.
  155052. * @param segment segment vector
  155053. * @param tokens token vector list
  155054. * @returns index of the most similar token to the segment
  155055. */
  155056. private static _tokenizeSegment;
  155057. }
  155058. /**
  155059. * Class representing a set of known, named trajectories to which Trajectories can be
  155060. * added and using which Trajectories can be recognized.
  155061. */
  155062. export class TrajectoryClassifier {
  155063. private _maximumAllowableMatchCost;
  155064. private _vector3Alphabet;
  155065. private _levenshteinAlphabet;
  155066. private _nameToDescribedTrajectory;
  155067. /**
  155068. * Serialize to JSON.
  155069. * @returns JSON serialization
  155070. */
  155071. serialize(): string;
  155072. /**
  155073. * Deserialize from JSON.
  155074. * @param json JSON serialization
  155075. * @returns deserialized TrajectorySet
  155076. */
  155077. static Deserialize(json: string): TrajectoryClassifier;
  155078. /**
  155079. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  155080. * VERY naive, need to be generating these things from known
  155081. * sets. Better version later, probably eliminating this one.
  155082. * @returns auto-generated TrajectorySet
  155083. */
  155084. static Generate(): TrajectoryClassifier;
  155085. private constructor();
  155086. /**
  155087. * Add a new Trajectory to the set with a given name.
  155088. * @param trajectory new Trajectory to be added
  155089. * @param classification name to which to add the Trajectory
  155090. */
  155091. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  155092. /**
  155093. * Remove a known named trajectory and all Trajectories associated with it.
  155094. * @param classification name to remove
  155095. * @returns whether anything was removed
  155096. */
  155097. deleteClassification(classification: string): boolean;
  155098. /**
  155099. * Attempt to recognize a Trajectory from among all the classifications
  155100. * already known to the classifier.
  155101. * @param trajectory Trajectory to be recognized
  155102. * @returns classification of Trajectory if recognized, null otherwise
  155103. */
  155104. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  155105. }
  155106. }
  155107. declare module BABYLON {
  155108. /**
  155109. * An interface for all Hit test features
  155110. */
  155111. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  155112. /**
  155113. * Triggered when new babylon (transformed) hit test results are available
  155114. */
  155115. onHitTestResultObservable: Observable<T[]>;
  155116. }
  155117. /**
  155118. * Options used for hit testing
  155119. */
  155120. export interface IWebXRLegacyHitTestOptions {
  155121. /**
  155122. * Only test when user interacted with the scene. Default - hit test every frame
  155123. */
  155124. testOnPointerDownOnly?: boolean;
  155125. /**
  155126. * The node to use to transform the local results to world coordinates
  155127. */
  155128. worldParentNode?: TransformNode;
  155129. }
  155130. /**
  155131. * Interface defining the babylon result of raycasting/hit-test
  155132. */
  155133. export interface IWebXRLegacyHitResult {
  155134. /**
  155135. * Transformation matrix that can be applied to a node that will put it in the hit point location
  155136. */
  155137. transformationMatrix: Matrix;
  155138. /**
  155139. * The native hit test result
  155140. */
  155141. xrHitResult: XRHitResult | XRHitTestResult;
  155142. }
  155143. /**
  155144. * The currently-working hit-test module.
  155145. * Hit test (or Ray-casting) is used to interact with the real world.
  155146. * For further information read here - https://github.com/immersive-web/hit-test
  155147. */
  155148. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  155149. /**
  155150. * options to use when constructing this feature
  155151. */
  155152. readonly options: IWebXRLegacyHitTestOptions;
  155153. private _direction;
  155154. private _mat;
  155155. private _onSelectEnabled;
  155156. private _origin;
  155157. /**
  155158. * The module's name
  155159. */
  155160. static readonly Name: string;
  155161. /**
  155162. * The (Babylon) version of this module.
  155163. * This is an integer representing the implementation version.
  155164. * This number does not correspond to the WebXR specs version
  155165. */
  155166. static readonly Version: number;
  155167. /**
  155168. * Populated with the last native XR Hit Results
  155169. */
  155170. lastNativeXRHitResults: XRHitResult[];
  155171. /**
  155172. * Triggered when new babylon (transformed) hit test results are available
  155173. */
  155174. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  155175. /**
  155176. * Creates a new instance of the (legacy version) hit test feature
  155177. * @param _xrSessionManager an instance of WebXRSessionManager
  155178. * @param options options to use when constructing this feature
  155179. */
  155180. constructor(_xrSessionManager: WebXRSessionManager,
  155181. /**
  155182. * options to use when constructing this feature
  155183. */
  155184. options?: IWebXRLegacyHitTestOptions);
  155185. /**
  155186. * execute a hit test with an XR Ray
  155187. *
  155188. * @param xrSession a native xrSession that will execute this hit test
  155189. * @param xrRay the ray (position and direction) to use for ray-casting
  155190. * @param referenceSpace native XR reference space to use for the hit-test
  155191. * @param filter filter function that will filter the results
  155192. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155193. */
  155194. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  155195. /**
  155196. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  155197. * @param event the (select) event to use to select with
  155198. * @param referenceSpace the reference space to use for this hit test
  155199. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155200. */
  155201. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155202. /**
  155203. * attach this feature
  155204. * Will usually be called by the features manager
  155205. *
  155206. * @returns true if successful.
  155207. */
  155208. attach(): boolean;
  155209. /**
  155210. * detach this feature.
  155211. * Will usually be called by the features manager
  155212. *
  155213. * @returns true if successful.
  155214. */
  155215. detach(): boolean;
  155216. /**
  155217. * Dispose this feature and all of the resources attached
  155218. */
  155219. dispose(): void;
  155220. protected _onXRFrame(frame: XRFrame): void;
  155221. private _onHitTestResults;
  155222. private _onSelect;
  155223. }
  155224. }
  155225. declare module BABYLON {
  155226. /**
  155227. * Options used for hit testing (version 2)
  155228. */
  155229. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  155230. /**
  155231. * Do not create a permanent hit test. Will usually be used when only
  155232. * transient inputs are needed.
  155233. */
  155234. disablePermanentHitTest?: boolean;
  155235. /**
  155236. * Enable transient (for example touch-based) hit test inspections
  155237. */
  155238. enableTransientHitTest?: boolean;
  155239. /**
  155240. * Offset ray for the permanent hit test
  155241. */
  155242. offsetRay?: Vector3;
  155243. /**
  155244. * Offset ray for the transient hit test
  155245. */
  155246. transientOffsetRay?: Vector3;
  155247. /**
  155248. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  155249. */
  155250. useReferenceSpace?: boolean;
  155251. /**
  155252. * Override the default entity type(s) of the hit-test result
  155253. */
  155254. entityTypes?: XRHitTestTrackableType[];
  155255. }
  155256. /**
  155257. * Interface defining the babylon result of hit-test
  155258. */
  155259. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  155260. /**
  155261. * The input source that generated this hit test (if transient)
  155262. */
  155263. inputSource?: XRInputSource;
  155264. /**
  155265. * Is this a transient hit test
  155266. */
  155267. isTransient?: boolean;
  155268. /**
  155269. * Position of the hit test result
  155270. */
  155271. position: Vector3;
  155272. /**
  155273. * Rotation of the hit test result
  155274. */
  155275. rotationQuaternion: Quaternion;
  155276. /**
  155277. * The native hit test result
  155278. */
  155279. xrHitResult: XRHitTestResult;
  155280. }
  155281. /**
  155282. * The currently-working hit-test module.
  155283. * Hit test (or Ray-casting) is used to interact with the real world.
  155284. * For further information read here - https://github.com/immersive-web/hit-test
  155285. *
  155286. * Tested on chrome (mobile) 80.
  155287. */
  155288. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  155289. /**
  155290. * options to use when constructing this feature
  155291. */
  155292. readonly options: IWebXRHitTestOptions;
  155293. private _tmpMat;
  155294. private _tmpPos;
  155295. private _tmpQuat;
  155296. private _transientXrHitTestSource;
  155297. private _xrHitTestSource;
  155298. private initHitTestSource;
  155299. /**
  155300. * The module's name
  155301. */
  155302. static readonly Name: string;
  155303. /**
  155304. * The (Babylon) version of this module.
  155305. * This is an integer representing the implementation version.
  155306. * This number does not correspond to the WebXR specs version
  155307. */
  155308. static readonly Version: number;
  155309. /**
  155310. * When set to true, each hit test will have its own position/rotation objects
  155311. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  155312. * the developers will clone them or copy them as they see fit.
  155313. */
  155314. autoCloneTransformation: boolean;
  155315. /**
  155316. * Triggered when new babylon (transformed) hit test results are available
  155317. * Note - this will be called when results come back from the device. It can be an empty array!!
  155318. */
  155319. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  155320. /**
  155321. * Use this to temporarily pause hit test checks.
  155322. */
  155323. paused: boolean;
  155324. /**
  155325. * Creates a new instance of the hit test feature
  155326. * @param _xrSessionManager an instance of WebXRSessionManager
  155327. * @param options options to use when constructing this feature
  155328. */
  155329. constructor(_xrSessionManager: WebXRSessionManager,
  155330. /**
  155331. * options to use when constructing this feature
  155332. */
  155333. options?: IWebXRHitTestOptions);
  155334. /**
  155335. * attach this feature
  155336. * Will usually be called by the features manager
  155337. *
  155338. * @returns true if successful.
  155339. */
  155340. attach(): boolean;
  155341. /**
  155342. * detach this feature.
  155343. * Will usually be called by the features manager
  155344. *
  155345. * @returns true if successful.
  155346. */
  155347. detach(): boolean;
  155348. /**
  155349. * Dispose this feature and all of the resources attached
  155350. */
  155351. dispose(): void;
  155352. protected _onXRFrame(frame: XRFrame): void;
  155353. private _processWebXRHitTestResult;
  155354. }
  155355. }
  155356. declare module BABYLON {
  155357. /**
  155358. * Configuration options of the anchor system
  155359. */
  155360. export interface IWebXRAnchorSystemOptions {
  155361. /**
  155362. * a node that will be used to convert local to world coordinates
  155363. */
  155364. worldParentNode?: TransformNode;
  155365. /**
  155366. * If set to true a reference of the created anchors will be kept until the next session starts
  155367. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  155368. */
  155369. doNotRemoveAnchorsOnSessionEnded?: boolean;
  155370. }
  155371. /**
  155372. * A babylon container for an XR Anchor
  155373. */
  155374. export interface IWebXRAnchor {
  155375. /**
  155376. * A babylon-assigned ID for this anchor
  155377. */
  155378. id: number;
  155379. /**
  155380. * Transformation matrix to apply to an object attached to this anchor
  155381. */
  155382. transformationMatrix: Matrix;
  155383. /**
  155384. * The native anchor object
  155385. */
  155386. xrAnchor: XRAnchor;
  155387. /**
  155388. * if defined, this object will be constantly updated by the anchor's position and rotation
  155389. */
  155390. attachedNode?: TransformNode;
  155391. }
  155392. /**
  155393. * An implementation of the anchor system for WebXR.
  155394. * For further information see https://github.com/immersive-web/anchors/
  155395. */
  155396. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  155397. private _options;
  155398. private _lastFrameDetected;
  155399. private _trackedAnchors;
  155400. private _referenceSpaceForFrameAnchors;
  155401. private _futureAnchors;
  155402. /**
  155403. * The module's name
  155404. */
  155405. static readonly Name: string;
  155406. /**
  155407. * The (Babylon) version of this module.
  155408. * This is an integer representing the implementation version.
  155409. * This number does not correspond to the WebXR specs version
  155410. */
  155411. static readonly Version: number;
  155412. /**
  155413. * Observers registered here will be executed when a new anchor was added to the session
  155414. */
  155415. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  155416. /**
  155417. * Observers registered here will be executed when an anchor was removed from the session
  155418. */
  155419. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  155420. /**
  155421. * Observers registered here will be executed when an existing anchor updates
  155422. * This can execute N times every frame
  155423. */
  155424. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  155425. /**
  155426. * Set the reference space to use for anchor creation, when not using a hit test.
  155427. * Will default to the session's reference space if not defined
  155428. */
  155429. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  155430. /**
  155431. * constructs a new anchor system
  155432. * @param _xrSessionManager an instance of WebXRSessionManager
  155433. * @param _options configuration object for this feature
  155434. */
  155435. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  155436. private _tmpVector;
  155437. private _tmpQuaternion;
  155438. private _populateTmpTransformation;
  155439. /**
  155440. * Create a new anchor point using a hit test result at a specific point in the scene
  155441. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  155442. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  155443. *
  155444. * @param hitTestResult The hit test result to use for this anchor creation
  155445. * @param position an optional position offset for this anchor
  155446. * @param rotationQuaternion an optional rotation offset for this anchor
  155447. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  155448. */
  155449. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  155450. /**
  155451. * Add a new anchor at a specific position and rotation
  155452. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  155453. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  155454. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  155455. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  155456. *
  155457. * @param position the position in which to add an anchor
  155458. * @param rotationQuaternion an optional rotation for the anchor transformation
  155459. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  155460. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  155461. */
  155462. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  155463. /**
  155464. * detach this feature.
  155465. * Will usually be called by the features manager
  155466. *
  155467. * @returns true if successful.
  155468. */
  155469. detach(): boolean;
  155470. /**
  155471. * Dispose this feature and all of the resources attached
  155472. */
  155473. dispose(): void;
  155474. protected _onXRFrame(frame: XRFrame): void;
  155475. /**
  155476. * avoiding using Array.find for global support.
  155477. * @param xrAnchor the plane to find in the array
  155478. */
  155479. private _findIndexInAnchorArray;
  155480. private _updateAnchorWithXRFrame;
  155481. private _createAnchorAtTransformation;
  155482. }
  155483. }
  155484. declare module BABYLON {
  155485. /**
  155486. * Options used in the plane detector module
  155487. */
  155488. export interface IWebXRPlaneDetectorOptions {
  155489. /**
  155490. * The node to use to transform the local results to world coordinates
  155491. */
  155492. worldParentNode?: TransformNode;
  155493. /**
  155494. * If set to true a reference of the created planes will be kept until the next session starts
  155495. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  155496. */
  155497. doNotRemovePlanesOnSessionEnded?: boolean;
  155498. }
  155499. /**
  155500. * A babylon interface for a WebXR plane.
  155501. * A Plane is actually a polygon, built from N points in space
  155502. *
  155503. * Supported in chrome 79, not supported in canary 81 ATM
  155504. */
  155505. export interface IWebXRPlane {
  155506. /**
  155507. * a babylon-assigned ID for this polygon
  155508. */
  155509. id: number;
  155510. /**
  155511. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  155512. */
  155513. polygonDefinition: Array<Vector3>;
  155514. /**
  155515. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  155516. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  155517. */
  155518. transformationMatrix: Matrix;
  155519. /**
  155520. * the native xr-plane object
  155521. */
  155522. xrPlane: XRPlane;
  155523. }
  155524. /**
  155525. * The plane detector is used to detect planes in the real world when in AR
  155526. * For more information see https://github.com/immersive-web/real-world-geometry/
  155527. */
  155528. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  155529. private _options;
  155530. private _detectedPlanes;
  155531. private _enabled;
  155532. private _lastFrameDetected;
  155533. /**
  155534. * The module's name
  155535. */
  155536. static readonly Name: string;
  155537. /**
  155538. * The (Babylon) version of this module.
  155539. * This is an integer representing the implementation version.
  155540. * This number does not correspond to the WebXR specs version
  155541. */
  155542. static readonly Version: number;
  155543. /**
  155544. * Observers registered here will be executed when a new plane was added to the session
  155545. */
  155546. onPlaneAddedObservable: Observable<IWebXRPlane>;
  155547. /**
  155548. * Observers registered here will be executed when a plane is no longer detected in the session
  155549. */
  155550. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  155551. /**
  155552. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  155553. * This can execute N times every frame
  155554. */
  155555. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  155556. /**
  155557. * construct a new Plane Detector
  155558. * @param _xrSessionManager an instance of xr Session manager
  155559. * @param _options configuration to use when constructing this feature
  155560. */
  155561. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  155562. /**
  155563. * detach this feature.
  155564. * Will usually be called by the features manager
  155565. *
  155566. * @returns true if successful.
  155567. */
  155568. detach(): boolean;
  155569. /**
  155570. * Dispose this feature and all of the resources attached
  155571. */
  155572. dispose(): void;
  155573. protected _onXRFrame(frame: XRFrame): void;
  155574. private _init;
  155575. private _updatePlaneWithXRPlane;
  155576. /**
  155577. * avoiding using Array.find for global support.
  155578. * @param xrPlane the plane to find in the array
  155579. */
  155580. private findIndexInPlaneArray;
  155581. }
  155582. }
  155583. declare module BABYLON {
  155584. /**
  155585. * Options interface for the background remover plugin
  155586. */
  155587. export interface IWebXRBackgroundRemoverOptions {
  155588. /**
  155589. * Further background meshes to disable when entering AR
  155590. */
  155591. backgroundMeshes?: AbstractMesh[];
  155592. /**
  155593. * flags to configure the removal of the environment helper.
  155594. * If not set, the entire background will be removed. If set, flags should be set as well.
  155595. */
  155596. environmentHelperRemovalFlags?: {
  155597. /**
  155598. * Should the skybox be removed (default false)
  155599. */
  155600. skyBox?: boolean;
  155601. /**
  155602. * Should the ground be removed (default false)
  155603. */
  155604. ground?: boolean;
  155605. };
  155606. /**
  155607. * don't disable the environment helper
  155608. */
  155609. ignoreEnvironmentHelper?: boolean;
  155610. }
  155611. /**
  155612. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  155613. */
  155614. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  155615. /**
  155616. * read-only options to be used in this module
  155617. */
  155618. readonly options: IWebXRBackgroundRemoverOptions;
  155619. /**
  155620. * The module's name
  155621. */
  155622. static readonly Name: string;
  155623. /**
  155624. * The (Babylon) version of this module.
  155625. * This is an integer representing the implementation version.
  155626. * This number does not correspond to the WebXR specs version
  155627. */
  155628. static readonly Version: number;
  155629. /**
  155630. * registered observers will be triggered when the background state changes
  155631. */
  155632. onBackgroundStateChangedObservable: Observable<boolean>;
  155633. /**
  155634. * constructs a new background remover module
  155635. * @param _xrSessionManager the session manager for this module
  155636. * @param options read-only options to be used in this module
  155637. */
  155638. constructor(_xrSessionManager: WebXRSessionManager,
  155639. /**
  155640. * read-only options to be used in this module
  155641. */
  155642. options?: IWebXRBackgroundRemoverOptions);
  155643. /**
  155644. * attach this feature
  155645. * Will usually be called by the features manager
  155646. *
  155647. * @returns true if successful.
  155648. */
  155649. attach(): boolean;
  155650. /**
  155651. * detach this feature.
  155652. * Will usually be called by the features manager
  155653. *
  155654. * @returns true if successful.
  155655. */
  155656. detach(): boolean;
  155657. /**
  155658. * Dispose this feature and all of the resources attached
  155659. */
  155660. dispose(): void;
  155661. protected _onXRFrame(_xrFrame: XRFrame): void;
  155662. private _setBackgroundState;
  155663. }
  155664. }
  155665. declare module BABYLON {
  155666. /**
  155667. * Options for the controller physics feature
  155668. */
  155669. export class IWebXRControllerPhysicsOptions {
  155670. /**
  155671. * Should the headset get its own impostor
  155672. */
  155673. enableHeadsetImpostor?: boolean;
  155674. /**
  155675. * Optional parameters for the headset impostor
  155676. */
  155677. headsetImpostorParams?: {
  155678. /**
  155679. * The type of impostor to create. Default is sphere
  155680. */
  155681. impostorType: number;
  155682. /**
  155683. * the size of the impostor. Defaults to 10cm
  155684. */
  155685. impostorSize?: number | {
  155686. width: number;
  155687. height: number;
  155688. depth: number;
  155689. };
  155690. /**
  155691. * Friction definitions
  155692. */
  155693. friction?: number;
  155694. /**
  155695. * Restitution
  155696. */
  155697. restitution?: number;
  155698. };
  155699. /**
  155700. * The physics properties of the future impostors
  155701. */
  155702. physicsProperties?: {
  155703. /**
  155704. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  155705. * Note that this requires a physics engine that supports mesh impostors!
  155706. */
  155707. useControllerMesh?: boolean;
  155708. /**
  155709. * The type of impostor to create. Default is sphere
  155710. */
  155711. impostorType?: number;
  155712. /**
  155713. * the size of the impostor. Defaults to 10cm
  155714. */
  155715. impostorSize?: number | {
  155716. width: number;
  155717. height: number;
  155718. depth: number;
  155719. };
  155720. /**
  155721. * Friction definitions
  155722. */
  155723. friction?: number;
  155724. /**
  155725. * Restitution
  155726. */
  155727. restitution?: number;
  155728. };
  155729. /**
  155730. * the xr input to use with this pointer selection
  155731. */
  155732. xrInput: WebXRInput;
  155733. }
  155734. /**
  155735. * Add physics impostor to your webxr controllers,
  155736. * including naive calculation of their linear and angular velocity
  155737. */
  155738. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  155739. private readonly _options;
  155740. private _attachController;
  155741. private _controllers;
  155742. private _debugMode;
  155743. private _delta;
  155744. private _headsetImpostor?;
  155745. private _headsetMesh?;
  155746. private _lastTimestamp;
  155747. private _tmpQuaternion;
  155748. private _tmpVector;
  155749. /**
  155750. * The module's name
  155751. */
  155752. static readonly Name: string;
  155753. /**
  155754. * The (Babylon) version of this module.
  155755. * This is an integer representing the implementation version.
  155756. * This number does not correspond to the webxr specs version
  155757. */
  155758. static readonly Version: number;
  155759. /**
  155760. * Construct a new Controller Physics Feature
  155761. * @param _xrSessionManager the corresponding xr session manager
  155762. * @param _options options to create this feature with
  155763. */
  155764. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  155765. /**
  155766. * @hidden
  155767. * enable debugging - will show console outputs and the impostor mesh
  155768. */
  155769. _enablePhysicsDebug(): void;
  155770. /**
  155771. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  155772. * @param xrController the controller to add
  155773. */
  155774. addController(xrController: WebXRInputSource): void;
  155775. /**
  155776. * attach this feature
  155777. * Will usually be called by the features manager
  155778. *
  155779. * @returns true if successful.
  155780. */
  155781. attach(): boolean;
  155782. /**
  155783. * detach this feature.
  155784. * Will usually be called by the features manager
  155785. *
  155786. * @returns true if successful.
  155787. */
  155788. detach(): boolean;
  155789. /**
  155790. * Get the headset impostor, if enabled
  155791. * @returns the impostor
  155792. */
  155793. getHeadsetImpostor(): PhysicsImpostor | undefined;
  155794. /**
  155795. * Get the physics impostor of a specific controller.
  155796. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  155797. * @param controller the controller or the controller id of which to get the impostor
  155798. * @returns the impostor or null
  155799. */
  155800. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  155801. /**
  155802. * Update the physics properties provided in the constructor
  155803. * @param newProperties the new properties object
  155804. */
  155805. setPhysicsProperties(newProperties: {
  155806. impostorType?: number;
  155807. impostorSize?: number | {
  155808. width: number;
  155809. height: number;
  155810. depth: number;
  155811. };
  155812. friction?: number;
  155813. restitution?: number;
  155814. }): void;
  155815. protected _onXRFrame(_xrFrame: any): void;
  155816. private _detachController;
  155817. }
  155818. }
  155819. declare module BABYLON {
  155820. /**
  155821. * A babylon interface for a "WebXR" feature point.
  155822. * Represents the position and confidence value of a given feature point.
  155823. */
  155824. export interface IWebXRFeaturePoint {
  155825. /**
  155826. * Represents the position of the feature point in world space.
  155827. */
  155828. position: Vector3;
  155829. /**
  155830. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  155831. */
  155832. confidenceValue: number;
  155833. }
  155834. /**
  155835. * The feature point system is used to detect feature points from real world geometry.
  155836. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  155837. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  155838. */
  155839. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  155840. private _enabled;
  155841. private _featurePointCloud;
  155842. /**
  155843. * The module's name
  155844. */
  155845. static readonly Name: string;
  155846. /**
  155847. * The (Babylon) version of this module.
  155848. * This is an integer representing the implementation version.
  155849. * This number does not correspond to the WebXR specs version
  155850. */
  155851. static readonly Version: number;
  155852. /**
  155853. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  155854. * Will notify the observers about which feature points have been added.
  155855. */
  155856. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  155857. /**
  155858. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  155859. * Will notify the observers about which feature points have been updated.
  155860. */
  155861. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  155862. /**
  155863. * The current feature point cloud maintained across frames.
  155864. */
  155865. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  155866. /**
  155867. * construct the feature point system
  155868. * @param _xrSessionManager an instance of xr Session manager
  155869. */
  155870. constructor(_xrSessionManager: WebXRSessionManager);
  155871. /**
  155872. * Detach this feature.
  155873. * Will usually be called by the features manager
  155874. *
  155875. * @returns true if successful.
  155876. */
  155877. detach(): boolean;
  155878. /**
  155879. * Dispose this feature and all of the resources attached
  155880. */
  155881. dispose(): void;
  155882. /**
  155883. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  155884. */
  155885. protected _onXRFrame(frame: XRFrame): void;
  155886. /**
  155887. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  155888. */
  155889. private _init;
  155890. }
  155891. }
  155892. declare module BABYLON {
  155893. /**
  155894. * Configuration interface for the hand tracking feature
  155895. */
  155896. export interface IWebXRHandTrackingOptions {
  155897. /**
  155898. * The xrInput that will be used as source for new hands
  155899. */
  155900. xrInput: WebXRInput;
  155901. /**
  155902. * Configuration object for the joint meshes
  155903. */
  155904. jointMeshes?: {
  155905. /**
  155906. * Should the meshes created be invisible (defaults to false)
  155907. */
  155908. invisible?: boolean;
  155909. /**
  155910. * A source mesh to be used to create instances. Defaults to a sphere.
  155911. * This mesh will be the source for all other (25) meshes.
  155912. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  155913. */
  155914. sourceMesh?: Mesh;
  155915. /**
  155916. * Should the source mesh stay visible. Defaults to false
  155917. */
  155918. keepOriginalVisible?: boolean;
  155919. /**
  155920. * Scale factor for all instances (defaults to 2)
  155921. */
  155922. scaleFactor?: number;
  155923. /**
  155924. * Should each instance have its own physics impostor
  155925. */
  155926. enablePhysics?: boolean;
  155927. /**
  155928. * If enabled, override default physics properties
  155929. */
  155930. physicsProps?: {
  155931. friction?: number;
  155932. restitution?: number;
  155933. impostorType?: number;
  155934. };
  155935. /**
  155936. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  155937. */
  155938. handMesh?: AbstractMesh;
  155939. };
  155940. }
  155941. /**
  155942. * Parts of the hands divided to writs and finger names
  155943. */
  155944. export const enum HandPart {
  155945. /**
  155946. * HandPart - Wrist
  155947. */
  155948. WRIST = "wrist",
  155949. /**
  155950. * HandPart - The THumb
  155951. */
  155952. THUMB = "thumb",
  155953. /**
  155954. * HandPart - Index finger
  155955. */
  155956. INDEX = "index",
  155957. /**
  155958. * HandPart - Middle finger
  155959. */
  155960. MIDDLE = "middle",
  155961. /**
  155962. * HandPart - Ring finger
  155963. */
  155964. RING = "ring",
  155965. /**
  155966. * HandPart - Little finger
  155967. */
  155968. LITTLE = "little"
  155969. }
  155970. /**
  155971. * Representing a single hand (with its corresponding native XRHand object)
  155972. */
  155973. export class WebXRHand implements IDisposable {
  155974. /** the controller to which the hand correlates */
  155975. readonly xrController: WebXRInputSource;
  155976. /** the meshes to be used to track the hand joints */
  155977. readonly trackedMeshes: AbstractMesh[];
  155978. /**
  155979. * Hand-parts definition (key is HandPart)
  155980. */
  155981. handPartsDefinition: {
  155982. [key: string]: number[];
  155983. };
  155984. /**
  155985. * Populate the HandPartsDefinition object.
  155986. * This is called as a side effect since certain browsers don't have XRHand defined.
  155987. */
  155988. private generateHandPartsDefinition;
  155989. /**
  155990. * Construct a new hand object
  155991. * @param xrController the controller to which the hand correlates
  155992. * @param trackedMeshes the meshes to be used to track the hand joints
  155993. */
  155994. constructor(
  155995. /** the controller to which the hand correlates */
  155996. xrController: WebXRInputSource,
  155997. /** the meshes to be used to track the hand joints */
  155998. trackedMeshes: AbstractMesh[]);
  155999. /**
  156000. * Update this hand from the latest xr frame
  156001. * @param xrFrame xrFrame to update from
  156002. * @param referenceSpace The current viewer reference space
  156003. * @param scaleFactor optional scale factor for the meshes
  156004. */
  156005. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  156006. /**
  156007. * Get meshes of part of the hand
  156008. * @param part the part of hand to get
  156009. * @returns An array of meshes that correlate to the hand part requested
  156010. */
  156011. getHandPartMeshes(part: HandPart): AbstractMesh[];
  156012. /**
  156013. * Dispose this Hand object
  156014. */
  156015. dispose(): void;
  156016. }
  156017. /**
  156018. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  156019. */
  156020. export class WebXRHandTracking extends WebXRAbstractFeature {
  156021. /**
  156022. * options to use when constructing this feature
  156023. */
  156024. readonly options: IWebXRHandTrackingOptions;
  156025. private static _idCounter;
  156026. /**
  156027. * The module's name
  156028. */
  156029. static readonly Name: string;
  156030. /**
  156031. * The (Babylon) version of this module.
  156032. * This is an integer representing the implementation version.
  156033. * This number does not correspond to the WebXR specs version
  156034. */
  156035. static readonly Version: number;
  156036. /**
  156037. * This observable will notify registered observers when a new hand object was added and initialized
  156038. */
  156039. onHandAddedObservable: Observable<WebXRHand>;
  156040. /**
  156041. * This observable will notify its observers right before the hand object is disposed
  156042. */
  156043. onHandRemovedObservable: Observable<WebXRHand>;
  156044. private _hands;
  156045. /**
  156046. * Creates a new instance of the hit test feature
  156047. * @param _xrSessionManager an instance of WebXRSessionManager
  156048. * @param options options to use when constructing this feature
  156049. */
  156050. constructor(_xrSessionManager: WebXRSessionManager,
  156051. /**
  156052. * options to use when constructing this feature
  156053. */
  156054. options: IWebXRHandTrackingOptions);
  156055. /**
  156056. * Check if the needed objects are defined.
  156057. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  156058. */
  156059. isCompatible(): boolean;
  156060. /**
  156061. * attach this feature
  156062. * Will usually be called by the features manager
  156063. *
  156064. * @returns true if successful.
  156065. */
  156066. attach(): boolean;
  156067. /**
  156068. * detach this feature.
  156069. * Will usually be called by the features manager
  156070. *
  156071. * @returns true if successful.
  156072. */
  156073. detach(): boolean;
  156074. /**
  156075. * Dispose this feature and all of the resources attached
  156076. */
  156077. dispose(): void;
  156078. /**
  156079. * Get the hand object according to the controller id
  156080. * @param controllerId the controller id to which we want to get the hand
  156081. * @returns null if not found or the WebXRHand object if found
  156082. */
  156083. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  156084. /**
  156085. * Get a hand object according to the requested handedness
  156086. * @param handedness the handedness to request
  156087. * @returns null if not found or the WebXRHand object if found
  156088. */
  156089. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  156090. protected _onXRFrame(_xrFrame: XRFrame): void;
  156091. private _attachHand;
  156092. private _detachHand;
  156093. }
  156094. }
  156095. declare module BABYLON {
  156096. /**
  156097. * The motion controller class for all microsoft mixed reality controllers
  156098. */
  156099. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  156100. protected readonly _mapping: {
  156101. defaultButton: {
  156102. valueNodeName: string;
  156103. unpressedNodeName: string;
  156104. pressedNodeName: string;
  156105. };
  156106. defaultAxis: {
  156107. valueNodeName: string;
  156108. minNodeName: string;
  156109. maxNodeName: string;
  156110. };
  156111. buttons: {
  156112. "xr-standard-trigger": {
  156113. rootNodeName: string;
  156114. componentProperty: string;
  156115. states: string[];
  156116. };
  156117. "xr-standard-squeeze": {
  156118. rootNodeName: string;
  156119. componentProperty: string;
  156120. states: string[];
  156121. };
  156122. "xr-standard-touchpad": {
  156123. rootNodeName: string;
  156124. labelAnchorNodeName: string;
  156125. touchPointNodeName: string;
  156126. };
  156127. "xr-standard-thumbstick": {
  156128. rootNodeName: string;
  156129. componentProperty: string;
  156130. states: string[];
  156131. };
  156132. };
  156133. axes: {
  156134. "xr-standard-touchpad": {
  156135. "x-axis": {
  156136. rootNodeName: string;
  156137. };
  156138. "y-axis": {
  156139. rootNodeName: string;
  156140. };
  156141. };
  156142. "xr-standard-thumbstick": {
  156143. "x-axis": {
  156144. rootNodeName: string;
  156145. };
  156146. "y-axis": {
  156147. rootNodeName: string;
  156148. };
  156149. };
  156150. };
  156151. };
  156152. /**
  156153. * The base url used to load the left and right controller models
  156154. */
  156155. static MODEL_BASE_URL: string;
  156156. /**
  156157. * The name of the left controller model file
  156158. */
  156159. static MODEL_LEFT_FILENAME: string;
  156160. /**
  156161. * The name of the right controller model file
  156162. */
  156163. static MODEL_RIGHT_FILENAME: string;
  156164. profileId: string;
  156165. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156166. protected _getFilenameAndPath(): {
  156167. filename: string;
  156168. path: string;
  156169. };
  156170. protected _getModelLoadingConstraints(): boolean;
  156171. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156172. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156173. protected _updateModel(): void;
  156174. }
  156175. }
  156176. declare module BABYLON {
  156177. /**
  156178. * The motion controller class for oculus touch (quest, rift).
  156179. * This class supports legacy mapping as well the standard xr mapping
  156180. */
  156181. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  156182. private _forceLegacyControllers;
  156183. private _modelRootNode;
  156184. /**
  156185. * The base url used to load the left and right controller models
  156186. */
  156187. static MODEL_BASE_URL: string;
  156188. /**
  156189. * The name of the left controller model file
  156190. */
  156191. static MODEL_LEFT_FILENAME: string;
  156192. /**
  156193. * The name of the right controller model file
  156194. */
  156195. static MODEL_RIGHT_FILENAME: string;
  156196. /**
  156197. * Base Url for the Quest controller model.
  156198. */
  156199. static QUEST_MODEL_BASE_URL: string;
  156200. profileId: string;
  156201. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  156202. protected _getFilenameAndPath(): {
  156203. filename: string;
  156204. path: string;
  156205. };
  156206. protected _getModelLoadingConstraints(): boolean;
  156207. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156208. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156209. protected _updateModel(): void;
  156210. /**
  156211. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  156212. * between the touch and touch 2.
  156213. */
  156214. private _isQuest;
  156215. }
  156216. }
  156217. declare module BABYLON {
  156218. /**
  156219. * The motion controller class for the standard HTC-Vive controllers
  156220. */
  156221. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  156222. private _modelRootNode;
  156223. /**
  156224. * The base url used to load the left and right controller models
  156225. */
  156226. static MODEL_BASE_URL: string;
  156227. /**
  156228. * File name for the controller model.
  156229. */
  156230. static MODEL_FILENAME: string;
  156231. profileId: string;
  156232. /**
  156233. * Create a new Vive motion controller object
  156234. * @param scene the scene to use to create this controller
  156235. * @param gamepadObject the corresponding gamepad object
  156236. * @param handedness the handedness of the controller
  156237. */
  156238. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156239. protected _getFilenameAndPath(): {
  156240. filename: string;
  156241. path: string;
  156242. };
  156243. protected _getModelLoadingConstraints(): boolean;
  156244. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156245. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156246. protected _updateModel(): void;
  156247. }
  156248. }
  156249. declare module BABYLON {
  156250. /**
  156251. * A cursor which tracks a point on a path
  156252. */
  156253. export class PathCursor {
  156254. private path;
  156255. /**
  156256. * Stores path cursor callbacks for when an onchange event is triggered
  156257. */
  156258. private _onchange;
  156259. /**
  156260. * The value of the path cursor
  156261. */
  156262. value: number;
  156263. /**
  156264. * The animation array of the path cursor
  156265. */
  156266. animations: Animation[];
  156267. /**
  156268. * Initializes the path cursor
  156269. * @param path The path to track
  156270. */
  156271. constructor(path: Path2);
  156272. /**
  156273. * Gets the cursor point on the path
  156274. * @returns A point on the path cursor at the cursor location
  156275. */
  156276. getPoint(): Vector3;
  156277. /**
  156278. * Moves the cursor ahead by the step amount
  156279. * @param step The amount to move the cursor forward
  156280. * @returns This path cursor
  156281. */
  156282. moveAhead(step?: number): PathCursor;
  156283. /**
  156284. * Moves the cursor behind by the step amount
  156285. * @param step The amount to move the cursor back
  156286. * @returns This path cursor
  156287. */
  156288. moveBack(step?: number): PathCursor;
  156289. /**
  156290. * Moves the cursor by the step amount
  156291. * If the step amount is greater than one, an exception is thrown
  156292. * @param step The amount to move the cursor
  156293. * @returns This path cursor
  156294. */
  156295. move(step: number): PathCursor;
  156296. /**
  156297. * Ensures that the value is limited between zero and one
  156298. * @returns This path cursor
  156299. */
  156300. private ensureLimits;
  156301. /**
  156302. * Runs onchange callbacks on change (used by the animation engine)
  156303. * @returns This path cursor
  156304. */
  156305. private raiseOnChange;
  156306. /**
  156307. * Executes a function on change
  156308. * @param f A path cursor onchange callback
  156309. * @returns This path cursor
  156310. */
  156311. onchange(f: (cursor: PathCursor) => void): PathCursor;
  156312. }
  156313. }
  156314. declare module BABYLON {
  156315. /** @hidden */
  156316. export var blurPixelShader: {
  156317. name: string;
  156318. shader: string;
  156319. };
  156320. }
  156321. declare module BABYLON {
  156322. /** @hidden */
  156323. export var pointCloudVertexDeclaration: {
  156324. name: string;
  156325. shader: string;
  156326. };
  156327. }
  156328. // Mixins
  156329. interface Window {
  156330. mozIndexedDB: IDBFactory;
  156331. webkitIndexedDB: IDBFactory;
  156332. msIndexedDB: IDBFactory;
  156333. webkitURL: typeof URL;
  156334. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  156335. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  156336. WebGLRenderingContext: WebGLRenderingContext;
  156337. MSGesture: MSGesture;
  156338. CANNON: any;
  156339. AudioContext: AudioContext;
  156340. webkitAudioContext: AudioContext;
  156341. PointerEvent: any;
  156342. Math: Math;
  156343. Uint8Array: Uint8ArrayConstructor;
  156344. Float32Array: Float32ArrayConstructor;
  156345. mozURL: typeof URL;
  156346. msURL: typeof URL;
  156347. VRFrameData: any; // WebVR, from specs 1.1
  156348. DracoDecoderModule: any;
  156349. setImmediate(handler: (...args: any[]) => void): number;
  156350. }
  156351. interface HTMLCanvasElement {
  156352. requestPointerLock(): void;
  156353. msRequestPointerLock?(): void;
  156354. mozRequestPointerLock?(): void;
  156355. webkitRequestPointerLock?(): void;
  156356. /** Track wether a record is in progress */
  156357. isRecording: boolean;
  156358. /** Capture Stream method defined by some browsers */
  156359. captureStream(fps?: number): MediaStream;
  156360. }
  156361. interface CanvasRenderingContext2D {
  156362. msImageSmoothingEnabled: boolean;
  156363. }
  156364. interface MouseEvent {
  156365. mozMovementX: number;
  156366. mozMovementY: number;
  156367. webkitMovementX: number;
  156368. webkitMovementY: number;
  156369. msMovementX: number;
  156370. msMovementY: number;
  156371. }
  156372. interface Navigator {
  156373. mozGetVRDevices: (any: any) => any;
  156374. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156375. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156376. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156377. webkitGetGamepads(): Gamepad[];
  156378. msGetGamepads(): Gamepad[];
  156379. webkitGamepads(): Gamepad[];
  156380. }
  156381. interface HTMLVideoElement {
  156382. mozSrcObject: any;
  156383. }
  156384. interface Math {
  156385. fround(x: number): number;
  156386. imul(a: number, b: number): number;
  156387. }
  156388. interface WebGLRenderingContext {
  156389. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  156390. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  156391. vertexAttribDivisor(index: number, divisor: number): void;
  156392. createVertexArray(): any;
  156393. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  156394. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  156395. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  156396. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  156397. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  156398. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  156399. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  156400. // Queries
  156401. createQuery(): WebGLQuery;
  156402. deleteQuery(query: WebGLQuery): void;
  156403. beginQuery(target: number, query: WebGLQuery): void;
  156404. endQuery(target: number): void;
  156405. getQueryParameter(query: WebGLQuery, pname: number): any;
  156406. getQuery(target: number, pname: number): any;
  156407. MAX_SAMPLES: number;
  156408. RGBA8: number;
  156409. READ_FRAMEBUFFER: number;
  156410. DRAW_FRAMEBUFFER: number;
  156411. UNIFORM_BUFFER: number;
  156412. HALF_FLOAT_OES: number;
  156413. RGBA16F: number;
  156414. RGBA32F: number;
  156415. R32F: number;
  156416. RG32F: number;
  156417. RGB32F: number;
  156418. R16F: number;
  156419. RG16F: number;
  156420. RGB16F: number;
  156421. RED: number;
  156422. RG: number;
  156423. R8: number;
  156424. RG8: number;
  156425. UNSIGNED_INT_24_8: number;
  156426. DEPTH24_STENCIL8: number;
  156427. MIN: number;
  156428. MAX: number;
  156429. /* Multiple Render Targets */
  156430. drawBuffers(buffers: number[]): void;
  156431. readBuffer(src: number): void;
  156432. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  156433. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  156434. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  156435. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  156436. // Occlusion Query
  156437. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  156438. ANY_SAMPLES_PASSED: number;
  156439. QUERY_RESULT_AVAILABLE: number;
  156440. QUERY_RESULT: number;
  156441. }
  156442. interface WebGLProgram {
  156443. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  156444. }
  156445. interface EXT_disjoint_timer_query {
  156446. QUERY_COUNTER_BITS_EXT: number;
  156447. TIME_ELAPSED_EXT: number;
  156448. TIMESTAMP_EXT: number;
  156449. GPU_DISJOINT_EXT: number;
  156450. QUERY_RESULT_EXT: number;
  156451. QUERY_RESULT_AVAILABLE_EXT: number;
  156452. queryCounterEXT(query: WebGLQuery, target: number): void;
  156453. createQueryEXT(): WebGLQuery;
  156454. beginQueryEXT(target: number, query: WebGLQuery): void;
  156455. endQueryEXT(target: number): void;
  156456. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  156457. deleteQueryEXT(query: WebGLQuery): void;
  156458. }
  156459. interface WebGLUniformLocation {
  156460. _currentState: any;
  156461. }
  156462. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  156463. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  156464. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  156465. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  156466. interface WebGLRenderingContext {
  156467. readonly RASTERIZER_DISCARD: number;
  156468. readonly DEPTH_COMPONENT24: number;
  156469. readonly TEXTURE_3D: number;
  156470. readonly TEXTURE_2D_ARRAY: number;
  156471. readonly TEXTURE_COMPARE_FUNC: number;
  156472. readonly TEXTURE_COMPARE_MODE: number;
  156473. readonly COMPARE_REF_TO_TEXTURE: number;
  156474. readonly TEXTURE_WRAP_R: number;
  156475. readonly HALF_FLOAT: number;
  156476. readonly RGB8: number;
  156477. readonly RED_INTEGER: number;
  156478. readonly RG_INTEGER: number;
  156479. readonly RGB_INTEGER: number;
  156480. readonly RGBA_INTEGER: number;
  156481. readonly R8_SNORM: number;
  156482. readonly RG8_SNORM: number;
  156483. readonly RGB8_SNORM: number;
  156484. readonly RGBA8_SNORM: number;
  156485. readonly R8I: number;
  156486. readonly RG8I: number;
  156487. readonly RGB8I: number;
  156488. readonly RGBA8I: number;
  156489. readonly R8UI: number;
  156490. readonly RG8UI: number;
  156491. readonly RGB8UI: number;
  156492. readonly RGBA8UI: number;
  156493. readonly R16I: number;
  156494. readonly RG16I: number;
  156495. readonly RGB16I: number;
  156496. readonly RGBA16I: number;
  156497. readonly R16UI: number;
  156498. readonly RG16UI: number;
  156499. readonly RGB16UI: number;
  156500. readonly RGBA16UI: number;
  156501. readonly R32I: number;
  156502. readonly RG32I: number;
  156503. readonly RGB32I: number;
  156504. readonly RGBA32I: number;
  156505. readonly R32UI: number;
  156506. readonly RG32UI: number;
  156507. readonly RGB32UI: number;
  156508. readonly RGBA32UI: number;
  156509. readonly RGB10_A2UI: number;
  156510. readonly R11F_G11F_B10F: number;
  156511. readonly RGB9_E5: number;
  156512. readonly RGB10_A2: number;
  156513. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  156514. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  156515. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  156516. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  156517. readonly DEPTH_COMPONENT32F: number;
  156518. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  156519. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  156520. 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;
  156521. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  156522. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  156523. readonly TRANSFORM_FEEDBACK: number;
  156524. readonly INTERLEAVED_ATTRIBS: number;
  156525. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  156526. createTransformFeedback(): WebGLTransformFeedback;
  156527. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  156528. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  156529. beginTransformFeedback(primitiveMode: number): void;
  156530. endTransformFeedback(): void;
  156531. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  156532. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156533. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156534. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156535. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  156536. }
  156537. interface ImageBitmap {
  156538. readonly width: number;
  156539. readonly height: number;
  156540. close(): void;
  156541. }
  156542. interface WebGLQuery extends WebGLObject {
  156543. }
  156544. declare var WebGLQuery: {
  156545. prototype: WebGLQuery;
  156546. new(): WebGLQuery;
  156547. };
  156548. interface WebGLSampler extends WebGLObject {
  156549. }
  156550. declare var WebGLSampler: {
  156551. prototype: WebGLSampler;
  156552. new(): WebGLSampler;
  156553. };
  156554. interface WebGLSync extends WebGLObject {
  156555. }
  156556. declare var WebGLSync: {
  156557. prototype: WebGLSync;
  156558. new(): WebGLSync;
  156559. };
  156560. interface WebGLTransformFeedback extends WebGLObject {
  156561. }
  156562. declare var WebGLTransformFeedback: {
  156563. prototype: WebGLTransformFeedback;
  156564. new(): WebGLTransformFeedback;
  156565. };
  156566. interface WebGLVertexArrayObject extends WebGLObject {
  156567. }
  156568. declare var WebGLVertexArrayObject: {
  156569. prototype: WebGLVertexArrayObject;
  156570. new(): WebGLVertexArrayObject;
  156571. };
  156572. // Type definitions for WebVR API
  156573. // Project: https://w3c.github.io/webvr/
  156574. // Definitions by: six a <https://github.com/lostfictions>
  156575. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  156576. interface VRDisplay extends EventTarget {
  156577. /**
  156578. * Dictionary of capabilities describing the VRDisplay.
  156579. */
  156580. readonly capabilities: VRDisplayCapabilities;
  156581. /**
  156582. * z-depth defining the far plane of the eye view frustum
  156583. * enables mapping of values in the render target depth
  156584. * attachment to scene coordinates. Initially set to 10000.0.
  156585. */
  156586. depthFar: number;
  156587. /**
  156588. * z-depth defining the near plane of the eye view frustum
  156589. * enables mapping of values in the render target depth
  156590. * attachment to scene coordinates. Initially set to 0.01.
  156591. */
  156592. depthNear: number;
  156593. /**
  156594. * An identifier for this distinct VRDisplay. Used as an
  156595. * association point in the Gamepad API.
  156596. */
  156597. readonly displayId: number;
  156598. /**
  156599. * A display name, a user-readable name identifying it.
  156600. */
  156601. readonly displayName: string;
  156602. readonly isConnected: boolean;
  156603. readonly isPresenting: boolean;
  156604. /**
  156605. * If this VRDisplay supports room-scale experiences, the optional
  156606. * stage attribute contains details on the room-scale parameters.
  156607. */
  156608. readonly stageParameters: VRStageParameters | null;
  156609. /**
  156610. * Passing the value returned by `requestAnimationFrame` to
  156611. * `cancelAnimationFrame` will unregister the callback.
  156612. * @param handle Define the hanle of the request to cancel
  156613. */
  156614. cancelAnimationFrame(handle: number): void;
  156615. /**
  156616. * Stops presenting to the VRDisplay.
  156617. * @returns a promise to know when it stopped
  156618. */
  156619. exitPresent(): Promise<void>;
  156620. /**
  156621. * Return the current VREyeParameters for the given eye.
  156622. * @param whichEye Define the eye we want the parameter for
  156623. * @returns the eye parameters
  156624. */
  156625. getEyeParameters(whichEye: string): VREyeParameters;
  156626. /**
  156627. * Populates the passed VRFrameData with the information required to render
  156628. * the current frame.
  156629. * @param frameData Define the data structure to populate
  156630. * @returns true if ok otherwise false
  156631. */
  156632. getFrameData(frameData: VRFrameData): boolean;
  156633. /**
  156634. * Get the layers currently being presented.
  156635. * @returns the list of VR layers
  156636. */
  156637. getLayers(): VRLayer[];
  156638. /**
  156639. * Return a VRPose containing the future predicted pose of the VRDisplay
  156640. * when the current frame will be presented. The value returned will not
  156641. * change until JavaScript has returned control to the browser.
  156642. *
  156643. * The VRPose will contain the position, orientation, velocity,
  156644. * and acceleration of each of these properties.
  156645. * @returns the pose object
  156646. */
  156647. getPose(): VRPose;
  156648. /**
  156649. * Return the current instantaneous pose of the VRDisplay, with no
  156650. * prediction applied.
  156651. * @returns the current instantaneous pose
  156652. */
  156653. getImmediatePose(): VRPose;
  156654. /**
  156655. * The callback passed to `requestAnimationFrame` will be called
  156656. * any time a new frame should be rendered. When the VRDisplay is
  156657. * presenting the callback will be called at the native refresh
  156658. * rate of the HMD. When not presenting this function acts
  156659. * identically to how window.requestAnimationFrame acts. Content should
  156660. * make no assumptions of frame rate or vsync behavior as the HMD runs
  156661. * asynchronously from other displays and at differing refresh rates.
  156662. * @param callback Define the eaction to run next frame
  156663. * @returns the request handle it
  156664. */
  156665. requestAnimationFrame(callback: FrameRequestCallback): number;
  156666. /**
  156667. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  156668. * Repeat calls while already presenting will update the VRLayers being displayed.
  156669. * @param layers Define the list of layer to present
  156670. * @returns a promise to know when the request has been fulfilled
  156671. */
  156672. requestPresent(layers: VRLayer[]): Promise<void>;
  156673. /**
  156674. * Reset the pose for this display, treating its current position and
  156675. * orientation as the "origin/zero" values. VRPose.position,
  156676. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  156677. * updated when calling resetPose(). This should be called in only
  156678. * sitting-space experiences.
  156679. */
  156680. resetPose(): void;
  156681. /**
  156682. * The VRLayer provided to the VRDisplay will be captured and presented
  156683. * in the HMD. Calling this function has the same effect on the source
  156684. * canvas as any other operation that uses its source image, and canvases
  156685. * created without preserveDrawingBuffer set to true will be cleared.
  156686. * @param pose Define the pose to submit
  156687. */
  156688. submitFrame(pose?: VRPose): void;
  156689. }
  156690. declare var VRDisplay: {
  156691. prototype: VRDisplay;
  156692. new(): VRDisplay;
  156693. };
  156694. interface VRLayer {
  156695. leftBounds?: number[] | Float32Array | null;
  156696. rightBounds?: number[] | Float32Array | null;
  156697. source?: HTMLCanvasElement | null;
  156698. }
  156699. interface VRDisplayCapabilities {
  156700. readonly canPresent: boolean;
  156701. readonly hasExternalDisplay: boolean;
  156702. readonly hasOrientation: boolean;
  156703. readonly hasPosition: boolean;
  156704. readonly maxLayers: number;
  156705. }
  156706. interface VREyeParameters {
  156707. /** @deprecated */
  156708. readonly fieldOfView: VRFieldOfView;
  156709. readonly offset: Float32Array;
  156710. readonly renderHeight: number;
  156711. readonly renderWidth: number;
  156712. }
  156713. interface VRFieldOfView {
  156714. readonly downDegrees: number;
  156715. readonly leftDegrees: number;
  156716. readonly rightDegrees: number;
  156717. readonly upDegrees: number;
  156718. }
  156719. interface VRFrameData {
  156720. readonly leftProjectionMatrix: Float32Array;
  156721. readonly leftViewMatrix: Float32Array;
  156722. readonly pose: VRPose;
  156723. readonly rightProjectionMatrix: Float32Array;
  156724. readonly rightViewMatrix: Float32Array;
  156725. readonly timestamp: number;
  156726. }
  156727. interface VRPose {
  156728. readonly angularAcceleration: Float32Array | null;
  156729. readonly angularVelocity: Float32Array | null;
  156730. readonly linearAcceleration: Float32Array | null;
  156731. readonly linearVelocity: Float32Array | null;
  156732. readonly orientation: Float32Array | null;
  156733. readonly position: Float32Array | null;
  156734. readonly timestamp: number;
  156735. }
  156736. interface VRStageParameters {
  156737. sittingToStandingTransform?: Float32Array;
  156738. sizeX?: number;
  156739. sizeY?: number;
  156740. }
  156741. interface Navigator {
  156742. getVRDisplays(): Promise<VRDisplay[]>;
  156743. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  156744. }
  156745. interface Window {
  156746. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  156747. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  156748. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  156749. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  156750. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  156751. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  156752. }
  156753. interface Gamepad {
  156754. readonly displayId: number;
  156755. }
  156756. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  156757. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  156758. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  156759. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  156760. type XRHandedness = "none" | "left" | "right";
  156761. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  156762. type XREye = "none" | "left" | "right";
  156763. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  156764. interface XRSpace extends EventTarget {}
  156765. interface XRRenderState {
  156766. depthNear?: number;
  156767. depthFar?: number;
  156768. inlineVerticalFieldOfView?: number;
  156769. baseLayer?: XRWebGLLayer;
  156770. }
  156771. interface XRInputSource {
  156772. handedness: XRHandedness;
  156773. targetRayMode: XRTargetRayMode;
  156774. targetRaySpace: XRSpace;
  156775. gripSpace: XRSpace | undefined;
  156776. gamepad: Gamepad | undefined;
  156777. profiles: Array<string>;
  156778. hand: XRHand | undefined;
  156779. }
  156780. interface XRSessionInit {
  156781. optionalFeatures?: string[];
  156782. requiredFeatures?: string[];
  156783. }
  156784. interface XRSession {
  156785. addEventListener: Function;
  156786. removeEventListener: Function;
  156787. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  156788. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  156789. requestAnimationFrame: Function;
  156790. end(): Promise<void>;
  156791. renderState: XRRenderState;
  156792. inputSources: Array<XRInputSource>;
  156793. // hit test
  156794. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  156795. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  156796. // legacy AR hit test
  156797. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  156798. // legacy plane detection
  156799. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  156800. }
  156801. interface XRReferenceSpace extends XRSpace {
  156802. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  156803. onreset: any;
  156804. }
  156805. type XRPlaneSet = Set<XRPlane>;
  156806. type XRAnchorSet = Set<XRAnchor>;
  156807. interface XRFrame {
  156808. session: XRSession;
  156809. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  156810. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  156811. // AR
  156812. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  156813. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  156814. // Anchors
  156815. trackedAnchors?: XRAnchorSet;
  156816. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  156817. // Planes
  156818. worldInformation: {
  156819. detectedPlanes?: XRPlaneSet;
  156820. };
  156821. // Hand tracking
  156822. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  156823. }
  156824. interface XRViewerPose extends XRPose {
  156825. views: Array<XRView>;
  156826. }
  156827. interface XRPose {
  156828. transform: XRRigidTransform;
  156829. emulatedPosition: boolean;
  156830. }
  156831. interface XRWebGLLayerOptions {
  156832. antialias?: boolean;
  156833. depth?: boolean;
  156834. stencil?: boolean;
  156835. alpha?: boolean;
  156836. multiview?: boolean;
  156837. framebufferScaleFactor?: number;
  156838. }
  156839. declare var XRWebGLLayer: {
  156840. prototype: XRWebGLLayer;
  156841. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  156842. };
  156843. interface XRWebGLLayer {
  156844. framebuffer: WebGLFramebuffer;
  156845. framebufferWidth: number;
  156846. framebufferHeight: number;
  156847. getViewport: Function;
  156848. }
  156849. declare class XRRigidTransform {
  156850. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  156851. position: DOMPointReadOnly;
  156852. orientation: DOMPointReadOnly;
  156853. matrix: Float32Array;
  156854. inverse: XRRigidTransform;
  156855. }
  156856. interface XRView {
  156857. eye: XREye;
  156858. projectionMatrix: Float32Array;
  156859. transform: XRRigidTransform;
  156860. }
  156861. interface XRInputSourceChangeEvent {
  156862. session: XRSession;
  156863. removed: Array<XRInputSource>;
  156864. added: Array<XRInputSource>;
  156865. }
  156866. interface XRInputSourceEvent extends Event {
  156867. readonly frame: XRFrame;
  156868. readonly inputSource: XRInputSource;
  156869. }
  156870. // Experimental(er) features
  156871. declare class XRRay {
  156872. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  156873. origin: DOMPointReadOnly;
  156874. direction: DOMPointReadOnly;
  156875. matrix: Float32Array;
  156876. }
  156877. declare enum XRHitTestTrackableType {
  156878. "point",
  156879. "plane",
  156880. "mesh",
  156881. }
  156882. interface XRHitResult {
  156883. hitMatrix: Float32Array;
  156884. }
  156885. interface XRTransientInputHitTestResult {
  156886. readonly inputSource: XRInputSource;
  156887. readonly results: Array<XRHitTestResult>;
  156888. }
  156889. interface XRHitTestResult {
  156890. getPose(baseSpace: XRSpace): XRPose | undefined;
  156891. // When anchor system is enabled
  156892. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  156893. }
  156894. interface XRHitTestSource {
  156895. cancel(): void;
  156896. }
  156897. interface XRTransientInputHitTestSource {
  156898. cancel(): void;
  156899. }
  156900. interface XRHitTestOptionsInit {
  156901. space: XRSpace;
  156902. entityTypes?: Array<XRHitTestTrackableType>;
  156903. offsetRay?: XRRay;
  156904. }
  156905. interface XRTransientInputHitTestOptionsInit {
  156906. profile: string;
  156907. entityTypes?: Array<XRHitTestTrackableType>;
  156908. offsetRay?: XRRay;
  156909. }
  156910. interface XRAnchor {
  156911. anchorSpace: XRSpace;
  156912. delete(): void;
  156913. }
  156914. interface XRPlane {
  156915. orientation: "Horizontal" | "Vertical";
  156916. planeSpace: XRSpace;
  156917. polygon: Array<DOMPointReadOnly>;
  156918. lastChangedTime: number;
  156919. }
  156920. interface XRJointSpace extends XRSpace {}
  156921. interface XRJointPose extends XRPose {
  156922. radius: number | undefined;
  156923. }
  156924. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  156925. readonly length: number;
  156926. [index: number]: XRJointSpace;
  156927. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  156928. readonly WRIST: number;
  156929. readonly THUMB_METACARPAL: number;
  156930. readonly THUMB_PHALANX_PROXIMAL: number;
  156931. readonly THUMB_PHALANX_DISTAL: number;
  156932. readonly THUMB_PHALANX_TIP: number;
  156933. readonly INDEX_METACARPAL: number;
  156934. readonly INDEX_PHALANX_PROXIMAL: number;
  156935. readonly INDEX_PHALANX_INTERMEDIATE: number;
  156936. readonly INDEX_PHALANX_DISTAL: number;
  156937. readonly INDEX_PHALANX_TIP: number;
  156938. readonly MIDDLE_METACARPAL: number;
  156939. readonly MIDDLE_PHALANX_PROXIMAL: number;
  156940. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  156941. readonly MIDDLE_PHALANX_DISTAL: number;
  156942. readonly MIDDLE_PHALANX_TIP: number;
  156943. readonly RING_METACARPAL: number;
  156944. readonly RING_PHALANX_PROXIMAL: number;
  156945. readonly RING_PHALANX_INTERMEDIATE: number;
  156946. readonly RING_PHALANX_DISTAL: number;
  156947. readonly RING_PHALANX_TIP: number;
  156948. readonly LITTLE_METACARPAL: number;
  156949. readonly LITTLE_PHALANX_PROXIMAL: number;
  156950. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  156951. readonly LITTLE_PHALANX_DISTAL: number;
  156952. readonly LITTLE_PHALANX_TIP: number;
  156953. }
  156954. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  156955. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  156956. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  156957. interface XRSession {
  156958. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  156959. }
  156960. interface XRFrame {
  156961. featurePointCloud? : Array<number>;
  156962. }